@haklex/rich-editor 0.1.1 → 0.3.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.
- package/dist/AlertQuoteEditNode-C55sxsR3.js +267 -0
- package/dist/KaTeXRenderer-CQQT3BMw.js +215 -0
- package/dist/LinkCardRenderer-CigqFwCv.js +45 -0
- package/dist/MermaidPlugin-BrOr-wQi.js +67 -0
- package/dist/RubyRenderer-jOkydJHg.js +15 -0
- package/dist/SubmitShortcutPlugin-DhyVFzoj.js +2186 -0
- package/dist/commands-entry.mjs +54 -74
- package/dist/components/decorators/PollEditDecorator.d.ts +13 -0
- package/dist/components/decorators/PollEditDecorator.d.ts.map +1 -0
- package/dist/components/renderers/PollRenderer.d.ts +3 -0
- package/dist/components/renderers/PollRenderer.d.ts.map +1 -0
- package/dist/config-B5BuLljq.js +1633 -0
- package/dist/config-edit.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/context/PollDataContext.d.ts +11 -0
- package/dist/context/PollDataContext.d.ts.map +1 -0
- package/dist/extractPolls-DO31LNrp.js +116 -0
- package/dist/grid.css-CJCkLTZc.js +44 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +121 -180
- package/dist/katex.css-CIOEOXyd.js +145 -0
- package/dist/node-registry-Dz5OTkh4.js +946 -0
- package/dist/nodes/PollEditNode.d.ts +14 -0
- package/dist/nodes/PollEditNode.d.ts.map +1 -0
- package/dist/nodes/PollNode.d.ts +52 -0
- package/dist/nodes/PollNode.d.ts.map +1 -0
- package/dist/nodes-entry.d.ts +3 -0
- package/dist/nodes-entry.d.ts.map +1 -1
- package/dist/nodes-entry.mjs +5 -50
- package/dist/normalizeSerializedEditorState-B-1wmGzd.js +78 -0
- package/dist/plugins-entry.mjs +3 -28
- package/dist/renderers-entry.mjs +41 -61
- package/dist/rich-editor.css +2 -1
- package/dist/static-entry.d.ts +5 -0
- package/dist/static-entry.d.ts.map +1 -1
- package/dist/static-entry.mjs +16 -66
- package/dist/styles/index.d.ts +2 -0
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/poll-edit.css.d.ts +35 -0
- package/dist/styles/poll-edit.css.d.ts.map +1 -0
- package/dist/styles/poll.css.d.ts +43 -0
- package/dist/styles/poll.css.d.ts.map +1 -0
- package/dist/styles-entry.mjs +3 -21
- package/dist/theme-B5B2EOWM.js +1099 -0
- package/dist/types/poll.d.ts +36 -0
- package/dist/types/poll.d.ts.map +1 -0
- package/dist/types/renderer-config.d.ts +3 -0
- package/dist/types/renderer-config.d.ts.map +1 -1
- package/dist/utils/extractPolls.d.ts +4 -0
- package/dist/utils/extractPolls.d.ts.map +1 -0
- package/package.json +30 -30
- package/dist/AlertQuoteEditNode-sPNf3_7P.js +0 -293
- package/dist/KaTeXRenderer-CQyQzNTJ.js +0 -218
- package/dist/LinkCardRenderer-QmkOlyXb.js +0 -36
- package/dist/MermaidPlugin-DKuGUcCG.js +0 -101
- package/dist/PresentDialogContext-DRroMIoK.js +0 -71
- package/dist/RubyRenderer-CJQmODir.js +0 -14
- package/dist/SubmitShortcutPlugin-D9uKYHda.js +0 -2427
- package/dist/config-Dl3ZkytB.js +0 -1362
- package/dist/grid.css-Md5-Cfx_.js +0 -11
- package/dist/katex.css-Csc-7N7u.js +0 -28
- package/dist/node-registry-CovhHUB6.js +0 -824
- package/dist/normalizeSerializedEditorState-k5G4xSi9.js +0 -85
- package/dist/theme-lEwScxEX.js +0 -1113
package/dist/commands-entry.mjs
CHANGED
|
@@ -1,86 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
33
|
+
return getSpoilerNodesInSelection(selection.getNodes()).length > 0;
|
|
40
34
|
}
|
|
41
35
|
function unwrapSpoiler(spoiler) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
76
|
-
|
|
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 };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PollMode, PollOption, PollShowResults } from '../../types/poll';
|
|
2
|
+
interface PollEditDecoratorProps {
|
|
3
|
+
closeAt?: string;
|
|
4
|
+
mode: PollMode;
|
|
5
|
+
nodeKey: string;
|
|
6
|
+
options: PollOption[];
|
|
7
|
+
pollId: string;
|
|
8
|
+
question: string;
|
|
9
|
+
showResults?: PollShowResults;
|
|
10
|
+
}
|
|
11
|
+
export declare function PollEditDecorator({ closeAt, mode, nodeKey, options, pollId, question, showResults, }: PollEditDecoratorProps): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=PollEditDecorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PollEditDecorator.d.ts","sourceRoot":"","sources":["../../../src/components/decorators/PollEditDecorator.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAK9E,UAAU,sBAAsB;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAUD,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,IAAI,EACJ,OAAO,EACP,OAAO,EACP,MAAM,EACN,QAAQ,EACR,WAAW,GACZ,EAAE,sBAAsB,+BA8MxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PollRenderer.d.ts","sourceRoot":"","sources":["../../../src/components/renderers/PollRenderer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,iBAAiB,EAGlB,MAAM,kBAAkB,CAAC;AAgP1B,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,+BAIpD"}
|