fix: inline card set mark style
This commit is contained in:
parent
da2fb2b923
commit
76da0d7c9c
|
@ -265,6 +265,10 @@ class CardModel implements CardModelInterface {
|
|||
if (isInline) {
|
||||
if (isEngine(editor) && card.executeMark) {
|
||||
marks = editor.change.marks.map((mark) => mark.clone());
|
||||
const cardComponent = editor.card.find(range.startNode);
|
||||
if (cardComponent?.queryMarks) {
|
||||
marks.push(...cardComponent.queryMarks());
|
||||
}
|
||||
}
|
||||
inline.insert(card.root, range);
|
||||
} else {
|
||||
|
@ -404,6 +408,8 @@ class CardModel implements CardModelInterface {
|
|||
card.activate(true);
|
||||
} else if (card.isEditable) {
|
||||
card.select(false);
|
||||
} else if (trigger === CardActiveTrigger.MOUSE_DOWN) {
|
||||
event?.preventDefault();
|
||||
}
|
||||
if (
|
||||
!isCurrentActiveCard &&
|
||||
|
|
|
@ -670,10 +670,10 @@
|
|||
user-select: text;
|
||||
}
|
||||
|
||||
.am-engine span[data-card-type="inline"].card-selected span[data-card-element="left"],
|
||||
.am-engine-view span[data-card-type="inline"].card-selected span[data-card-element="left"],
|
||||
.am-engine span[data-card-type="inline"].card-selected span[data-card-element="right"],
|
||||
.am-engine-view span[data-card-type="inline"].card-selected span[data-card-element="right"] {
|
||||
.am-engine span[data-card-type="inline"].card-selected:not(.card-activated) span[data-card-element="left"],
|
||||
.am-engine-view span[data-card-type="inline"].card-selected:not(.card-activated) span[data-card-element="left"],
|
||||
.am-engine span[data-card-type="inline"].card-selected:not(.card-activated) span[data-card-element="right"],
|
||||
.am-engine-view span[data-card-type="inline"].card-selected:not(.card-activated) span[data-card-element="right"] {
|
||||
background: rgba(180, 213, 254, 0.5) !important;
|
||||
}
|
||||
|
||||
|
|
|
@ -545,7 +545,7 @@ class Inline implements InlineModelInterface {
|
|||
}
|
||||
});
|
||||
}
|
||||
range.enlargeToElementNode();
|
||||
range.enlargeToElementNode(!node.isBlock(range.startNode), false);
|
||||
return keelpNode;
|
||||
}
|
||||
/**
|
||||
|
@ -929,8 +929,21 @@ class Inline implements InlineModelInterface {
|
|||
repairCursor(node: NodeInterface | Node) {
|
||||
const nodeApi = this.editor.node;
|
||||
if (isNode(node)) node = $(node);
|
||||
if (!nodeApi.isInline(node) || nodeApi.isVoid(node) || node.isCard())
|
||||
if (!nodeApi.isInline(node) || nodeApi.isVoid(node) || node.isCard()) {
|
||||
const prev = node.prev();
|
||||
const prevText = prev?.isText() ? prev.text() : undefined;
|
||||
if (prevText && /\u200b$/.test(prevText)) {
|
||||
const pPrev = prev?.prev();
|
||||
if (!pPrev || !nodeApi.isInline(pPrev)) {
|
||||
if (prevText.length === 1) {
|
||||
prev?.remove();
|
||||
} else {
|
||||
prev?.text(prevText.slice(0, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
const childrenNodes = node.children();
|
||||
childrenNodes.each((_, index) => {
|
||||
const child = childrenNodes.eq(index);
|
||||
|
|
|
@ -299,8 +299,12 @@ class Range implements RangeInterface {
|
|||
* <p>[<strong><span>123</span>abc</strong>]def</p>
|
||||
* @param range 选区
|
||||
* @param toBlock 是否扩大到块级节点
|
||||
* @param toTop 是否尽可能扩大的可编辑节点下
|
||||
*/
|
||||
enlargeToElementNode = (toBlock?: boolean) => {
|
||||
enlargeToElementNode = (
|
||||
toBlock: boolean = false,
|
||||
toTop: boolean = true,
|
||||
) => {
|
||||
const range = this.enlargeFromTextNode();
|
||||
const nodeApi = this.editor.node;
|
||||
const enlargePosition = (
|
||||
|
@ -326,6 +330,10 @@ class Range implements RangeInterface {
|
|||
if (!parent.inEditor() || parent.isEditable()) {
|
||||
break;
|
||||
}
|
||||
if (!toTop) {
|
||||
if (!toBlock && parent.isElement()) break;
|
||||
if (toBlock && nodeApi.isBlock(parent)) break;
|
||||
}
|
||||
domNode = parent;
|
||||
}
|
||||
if (isStart) {
|
||||
|
@ -342,6 +350,10 @@ class Range implements RangeInterface {
|
|||
if (!parent.inEditor() || parent.isEditable()) {
|
||||
break;
|
||||
}
|
||||
if (!toTop) {
|
||||
if (!toBlock && parent.isElement()) break;
|
||||
if (toBlock && nodeApi.isBlock(parent)) break;
|
||||
}
|
||||
domNode = parent;
|
||||
}
|
||||
if (isStart) {
|
||||
|
|
|
@ -200,8 +200,9 @@ export interface RangeInterface {
|
|||
* <p>[<strong><span>123</span>abc</strong>]def</p>
|
||||
* @param range 选区
|
||||
* @param toBlock 是否扩大到块级节点
|
||||
* @param toTop 是否尽可能扩大的可编辑节点下
|
||||
*/
|
||||
enlargeToElementNode(toBlock?: boolean): RangeInterface;
|
||||
enlargeToElementNode(toBlock?: boolean, toTop?: boolean): RangeInterface;
|
||||
/**
|
||||
* 缩小边界
|
||||
* <body>[<p><strong>123</strong></p>]</body>
|
||||
|
|
Loading…
Reference in New Issue