@haklex/rich-editor 0.1.1 → 0.2.0

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.
Files changed (35) hide show
  1. package/dist/AlertQuoteEditNode-C55sxsR3.js +267 -0
  2. package/dist/KaTeXRenderer-CQQT3BMw.js +215 -0
  3. package/dist/LinkCardRenderer-CigqFwCv.js +45 -0
  4. package/dist/MermaidPlugin-BrOr-wQi.js +67 -0
  5. package/dist/PresentDialogContext-DKNicgia.js +74 -0
  6. package/dist/RubyRenderer-jOkydJHg.js +15 -0
  7. package/dist/SubmitShortcutPlugin-D-7XrQfm.js +2186 -0
  8. package/dist/commands-entry.mjs +54 -74
  9. package/dist/config-CNiK9v2M.js +1246 -0
  10. package/dist/grid.css-CJCkLTZc.js +44 -0
  11. package/dist/index.mjs +121 -180
  12. package/dist/katex.css-CIOEOXyd.js +145 -0
  13. package/dist/node-registry-DOYK_WIp.js +669 -0
  14. package/dist/nodes-entry.mjs +5 -50
  15. package/dist/normalizeSerializedEditorState-B-1wmGzd.js +78 -0
  16. package/dist/plugins-entry.mjs +3 -28
  17. package/dist/renderers-entry.mjs +41 -61
  18. package/dist/rich-editor.css +2 -1
  19. package/dist/static-entry.mjs +16 -66
  20. package/dist/styles-entry.mjs +3 -21
  21. package/dist/theme-B5B2EOWM.js +1099 -0
  22. package/package.json +30 -30
  23. package/dist/AlertQuoteEditNode-sPNf3_7P.js +0 -293
  24. package/dist/KaTeXRenderer-CQyQzNTJ.js +0 -218
  25. package/dist/LinkCardRenderer-QmkOlyXb.js +0 -36
  26. package/dist/MermaidPlugin-DKuGUcCG.js +0 -101
  27. package/dist/PresentDialogContext-DRroMIoK.js +0 -71
  28. package/dist/RubyRenderer-CJQmODir.js +0 -14
  29. package/dist/SubmitShortcutPlugin-D9uKYHda.js +0 -2427
  30. package/dist/config-Dl3ZkytB.js +0 -1362
  31. package/dist/grid.css-Md5-Cfx_.js +0 -11
  32. package/dist/katex.css-Csc-7N7u.js +0 -28
  33. package/dist/node-registry-CovhHUB6.js +0 -824
  34. package/dist/normalizeSerializedEditorState-k5G4xSi9.js +0 -85
  35. package/dist/theme-lEwScxEX.js +0 -1113
@@ -1,86 +1,66 @@
1
- import { a, b, c, d, e } from "./MermaidPlugin-DKuGUcCG.js";
2
- import { q as $createSpoilerNode, r as $isSpoilerNode } from "./theme-lEwScxEX.js";
3
- import { O, o } from "./theme-lEwScxEX.js";
4
- import { $getSelection, $isRangeSelection, $createTextNode } from "lexical";
1
+ import { M as extractTextContent, o as $createSpoilerNode, s as $isSpoilerNode, w as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND } from "./theme-B5B2EOWM.js";
2
+ import { i as INSERT_KATEX_INLINE_COMMAND, l as INSERT_ALERT_COMMAND, o as INSERT_IMAGE_COMMAND, r as INSERT_KATEX_BLOCK_COMMAND, t as INSERT_MERMAID_COMMAND } from "./MermaidPlugin-BrOr-wQi.js";
3
+ import { $createTextNode, $getSelection, $isRangeSelection } from "lexical";
4
+ //#region src/utils/collect-command-items.ts
5
5
  function collectCommandItems(editor) {
6
- const items = [];
7
- const nodes = editor._nodes;
8
- for (const { klass } of nodes.values()) {
9
- const configs = klass.commandItems ?? klass.slashMenuItems;
10
- if (configs) {
11
- for (const config of configs) {
12
- items.push(config);
13
- }
14
- }
15
- }
16
- return items;
6
+ const items = [];
7
+ const nodes = editor._nodes;
8
+ for (const { klass } of nodes.values()) {
9
+ const configs = klass.commandItems ?? klass.slashMenuItems;
10
+ if (configs) for (const config of configs) items.push(config);
11
+ }
12
+ return items;
17
13
  }
14
+ //#endregion
15
+ //#region src/utils/toggle-spoiler.ts
18
16
  function findSpoilerAncestor(node) {
19
- let current = node;
20
- while (current) {
21
- if ($isSpoilerNode(current)) {
22
- return current;
23
- }
24
- current = current.getParent();
25
- }
26
- return null;
17
+ let current = node;
18
+ while (current) {
19
+ if ($isSpoilerNode(current)) return current;
20
+ current = current.getParent();
21
+ }
22
+ return null;
27
23
  }
28
24
  function getSpoilerNodesInSelection(nodes) {
29
- const spoilers = /* @__PURE__ */ new Map();
30
- for (const node of nodes) {
31
- const spoiler = findSpoilerAncestor(node);
32
- if (spoiler) {
33
- spoilers.set(spoiler.getKey(), spoiler);
34
- }
35
- }
36
- return Array.from(spoilers.values());
25
+ const spoilers = /* @__PURE__ */ new Map();
26
+ for (const node of nodes) {
27
+ const spoiler = findSpoilerAncestor(node);
28
+ if (spoiler) spoilers.set(spoiler.getKey(), spoiler);
29
+ }
30
+ return Array.from(spoilers.values());
37
31
  }
38
32
  function $selectionTouchesSpoiler(selection) {
39
- return getSpoilerNodesInSelection(selection.getNodes()).length > 0;
33
+ return getSpoilerNodesInSelection(selection.getNodes()).length > 0;
40
34
  }
41
35
  function unwrapSpoiler(spoiler) {
42
- const children = spoiler.getChildren();
43
- for (const child of children) {
44
- spoiler.insertBefore(child);
45
- }
46
- spoiler.remove();
36
+ const children = spoiler.getChildren();
37
+ for (const child of children) spoiler.insertBefore(child);
38
+ spoiler.remove();
47
39
  }
40
+ /**
41
+ * Toggle inline spoiler on the current selection: wraps plain text in {@link SpoilerNode},
42
+ * or removes spoiler when the selection touches existing spoiler content.
43
+ */
48
44
  function $toggleSpoilerSelection() {
49
- const selection = $getSelection();
50
- if (!$isRangeSelection(selection)) return;
51
- if (selection.isCollapsed()) {
52
- const spoiler2 = findSpoilerAncestor(selection.anchor.getNode());
53
- if (spoiler2) {
54
- unwrapSpoiler(spoiler2);
55
- }
56
- return;
57
- }
58
- const spoilerNodes = getSpoilerNodesInSelection(selection.getNodes());
59
- if (spoilerNodes.length > 0) {
60
- for (const spoiler2 of spoilerNodes) {
61
- unwrapSpoiler(spoiler2);
62
- }
63
- return;
64
- }
65
- const text = selection.getTextContent();
66
- if (!text.trim()) return;
67
- selection.removeText();
68
- const spoiler = $createSpoilerNode();
69
- spoiler.append($createTextNode(text));
70
- const freshSelection = $getSelection();
71
- if ($isRangeSelection(freshSelection)) {
72
- freshSelection.insertNodes([spoiler]);
73
- }
45
+ const selection = $getSelection();
46
+ if (!$isRangeSelection(selection)) return;
47
+ if (selection.isCollapsed()) {
48
+ const spoiler = findSpoilerAncestor(selection.anchor.getNode());
49
+ if (spoiler) unwrapSpoiler(spoiler);
50
+ return;
51
+ }
52
+ const spoilerNodes = getSpoilerNodesInSelection(selection.getNodes());
53
+ if (spoilerNodes.length > 0) {
54
+ for (const spoiler of spoilerNodes) unwrapSpoiler(spoiler);
55
+ return;
56
+ }
57
+ const text = selection.getTextContent();
58
+ if (!text.trim()) return;
59
+ selection.removeText();
60
+ const spoiler = $createSpoilerNode();
61
+ spoiler.append($createTextNode(text));
62
+ const freshSelection = $getSelection();
63
+ if ($isRangeSelection(freshSelection)) freshSelection.insertNodes([spoiler]);
74
64
  }
75
- export {
76
- $selectionTouchesSpoiler,
77
- $toggleSpoilerSelection,
78
- a as INSERT_ALERT_COMMAND,
79
- b as INSERT_IMAGE_COMMAND,
80
- c as INSERT_KATEX_BLOCK_COMMAND,
81
- d as INSERT_KATEX_INLINE_COMMAND,
82
- e as INSERT_MERMAID_COMMAND,
83
- O as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND,
84
- collectCommandItems,
85
- o as extractTextContent
86
- };
65
+ //#endregion
66
+ export { $selectionTouchesSpoiler, $toggleSpoilerSelection, INSERT_ALERT_COMMAND, INSERT_IMAGE_COMMAND, INSERT_KATEX_BLOCK_COMMAND, INSERT_KATEX_INLINE_COMMAND, INSERT_MERMAID_COMMAND, OPEN_IMAGE_UPLOAD_DIALOG_COMMAND, collectCommandItems, extractTextContent };