update(link)

This commit is contained in:
yanmao 2022-01-22 15:39:51 +08:00
parent 14f8f04ba1
commit cc109b38f0
3 changed files with 22 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import {
CARD_EDITABLE_KEY,
CARD_ELEMENT_KEY,
CARD_KEY,
CARD_SELECTOR,
@ -934,7 +935,13 @@ 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) ||
node.closest(CARD_SELECTOR).attributes(CARD_EDITABLE_KEY) ===
'false' ||
nodeApi.isVoid(node) ||
node.isCard()
) {
const prev = node.prev();
const prevText = prev?.isText() ? prev.text() : undefined;
if (prevText && /\u200b$/.test(prevText)) {
@ -947,6 +954,18 @@ class Inline implements InlineModelInterface {
}
}
}
const next = node.next();
const nextText = next?.isText() ? next.text() : undefined;
if (nextText && /^\u200b/.test(nextText)) {
const nNext = next?.next();
if (!nNext || !nodeApi.isInline(nNext)) {
if (nextText.length === 1) {
next?.remove();
} else {
next?.text(nextText.slice(1));
}
}
}
return;
}
const childrenNodes = node.children();

View File

@ -217,7 +217,7 @@ export default class<
const { node, inline } = this.editor;
if (
/^https?:\/\/\S+$/.test(text.toLowerCase().trim()) &&
inline.closest(child)
!inline.closest(child).equal(child)
) {
node.wrap(
child,

View File

@ -217,7 +217,7 @@ export default class<
const { node, inline } = this.editor;
if (
/^https?:\/\/\S+$/.test(text.toLowerCase().trim()) &&
inline.closest(child)
!inline.closest(child).equal(child)
) {
node.wrap(
child,