fix(toPath & block.insert)
- 评论标记获取路径错误,增加 range.toPath root 参数 - block 节点插入会跳转到下一行
This commit is contained in:
parent
9200b3386f
commit
4c057a901a
|
@ -331,7 +331,7 @@ export default defineConfig({
|
|||
'/api': getMenus({ base: '/api' }),
|
||||
},
|
||||
analytics: {
|
||||
baidu: 'c2e2e4254b6e4388806848d06be68a69',
|
||||
baidu: '285af37fc760a8f865a67cb9120bfd8f',
|
||||
},
|
||||
manifest: {
|
||||
fileName: 'manifest.json',
|
||||
|
|
|
@ -668,13 +668,8 @@ class Block implements BlockModelInterface {
|
|||
}
|
||||
|
||||
if (container && container.length > 0) {
|
||||
if (rightNodes.length > 0) {
|
||||
safeRange.setStartAfter(container);
|
||||
safeRange.collapse(true);
|
||||
} else {
|
||||
safeRange.select(container, true);
|
||||
safeRange.collapse(false);
|
||||
}
|
||||
safeRange.select(container, true);
|
||||
safeRange.collapse(false);
|
||||
}
|
||||
if (selection.focus) selection.focus.remove();
|
||||
if (selection.anchor) selection.anchor.remove();
|
||||
|
|
|
@ -767,7 +767,10 @@ class Range implements RangeInterface {
|
|||
};
|
||||
}
|
||||
|
||||
toPath(includeCardCursor: boolean = false) {
|
||||
toPath(
|
||||
includeCardCursor: boolean = false,
|
||||
root: NodeInterface = this.editor.container,
|
||||
) {
|
||||
const range = this.cloneRange();
|
||||
const node = range.commonAncestorNode;
|
||||
if (!node.isRoot() && !node.inEditor()) return;
|
||||
|
@ -777,7 +780,7 @@ class Range implements RangeInterface {
|
|||
let rootBeginId: string = node.attributes(DATA_ID);
|
||||
let rootBeginIndex: number = rootBeginId ? 0 : -1;
|
||||
const path = node.getPath(
|
||||
this.editor.container,
|
||||
root,
|
||||
node.parent()?.isRoot()
|
||||
? undefined
|
||||
: this.filterPath(includeCardCursor),
|
||||
|
|
|
@ -305,8 +305,10 @@ export interface RangeInterface {
|
|||
/**
|
||||
* 获取光标路径
|
||||
* @param includeCardCursor 是否包含卡片两侧光标
|
||||
* @param root 根节点,默认编辑器根节点
|
||||
*/
|
||||
toPath(
|
||||
includeCardCursor?: boolean,
|
||||
root?: NodeInterface,
|
||||
): { start: RangePath; end: RangePath } | undefined;
|
||||
}
|
||||
|
|
|
@ -662,7 +662,7 @@ export default class extends MarkPlugin<Options> {
|
|||
const rangePath = rangeClone
|
||||
.shrinkToElementNode()
|
||||
.shrinkToTextNode()
|
||||
.toPath();
|
||||
.toPath(undefined, container);
|
||||
paths.push({
|
||||
id: id.split(','),
|
||||
path: rangePath
|
||||
|
|
Loading…
Reference in New Issue