CodeMirrorEditorMain.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { jsx as m } from "react/jsx-runtime";
  2. import { useEffect as s } from "react";
  3. import { scrollPastEnd as f, keymap as i } from "@codemirror/view";
  4. import { GlobalCodeMirrorEditorKey as u } from "../consts/global-code-mirror-editor-key.js";
  5. import { useCodeMirrorEditorIsolated as r } from "../stores/codemirror-editor.js";
  6. import { CodeMirrorEditor as c } from "./CodeMirrorEditor/CodeMirrorEditor.js";
  7. const x = [
  8. f()
  9. ], D = (a) => {
  10. const {
  11. onSave: e,
  12. onChange: p,
  13. indentSize: l
  14. } = a, { data: n } = r(u.MAIN);
  15. return s(() => {
  16. var t;
  17. return (t = n == null ? void 0 : n.appendExtensions) == null ? void 0 : t.call(n, x);
  18. }, [n]), s(() => {
  19. var o;
  20. if (e == null)
  21. return;
  22. const t = i.of([
  23. {
  24. key: "Mod-s",
  25. preventDefault: !0,
  26. run: () => ((n == null ? void 0 : n.getDoc()) != null && e(), !0)
  27. }
  28. ]);
  29. return (o = n == null ? void 0 : n.appendExtensions) == null ? void 0 : o.call(n, t);
  30. }, [n, e]), /* @__PURE__ */ m(
  31. c,
  32. {
  33. editorKey: u.MAIN,
  34. onChange: p,
  35. indentSize: l
  36. }
  37. );
  38. };
  39. export {
  40. D as CodeMirrorEditorMain
  41. };
  42. //# sourceMappingURL=CodeMirrorEditorMain.js.map