@ylzcc/editor 0.0.10 → 0.1.1
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 +50 -36
- package/dist/editor.umd.js +4 -4
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/editor.es.js
CHANGED
|
@@ -64417,6 +64417,19 @@ const Heading = Node$1.create({
|
|
|
64417
64417
|
}
|
|
64418
64418
|
return !1;
|
|
64419
64419
|
}
|
|
64420
|
+
// handleKeyDown(view, event) {
|
|
64421
|
+
// const { state } = view
|
|
64422
|
+
// const { selection, doc } = state
|
|
64423
|
+
// const { anchor, $from } = selection
|
|
64424
|
+
// // 仅针对第一个节点做限制
|
|
64425
|
+
// const node = doc.firstChild
|
|
64426
|
+
// console.log(anchor, node?.nodeSize)
|
|
64427
|
+
// if (event.key === 'Enter' && node && anchor <= node?.nodeSize) {
|
|
64428
|
+
// console.log(view, event)
|
|
64429
|
+
// return true
|
|
64430
|
+
// }
|
|
64431
|
+
// return false
|
|
64432
|
+
// },
|
|
64420
64433
|
}
|
|
64421
64434
|
})
|
|
64422
64435
|
];
|
|
@@ -86055,11 +86068,12 @@ const setAlign = (Ff) => {
|
|
|
86055
86068
|
}
|
|
86056
86069
|
}, ime = (ome) => /^https?:\/\//.test(ome);
|
|
86057
86070
|
return useEffect(() => {
|
|
86058
|
-
var
|
|
86059
|
-
if (kh
|
|
86060
|
-
|
|
86061
|
-
|
|
86062
|
-
|
|
86071
|
+
var lme, dme;
|
|
86072
|
+
if (!kh)
|
|
86073
|
+
return;
|
|
86074
|
+
const ome = kh.state.doc, ame = (dme = (lme = kh == null ? void 0 : kh.view) == null ? void 0 : lme.state) == null ? void 0 : dme.selection, { $from: ume, $to: cme } = ame, sme = ome.textBetween(ume.pos, cme.pos, " ");
|
|
86075
|
+
if (zP(sme ?? ""), kh != null && kh.isActive("link")) {
|
|
86076
|
+
const fme = ume.node();
|
|
86063
86077
|
fme == null || fme.forEach((pme) => {
|
|
86064
86078
|
var hme;
|
|
86065
86079
|
pme != null && pme.marks && ((hme = pme == null ? void 0 : pme.marks) == null || hme.forEach((mme) => {
|
|
@@ -86512,45 +86526,45 @@ function LowlightPlugin({
|
|
|
86512
86526
|
return B_;
|
|
86513
86527
|
}
|
|
86514
86528
|
const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension: B_ }) => {
|
|
86515
|
-
var
|
|
86516
|
-
const $_ = useContext(shareData), [$P, zP] = useState("light"), [eme, tme] = useState(((
|
|
86529
|
+
var lme, dme, fme, pme, hme, mme, vme;
|
|
86530
|
+
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 = (gme) => {
|
|
86517
86531
|
x_({
|
|
86518
|
-
language:
|
|
86532
|
+
language: gme
|
|
86519
86533
|
});
|
|
86520
|
-
},
|
|
86521
|
-
var
|
|
86522
|
-
const
|
|
86523
|
-
tme(
|
|
86524
|
-
exec:
|
|
86534
|
+
}, ume = (gme) => {
|
|
86535
|
+
var Sme;
|
|
86536
|
+
const _me = (Sme = gme == null ? void 0 : gme.target) == null ? void 0 : Sme.checked;
|
|
86537
|
+
tme(_me), x_({
|
|
86538
|
+
exec: _me
|
|
86525
86539
|
});
|
|
86526
|
-
},
|
|
86527
|
-
var
|
|
86528
|
-
(
|
|
86540
|
+
}, cme = () => {
|
|
86541
|
+
var gme;
|
|
86542
|
+
(gme = navigator == null ? void 0 : navigator.clipboard) == null || gme.writeText(kh == null ? void 0 : kh.textContent).then(() => {
|
|
86529
86543
|
rme(!0);
|
|
86530
|
-
const
|
|
86531
|
-
rme(!1), clearTimeout(
|
|
86544
|
+
const _me = setTimeout(() => {
|
|
86545
|
+
rme(!1), clearTimeout(_me);
|
|
86532
86546
|
}, 2e3);
|
|
86533
86547
|
});
|
|
86534
|
-
},
|
|
86535
|
-
var
|
|
86536
|
-
(
|
|
86548
|
+
}, sme = () => {
|
|
86549
|
+
var gme;
|
|
86550
|
+
(gme = B_ == null ? void 0 : B_.options) == null || gme.onExec(kh == null ? void 0 : kh.textContent);
|
|
86537
86551
|
};
|
|
86538
86552
|
return useEffect(() => {
|
|
86539
86553
|
zP(eme ? "dark" : "light");
|
|
86540
|
-
}, [eme]), /* @__PURE__ */ jsxRuntimeExports.
|
|
86541
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-header", contentEditable: !1, children: [
|
|
86554
|
+
}, [eme]), /* @__PURE__ */ jsxRuntimeExports.jsx(NodeViewWrapper, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `code-block code-block-${$P}`, onMouseEnter: () => ome(!0), onMouseLeave: () => ome(!1), children: [
|
|
86555
|
+
ime && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-header", contentEditable: !1, children: [
|
|
86542
86556
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-header-left", children: [
|
|
86543
86557
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
86544
86558
|
Select$1,
|
|
86545
86559
|
{
|
|
86546
86560
|
disabled: !(Ff != null && Ff.isEditable),
|
|
86547
86561
|
placeholder: "选择语言",
|
|
86548
|
-
defaultValue: ((
|
|
86562
|
+
defaultValue: ((dme = kh == null ? void 0 : kh.attrs) == null ? void 0 : dme.language) ?? "",
|
|
86549
86563
|
style: { width: 90 },
|
|
86550
|
-
onChange:
|
|
86564
|
+
onChange: ame,
|
|
86551
86565
|
options: [
|
|
86552
86566
|
{ value: "", label: "atuo" },
|
|
86553
|
-
...(
|
|
86567
|
+
...(hme = (pme = (fme = B_ == null ? void 0 : B_.options) == null ? void 0 : fme.lowlight) == null ? void 0 : pme.listLanguages()) == null ? void 0 : hme.map((gme) => ({ value: gme, label: gme }))
|
|
86554
86568
|
]
|
|
86555
86569
|
}
|
|
86556
86570
|
),
|
|
@@ -86558,15 +86572,15 @@ const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension:
|
|
|
86558
86572
|
Select$1,
|
|
86559
86573
|
{
|
|
86560
86574
|
disabled: !0,
|
|
86561
|
-
defaultValue: ((
|
|
86575
|
+
defaultValue: ((mme = $_ == null ? void 0 : $_.template) == null ? void 0 : mme.name) || ((vme = $_ == null ? void 0 : $_.template) == null ? void 0 : vme.experEnv)
|
|
86562
86576
|
}
|
|
86563
86577
|
)
|
|
86564
86578
|
] }),
|
|
86565
|
-
($_ == null ? void 0 : $_.template) && (Ff == null ? void 0 : Ff.isEditable) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "code-block-header-right", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox$1, { checked: eme, onChange:
|
|
86579
|
+
($_ == null ? void 0 : $_.template) && (Ff == null ? void 0 : Ff.isEditable) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "code-block-header-right", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox$1, { checked: eme, onChange: ume, children: "执行" }) })
|
|
86566
86580
|
] }),
|
|
86567
86581
|
/* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "code-block-body", children: /* @__PURE__ */ jsxRuntimeExports.jsx(NodeViewContent, { as: "code" }) }),
|
|
86568
86582
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-action", contentEditable: !1, children: [
|
|
86569
|
-
eme && ($_ == null ? void 0 : $_.template) && /* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { type: "primary", onClick:
|
|
86583
|
+
eme && ($_ == null ? void 0 : $_.template) && /* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { type: "primary", onClick: sme, children: "执行" }),
|
|
86570
86584
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "code-block-action-copy", children: [
|
|
86571
86585
|
nme && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "copy-tip", children: [
|
|
86572
86586
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
@@ -86576,10 +86590,10 @@ const CodeBlockView = ({ editor: Ff, node: kh, updateAttributes: x_, extension:
|
|
|
86576
86590
|
] }),
|
|
86577
86591
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "复制成功" })
|
|
86578
86592
|
] }),
|
|
86579
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { type: "primary", onClick:
|
|
86593
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button$1, { type: "primary", onClick: cme, children: "复制" })
|
|
86580
86594
|
] })
|
|
86581
86595
|
] })
|
|
86582
|
-
] });
|
|
86596
|
+
] }) });
|
|
86583
86597
|
}, CodeBlockLowlight = CodeBlock.extend({
|
|
86584
86598
|
addOptions() {
|
|
86585
86599
|
var Ff;
|
|
@@ -88406,7 +88420,7 @@ const upload = async (Ff) => {
|
|
|
88406
88420
|
// getReferenceClientRect: tableDom.getBoundingClientRect
|
|
88407
88421
|
});
|
|
88408
88422
|
}, [$_, zP]);
|
|
88409
|
-
const vme = window.innerHeight / 2;
|
|
88423
|
+
const vme = window.innerHeight / 2 - 30;
|
|
88410
88424
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "tiptap-menu tiptap-scroll", style: { maxHeight: vme, overflowY: "auto" }, children: [
|
|
88411
88425
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "tiptap-menu-item", children: [
|
|
88412
88426
|
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "tiptap-menu-item-title", children: "基础" }),
|
|
@@ -88997,7 +89011,7 @@ const normalClass = "tiptap-menu-item-menus-item", lighClass = "tiptap-menu-item
|
|
|
88997
89011
|
x_ == null || x_.chain().focus(eme).deleteRange($_.range).setHorizontalRule().hideMenu().run();
|
|
88998
89012
|
}, fme = () => {
|
|
88999
89013
|
x_ == null || x_.chain().focus(eme).deleteRange($_.range).setBlockquote().hideMenu().run();
|
|
89000
|
-
}, pme = window.innerHeight / 2;
|
|
89014
|
+
}, pme = window.innerHeight / 2 - 30;
|
|
89001
89015
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "tiptap-menu tiptap-scroll", style: { maxHeight: pme, overflowY: "auto" }, ref: zP, children: [
|
|
89002
89016
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "tiptap-menu-item", children: [
|
|
89003
89017
|
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "tiptap-menu-item-title", children: "基础" }),
|
|
@@ -140083,8 +140097,8 @@ let Editor = (Ff, kh) => {
|
|
|
140083
140097
|
Tme(eme);
|
|
140084
140098
|
}, [eme]), useEffect(() => {
|
|
140085
140099
|
if (tme) {
|
|
140086
|
-
const Ome =
|
|
140087
|
-
xme(
|
|
140100
|
+
const Ome = Ime(tme), Cme = toEditorJSON(Ome);
|
|
140101
|
+
xme(Cme);
|
|
140088
140102
|
}
|
|
140089
140103
|
}, [tme]), useImperativeHandle(kh, () => ({
|
|
140090
140104
|
update: () => {
|
|
@@ -140112,7 +140126,7 @@ let Editor = (Ff, kh) => {
|
|
|
140112
140126
|
},
|
|
140113
140127
|
changeMdTest: (Ome) => {
|
|
140114
140128
|
console.log(Ome, sme);
|
|
140115
|
-
const Cme = sme.filter(
|
|
140129
|
+
const Cme = sme == null ? void 0 : sme.children.filter(
|
|
140116
140130
|
($me) => ($me == null ? void 0 : $me.props) !== "active" && ($me == null ? void 0 : $me.value) !== Ome[0].value
|
|
140117
140131
|
);
|
|
140118
140132
|
console.log(Cme);
|