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' }),
|
'/api': getMenus({ base: '/api' }),
|
||||||
},
|
},
|
||||||
analytics: {
|
analytics: {
|
||||||
baidu: 'c2e2e4254b6e4388806848d06be68a69',
|
baidu: '285af37fc760a8f865a67cb9120bfd8f',
|
||||||
},
|
},
|
||||||
manifest: {
|
manifest: {
|
||||||
fileName: 'manifest.json',
|
fileName: 'manifest.json',
|
||||||
|
|
|
@ -668,13 +668,8 @@ class Block implements BlockModelInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container && container.length > 0) {
|
if (container && container.length > 0) {
|
||||||
if (rightNodes.length > 0) {
|
safeRange.select(container, true);
|
||||||
safeRange.setStartAfter(container);
|
safeRange.collapse(false);
|
||||||
safeRange.collapse(true);
|
|
||||||
} else {
|
|
||||||
safeRange.select(container, true);
|
|
||||||
safeRange.collapse(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (selection.focus) selection.focus.remove();
|
if (selection.focus) selection.focus.remove();
|
||||||
if (selection.anchor) selection.anchor.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 range = this.cloneRange();
|
||||||
const node = range.commonAncestorNode;
|
const node = range.commonAncestorNode;
|
||||||
if (!node.isRoot() && !node.inEditor()) return;
|
if (!node.isRoot() && !node.inEditor()) return;
|
||||||
|
@ -777,7 +780,7 @@ class Range implements RangeInterface {
|
||||||
let rootBeginId: string = node.attributes(DATA_ID);
|
let rootBeginId: string = node.attributes(DATA_ID);
|
||||||
let rootBeginIndex: number = rootBeginId ? 0 : -1;
|
let rootBeginIndex: number = rootBeginId ? 0 : -1;
|
||||||
const path = node.getPath(
|
const path = node.getPath(
|
||||||
this.editor.container,
|
root,
|
||||||
node.parent()?.isRoot()
|
node.parent()?.isRoot()
|
||||||
? undefined
|
? undefined
|
||||||
: this.filterPath(includeCardCursor),
|
: this.filterPath(includeCardCursor),
|
||||||
|
|
|
@ -305,8 +305,10 @@ export interface RangeInterface {
|
||||||
/**
|
/**
|
||||||
* 获取光标路径
|
* 获取光标路径
|
||||||
* @param includeCardCursor 是否包含卡片两侧光标
|
* @param includeCardCursor 是否包含卡片两侧光标
|
||||||
|
* @param root 根节点,默认编辑器根节点
|
||||||
*/
|
*/
|
||||||
toPath(
|
toPath(
|
||||||
includeCardCursor?: boolean,
|
includeCardCursor?: boolean,
|
||||||
|
root?: NodeInterface,
|
||||||
): { start: RangePath; end: RangePath } | undefined;
|
): { start: RangePath; end: RangePath } | undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -662,7 +662,7 @@ export default class extends MarkPlugin<Options> {
|
||||||
const rangePath = rangeClone
|
const rangePath = rangeClone
|
||||||
.shrinkToElementNode()
|
.shrinkToElementNode()
|
||||||
.shrinkToTextNode()
|
.shrinkToTextNode()
|
||||||
.toPath();
|
.toPath(undefined, container);
|
||||||
paths.push({
|
paths.push({
|
||||||
id: id.split(','),
|
id: id.split(','),
|
||||||
path: rangePath
|
path: rangePath
|
||||||
|
|
Loading…
Reference in New Issue