@ylzcc/editor 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.es.js +76 -44
- package/dist/editor.umd.js +7 -7
- package/dist/style.css +1 -1
- package/package.json +6 -3
package/dist/editor.es.js
CHANGED
|
@@ -62471,7 +62471,7 @@ const Heading = Node$1.create({
|
|
|
62471
62471
|
HTMLAttributes: {
|
|
62472
62472
|
class: "tiptap-title"
|
|
62473
62473
|
},
|
|
62474
|
-
limitChar:
|
|
62474
|
+
limitChar: 10,
|
|
62475
62475
|
// 输入的字符个数限制
|
|
62476
62476
|
onChange: () => {
|
|
62477
62477
|
},
|
|
@@ -62480,17 +62480,17 @@ const Heading = Node$1.create({
|
|
|
62480
62480
|
// 标题是否可以编辑
|
|
62481
62481
|
};
|
|
62482
62482
|
},
|
|
62483
|
-
|
|
62484
|
-
|
|
62485
|
-
|
|
62486
|
-
|
|
62487
|
-
|
|
62488
|
-
|
|
62489
|
-
|
|
62490
|
-
|
|
62491
|
-
|
|
62492
|
-
|
|
62493
|
-
|
|
62483
|
+
addKeyboardShortcuts() {
|
|
62484
|
+
return {
|
|
62485
|
+
// 'Mod-x': (props) => {
|
|
62486
|
+
// console.log(props)
|
|
62487
|
+
// return true
|
|
62488
|
+
// },
|
|
62489
|
+
// 'Mod-c': (props) => {
|
|
62490
|
+
// return true
|
|
62491
|
+
// }
|
|
62492
|
+
};
|
|
62493
|
+
},
|
|
62494
62494
|
addProseMirrorPlugins() {
|
|
62495
62495
|
const { limitChar: Ff, onChange: kh, titleEditable: x_ } = this.options, { editor: B_ } = this;
|
|
62496
62496
|
return [
|
|
@@ -62506,8 +62506,12 @@ const Heading = Node$1.create({
|
|
|
62506
62506
|
handleTextInput($_, $P, zP, eme) {
|
|
62507
62507
|
var ume;
|
|
62508
62508
|
const { state: tme } = $_, { selection: nme, doc: rme } = tme, { anchor: ime, $from: ome } = nme, ame = rme.firstChild;
|
|
62509
|
-
if (ame && ime
|
|
62510
|
-
if (!x_
|
|
62509
|
+
if (ame && ime < (ame == null ? void 0 : ame.nodeSize)) {
|
|
62510
|
+
if (!x_)
|
|
62511
|
+
return !0;
|
|
62512
|
+
if ($_.composing)
|
|
62513
|
+
return !1;
|
|
62514
|
+
if (ame != null && ame.textContent && ((ume = ame == null ? void 0 : ame.textContent) == null ? void 0 : ume.length) >= Ff)
|
|
62511
62515
|
return !0;
|
|
62512
62516
|
const cme = new RegExp("^[a-zA-Z0-9 \\u4e00-\\u9fa5\\_\\-]+$");
|
|
62513
62517
|
if (ame != null && ame.textContent && !cme.test((ame == null ? void 0 : ame.textContent) + eme))
|
|
@@ -62523,8 +62527,12 @@ const Heading = Node$1.create({
|
|
|
62523
62527
|
filterTransaction($_, $P) {
|
|
62524
62528
|
if (x_)
|
|
62525
62529
|
return !0;
|
|
62526
|
-
|
|
62527
|
-
|
|
62530
|
+
{
|
|
62531
|
+
const zP = $_.doc.firstChild, eme = $P.doc.firstChild;
|
|
62532
|
+
if (B_.isFocused && (zP == null ? void 0 : zP.textContent) !== (eme == null ? void 0 : eme.textContent))
|
|
62533
|
+
return !1;
|
|
62534
|
+
}
|
|
62535
|
+
return !0;
|
|
62528
62536
|
}
|
|
62529
62537
|
})
|
|
62530
62538
|
];
|
|
@@ -62550,7 +62558,7 @@ const Heading = Node$1.create({
|
|
|
62550
62558
|
return {
|
|
62551
62559
|
emptyEditorClass: "tiptap-editor-is-empty",
|
|
62552
62560
|
emptyNodeClass: "tiptap-is-empty",
|
|
62553
|
-
placeholder: "
|
|
62561
|
+
placeholder: "点击“+”或输入“/”快速添加",
|
|
62554
62562
|
showOnlyWhenEditable: !0,
|
|
62555
62563
|
considerAnyAsEmpty: !1,
|
|
62556
62564
|
showOnlyCurrent: !0,
|
|
@@ -84755,6 +84763,10 @@ const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension:
|
|
|
84755
84763
|
nme.isEditable && (kh = setTimeout(() => {
|
|
84756
84764
|
rme == null || rme.move(eme, tme);
|
|
84757
84765
|
}, 0));
|
|
84766
|
+
},
|
|
84767
|
+
wheel: () => {
|
|
84768
|
+
var eme;
|
|
84769
|
+
(eme = Ff.tip) == null || eme.hide();
|
|
84758
84770
|
}
|
|
84759
84771
|
},
|
|
84760
84772
|
decorations(eme) {
|
|
@@ -86635,6 +86647,7 @@ const upload = async (Ff) => {
|
|
|
86635
86647
|
placement: "bottom-start",
|
|
86636
86648
|
content: $P,
|
|
86637
86649
|
interactive: !0,
|
|
86650
|
+
trigger: "mouseenter focus click focusin",
|
|
86638
86651
|
// duration: [300, 300],
|
|
86639
86652
|
// interactiveBorder: 40,
|
|
86640
86653
|
// interactiveDebounce: 75,
|
|
@@ -86664,8 +86677,10 @@ const upload = async (Ff) => {
|
|
|
86664
86677
|
// interactiveBorder: 40,
|
|
86665
86678
|
// interactiveDebounce: 75,
|
|
86666
86679
|
onTrigger(sme, lme) {
|
|
86680
|
+
kh == null || kh.commands.changeTip(!0);
|
|
86667
86681
|
},
|
|
86668
86682
|
onHide(sme) {
|
|
86683
|
+
kh == null || kh.commands.changeTip(!1);
|
|
86669
86684
|
}
|
|
86670
86685
|
});
|
|
86671
86686
|
return () => {
|
|
@@ -86704,6 +86719,20 @@ class EventEmitter {
|
|
|
86704
86719
|
this.callbacks = {};
|
|
86705
86720
|
}
|
|
86706
86721
|
}
|
|
86722
|
+
const allowTypes = [
|
|
86723
|
+
"paragraph",
|
|
86724
|
+
// 段落
|
|
86725
|
+
"heading",
|
|
86726
|
+
// 标题
|
|
86727
|
+
"horizontalRule",
|
|
86728
|
+
// 分割线
|
|
86729
|
+
"blockquote",
|
|
86730
|
+
// 引用
|
|
86731
|
+
"codeBlock",
|
|
86732
|
+
// 代码快
|
|
86733
|
+
"image"
|
|
86734
|
+
// 图片
|
|
86735
|
+
];
|
|
86707
86736
|
class Handle {
|
|
86708
86737
|
// 是否阻止显示或隐藏的开关
|
|
86709
86738
|
constructor(kh, x_, B_, $_ = []) {
|
|
@@ -86729,11 +86758,11 @@ class Handle {
|
|
|
86729
86758
|
}
|
|
86730
86759
|
// 是否覆盖创建,默认不覆盖,如果存在不进行创建
|
|
86731
86760
|
createTippy(kh = !1) {
|
|
86732
|
-
var B_, $_, $P
|
|
86761
|
+
var B_, $_, $P;
|
|
86733
86762
|
if (!kh && this.tippy)
|
|
86734
86763
|
return;
|
|
86735
86764
|
const x_ = this.build();
|
|
86736
|
-
this.tippy = tippy(
|
|
86765
|
+
this.tippy = tippy(document.body, {
|
|
86737
86766
|
duration: 0,
|
|
86738
86767
|
getReferenceClientRect: null,
|
|
86739
86768
|
content: x_,
|
|
@@ -86744,7 +86773,7 @@ class Handle {
|
|
|
86744
86773
|
placement: "left-start",
|
|
86745
86774
|
hideOnClick: "toggle",
|
|
86746
86775
|
...this.tippyOptions
|
|
86747
|
-
}), (
|
|
86776
|
+
}), ($P = ($_ = (B_ = this.editor) == null ? void 0 : B_.view) == null ? void 0 : $_.dom.parentElement) == null || $P.addEventListener("mouseleave", this.mouseLeave.bind(this));
|
|
86748
86777
|
}
|
|
86749
86778
|
mouseLeave() {
|
|
86750
86779
|
setTimeout(() => {
|
|
@@ -86783,14 +86812,14 @@ class Handle {
|
|
|
86783
86812
|
if (eme !== this.lastPos) {
|
|
86784
86813
|
this.lastPos = eme, this.emitter.emit("hover", { node: ime, pos: ome, range: { from: ome, to: ome + ime.nodeSize } });
|
|
86785
86814
|
const cme = posToDOMRect(kh, ome, ome + ime.nodeSize);
|
|
86786
|
-
ime.type.name === "horizontalRule" ? this.setProps({
|
|
86815
|
+
ime.type.name === "horizontalRule" ? (cme.top - 10 < 5 && (nme = !0), this.setProps({
|
|
86787
86816
|
getReferenceClientRect: () => ({ ...cme, top: cme.top - 10 })
|
|
86788
|
-
}) : this.setProps({
|
|
86789
|
-
getReferenceClientRect: () => ({ ...cme, top: cme.top +
|
|
86790
|
-
});
|
|
86817
|
+
})) : (cme.top + 6 < 5 && (nme = !0), this.setProps({
|
|
86818
|
+
getReferenceClientRect: () => ({ ...cme, top: cme.top + 6 })
|
|
86819
|
+
}));
|
|
86791
86820
|
} else
|
|
86792
86821
|
rme = !1;
|
|
86793
|
-
ime.type.name !== "paragraph" ? this.emitter.emit("type", { type: "content" }) : this.emitter.emit("type", { type: "add" }), this.ignoreType.includes(ime.type.name) && (nme = !0);
|
|
86822
|
+
ime.type.name !== "paragraph" ? this.emitter.emit("type", { type: "content" }) : this.emitter.emit("type", { type: "add" }), allowTypes.includes(ime.type.name) || (nme = !0), this.ignoreType.includes(ime.type.name) && (nme = !0);
|
|
86794
86823
|
}
|
|
86795
86824
|
return !1;
|
|
86796
86825
|
}), rme && (nme ? this.hide() : this.show());
|
|
@@ -86810,7 +86839,9 @@ const FloatingMenu = Extension.create({
|
|
|
86810
86839
|
},
|
|
86811
86840
|
onBeforeCreate() {
|
|
86812
86841
|
this.options.tip = new Handle(this.editor, Tip, {}, [
|
|
86813
|
-
"title"
|
|
86842
|
+
"title",
|
|
86843
|
+
"pdf",
|
|
86844
|
+
"active"
|
|
86814
86845
|
]);
|
|
86815
86846
|
},
|
|
86816
86847
|
addCommands() {
|
|
@@ -87080,7 +87111,7 @@ const normalClass = "tiptap-menu-item-menus-item", lighClass = "tiptap-menu-item
|
|
|
87080
87111
|
}, ume = () => {
|
|
87081
87112
|
x_ == null || x_.chain().focus(eme).deleteRange($_.range).showBubbleMenu({ from: eme, to: eme }).hideMenu().run();
|
|
87082
87113
|
}, cme = (mme) => {
|
|
87083
|
-
window.postMessage({
|
|
87114
|
+
x_ == null || x_.chain().focus(eme).deleteRange($_.range).hideMenu().run(), window.postMessage({
|
|
87084
87115
|
type: mme,
|
|
87085
87116
|
value: {
|
|
87086
87117
|
pos: eme
|
|
@@ -87217,7 +87248,7 @@ const normalClass = "tiptap-menu-item-menus-item", lighClass = "tiptap-menu-item
|
|
|
87217
87248
|
allow: (Ff) => {
|
|
87218
87249
|
const kh = Ff.editor.state.doc;
|
|
87219
87250
|
let x_ = !0;
|
|
87220
|
-
return kh.nodesBetween(Ff.range.from, Ff.range.to, (B_, $_, $P) => (ignoreChar.includes(B_.type.name) && (x_ = !1), !1)), x_;
|
|
87251
|
+
return Ff.editor.isFocused && kh.nodesBetween(Ff.range.from, Ff.range.to, (B_, $_, $P) => (ignoreChar.includes(B_.type.name) && (x_ = !1), !1)), x_;
|
|
87221
87252
|
}
|
|
87222
87253
|
};
|
|
87223
87254
|
},
|
|
@@ -87227,8 +87258,8 @@ const normalClass = "tiptap-menu-item-menus-item", lighClass = "tiptap-menu-item
|
|
|
87227
87258
|
if (this.options.tip)
|
|
87228
87259
|
return;
|
|
87229
87260
|
const kh = build(SlashMenu, this.editor, this.options.emitter);
|
|
87230
|
-
this.options.tip = tippy(
|
|
87231
|
-
appendTo: document.body,
|
|
87261
|
+
this.options.tip = tippy(document.body, {
|
|
87262
|
+
// appendTo: document.body,
|
|
87232
87263
|
getReferenceClientRect: null,
|
|
87233
87264
|
content: kh,
|
|
87234
87265
|
interactive: !0,
|
|
@@ -91911,19 +91942,20 @@ function code$1() {
|
|
|
91911
91942
|
}
|
|
91912
91943
|
function codeText() {
|
|
91913
91944
|
return {
|
|
91914
|
-
tokenize: Ff
|
|
91945
|
+
tokenize: Ff,
|
|
91946
|
+
concrete: !0
|
|
91915
91947
|
};
|
|
91916
91948
|
function Ff(kh, x_, B_) {
|
|
91917
91949
|
let $_ = 0, $P = 0, zP = 0, eme = 0, tme = 0, nme = 0;
|
|
91918
91950
|
return kh.enter("codeBlock"), kh.enter("codeMeta"), rme;
|
|
91919
91951
|
function rme(lme) {
|
|
91920
|
-
return lme === 96 ? ($_++, kh.consume(lme), rme) : $_ !== 3 || lme
|
|
91952
|
+
return lme === 96 ? ($_++, kh.consume(lme), rme) : $_ !== 3 || lme == null ? B_(lme) : ime(lme);
|
|
91921
91953
|
}
|
|
91922
91954
|
function ime(lme) {
|
|
91923
|
-
return
|
|
91955
|
+
return 0 > lme ? (kh.exit("codeMeta"), ome(lme)) : (kh.enter("codeMetadata"), kh.consume(lme), kh.exit("codeMetadata"), ime);
|
|
91924
91956
|
}
|
|
91925
91957
|
function ome(lme) {
|
|
91926
|
-
return lme ===
|
|
91958
|
+
return lme === 96 && zP ? ($P && kh.exit("codeData"), ame(lme)) : (0 > lme ? zP = 1 : zP = 0, $P || kh.enter("codeData"), !$P && 0 > lme ? ($P++, kh.enter("codeContentIgnore"), kh.consume(lme), kh.exit("codeContentIgnore"), ome) : ($P++, kh.enter("codeContent"), kh.consume(lme), kh.exit("codeContent"), ome));
|
|
91927
91959
|
}
|
|
91928
91960
|
function ame(lme) {
|
|
91929
91961
|
return lme === 96 ? (eme++, kh.enter("codeClose"), kh.consume(lme), kh.exit("codeClose"), ame) : eme !== 3 ? B_(lme) : lme == 123 ? ume(lme) : lme === null || 0 > lme ? (kh.exit("codeBlock"), x_(lme)) : B_(lme);
|
|
@@ -91932,10 +91964,10 @@ function codeText() {
|
|
|
91932
91964
|
return lme === 123 ? (tme++, kh.enter("codeLeft"), kh.consume(lme), kh.exit("codeLeft"), ume) : tme !== 2 ? B_(lme) : cme(lme);
|
|
91933
91965
|
}
|
|
91934
91966
|
function cme(lme) {
|
|
91935
|
-
return lme ===
|
|
91967
|
+
return lme === 125 ? sme(lme) : (kh.enter("codeProperties"), kh.consume(lme), kh.exit("codeProperties"), cme);
|
|
91936
91968
|
}
|
|
91937
91969
|
function sme(lme) {
|
|
91938
|
-
return lme === 125 ? (nme++, kh.enter("codeRight"), kh.consume(lme), kh.exit("codeRight"), sme) : nme != 2 ? B_(lme) :
|
|
91970
|
+
return lme === 125 ? (nme++, kh.enter("codeRight"), kh.consume(lme), kh.exit("codeRight"), sme) : nme != 2 ? B_(lme) : lme === null || 0 > lme ? (kh.exit("codeBlock"), x_(lme)) : B_(lme);
|
|
91939
91971
|
}
|
|
91940
91972
|
}
|
|
91941
91973
|
}
|
|
@@ -94253,8 +94285,8 @@ const LinkComponent = (Ff) => {
|
|
|
94253
94285
|
var dme;
|
|
94254
94286
|
kh == null || kh.commands.unsetLink(), (dme = kh == null ? void 0 : kh.commands) == null || dme.hideLinkTip();
|
|
94255
94287
|
}, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
94256
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("path", {
|
|
94257
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("path", {
|
|
94288
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.7787 13.7347L2.26416 3.22022L3.21875 2.26562L13.7333 12.7802L12.7787 13.7347Z", fill: "#666666" }),
|
|
94289
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M11.2993 9.41374L12.2422 10.3565L13.185 9.41374C15.0074 7.59134 15.0074 4.63655 13.185 2.8141C11.3625 0.991654 8.40781 0.991654 6.58533 2.8141L5.64253 3.75691L6.58533 4.69972L7.52815 3.75691C8.82988 2.45516 10.9404 2.45516 12.2422 3.75691C13.5439 5.05865 13.5439 7.16921 12.2422 8.47094L11.2993 9.41374ZM9.86676 12.732L8.92396 11.7892L8.47095 12.2422C7.16921 13.5439 5.05865 13.5439 3.75691 12.2422C2.45516 10.9405 2.45516 8.82987 3.75691 7.52814L4.2099 7.07515L3.2671 6.13234L2.8141 6.58533C0.991654 8.40781 0.991654 11.3625 2.8141 13.185C4.63655 15.0075 7.59135 15.0075 9.41375 13.185L9.86676 12.732ZM7.05011 8.00616L9.88515 5.17112L10.8279 6.11393L7.99293 8.94898L7.05011 8.00616ZM6.09551 8.96075L7.03834 9.90358L6.11393 10.828L5.17112 9.88514L6.09551 8.96075Z", fill: "#666666" })
|
|
94258
94290
|
] }) }),
|
|
94259
94291
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hoveValue", ref: nme, children: Ff == null ? void 0 : Ff.value }),
|
|
94260
94292
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hoveValue", ref: ime, children: ume }),
|
|
@@ -123388,7 +123420,7 @@ const EditorComponent = (Ff) => {
|
|
|
123388
123420
|
config: $P
|
|
123389
123421
|
});
|
|
123390
123422
|
$_(zP);
|
|
123391
|
-
}, [B_]), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: x_, style: { border: "none" } });
|
|
123423
|
+
}, [B_]), /* @__PURE__ */ jsxRuntimeExports.jsx("div", { contentEditable: !1, ref: x_, style: { border: "none" } });
|
|
123392
123424
|
}, AllActive = (Ff) => {
|
|
123393
123425
|
var Dme, Bme, $me, Ume, Vme, Gme, zme, qme, u_e, Zme, T_e, l_e, g_e, E_e, p_e, t_e, i_e, b_e, O_e, Kme, o_e, y_e, A_e, N_e, F_e, V_e, v_e, h_e, r_e, Jme;
|
|
123394
123426
|
const [kh, x_] = useState(), [B_, $_] = useState([]), [$P, zP] = useState(!1), [eme, tme] = useState(void 0), [nme, rme] = useState(!1), [ime, ome] = useState([]), [ame, ume] = useState(!0), [cme, sme] = useState([]), [lme, dme] = useState(!1), [fme, pme] = useState(!1), [hme, mme] = useState(0), [_me, gme] = useState(!1), [vme, Sme] = useState(), [Eme, bme] = useState(), [Rme, wme] = useState(), [Pme, Lme] = useState(), [Mme, yme] = useState(), kme = (d_e, R_e) => {
|
|
@@ -139904,13 +139936,13 @@ const deleteTableWhenAllCellsSelected = ({ editor: Ff }) => {
|
|
|
139904
139936
|
return [
|
|
139905
139937
|
{
|
|
139906
139938
|
tag: "div",
|
|
139907
|
-
|
|
139908
|
-
|
|
139939
|
+
getAttrs(Ff) {
|
|
139940
|
+
return Ff instanceof HTMLElement && (Ff != null && Ff.classList.contains("tableWrapper")) ? {} : !1;
|
|
139909
139941
|
}
|
|
139942
|
+
},
|
|
139943
|
+
{
|
|
139944
|
+
tag: "table"
|
|
139910
139945
|
}
|
|
139911
|
-
// {
|
|
139912
|
-
// tag: 'table'
|
|
139913
|
-
// }
|
|
139914
139946
|
];
|
|
139915
139947
|
}
|
|
139916
139948
|
}), { BubbleMenu, BubbleMenuView } = bubbleModules, shareData = createContext({});
|