@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.
@@ -15,5 +15,5 @@ type shareDataType = {
15
15
  [key: string]: any;
16
16
  };
17
17
  export declare const shareData: React.Context<Partial<shareDataType>>;
18
- declare const Editor: React.FC<EditorProps>;
18
+ declare let Editor: React.FC<EditorProps>;
19
19
  export default Editor;
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$2 = class extends EventEmitter$1 {
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$1 = class extends Editor$2 {
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$1(Ff), x_.current.on("transaction", () => {
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: 1,
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", from: x_, to: pme ?? x_ })) == null || lme.run(), $_ && $_();
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", children: nme ? /* @__PURE__ */ jsxRuntimeExports.jsx(Space$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(HyperlinkContent, { editor: kh, from: x_, to: B_, changeLink: () => {
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 (ime.type.name === "image" && console.log(ime), eme >= ome && eme < ome + ime.nodeSize) {
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, left: 36, top: cme.top + 2 })
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({}), Editor = (Ff) => {
139779
+ }), { BubbleMenu, BubbleMenuView } = bubbleModules, shareData = createContext({});
139780
+ let Editor = (Ff, kh) => {
139778
139781
  const {
139779
- showCatalogue: kh = !0,
139780
- canOpenCatalogue: x_ = !0,
139781
- editable: B_ = !0,
139782
- oss: $_ = "https://openapi-test.oscollege.net",
139783
- xternUrl: $P,
139784
- wsUrl: zP
139785
- } = Ff, eme = useEditor({
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: $P
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
- }), [tme, nme] = useState(!0), [rme, ime] = useState(!1), [ome, ame] = useState(), [ume, cme] = useState(!1), [sme, lme] = useState(), [dme, fme] = useState(!0), [pme, hme] = useState(), mme = (Sme) => unified().use(remarkParse).use(remarkGfm).use(remarkCode).parse(Sme), _me = (Sme) => unified().use(remarkParse).use(remarkGfm).use(remarkCode).use(remarkStringify).stringify(Sme), gme = () => {
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 (ome && (ome == null ? void 0 : ome.readyState) === 1) {
139871
- ome == null || ome.close();
139873
+ if (ame && (ame == null ? void 0 : ame.readyState) === 1) {
139874
+ ame == null || ame.close();
139872
139875
  return;
139873
139876
  }
139874
- const Sme = new WebSocket(`
139875
- wss://openapi-test.oscollege.net/?key=1665670138667524096&repo=171da62a8040e001/HfsvXx&path=%E7%AC%AC%E4%B8%80%E7%AB%A0%2F%E7%AC%AC1%E8%8A%82&component=file&file=index.md`);
139876
- ame(Sme), cme(!1), Sme.onmessage = function(Eme) {
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 Ame = JSON.parse(yme), Ome = Ame == null ? void 0 : Ame.type, Pme = Ame == null ? void 0 : Ame.data;
139880
- if (Ome === "read" && Pme) {
139881
- const Lme = base64ToText$1(Pme), Dme = mme(Lme), bme = toEditorJSON(Dme);
139882
- lme(bme);
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 (Ame) {
139885
- console.log(Ame);
139886
+ } catch (Ome) {
139887
+ console.log(Ome);
139886
139888
  }
139887
- }, Sme.onclose = function(Eme) {
139888
- Eme.code < 3e3 && cme(!0);
139889
+ }, Eme.onclose = function(yme) {
139890
+ yme.code < 3e3 && sme(!0);
139889
139891
  };
139890
- } catch (Sme) {
139891
- console.log(Sme);
139892
+ } catch (Eme) {
139893
+ console.log(Eme);
139892
139894
  }
139893
139895
  };
139894
139896
  useEffect(() => {
139895
- if (ume) {
139896
- const Sme = setTimeout(() => {
139897
- clearTimeout(Sme), gme();
139897
+ if (cme) {
139898
+ const Eme = setTimeout(() => {
139899
+ clearTimeout(Eme), vme();
139898
139900
  }, 1e3);
139899
139901
  }
139900
- }, [ume]), useEffect(() => () => {
139901
- ome && (ome == null ? void 0 : ome.readyState) === 1 && (ome == null || ome.close());
139902
- }, [ome]), useEffect(() => (zP && gme(), () => {
139903
- fme(!0), ime(!1);
139904
- }), [zP]);
139905
- const vme = () => {
139906
- pme && clearTimeout(pme);
139907
- const Sme = setTimeout(() => {
139908
- var Ome;
139909
- let Eme = eme == null ? void 0 : eme.getJSON();
139910
- Eme = {
139911
- ...Eme,
139912
- content: (Ome = Eme == null ? void 0 : Eme.content) == null ? void 0 : Ome.filter((Pme) => (Pme == null ? void 0 : Pme.type) !== "title")
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 yme = toMarkdownJson(Eme), Ame = _me(yme);
139915
- if ((ome == null ? void 0 : ome.readyState) === 1) {
139916
- const Pme = Ame ? textToBase64(Ame) : "";
139917
- ome == null || ome.send(JSON.stringify({
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: Pme
139921
+ data: Lme
139920
139922
  }));
139921
139923
  }
139922
- clearTimeout(Sme), hme("");
139924
+ clearTimeout(Eme), mme("");
139923
139925
  }, 1e3);
139924
- hme(Sme);
139925
- };
139926
- return useEffect(() => (eme && (eme == null || eme.on("update", vme)), () => {
139927
- eme && (eme == null || eme.off("update", vme));
139928
- }), [eme, pme]), useEffect(() => {
139929
- eme && sme && dme && (eme.commands.setContent(sme), fme(!1), ime(!0));
139930
- }, [sme, eme, dme]), useEffect(() => {
139931
- eme && eme.setEditable(B_);
139932
- }, [eme, B_]), /* @__PURE__ */ jsxRuntimeExports.jsx(shareData.Provider, { value: { editor: eme }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ylz-editor", children: [
139933
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "ylz-editor-container", className: `ylz-editor-container${!kh || x_ === !1 || !tme ? " ylz-editor-container-max" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
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: eme
139938
+ editor: tme
139937
139939
  }
139938
139940
  ) }),
139939
- kh && /* @__PURE__ */ jsxRuntimeExports.jsx(Catalogue, { editor: eme, isUpdate: rme, canOpenCatalogue: x_, onChangeVisible: (Sme) => nme(Sme) })
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
  };