@ylzcc/editor 0.2.4 → 0.2.6
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 +67 -45
- package/dist/editor.umd.js +4 -4
- package/dist/style.css +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +5 -2
package/dist/editor.es.js
CHANGED
|
@@ -62558,7 +62558,7 @@ const Heading = Node$1.create({
|
|
|
62558
62558
|
return {
|
|
62559
62559
|
emptyEditorClass: "tiptap-editor-is-empty",
|
|
62560
62560
|
emptyNodeClass: "tiptap-is-empty",
|
|
62561
|
-
placeholder: "
|
|
62561
|
+
placeholder: "点击“+”或输入“/”快速添加",
|
|
62562
62562
|
showOnlyWhenEditable: !0,
|
|
62563
62563
|
considerAnyAsEmpty: !1,
|
|
62564
62564
|
showOnlyCurrent: !0,
|
|
@@ -84630,33 +84630,33 @@ function LowlightPlugin({
|
|
|
84630
84630
|
return B_;
|
|
84631
84631
|
}
|
|
84632
84632
|
const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension: B_ }) => {
|
|
84633
|
-
var lme, dme, fme, pme, hme, mme
|
|
84634
|
-
const $_ = useContext(shareData), [$P, zP] = useState("light"), [eme, tme] = useState(((lme = kh == null ? void 0 : kh.attrs) == null ? void 0 : lme.exec) || !1), [nme, rme] = useState(!1), [ime, ome] = useState(!1), ame = (
|
|
84633
|
+
var lme, dme, fme, pme, hme, mme;
|
|
84634
|
+
const $_ = useContext(shareData), [$P, zP] = useState("light"), [eme, tme] = useState(((lme = kh == null ? void 0 : kh.attrs) == null ? void 0 : lme.exec) || !1), [nme, rme] = useState(!1), [ime, ome] = useState(!1), ame = (_me) => {
|
|
84635
84635
|
x_({
|
|
84636
|
-
language:
|
|
84636
|
+
language: _me
|
|
84637
84637
|
});
|
|
84638
|
-
}, ume = (
|
|
84639
|
-
var
|
|
84640
|
-
const
|
|
84641
|
-
tme(
|
|
84642
|
-
exec:
|
|
84638
|
+
}, ume = (_me) => {
|
|
84639
|
+
var vme;
|
|
84640
|
+
const gme = (vme = _me == null ? void 0 : _me.target) == null ? void 0 : vme.checked;
|
|
84641
|
+
tme(gme), x_({
|
|
84642
|
+
exec: gme
|
|
84643
84643
|
});
|
|
84644
84644
|
}, cme = () => {
|
|
84645
|
-
var
|
|
84646
|
-
(
|
|
84645
|
+
var _me;
|
|
84646
|
+
(_me = navigator == null ? void 0 : navigator.clipboard) == null || _me.writeText(kh == null ? void 0 : kh.textContent).then(() => {
|
|
84647
84647
|
rme(!0);
|
|
84648
|
-
const
|
|
84649
|
-
rme(!1), clearTimeout(
|
|
84648
|
+
const gme = setTimeout(() => {
|
|
84649
|
+
rme(!1), clearTimeout(gme);
|
|
84650
84650
|
}, 2e3);
|
|
84651
84651
|
});
|
|
84652
84652
|
}, sme = () => {
|
|
84653
|
-
var
|
|
84654
|
-
(
|
|
84653
|
+
var _me;
|
|
84654
|
+
(_me = B_ == null ? void 0 : B_.options) == null || _me.onExec(kh == null ? void 0 : kh.textContent);
|
|
84655
84655
|
};
|
|
84656
84656
|
return useEffect(() => {
|
|
84657
84657
|
zP(eme ? "dark" : "light");
|
|
84658
84658
|
}, [eme]), /* @__PURE__ */ jsxRuntimeExports.jsx(NodeViewWrapper, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `code-block code-block-${$P}`, onMouseEnter: () => ome(!0), onMouseLeave: () => ome(!1), children: [
|
|
84659
|
-
|
|
84659
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-header", contentEditable: !1, style: { display: ime ? "flex" : "none" }, children: [
|
|
84660
84660
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-header-left", children: [
|
|
84661
84661
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
84662
84662
|
Select$1,
|
|
@@ -84668,7 +84668,7 @@ const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension:
|
|
|
84668
84668
|
onChange: ame,
|
|
84669
84669
|
options: [
|
|
84670
84670
|
{ value: "", label: "atuo" },
|
|
84671
|
-
...(hme = (pme = (fme = B_ == null ? void 0 : B_.options) == null ? void 0 : fme.lowlight) == null ? void 0 : pme.listLanguages()) == null ? void 0 : hme.map((
|
|
84671
|
+
...(hme = (pme = (fme = B_ == null ? void 0 : B_.options) == null ? void 0 : fme.lowlight) == null ? void 0 : pme.listLanguages()) == null ? void 0 : hme.map((_me) => ({ value: _me, label: _me }))
|
|
84672
84672
|
]
|
|
84673
84673
|
}
|
|
84674
84674
|
),
|
|
@@ -84676,7 +84676,7 @@ const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension:
|
|
|
84676
84676
|
Select$1,
|
|
84677
84677
|
{
|
|
84678
84678
|
disabled: !0,
|
|
84679
|
-
defaultValue: (
|
|
84679
|
+
defaultValue: (mme = $_ == null ? void 0 : $_.template) == null ? void 0 : mme.name
|
|
84680
84680
|
}
|
|
84681
84681
|
)
|
|
84682
84682
|
] }),
|
|
@@ -84761,6 +84761,10 @@ const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension:
|
|
|
84761
84761
|
kh && clearTimeout(kh);
|
|
84762
84762
|
const { editor: nme, tip: rme } = Ff;
|
|
84763
84763
|
nme.isEditable && (kh = setTimeout(() => {
|
|
84764
|
+
var ume, cme;
|
|
84765
|
+
const ime = (cme = (ume = nme == null ? void 0 : nme.view) == null ? void 0 : ume.state) == null ? void 0 : cme.selection, { from: ome, to: ame } = ime;
|
|
84766
|
+
if (console.log(ome, ame), ome != ame)
|
|
84767
|
+
return !1;
|
|
84764
84768
|
rme == null || rme.move(eme, tme);
|
|
84765
84769
|
}, 0));
|
|
84766
84770
|
},
|
|
@@ -86299,13 +86303,16 @@ const upload = async (Ff) => {
|
|
|
86299
86303
|
}, textToBase64 = (Ff) => {
|
|
86300
86304
|
const x_ = new TextEncoder().encode(Ff), B_ = String.fromCharCode(...x_);
|
|
86301
86305
|
return btoa(B_);
|
|
86306
|
+
}, getFileSuffix = (Ff) => {
|
|
86307
|
+
const kh = Ff.indexOf(".") > -1 ? Ff.split(".") : [];
|
|
86308
|
+
return kh.length > 0 ? kh[kh.length - 1] : "";
|
|
86302
86309
|
}, marks = {
|
|
86303
86310
|
strong: "bold",
|
|
86304
86311
|
emphasis: "italic",
|
|
86305
86312
|
delete: "strike",
|
|
86306
86313
|
link: "link"
|
|
86307
86314
|
}, toNodeObj = (Ff, kh) => {
|
|
86308
|
-
var $_, $P, zP, eme;
|
|
86315
|
+
var $_, $P, zP, eme, tme;
|
|
86309
86316
|
const x_ = {};
|
|
86310
86317
|
x_.type = Ff == null ? void 0 : Ff.type;
|
|
86311
86318
|
const B_ = kh ? [...kh] : [];
|
|
@@ -86322,6 +86329,9 @@ const upload = async (Ff) => {
|
|
|
86322
86329
|
case "list":
|
|
86323
86330
|
x_.type = Ff != null && Ff.ordered ? "orderedList" : "bulletList";
|
|
86324
86331
|
break;
|
|
86332
|
+
case "listItem":
|
|
86333
|
+
($_ = Ff.children) != null && $_.length || (x_.content = [{ type: "paragraph" }]);
|
|
86334
|
+
break;
|
|
86325
86335
|
case "thematicBreak":
|
|
86326
86336
|
x_.type = "horizontalRule";
|
|
86327
86337
|
break;
|
|
@@ -86339,34 +86349,31 @@ const upload = async (Ff) => {
|
|
|
86339
86349
|
break;
|
|
86340
86350
|
default:
|
|
86341
86351
|
{
|
|
86342
|
-
const
|
|
86343
|
-
if (
|
|
86352
|
+
const nme = Object.keys(marks);
|
|
86353
|
+
if (nme != null && nme.includes(Ff == null ? void 0 : Ff.type))
|
|
86344
86354
|
if (Ff.type === "link" && /\.pdf$/i.test(Ff.url))
|
|
86345
86355
|
x_.type = "pdf", x_.attrs = { pdfUrl: Ff == null ? void 0 : Ff.url };
|
|
86346
86356
|
else {
|
|
86347
|
-
const
|
|
86348
|
-
Ff.type === "link" && (
|
|
86349
|
-
const
|
|
86350
|
-
(
|
|
86357
|
+
const rme = { type: marks[Ff == null ? void 0 : Ff.type] };
|
|
86358
|
+
Ff.type === "link" && (rme.attrs = { href: Ff == null ? void 0 : Ff.url, target: "_blank" });
|
|
86359
|
+
const ime = Ff == null ? void 0 : Ff.children;
|
|
86360
|
+
(ime == null ? void 0 : ime.length) === 1 && ime[0].type === "text" ? (x_.type = "text", x_.text = ime[0].value, x_.marks = [...B_, rme]) : (x_.type = "fragment", B_.push(rme));
|
|
86351
86361
|
}
|
|
86352
86362
|
}
|
|
86353
86363
|
break;
|
|
86354
86364
|
}
|
|
86355
|
-
if (($
|
|
86356
|
-
if ((Ff == null ? void 0 : Ff.type) === "paragraph" && ((
|
|
86365
|
+
if (($P = Ff == null ? void 0 : Ff.children) != null && $P.length)
|
|
86366
|
+
if ((Ff == null ? void 0 : Ff.type) === "paragraph" && ((zP = Ff == null ? void 0 : Ff.children) == null ? void 0 : zP.length) === 1 && ((eme = Ff == null ? void 0 : Ff.children[0]) == null ? void 0 : eme.type) === "image") {
|
|
86357
86367
|
x_.type = "image";
|
|
86358
|
-
const
|
|
86359
|
-
x_.attrs = { src:
|
|
86368
|
+
const nme = Ff == null ? void 0 : Ff.children[0];
|
|
86369
|
+
x_.attrs = { src: nme == null ? void 0 : nme.url, alt: nme == null ? void 0 : nme.alt, title: nme == null ? void 0 : nme.title };
|
|
86360
86370
|
} else
|
|
86361
|
-
x_.content = (
|
|
86371
|
+
x_.content = (tme = Ff == null ? void 0 : Ff.children) == null ? void 0 : tme.map((nme) => toNodeObj(nme, B_));
|
|
86362
86372
|
return x_.type === "text" && (x_ != null && x_.content) && (x_ == null || delete x_.content), x_;
|
|
86363
86373
|
}, toEditorJSON = (Ff) => {
|
|
86364
86374
|
var x_, B_, $_;
|
|
86365
86375
|
const kh = {};
|
|
86366
86376
|
return kh.type = "document", (x_ = Ff == null ? void 0 : Ff.children) != null && x_.length && (kh.content = ($_ = (B_ = Ff == null ? void 0 : Ff.children) == null ? void 0 : B_.filter(($P) => ($P == null ? void 0 : $P.type) !== "definition")) == null ? void 0 : $_.map(($P) => toNodeObj($P))), kh;
|
|
86367
|
-
}, getFileSuffix = (Ff) => {
|
|
86368
|
-
const kh = Ff.indexOf(".") > -1 ? Ff.split(".") : [];
|
|
86369
|
-
return kh.length > 0 ? kh[kh.length - 1] : "";
|
|
86370
86377
|
}, marksMD = {
|
|
86371
86378
|
bold: "strong",
|
|
86372
86379
|
italic: "emphasis",
|
|
@@ -86446,7 +86453,7 @@ const upload = async (Ff) => {
|
|
|
86446
86453
|
x_.type = "link", x_.url = (vme = Ff == null ? void 0 : Ff.attrs) == null ? void 0 : vme.pdfUrl;
|
|
86447
86454
|
break;
|
|
86448
86455
|
}
|
|
86449
|
-
return (Sme = Ff == null ? void 0 : Ff.content) != null && Sme.length && (x_.children = (Eme = Ff == null ? void 0 : Ff.content) == null ? void 0 : Eme.map((bme) => toMDNodeObj(bme, B_))), x_;
|
|
86456
|
+
return (Sme = Ff == null ? void 0 : Ff.content) != null && Sme.length && (x_.children = (Eme = Ff == null ? void 0 : Ff.content) == null ? void 0 : Eme.map((bme) => toMDNodeObj(bme, B_))), x_.type === "code" && (x_ != null && x_.children) && (x_ == null || delete x_.children), x_;
|
|
86450
86457
|
}, toMarkdownJson = (Ff) => {
|
|
86451
86458
|
var x_, B_;
|
|
86452
86459
|
const kh = {};
|
|
@@ -86670,7 +86677,7 @@ const upload = async (Ff) => {
|
|
|
86670
86677
|
if (!eme || !nme)
|
|
86671
86678
|
return;
|
|
86672
86679
|
const cme = tippy(eme, {
|
|
86673
|
-
placement: "
|
|
86680
|
+
placement: "right",
|
|
86674
86681
|
content: nme,
|
|
86675
86682
|
interactive: !0,
|
|
86676
86683
|
duration: [300, 300],
|
|
@@ -86719,6 +86726,20 @@ class EventEmitter {
|
|
|
86719
86726
|
this.callbacks = {};
|
|
86720
86727
|
}
|
|
86721
86728
|
}
|
|
86729
|
+
const allowTypes = [
|
|
86730
|
+
"paragraph",
|
|
86731
|
+
// 段落
|
|
86732
|
+
"heading",
|
|
86733
|
+
// 标题
|
|
86734
|
+
"horizontalRule",
|
|
86735
|
+
// 分割线
|
|
86736
|
+
"blockquote",
|
|
86737
|
+
// 引用
|
|
86738
|
+
"codeBlock",
|
|
86739
|
+
// 代码快
|
|
86740
|
+
"image"
|
|
86741
|
+
// 图片
|
|
86742
|
+
];
|
|
86722
86743
|
class Handle {
|
|
86723
86744
|
// 是否阻止显示或隐藏的开关
|
|
86724
86745
|
constructor(kh, x_, B_, $_ = []) {
|
|
@@ -86798,14 +86819,14 @@ class Handle {
|
|
|
86798
86819
|
if (eme !== this.lastPos) {
|
|
86799
86820
|
this.lastPos = eme, this.emitter.emit("hover", { node: ime, pos: ome, range: { from: ome, to: ome + ime.nodeSize } });
|
|
86800
86821
|
const cme = posToDOMRect(kh, ome, ome + ime.nodeSize);
|
|
86801
|
-
ime.type.name === "horizontalRule" ? this.setProps({
|
|
86822
|
+
ime.type.name === "horizontalRule" ? (cme.top - 10 < 5 && (nme = !0), this.setProps({
|
|
86802
86823
|
getReferenceClientRect: () => ({ ...cme, top: cme.top - 10 })
|
|
86803
|
-
}) : this.setProps({
|
|
86804
|
-
getReferenceClientRect: () => ({ ...cme, top: cme.top +
|
|
86805
|
-
});
|
|
86824
|
+
})) : (cme.top + 6 < 5 && (nme = !0), this.setProps({
|
|
86825
|
+
getReferenceClientRect: () => ({ ...cme, top: cme.top + 6 })
|
|
86826
|
+
}));
|
|
86806
86827
|
} else
|
|
86807
86828
|
rme = !1;
|
|
86808
|
-
ime.type.name !== "paragraph" ? this.emitter.emit("type", { type: "content" }) : this.emitter.emit("type", { type: "add" }), this.ignoreType.includes(ime.type.name) && (nme = !0);
|
|
86829
|
+
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);
|
|
86809
86830
|
}
|
|
86810
86831
|
return !1;
|
|
86811
86832
|
}), rme && (nme ? this.hide() : this.show());
|
|
@@ -87234,7 +87255,7 @@ const normalClass = "tiptap-menu-item-menus-item", lighClass = "tiptap-menu-item
|
|
|
87234
87255
|
allow: (Ff) => {
|
|
87235
87256
|
const kh = Ff.editor.state.doc;
|
|
87236
87257
|
let x_ = !0;
|
|
87237
|
-
return kh.nodesBetween(Ff.range.from, Ff.range.to, (B_, $_, $P) => (ignoreChar.includes(B_.type.name) && (x_ = !1), !1)), x_;
|
|
87258
|
+
return Ff.editor.isFocused && kh.nodesBetween(Ff.range.from, Ff.range.to, (B_, $_, $P) => (ignoreChar.includes(B_.type.name) && (x_ = !1), !1)), x_;
|
|
87238
87259
|
}
|
|
87239
87260
|
};
|
|
87240
87261
|
},
|
|
@@ -140140,17 +140161,18 @@ let Editor = (Ff, kh) => {
|
|
|
140140
140161
|
};
|
|
140141
140162
|
}, []), useEffect(() => {
|
|
140142
140163
|
const Dme = (Bme) => {
|
|
140143
|
-
var $me, Ume, Vme;
|
|
140164
|
+
var $me, Ume, Vme, Gme;
|
|
140144
140165
|
if ((($me = Bme == null ? void 0 : Bme.data) == null ? void 0 : $me.type) === "sectionChange") {
|
|
140145
|
-
const
|
|
140146
|
-
|
|
140166
|
+
const zme = (Vme = (Ume = Bme == null ? void 0 : Bme.data) == null ? void 0 : Ume.value) == null ? void 0 : Vme.template;
|
|
140167
|
+
zme && ((Gme = Object.keys(zme)) == null ? void 0 : Gme.length) === 0 ? Ime("") : Ime(zme);
|
|
140147
140168
|
}
|
|
140148
140169
|
};
|
|
140149
140170
|
return window.addEventListener("message", Dme), () => {
|
|
140150
140171
|
window.removeEventListener("message", Dme);
|
|
140151
140172
|
};
|
|
140152
140173
|
}, [fme]), useEffect(() => {
|
|
140153
|
-
|
|
140174
|
+
var Dme;
|
|
140175
|
+
eme && ((Dme = Object.keys(eme)) == null ? void 0 : Dme.length) === 0 ? Ime("") : Ime(eme);
|
|
140154
140176
|
}, [eme]);
|
|
140155
140177
|
const Tme = (Dme) => {
|
|
140156
140178
|
const Bme = Dme == null ? void 0 : Dme.target;
|