update: when marks are stored, do not nest
This commit is contained in:
parent
606fa7bae2
commit
4169dbf395
|
@ -295,7 +295,7 @@ export default class<T extends MarkRangeOptions> extends MarkPlugin<T> {
|
|||
subRanges.forEach((subRange) => {
|
||||
//如果是卡片,就给卡片加上预览样式
|
||||
const cardComponent = card.find(subRange.startNode);
|
||||
if (cardComponent) {
|
||||
if (cardComponent && !cardComponent.executeMark) {
|
||||
text += `[card:${
|
||||
(cardComponent.constructor as CardEntry).cardName
|
||||
},${cardComponent.id}]`;
|
||||
|
@ -670,8 +670,17 @@ export default class<T extends MarkRangeOptions> extends MarkPlugin<T> {
|
|||
const rangeClone = range.cloneRange();
|
||||
|
||||
if (childNode.isCard()) {
|
||||
rangeClone.select(childNode);
|
||||
const cardComponent = card.find(childNode);
|
||||
if (cardComponent && cardComponent.executeMark) {
|
||||
const idName = this.getIdName(key);
|
||||
const markNode = cardComponent.root.find(
|
||||
`[${idName}="${id}"]`,
|
||||
);
|
||||
cardComponent.executeMark(markNode.clone(), false);
|
||||
} else {
|
||||
childNode.removeAttributes(this.getIdName(key));
|
||||
}
|
||||
rangeClone.select(childNode);
|
||||
} else {
|
||||
rangeClone.select(childNode, true);
|
||||
const selection = rangeClone.createSelection();
|
||||
|
@ -765,8 +774,22 @@ export default class<T extends MarkRangeOptions> extends MarkPlugin<T> {
|
|||
elements.forEach((element) => {
|
||||
const node = $(element);
|
||||
if (node.isCard()) {
|
||||
const cardComponent = card.find(node);
|
||||
if (cardComponent && cardComponent.executeMark) {
|
||||
cardComponent.executeMark(
|
||||
$(
|
||||
`<${this.tagName} ${
|
||||
this.MARK_KEY
|
||||
}="${key}" ${this.getIdName(key)}="${id.join(
|
||||
',',
|
||||
)}" />`,
|
||||
),
|
||||
true,
|
||||
);
|
||||
} else {
|
||||
node.attributes(this.getIdName(key), id.join(','));
|
||||
}
|
||||
}
|
||||
});
|
||||
this.editor.mark.wrap(
|
||||
`<${this.tagName} ${this.MARK_KEY}="${key}" ${this.getIdName(
|
||||
|
|
|
@ -294,7 +294,7 @@ class Mention<T extends MentionValue = MentionValue> extends Card<T> {
|
|||
if (child) this.editor.mark.wrapByNode(child, mark);
|
||||
});
|
||||
const marks = this.queryMarks().map(
|
||||
(child) => child.get<HTMLElement>()?.outerHTML || '',
|
||||
(child) => child.clone().get<HTMLElement>()?.outerHTML || '',
|
||||
);
|
||||
this.setValue({
|
||||
marks,
|
||||
|
@ -315,7 +315,8 @@ class Mention<T extends MentionValue = MentionValue> extends Card<T> {
|
|||
if (!this.#container) return [];
|
||||
return this.#container
|
||||
.allChildren()
|
||||
.filter((child) => child.isElement());
|
||||
.filter((child) => child.isElement())
|
||||
.map((c) => c.clone());
|
||||
}
|
||||
|
||||
render(): string | void | NodeInterface {
|
||||
|
|
|
@ -192,7 +192,7 @@ class Status<T extends StatusValue = StatusValue> extends Card<T> {
|
|||
if (child) this.editor.mark.wrapByNode(child, mark);
|
||||
});
|
||||
const marks = this.queryMarks().map(
|
||||
(child) => child.get<HTMLElement>()?.outerHTML || '',
|
||||
(child) => child.clone().get<HTMLElement>()?.outerHTML || '',
|
||||
);
|
||||
this.setValue({
|
||||
marks,
|
||||
|
@ -214,7 +214,8 @@ class Status<T extends StatusValue = StatusValue> extends Card<T> {
|
|||
if (!this.#container) return [];
|
||||
return this.#container
|
||||
.allChildren()
|
||||
.filter((child) => child.isElement());
|
||||
.filter((child) => child.isElement())
|
||||
.map((c) => c.clone());
|
||||
}
|
||||
|
||||
focusEditor() {
|
||||
|
|
Loading…
Reference in New Issue