@ylzcc/editor 0.0.2 → 0.0.3
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/index.d.ts +1 -1
- package/dist/editor.es.js +75 -71
- package/dist/editor.umd.js +7 -8
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/Editor/index.d.ts
CHANGED
package/dist/editor.es.js
CHANGED
|
@@ -11813,7 +11813,7 @@ function createStyleTag(Ff, kh, x_) {
|
|
|
11813
11813
|
const $_ = document.createElement("style");
|
|
11814
11814
|
return kh && $_.setAttribute("nonce", kh), $_.setAttribute(`data-tiptap-style${x_ ? `-${x_}` : ""}`, ""), $_.innerHTML = Ff, document.getElementsByTagName("head")[0].appendChild($_), $_;
|
|
11815
11815
|
}
|
|
11816
|
-
let Editor$
|
|
11816
|
+
let Editor$3 = class extends EventEmitter$1 {
|
|
11817
11817
|
constructor(kh = {}) {
|
|
11818
11818
|
super(), this.isFocused = !1, this.extensionStorage = {}, this.options = {
|
|
11819
11819
|
element: document.createElement("div"),
|
|
@@ -14147,7 +14147,7 @@ const EditorContentWithKey = forwardRef((Ff, kh) => {
|
|
|
14147
14147
|
...Ff
|
|
14148
14148
|
});
|
|
14149
14149
|
}), EditorContent = React__default.memo(EditorContentWithKey);
|
|
14150
|
-
let Editor$
|
|
14150
|
+
let Editor$2 = class extends Editor$3 {
|
|
14151
14151
|
constructor() {
|
|
14152
14152
|
super(...arguments), this.contentComponent = null;
|
|
14153
14153
|
}
|
|
@@ -14158,7 +14158,7 @@ const useEditor = (Ff = {}, kh = []) => {
|
|
|
14158
14158
|
x_.current && ($_ && (x_.current.off("beforeCreate", ome.current), x_.current.on("beforeCreate", $_), ome.current = $_), $P && (x_.current.off("blur", ame.current), x_.current.on("blur", $P), ame.current = $P), zP && (x_.current.off("create", ume.current), x_.current.on("create", zP), ume.current = zP), eme && (x_.current.off("destroy", cme.current), x_.current.on("destroy", eme), cme.current = eme), tme && (x_.current.off("focus", sme.current), x_.current.on("focus", tme), sme.current = tme), nme && (x_.current.off("selectionUpdate", lme.current), x_.current.on("selectionUpdate", nme), lme.current = nme), rme && (x_.current.off("transaction", dme.current), x_.current.on("transaction", rme), dme.current = rme), ime && (x_.current.off("update", fme.current), x_.current.on("update", ime), fme.current = ime));
|
|
14159
14159
|
}, [$_, $P, zP, eme, tme, nme, rme, ime, x_.current]), useEffect(() => {
|
|
14160
14160
|
let pme = !0;
|
|
14161
|
-
return x_.current = new Editor$
|
|
14161
|
+
return x_.current = new Editor$2(Ff), x_.current.on("transaction", () => {
|
|
14162
14162
|
requestAnimationFrame(() => {
|
|
14163
14163
|
requestAnimationFrame(() => {
|
|
14164
14164
|
pme && B_({});
|
|
@@ -64559,7 +64559,7 @@ const Heading = Node$1.create({
|
|
|
64559
64559
|
return {
|
|
64560
64560
|
ignoreTypes: ["codeBlock"],
|
|
64561
64561
|
component: null,
|
|
64562
|
-
zIndex:
|
|
64562
|
+
zIndex: 9999,
|
|
64563
64563
|
tippy: null,
|
|
64564
64564
|
delay: 100,
|
|
64565
64565
|
debounce: null
|
|
@@ -86016,7 +86016,7 @@ const setAlign = (Ff) => {
|
|
|
86016
86016
|
const dme = kh == null ? void 0 : kh.view, fme = dme == null ? void 0 : dme.state.tr;
|
|
86017
86017
|
fme && (fme == null || fme.deleteRange(x_, B_), fme == null || fme.insertText($P, x_), dme == null || dme.dispatch(fme));
|
|
86018
86018
|
const pme = (ome = dme == null ? void 0 : dme.state) == null ? void 0 : ome.selection.to;
|
|
86019
|
-
console.log(dme, pme), (ame = kh == null ? void 0 : kh.commands) == null || ame.setTextSelection({ from: x_, to: pme ?? x_ }), (ume = kh == null ? void 0 : kh.view) == null || ume.focus(), (lme = (sme = (cme = kh == null ? void 0 : kh.chain()) == null ? void 0 : cme.focus()) == null ? void 0 : sme.setLink({ href: eme, target: "_blank"
|
|
86019
|
+
console.log(dme, pme), (ame = kh == null ? void 0 : kh.commands) == null || ame.setTextSelection({ from: x_, to: pme ?? x_ }), (ume = kh == null ? void 0 : kh.view) == null || ume.focus(), (lme = (sme = (cme = kh == null ? void 0 : kh.chain()) == null ? void 0 : cme.focus()) == null ? void 0 : sme.setLink({ href: eme, target: "_blank" })) == null || lme.run(), $_ && $_();
|
|
86020
86020
|
}
|
|
86021
86021
|
}, ime = (ome) => /^https?:\/\//.test(ome);
|
|
86022
86022
|
return useEffect(() => {
|
|
@@ -86081,7 +86081,9 @@ const setAlign = (Ff) => {
|
|
|
86081
86081
|
}, sme = (Bme) => {
|
|
86082
86082
|
tme(Bme);
|
|
86083
86083
|
};
|
|
86084
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bubble-new",
|
|
86084
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bubble-new", style: {
|
|
86085
|
+
display: kh != null && kh.isEditable ? "flex" : "none"
|
|
86086
|
+
}, children: nme ? /* @__PURE__ */ jsxRuntimeExports.jsx(Space$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(HyperlinkContent, { editor: kh, from: x_, to: B_, changeLink: () => {
|
|
86085
86087
|
var Bme;
|
|
86086
86088
|
rme(!1), (Bme = kh == null ? void 0 : kh.view) == null || Bme.focus();
|
|
86087
86089
|
} }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(Space$1, { className: "bubble-menu", children: [
|
|
@@ -88602,12 +88604,12 @@ class Handle {
|
|
|
88602
88604
|
const { pos: eme, inside: tme } = zP;
|
|
88603
88605
|
let nme = !1, rme = !0;
|
|
88604
88606
|
$_.descendants((ime, ome, ame, ume) => {
|
|
88605
|
-
if (
|
|
88607
|
+
if (eme >= ome && eme < ome + ime.nodeSize) {
|
|
88606
88608
|
if (eme !== this.lastPos) {
|
|
88607
88609
|
this.lastPos = eme, this.emitter.emit("hover", { node: ime, pos: ome, range: { from: ome, to: ome + ime.nodeSize } });
|
|
88608
88610
|
const cme = posToDOMRect(kh, ome, ome + ime.nodeSize);
|
|
88609
88611
|
this.setProps({
|
|
88610
|
-
getReferenceClientRect: () => ({ ...cme,
|
|
88612
|
+
getReferenceClientRect: () => ({ ...cme, top: cme.top + 2 })
|
|
88611
88613
|
});
|
|
88612
88614
|
} else
|
|
88613
88615
|
rme = !1;
|
|
@@ -96019,7 +96021,7 @@ const LinkComponent = (Ff) => {
|
|
|
96019
96021
|
{
|
|
96020
96022
|
className: "lintView",
|
|
96021
96023
|
style: {
|
|
96022
|
-
display: "flex"
|
|
96024
|
+
display: kh != null && kh.isEditable ? "flex" : "none"
|
|
96023
96025
|
},
|
|
96024
96026
|
children: [
|
|
96025
96027
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "lineValue", ref: B_, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: Ff == null ? void 0 : Ff.value }) }),
|
|
@@ -139774,15 +139776,16 @@ const PdfViewShow = ({ node: Ff }) => {
|
|
|
139774
139776
|
HTMLAttributes: {}
|
|
139775
139777
|
};
|
|
139776
139778
|
}
|
|
139777
|
-
}), { BubbleMenu, BubbleMenuView } = bubbleModules, shareData = createContext({})
|
|
139779
|
+
}), { BubbleMenu, BubbleMenuView } = bubbleModules, shareData = createContext({});
|
|
139780
|
+
let Editor = (Ff, kh) => {
|
|
139778
139781
|
const {
|
|
139779
|
-
showCatalogue:
|
|
139780
|
-
canOpenCatalogue:
|
|
139781
|
-
editable:
|
|
139782
|
-
oss: $
|
|
139783
|
-
xternUrl:
|
|
139784
|
-
wsUrl:
|
|
139785
|
-
} = Ff,
|
|
139782
|
+
showCatalogue: x_ = !0,
|
|
139783
|
+
canOpenCatalogue: B_ = !0,
|
|
139784
|
+
editable: $_ = !0,
|
|
139785
|
+
oss: $P = "https://openapi-test.oscollege.net",
|
|
139786
|
+
xternUrl: zP,
|
|
139787
|
+
wsUrl: eme
|
|
139788
|
+
} = Ff, tme = useEditor({
|
|
139786
139789
|
content: {
|
|
139787
139790
|
type: "document",
|
|
139788
139791
|
content: [
|
|
@@ -139845,7 +139848,7 @@ const PdfViewShow = ({ node: Ff }) => {
|
|
|
139845
139848
|
}),
|
|
139846
139849
|
FloatingMenu,
|
|
139847
139850
|
Image$1.configure({
|
|
139848
|
-
oss: $
|
|
139851
|
+
oss: $P
|
|
139849
139852
|
}),
|
|
139850
139853
|
CodeBlockLowlight.configure({
|
|
139851
139854
|
lowlight: createLowlight(grammars)
|
|
@@ -139855,7 +139858,7 @@ const PdfViewShow = ({ node: Ff }) => {
|
|
|
139855
139858
|
return ReactNodeViewRenderer(QuestionView);
|
|
139856
139859
|
}
|
|
139857
139860
|
}).configure({
|
|
139858
|
-
xternUrl:
|
|
139861
|
+
xternUrl: zP
|
|
139859
139862
|
}),
|
|
139860
139863
|
PdfView.extend({
|
|
139861
139864
|
addNodeView() {
|
|
@@ -139865,80 +139868,81 @@ const PdfViewShow = ({ node: Ff }) => {
|
|
|
139865
139868
|
Slash,
|
|
139866
139869
|
Fragment
|
|
139867
139870
|
]
|
|
139868
|
-
}), [
|
|
139871
|
+
}), [nme, rme] = useState(!0), [ime, ome] = useState(!1), [ame, ume] = useState(), [cme, sme] = useState(!1), [lme, dme] = useState(), [fme, pme] = useState(!0), [hme, mme] = useState(), _me = (Eme) => unified().use(remarkParse).use(remarkGfm).use(remarkCode).parse(Eme), gme = (Eme) => unified().use(remarkParse).use(remarkGfm).use(remarkCode).use(remarkStringify).stringify(Eme), vme = () => {
|
|
139869
139872
|
try {
|
|
139870
|
-
if (
|
|
139871
|
-
|
|
139873
|
+
if (ame && (ame == null ? void 0 : ame.readyState) === 1) {
|
|
139874
|
+
ame == null || ame.close();
|
|
139872
139875
|
return;
|
|
139873
139876
|
}
|
|
139874
|
-
const
|
|
139875
|
-
|
|
139876
|
-
|
|
139877
|
-
const { data: yme } = Eme;
|
|
139877
|
+
const Eme = new WebSocket(eme);
|
|
139878
|
+
ume(Eme), sme(!1), Eme.onmessage = function(yme) {
|
|
139879
|
+
const { data: Ame } = yme;
|
|
139878
139880
|
try {
|
|
139879
|
-
const
|
|
139880
|
-
if (
|
|
139881
|
-
const
|
|
139882
|
-
|
|
139881
|
+
const Ome = JSON.parse(Ame), Pme = Ome == null ? void 0 : Ome.type, Lme = Ome == null ? void 0 : Ome.data;
|
|
139882
|
+
if (Pme === "read" && Lme) {
|
|
139883
|
+
const Dme = base64ToText$1(Lme), bme = _me(Dme), kme = toEditorJSON(bme);
|
|
139884
|
+
dme(kme);
|
|
139883
139885
|
}
|
|
139884
|
-
} catch (
|
|
139885
|
-
console.log(
|
|
139886
|
+
} catch (Ome) {
|
|
139887
|
+
console.log(Ome);
|
|
139886
139888
|
}
|
|
139887
|
-
},
|
|
139888
|
-
|
|
139889
|
+
}, Eme.onclose = function(yme) {
|
|
139890
|
+
yme.code < 3e3 && sme(!0);
|
|
139889
139891
|
};
|
|
139890
|
-
} catch (
|
|
139891
|
-
console.log(
|
|
139892
|
+
} catch (Eme) {
|
|
139893
|
+
console.log(Eme);
|
|
139892
139894
|
}
|
|
139893
139895
|
};
|
|
139894
139896
|
useEffect(() => {
|
|
139895
|
-
if (
|
|
139896
|
-
const
|
|
139897
|
-
clearTimeout(
|
|
139897
|
+
if (cme) {
|
|
139898
|
+
const Eme = setTimeout(() => {
|
|
139899
|
+
clearTimeout(Eme), vme();
|
|
139898
139900
|
}, 1e3);
|
|
139899
139901
|
}
|
|
139900
|
-
}, [
|
|
139901
|
-
|
|
139902
|
-
}, [
|
|
139903
|
-
|
|
139904
|
-
}), [
|
|
139905
|
-
const
|
|
139906
|
-
|
|
139907
|
-
const
|
|
139908
|
-
var
|
|
139909
|
-
let
|
|
139910
|
-
|
|
139911
|
-
...
|
|
139912
|
-
content: (
|
|
139902
|
+
}, [cme]), useEffect(() => () => {
|
|
139903
|
+
ame && (ame == null ? void 0 : ame.readyState) === 1 && (ame == null || ame.close());
|
|
139904
|
+
}, [ame]), useEffect(() => (eme && vme(), () => {
|
|
139905
|
+
pme(!0), ome(!1);
|
|
139906
|
+
}), [eme]);
|
|
139907
|
+
const Sme = () => {
|
|
139908
|
+
hme && clearTimeout(hme);
|
|
139909
|
+
const Eme = setTimeout(() => {
|
|
139910
|
+
var Pme;
|
|
139911
|
+
let yme = tme == null ? void 0 : tme.getJSON();
|
|
139912
|
+
yme = {
|
|
139913
|
+
...yme,
|
|
139914
|
+
content: (Pme = yme == null ? void 0 : yme.content) == null ? void 0 : Pme.filter((Lme) => (Lme == null ? void 0 : Lme.type) !== "title")
|
|
139913
139915
|
};
|
|
139914
|
-
const
|
|
139915
|
-
if ((
|
|
139916
|
-
const
|
|
139917
|
-
|
|
139916
|
+
const Ame = toMarkdownJson(yme), Ome = gme(Ame);
|
|
139917
|
+
if ((ame == null ? void 0 : ame.readyState) === 1) {
|
|
139918
|
+
const Lme = Ome ? textToBase64(Ome) : "";
|
|
139919
|
+
ame == null || ame.send(JSON.stringify({
|
|
139918
139920
|
type: "write",
|
|
139919
|
-
data:
|
|
139921
|
+
data: Lme
|
|
139920
139922
|
}));
|
|
139921
139923
|
}
|
|
139922
|
-
clearTimeout(
|
|
139924
|
+
clearTimeout(Eme), mme("");
|
|
139923
139925
|
}, 1e3);
|
|
139924
|
-
|
|
139925
|
-
};
|
|
139926
|
-
return useEffect(() => (
|
|
139927
|
-
|
|
139928
|
-
}), [
|
|
139929
|
-
|
|
139930
|
-
}, [
|
|
139931
|
-
|
|
139932
|
-
}, [
|
|
139933
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "ylz-editor-container", className: `ylz-editor-container${!
|
|
139926
|
+
mme(Eme);
|
|
139927
|
+
};
|
|
139928
|
+
return useEffect(() => (tme && (tme == null || tme.on("update", Sme)), () => {
|
|
139929
|
+
tme && (tme == null || tme.off("update", Sme));
|
|
139930
|
+
}), [tme, hme]), useEffect(() => {
|
|
139931
|
+
tme && lme && fme && (tme.commands.setContent(lme), pme(!1), ome(!0));
|
|
139932
|
+
}, [lme, tme, fme]), useEffect(() => {
|
|
139933
|
+
tme && tme.setEditable($_);
|
|
139934
|
+
}, [tme, $_]), useImperativeHandle(kh, () => ({})), /* @__PURE__ */ jsxRuntimeExports.jsx(shareData.Provider, { value: { editor: tme }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ylz-editor", children: [
|
|
139935
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "ylz-editor-container", className: `ylz-editor-container${!x_ || B_ === !1 || !nme ? " ylz-editor-container-max" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
139934
139936
|
EditorContent,
|
|
139935
139937
|
{
|
|
139936
|
-
editor:
|
|
139938
|
+
editor: tme
|
|
139937
139939
|
}
|
|
139938
139940
|
) }),
|
|
139939
|
-
|
|
139941
|
+
x_ && /* @__PURE__ */ jsxRuntimeExports.jsx(Catalogue, { editor: tme, isUpdate: ime, canOpenCatalogue: B_, onChangeVisible: (Eme) => rme(Eme) })
|
|
139940
139942
|
] }) });
|
|
139941
139943
|
};
|
|
139944
|
+
Editor = forwardRef(Editor);
|
|
139945
|
+
const Editor$1 = Editor;
|
|
139942
139946
|
export {
|
|
139943
|
-
Editor as default
|
|
139947
|
+
Editor$1 as default
|
|
139944
139948
|
};
|