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