@collabchron/notiq 1.1.11 → 1.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 (152) hide show
  1. package/dist/AICommandBarPlugin-ZEC755KY.mjs +27 -0
  2. package/dist/{AIDialog-2WZUFWSC.mjs → AIDialog-HJW6PQPR.mjs} +12 -13
  3. package/dist/{AudioComponent-CKLMLB5T.mjs → AudioComponent-W5XMZPQB.mjs} +10 -6
  4. package/dist/{DynamicBlockComponent-2LOADZUX.mjs → DynamicBlockComponent-CHRL2GAQ.mjs} +7 -6
  5. package/dist/{EquationComponent-4NFG55NQ.mjs → EquationComponent-GNQHG53L.mjs} +26 -7
  6. package/dist/{ExcalidrawComponent-SIMURTCA.mjs → ExcalidrawComponent-POMYXDSG.mjs} +34 -7
  7. package/dist/{FileComponent-Y56MX5QD.mjs → FileComponent-EOVCH4V5.mjs} +9 -5
  8. package/dist/{HintComponet-ET7M2Q7S.mjs → HintComponet-QXL5ESND.mjs} +32 -8
  9. package/dist/{InlineImageComponent-FVTA4LXZ.mjs → InlineImageComponent-KDN3VGZC.mjs} +8 -3
  10. package/dist/{StoryBuilderComponent-WQSNFPMM.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +9 -10
  11. package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
  12. package/dist/chunk-5CJZC5IB.mjs +9086 -0
  13. package/dist/{chunk-MW6MAUY3.mjs → chunk-6NK5DONB.mjs} +1 -1
  14. package/dist/{chunk-N6ILV6NF.mjs → chunk-ACW4DLVO.mjs} +21 -7
  15. package/dist/chunk-BCGD2YXP.mjs +574 -0
  16. package/dist/{chunk-TC3IISJZ.mjs → chunk-BTR3TPIN.mjs} +18 -5
  17. package/dist/{chunk-XAVQAXOJ.mjs → chunk-CQCS5YPS.mjs} +3 -5
  18. package/dist/{chunk-YTLUQJE2.mjs → chunk-D4UBNSUW.mjs} +1 -1
  19. package/dist/{chunk-KNW2CGIP.mjs → chunk-DBRZIA43.mjs} +4 -1
  20. package/dist/{chunk-CDAMHK63.mjs → chunk-GJK2L7ZM.mjs} +23 -2
  21. package/dist/{chunk-GYYLZ3MQ.mjs → chunk-IKYVBTCJ.mjs} +43 -20
  22. package/dist/chunk-IXRA5D53.mjs +10447 -0
  23. package/dist/{chunk-W6VQSFE5.mjs → chunk-J2CEQXG4.mjs} +1 -1
  24. package/dist/{chunk-43Z4Z2KD.mjs → chunk-JTNLN4JI.mjs} +1 -1
  25. package/dist/{chunk-OE5JRLCN.mjs → chunk-ONOHG5NB.mjs} +6 -4
  26. package/dist/{chunk-XZXGYNTY.mjs → chunk-OO42URWA.mjs} +27 -6
  27. package/dist/chunk-PBVRSNGU.mjs +129 -0
  28. package/dist/chunk-QCS57TIF.mjs +1794 -0
  29. package/dist/chunk-RNEIJRUS.mjs +60 -0
  30. package/dist/chunk-TJPTGECP.mjs +1556 -0
  31. package/dist/{chunk-XYMXGU4T.mjs → chunk-TMYRA2W4.mjs} +1 -1
  32. package/dist/{chunk-ZFV2HGD3.mjs → chunk-UNEFOZTS.mjs} +1 -1
  33. package/dist/chunk-X4NI7EQS.mjs +282 -0
  34. package/dist/chunk-XAJ4GACN.mjs +746 -0
  35. package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
  36. package/dist/components/editor/Core.d.ts +15 -2
  37. package/dist/components/editor/index.d.ts +16 -5
  38. package/dist/components/editor/nodes/EquationNode/EquationNode.d.ts +1 -0
  39. package/dist/components/editor/nodes/Hint/index.d.ts +2 -1
  40. package/dist/components/editor/plugins/AICommandBarPlugin/index.d.ts +73 -1
  41. package/dist/components/editor/plugins/DraggableBlockPlugin/index.d.ts +25 -3
  42. package/dist/components/editor/plugins/InlineCopilotPlugin/index.d.ts +16 -3
  43. package/dist/components/editor/plugins/LinkWithMetaData/index.d.ts +20 -25
  44. package/dist/components/editor/plugins/MarkdownPastePlugin/index.d.ts +5 -0
  45. package/dist/components/editor/plugins/MarkdownTransformers/index.d.ts +2 -0
  46. package/dist/components/editor/plugins/SlashCommand/index.d.ts +18 -1
  47. package/dist/components/editor/plugins/SmartTypographyPlugin/index.d.ts +26 -0
  48. package/dist/components/editor/utils/aiStream.d.ts +27 -0
  49. package/dist/components/editor/utils/excalidrawDiagramBuilder.d.ts +29 -0
  50. package/dist/components/editor/utils/markdownTransformers.d.ts +4 -1
  51. package/dist/components/editor/utils/url.d.ts +16 -4
  52. package/dist/components/providers/AIContext.d.ts +8 -0
  53. package/dist/components/ui/equation/equationTypography.d.ts +23 -0
  54. package/dist/core/extension.d.ts +3 -1
  55. package/dist/core/extensions/blocks-kit.d.ts +22 -1
  56. package/dist/core/extensions/copilot-and-collab.d.ts +15 -1
  57. package/dist/core/index.d.ts +2 -1
  58. package/dist/core/react/NotiqContent.d.ts +4 -1
  59. package/dist/core/react/NotiqEditor.d.ts +8 -8
  60. package/dist/core/react/index.d.ts +1 -0
  61. package/dist/core/react/node-renderers.d.ts +73 -0
  62. package/dist/core/types.d.ts +1 -0
  63. package/dist/core.js +18136 -9084
  64. package/dist/core.mjs +58 -44
  65. package/dist/hooks/instructions-messages.d.ts +13 -4
  66. package/dist/{image-TPW7PZZK.mjs → image-AL6PHM2A.mjs} +18 -13
  67. package/dist/index.js +15180 -12858
  68. package/dist/index.mjs +121 -1641
  69. package/dist/{insert-audio-C66RZRKY.mjs → insert-audio-CRWR7EO5.mjs} +6 -8
  70. package/dist/{insert-file-3DTGRO7W.mjs → insert-file-I73AZW3L.mjs} +6 -8
  71. package/dist/{insert-gif-FIMCCBAI.mjs → insert-gif-KWRC3ACT.mjs} +4 -4
  72. package/dist/{insert-image-CZV6HWQZ.mjs → insert-image-XIY6BGW5.mjs} +6 -5
  73. package/dist/{insert-poll-6BCIFY5G.mjs → insert-poll-J5YVZNZ4.mjs} +4 -3
  74. package/dist/{insert-table-ZRJP6X52.mjs → insert-table-OIMJRFFK.mjs} +1 -1
  75. package/dist/{poll-component-VHMM5KKZ.mjs → poll-component-TVHXIKGQ.mjs} +3 -2
  76. package/dist/react.js +17933 -9531
  77. package/dist/react.mjs +41 -34
  78. package/dist/{stepper-4AO5XMO7.mjs → stepper-ILF7YXTO.mjs} +64 -74
  79. package/dist/styles/notiq.css +1 -1
  80. package/package.json +2 -2
  81. package/src/styles/notiq.css +20 -0
  82. package/dist/AICommandBarPlugin-TADJ3X2Y.mjs +0 -12
  83. package/dist/CodeActionMenuPlugin-MRKY67ED.mjs +0 -14
  84. package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
  85. package/dist/CollaboratorsBar-TMKBOBJI.mjs +0 -20
  86. package/dist/CommentsPlugin-5M4RD6YO.mjs +0 -19
  87. package/dist/ExcalidrawPlugin-2SGPIQ6U.mjs +0 -14
  88. package/dist/ExportPlugin-OKZOLBGS.mjs +0 -42
  89. package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
  90. package/dist/FloatingTextFormatToolbarPlugin-SO5VON7Q.mjs +0 -45
  91. package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
  92. package/dist/MobileToolbar-JKP2MLQJ.mjs +0 -984
  93. package/dist/SlashCommand-2TNOOUBM.mjs +0 -39
  94. package/dist/TableCellActionMenuPlugin-YWBA64J7.mjs +0 -838
  95. package/dist/TableHoverActionsPlugin-2EIXHEXN.mjs +0 -265
  96. package/dist/TemplatePlugin-HNTPEXBB.mjs +0 -9
  97. package/dist/ToolbarPlugin-IIAOU4P5.mjs +0 -35
  98. package/dist/VersionHistoryPlugin-23MAZB4G.mjs +0 -371
  99. package/dist/background-color-OZJCBYCT.mjs +0 -425
  100. package/dist/block-format-MTSIXWID.mjs +0 -14
  101. package/dist/chunk-2KESP7OU.mjs +0 -809
  102. package/dist/chunk-3AHNLIME.mjs +0 -1701
  103. package/dist/chunk-3IILA3IP.mjs +0 -28
  104. package/dist/chunk-4DVIYZVB.mjs +0 -193
  105. package/dist/chunk-4FFTOZGJ.mjs +0 -103
  106. package/dist/chunk-4UMUPCDK.mjs +0 -68
  107. package/dist/chunk-6D6QLRYR.mjs +0 -238
  108. package/dist/chunk-6SRMKQSD.mjs +0 -682
  109. package/dist/chunk-ACV47ZKE.mjs +0 -201
  110. package/dist/chunk-AYNKORDO.mjs +0 -6
  111. package/dist/chunk-BGV62GC2.mjs +0 -26
  112. package/dist/chunk-D3IOUQFR.mjs +0 -441
  113. package/dist/chunk-EEBA6OAH.mjs +0 -59
  114. package/dist/chunk-EIZMKFHF.mjs +0 -32
  115. package/dist/chunk-EVPWKNE4.mjs +0 -27
  116. package/dist/chunk-FMJ7DGWP.mjs +0 -144
  117. package/dist/chunk-FYLRS4BG.mjs +0 -88
  118. package/dist/chunk-HOZ4QRFV.mjs +0 -536
  119. package/dist/chunk-IAFCQV3Z.mjs +0 -349
  120. package/dist/chunk-IU2N42JJ.mjs +0 -1763
  121. package/dist/chunk-J6ZUY5BY.mjs +0 -202
  122. package/dist/chunk-K5OAFEVY.mjs +0 -191
  123. package/dist/chunk-KDA7ZYMJ.mjs +0 -431
  124. package/dist/chunk-KXRLARGI.mjs +0 -26
  125. package/dist/chunk-LAUAYRPC.mjs +0 -944
  126. package/dist/chunk-LLCP7NVE.mjs +0 -449
  127. package/dist/chunk-LU2XWLOE.mjs +0 -219
  128. package/dist/chunk-MPTE332I.mjs +0 -787
  129. package/dist/chunk-MTQZWJHR.mjs +0 -111
  130. package/dist/chunk-OXWTZV3U.mjs +0 -174
  131. package/dist/chunk-PD5K4AGP.mjs +0 -64
  132. package/dist/chunk-PFH63ZU4.mjs +0 -33
  133. package/dist/chunk-PHRVYPVM.mjs +0 -808
  134. package/dist/chunk-R7WFRENU.mjs +0 -262
  135. package/dist/chunk-RAVYEEIC.mjs +0 -36
  136. package/dist/chunk-RJQTA6HG.mjs +0 -358
  137. package/dist/chunk-SAOJHVPE.mjs +0 -153
  138. package/dist/chunk-VGAX6YEY.mjs +0 -399
  139. package/dist/chunk-W6GAJXUS.mjs +0 -334
  140. package/dist/chunk-XYDBUQ6Z.mjs +0 -1978
  141. package/dist/chunk-XYT6XM5S.mjs +0 -496
  142. package/dist/chunk-YDDBQZ77.mjs +0 -409
  143. package/dist/chunk-YE7M2VKR.mjs +0 -132
  144. package/dist/chunk-Z6JAFF55.mjs +0 -555
  145. package/dist/chunk-ZKZ7MLSS.mjs +0 -165
  146. package/dist/color-23323E3B.mjs +0 -13
  147. package/dist/font-IJKFR4BM.mjs +0 -12
  148. package/dist/font-size-GTL6UVQL.mjs +0 -15
  149. package/dist/insert-node-MA3FXEYN.mjs +0 -245
  150. package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
  151. package/dist/text-align-CSDLJUDA.mjs +0 -121
  152. package/dist/text-format-6L5N3CHZ.mjs +0 -15
@@ -0,0 +1,1794 @@
1
+ import {
2
+ $isPollNode,
3
+ PollNode
4
+ } from "./chunk-ACW4DLVO.mjs";
5
+ import {
6
+ $createAudioNode,
7
+ $isAudioNode,
8
+ AudioNode
9
+ } from "./chunk-TMYRA2W4.mjs";
10
+ import {
11
+ $createFileNode,
12
+ $isFileNode,
13
+ FileNode
14
+ } from "./chunk-UNEFOZTS.mjs";
15
+ import {
16
+ Skeleton
17
+ } from "./chunk-NBE6FF6L.mjs";
18
+ import {
19
+ $createImageNode,
20
+ $isImageNode,
21
+ ImageNode
22
+ } from "./chunk-IKYVBTCJ.mjs";
23
+ import {
24
+ $createExcalidrawNode,
25
+ $isExcalidrawNode,
26
+ ExcalidrawNode
27
+ } from "./chunk-OO42URWA.mjs";
28
+ import {
29
+ $createEquationNode,
30
+ $isEquationNode,
31
+ EquationNode
32
+ } from "./chunk-DBRZIA43.mjs";
33
+ import {
34
+ $createHintNode,
35
+ Hint
36
+ } from "./chunk-YVUQRJVV.mjs";
37
+ import {
38
+ NodeRendererSlot
39
+ } from "./chunk-RNEIJRUS.mjs";
40
+ import {
41
+ __objRest,
42
+ __spreadProps,
43
+ __spreadValues,
44
+ init_react_shim
45
+ } from "./chunk-WYCFGRFJ.mjs";
46
+
47
+ // src/components/editor/nodes/Stepper/index.tsx
48
+ init_react_shim();
49
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
50
+ import {
51
+ DecoratorNode,
52
+ createEditor,
53
+ createCommand,
54
+ $getSelection,
55
+ $isRangeSelection,
56
+ COMMAND_PRIORITY_LOW
57
+ } from "lexical";
58
+ import React, { Suspense, useEffect } from "react";
59
+ import { jsx } from "react/jsx-runtime";
60
+ var StepperComponent = React.lazy(
61
+ () => import("./stepper-ILF7YXTO.mjs")
62
+ );
63
+ var initialEditorState = {
64
+ root: {
65
+ children: [
66
+ {
67
+ children: [
68
+ {
69
+ detail: 0,
70
+ format: 0,
71
+ mode: "normal",
72
+ style: "",
73
+ text: "type the content here..",
74
+ type: "text",
75
+ version: 1
76
+ }
77
+ ],
78
+ direction: null,
79
+ format: "",
80
+ indent: 0,
81
+ type: "paragraph",
82
+ version: 1,
83
+ textFormat: 0,
84
+ textStyle: ""
85
+ }
86
+ ],
87
+ direction: null,
88
+ format: "",
89
+ indent: 0,
90
+ type: "root",
91
+ version: 1
92
+ }
93
+ };
94
+ function safelySetEditorState(editor, rawContent) {
95
+ try {
96
+ let parsedObj = rawContent;
97
+ if (typeof rawContent === "string") {
98
+ try {
99
+ parsedObj = JSON.parse(rawContent);
100
+ } catch (e) {
101
+ parsedObj = null;
102
+ }
103
+ }
104
+ if (parsedObj && typeof parsedObj === "object" && parsedObj.root && typeof parsedObj.root === "object" && parsedObj.root.type === "root" && Array.isArray(parsedObj.root.children) && parsedObj.root.children.length > 0) {
105
+ editor.setEditorState(editor.parseEditorState(JSON.stringify(parsedObj)));
106
+ return;
107
+ }
108
+ } catch (e) {
109
+ }
110
+ try {
111
+ editor.setEditorState(editor.parseEditorState(JSON.stringify(initialEditorState)));
112
+ } catch (e) {
113
+ console.error("Failed to set initialEditorState for Stepper:", e);
114
+ }
115
+ }
116
+ var StepperNode = class _StepperNode extends DecoratorNode {
117
+ constructor(steps, key) {
118
+ super(key);
119
+ const safeSteps = Array.isArray(steps) ? steps : [];
120
+ this.__steps = safeSteps.map((step) => {
121
+ var _a;
122
+ if (!step || typeof step !== "object") {
123
+ const newEditor = createEditor();
124
+ safelySetEditorState(newEditor, null);
125
+ return { id: 1, title: "Step 1", content: newEditor };
126
+ }
127
+ if (!step.content || typeof step.content.isEditable !== "function") {
128
+ const newEditor = createEditor();
129
+ const rawContent = ((_a = step.content) == null ? void 0 : _a.editorState) || step.content;
130
+ safelySetEditorState(newEditor, rawContent);
131
+ return __spreadProps(__spreadValues({}, step), { content: newEditor });
132
+ }
133
+ return step;
134
+ });
135
+ }
136
+ static getType() {
137
+ return "stepper";
138
+ }
139
+ addStep(step) {
140
+ const self = this.getWritable();
141
+ const newEditor = createEditor();
142
+ safelySetEditorState(newEditor, null);
143
+ const newStep = __spreadProps(__spreadValues({}, step), {
144
+ content: newEditor
145
+ });
146
+ self.__steps.push(newStep);
147
+ return self;
148
+ }
149
+ insertStepAtIndex(step, index) {
150
+ if (index < 0 || index > this.__steps.length) {
151
+ throw new Error("Invalid index for inserting step.");
152
+ }
153
+ const self = this.getWritable();
154
+ const newEditor = createEditor();
155
+ safelySetEditorState(newEditor, null);
156
+ const newStep = __spreadProps(__spreadValues({}, step), {
157
+ content: newEditor
158
+ });
159
+ self.__steps.splice(index, 0, newStep);
160
+ return self;
161
+ }
162
+ deleteStep(idOrIndex) {
163
+ const self = this.getWritable();
164
+ const hasId = self.__steps.some((step) => step.id === idOrIndex);
165
+ if (hasId) {
166
+ self.__steps = self.__steps.filter((step) => step.id !== idOrIndex);
167
+ } else if (idOrIndex >= 0 && idOrIndex < self.__steps.length) {
168
+ self.__steps.splice(idOrIndex, 1);
169
+ }
170
+ return self;
171
+ }
172
+ updateTitle(id, title) {
173
+ const self = this.getWritable();
174
+ const step = self.__steps.find((s) => s.id === id);
175
+ if (step) step.title = title;
176
+ return self;
177
+ }
178
+ replaceSteps(steps) {
179
+ const self = this.getWritable();
180
+ const safeSteps = Array.isArray(steps) ? steps : [];
181
+ self.__steps = safeSteps.map((step) => {
182
+ var _a;
183
+ if ((step == null ? void 0 : step.content) && typeof step.content.isEditable === "function") return step;
184
+ const newEditor = createEditor();
185
+ const rawContent = ((_a = step == null ? void 0 : step.content) == null ? void 0 : _a.editorState) || (step == null ? void 0 : step.content);
186
+ safelySetEditorState(newEditor, rawContent);
187
+ return __spreadProps(__spreadValues({}, step), { content: newEditor });
188
+ });
189
+ return self;
190
+ }
191
+ reorderSteps(newSteps) {
192
+ const self = this.getWritable();
193
+ self.__steps = newSteps;
194
+ return self;
195
+ }
196
+ static clone(node) {
197
+ const safeSteps = Array.isArray(node.__steps) ? node.__steps : [];
198
+ return new _StepperNode(safeSteps, node.__key);
199
+ }
200
+ static importJSON(serializedNode) {
201
+ const serializedSteps = Array.isArray(serializedNode == null ? void 0 : serializedNode.steps) ? serializedNode.steps : [];
202
+ const steps = serializedSteps.map((serializedStep, index) => {
203
+ var _a;
204
+ const newEditor = createEditor();
205
+ const rawContentState = ((_a = serializedStep == null ? void 0 : serializedStep.content) == null ? void 0 : _a.editorState) || (serializedStep == null ? void 0 : serializedStep.content);
206
+ safelySetEditorState(newEditor, rawContentState);
207
+ return {
208
+ title: (serializedStep == null ? void 0 : serializedStep.title) || `Step ${index + 1}`,
209
+ id: parseInt((serializedStep == null ? void 0 : serializedStep.id) || `${index + 1}`, 10) || index + 1,
210
+ content: newEditor
211
+ };
212
+ });
213
+ return new _StepperNode(steps);
214
+ }
215
+ exportJSON() {
216
+ const safeSteps = Array.isArray(this.__steps) ? this.__steps : [];
217
+ return __spreadProps(__spreadValues({}, super.exportJSON()), {
218
+ steps: safeSteps.map((step) => {
219
+ var _a, _b;
220
+ let serializedEditorState = initialEditorState;
221
+ try {
222
+ if ((step == null ? void 0 : step.content) && typeof step.content.getEditorState === "function") {
223
+ serializedEditorState = step.content.getEditorState().toJSON();
224
+ } else if ((_a = step == null ? void 0 : step.content) == null ? void 0 : _a.editorState) {
225
+ serializedEditorState = step.content.editorState;
226
+ }
227
+ } catch (e) {
228
+ serializedEditorState = initialEditorState;
229
+ }
230
+ return {
231
+ title: (step == null ? void 0 : step.title) || "",
232
+ id: ((_b = step == null ? void 0 : step.id) != null ? _b : "").toString(),
233
+ content: {
234
+ editorState: serializedEditorState
235
+ }
236
+ };
237
+ }),
238
+ type: "stepper"
239
+ });
240
+ }
241
+ createDOM() {
242
+ const element = document.createElement("div");
243
+ element.className = `stepper-${this.__type}`;
244
+ return element;
245
+ }
246
+ updateDOM() {
247
+ return false;
248
+ }
249
+ decorate() {
250
+ const safeSteps = Array.isArray(this.__steps) ? this.__steps : [];
251
+ return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(StepperComponent, { steps: safeSteps, nodeKey: this.getKey() }) }) });
252
+ }
253
+ };
254
+ function $isStepperNode(node) {
255
+ return node instanceof StepperNode;
256
+ }
257
+ function $createStepperNode(steps) {
258
+ return new StepperNode(steps || []);
259
+ }
260
+ var INSERT_STEPPER_COMMAND = createCommand();
261
+ function $insertStepperNode(steps) {
262
+ const selection = $getSelection();
263
+ if ($isRangeSelection(selection)) {
264
+ const stepperNode = $createStepperNode(steps);
265
+ selection.insertNodes([stepperNode]);
266
+ }
267
+ }
268
+ function StepperPlugin() {
269
+ const [editor] = useLexicalComposerContext();
270
+ useEffect(() => {
271
+ if (!editor.hasNodes([StepperNode])) {
272
+ throw new Error("StepperNode: StepperNode not registered on editor");
273
+ }
274
+ }, [editor]);
275
+ useEffect(() => {
276
+ return editor.registerCommand(
277
+ INSERT_STEPPER_COMMAND,
278
+ (payload) => {
279
+ editor.update(() => {
280
+ $insertStepperNode(payload);
281
+ });
282
+ return true;
283
+ },
284
+ COMMAND_PRIORITY_LOW
285
+ );
286
+ }, [editor]);
287
+ return null;
288
+ }
289
+
290
+ // src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx
291
+ init_react_shim();
292
+ import {
293
+ addClassNamesToElement,
294
+ removeClassNamesFromElement
295
+ } from "@lexical/utils";
296
+ import {
297
+ $applyNodeReplacement,
298
+ createEditor as createEditor2,
299
+ DecoratorNode as DecoratorNode2,
300
+ isHTMLElement
301
+ } from "lexical";
302
+ import * as React2 from "react";
303
+ import { jsx as jsx2 } from "react/jsx-runtime";
304
+ var InlineImageComponent = React2.lazy(() => import("./InlineImageComponent-KDN3VGZC.mjs"));
305
+ function $convertInlineImageElement(domNode) {
306
+ if (isHTMLElement(domNode) && domNode.nodeName === "IMG") {
307
+ const { alt: altText, src, width, height } = domNode;
308
+ const node = $createInlineImageNode({ altText, height, src, width });
309
+ return { node };
310
+ }
311
+ return null;
312
+ }
313
+ function getPositionClass(position) {
314
+ return typeof position === "string" ? `position-${position}` : void 0;
315
+ }
316
+ var InlineImageNode = class _InlineImageNode extends DecoratorNode2 {
317
+ static getType() {
318
+ return "inline-image";
319
+ }
320
+ static clone(node) {
321
+ return new _InlineImageNode(
322
+ node.__src,
323
+ node.__altText,
324
+ node.__position,
325
+ node.__width,
326
+ node.__height,
327
+ node.__showCaption,
328
+ node.__caption,
329
+ node.__key
330
+ );
331
+ }
332
+ static importJSON(serializedNode) {
333
+ const { altText, height, width, src, showCaption, position } = serializedNode;
334
+ return $createInlineImageNode({
335
+ altText,
336
+ height,
337
+ position,
338
+ showCaption,
339
+ src,
340
+ width
341
+ }).updateFromJSON(serializedNode);
342
+ }
343
+ updateFromJSON(serializedNode) {
344
+ const { caption } = serializedNode;
345
+ const node = super.updateFromJSON(serializedNode);
346
+ const nestedEditor = node.__caption;
347
+ const editorState = nestedEditor.parseEditorState(caption.editorState);
348
+ if (!editorState.isEmpty()) {
349
+ nestedEditor.setEditorState(editorState);
350
+ }
351
+ return node;
352
+ }
353
+ static importDOM() {
354
+ return {
355
+ img: (node) => ({
356
+ conversion: $convertInlineImageElement,
357
+ priority: 0
358
+ })
359
+ };
360
+ }
361
+ constructor(src, altText, position, width, height, showCaption, caption, key) {
362
+ super(key);
363
+ this.__src = src;
364
+ this.__altText = altText;
365
+ this.__width = width || "inherit";
366
+ this.__height = height || "inherit";
367
+ this.__showCaption = showCaption || false;
368
+ this.__caption = caption || createEditor2();
369
+ this.__position = position;
370
+ }
371
+ exportDOM() {
372
+ const element = document.createElement("img");
373
+ element.setAttribute("src", this.__src);
374
+ element.setAttribute("alt", this.__altText);
375
+ element.setAttribute("width", this.__width.toString());
376
+ element.setAttribute("height", this.__height.toString());
377
+ return { element };
378
+ }
379
+ exportJSON() {
380
+ return __spreadProps(__spreadValues({}, super.exportJSON()), {
381
+ altText: this.getAltText(),
382
+ caption: this.__caption.toJSON(),
383
+ height: this.__height === "inherit" ? 0 : this.__height,
384
+ position: this.__position,
385
+ showCaption: this.__showCaption,
386
+ src: this.getSrc(),
387
+ width: this.__width === "inherit" ? 0 : this.__width
388
+ });
389
+ }
390
+ getSrc() {
391
+ return this.__src;
392
+ }
393
+ getAltText() {
394
+ return this.__altText;
395
+ }
396
+ setAltText(altText) {
397
+ const writable = this.getWritable();
398
+ writable.__altText = altText;
399
+ }
400
+ setWidthAndHeight(width, height) {
401
+ const writable = this.getWritable();
402
+ writable.__width = width;
403
+ writable.__height = height;
404
+ }
405
+ getShowCaption() {
406
+ return this.__showCaption;
407
+ }
408
+ setShowCaption(showCaption) {
409
+ const writable = this.getWritable();
410
+ writable.__showCaption = showCaption;
411
+ }
412
+ getPosition() {
413
+ return this.__position;
414
+ }
415
+ setPosition(position) {
416
+ const writable = this.getWritable();
417
+ writable.__position = position;
418
+ }
419
+ update(payload) {
420
+ const writable = this.getWritable();
421
+ const { altText, showCaption, position } = payload;
422
+ if (altText !== void 0) {
423
+ writable.__altText = altText;
424
+ }
425
+ if (showCaption !== void 0) {
426
+ writable.__showCaption = showCaption;
427
+ }
428
+ if (position !== void 0) {
429
+ writable.__position = position;
430
+ }
431
+ }
432
+ // View
433
+ createDOM(config) {
434
+ const span = document.createElement("span");
435
+ for (const cls of [
436
+ config.theme.inlineImage,
437
+ getPositionClass(this.__position)
438
+ ]) {
439
+ if (cls) {
440
+ addClassNamesToElement(span, cls);
441
+ }
442
+ }
443
+ return span;
444
+ }
445
+ updateDOM(prevNode, dom, config) {
446
+ const position = this.__position;
447
+ if (position !== prevNode.__position) {
448
+ removeClassNamesFromElement(dom, getPositionClass(prevNode.__position));
449
+ addClassNamesToElement(dom, getPositionClass(position));
450
+ }
451
+ return false;
452
+ }
453
+ decorate() {
454
+ return /* @__PURE__ */ jsx2(
455
+ NodeRendererSlot,
456
+ {
457
+ nodeType: "inlineImage",
458
+ rendererProps: {
459
+ src: this.__src,
460
+ altText: this.__altText,
461
+ width: this.__width,
462
+ height: this.__height,
463
+ nodeKey: this.getKey(),
464
+ showCaption: this.__showCaption,
465
+ caption: this.__caption,
466
+ position: this.__position
467
+ },
468
+ fallback: /* @__PURE__ */ jsx2(
469
+ InlineImageComponent,
470
+ {
471
+ src: this.__src,
472
+ altText: this.__altText,
473
+ width: this.__width,
474
+ height: this.__height,
475
+ nodeKey: this.getKey(),
476
+ showCaption: this.__showCaption,
477
+ caption: this.__caption,
478
+ position: this.__position
479
+ }
480
+ )
481
+ }
482
+ );
483
+ }
484
+ };
485
+ function $createInlineImageNode({
486
+ altText,
487
+ position,
488
+ height,
489
+ src,
490
+ width,
491
+ showCaption,
492
+ caption,
493
+ key
494
+ }) {
495
+ return $applyNodeReplacement(
496
+ new InlineImageNode(
497
+ src,
498
+ altText,
499
+ position,
500
+ width,
501
+ height,
502
+ showCaption,
503
+ caption,
504
+ key
505
+ )
506
+ );
507
+ }
508
+ function $isInlineImageNode(node) {
509
+ return node instanceof InlineImageNode;
510
+ }
511
+
512
+ // src/components/editor/plugins/YouTubeNode/index.tsx
513
+ init_react_shim();
514
+ import { BlockWithAlignableContents } from "@lexical/react/LexicalBlockWithAlignableContents";
515
+ import {
516
+ DecoratorBlockNode
517
+ } from "@lexical/react/LexicalDecoratorBlockNode";
518
+ import { jsx as jsx3 } from "react/jsx-runtime";
519
+ function YouTubeComponent({
520
+ className,
521
+ format,
522
+ nodeKey,
523
+ videoID
524
+ }) {
525
+ return /* @__PURE__ */ jsx3(
526
+ BlockWithAlignableContents,
527
+ {
528
+ className,
529
+ format,
530
+ nodeKey,
531
+ children: /* @__PURE__ */ jsx3(
532
+ "iframe",
533
+ {
534
+ width: "560",
535
+ height: "315",
536
+ style: {
537
+ width: "100%",
538
+ aspectRatio: "16/9",
539
+ borderRadius: "8px",
540
+ border: "4px solid #e6c10aff"
541
+ },
542
+ src: `https://www.youtube-nocookie.com/embed/${videoID}`,
543
+ frameBorder: "0",
544
+ allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
545
+ allowFullScreen: true,
546
+ title: "YouTube video"
547
+ }
548
+ )
549
+ }
550
+ );
551
+ }
552
+ function $convertYoutubeElement(domNode) {
553
+ const videoID = domNode.getAttribute("data-lexical-youtube");
554
+ if (videoID) {
555
+ const node = $createYouTubeNode(videoID);
556
+ return { node };
557
+ }
558
+ return null;
559
+ }
560
+ var YouTubeNode = class _YouTubeNode extends DecoratorBlockNode {
561
+ static getType() {
562
+ return "youtube";
563
+ }
564
+ static clone(node) {
565
+ return new _YouTubeNode(node.__id, node.__format, node.__key);
566
+ }
567
+ static importJSON(serializedNode) {
568
+ return $createYouTubeNode(serializedNode.videoID).updateFromJSON(
569
+ serializedNode
570
+ );
571
+ }
572
+ exportJSON() {
573
+ return __spreadProps(__spreadValues({}, super.exportJSON()), {
574
+ videoID: this.__id
575
+ });
576
+ }
577
+ constructor(id, format, key) {
578
+ super(format, key);
579
+ this.__id = id;
580
+ }
581
+ exportDOM() {
582
+ const element = document.createElement("iframe");
583
+ element.setAttribute("data-lexical-youtube", this.__id);
584
+ element.setAttribute("width", "560");
585
+ element.setAttribute("height", "315");
586
+ element.setAttribute(
587
+ "src",
588
+ `https://www.youtube-nocookie.com/embed/${this.__id}`
589
+ );
590
+ element.setAttribute("frameborder", "0");
591
+ element.setAttribute(
592
+ "allow",
593
+ "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
594
+ );
595
+ element.setAttribute("allowfullscreen", "true");
596
+ element.setAttribute("title", "YouTube video");
597
+ return { element };
598
+ }
599
+ static importDOM() {
600
+ return {
601
+ iframe: (domNode) => {
602
+ if (!domNode.hasAttribute("data-lexical-youtube")) {
603
+ return null;
604
+ }
605
+ return {
606
+ conversion: $convertYoutubeElement,
607
+ priority: 1
608
+ };
609
+ }
610
+ };
611
+ }
612
+ updateDOM() {
613
+ return false;
614
+ }
615
+ getId() {
616
+ return this.__id;
617
+ }
618
+ getTextContent() {
619
+ return `https://www.youtube.com/watch?v=${this.__id}`;
620
+ }
621
+ decorate(_editor, config) {
622
+ const embedBlockTheme = config.theme.embedBlock || {};
623
+ const className = {
624
+ base: embedBlockTheme.base || "",
625
+ focus: embedBlockTheme.focus || ""
626
+ };
627
+ return /* @__PURE__ */ jsx3(
628
+ YouTubeComponent,
629
+ {
630
+ className,
631
+ format: this.__format,
632
+ nodeKey: this.getKey(),
633
+ videoID: this.__id
634
+ }
635
+ );
636
+ }
637
+ };
638
+ function $createYouTubeNode(videoID) {
639
+ return new YouTubeNode(videoID);
640
+ }
641
+ function $isYouTubeNode(node) {
642
+ return node instanceof YouTubeNode;
643
+ }
644
+
645
+ // src/components/editor/nodes/TweetNode/index.tsx
646
+ init_react_shim();
647
+ import { BlockWithAlignableContents as BlockWithAlignableContents2 } from "@lexical/react/LexicalBlockWithAlignableContents";
648
+ import {
649
+ DecoratorBlockNode as DecoratorBlockNode2
650
+ } from "@lexical/react/LexicalDecoratorBlockNode";
651
+ import { useCallback, useEffect as useEffect2, useRef, useState } from "react";
652
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
653
+ var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
654
+ function $convertTweetElement(domNode) {
655
+ const id = domNode.getAttribute("data-lexical-tweet-id");
656
+ if (id) {
657
+ const node = $createTweetNode(id);
658
+ return { node };
659
+ }
660
+ return null;
661
+ }
662
+ var isTwitterScriptLoading = true;
663
+ function TweetComponent({
664
+ className,
665
+ format,
666
+ nodeKey,
667
+ onError,
668
+ onLoad,
669
+ tweetID
670
+ }) {
671
+ const containerRef = useRef(null);
672
+ const previousTweetIDRef = useRef("");
673
+ const [isTweetLoading, setIsTweetLoading] = useState(false);
674
+ const createTweet = useCallback(async () => {
675
+ try {
676
+ await window.twttr.widgets.createTweet(tweetID, containerRef.current);
677
+ setIsTweetLoading(false);
678
+ isTwitterScriptLoading = false;
679
+ if (onLoad) {
680
+ onLoad();
681
+ }
682
+ } catch (error) {
683
+ if (onError) {
684
+ onError(String(error));
685
+ }
686
+ }
687
+ }, [onError, onLoad, tweetID]);
688
+ useEffect2(() => {
689
+ var _a;
690
+ if (tweetID !== previousTweetIDRef.current) {
691
+ setIsTweetLoading(true);
692
+ if (isTwitterScriptLoading) {
693
+ const script = document.createElement("script");
694
+ script.src = WIDGET_SCRIPT_URL;
695
+ script.async = true;
696
+ (_a = document.body) == null ? void 0 : _a.appendChild(script);
697
+ script.onload = createTweet;
698
+ if (onError) {
699
+ script.onerror = onError;
700
+ }
701
+ } else {
702
+ createTweet();
703
+ }
704
+ if (previousTweetIDRef) {
705
+ previousTweetIDRef.current = tweetID;
706
+ }
707
+ }
708
+ }, [createTweet, onError, tweetID]);
709
+ return /* @__PURE__ */ jsxs(
710
+ BlockWithAlignableContents2,
711
+ {
712
+ className,
713
+ format,
714
+ nodeKey,
715
+ children: [
716
+ isTweetLoading ? /* @__PURE__ */ jsx4(Skeleton, { className: "max-h-[200px] w-full h-full max-w-[400px]" }) : null,
717
+ /* @__PURE__ */ jsx4(
718
+ "div",
719
+ {
720
+ style: {
721
+ display: "inline-block",
722
+ width: "100%"
723
+ },
724
+ ref: containerRef
725
+ }
726
+ )
727
+ ]
728
+ }
729
+ );
730
+ }
731
+ var TweetNode = class _TweetNode extends DecoratorBlockNode2 {
732
+ static getType() {
733
+ return "tweet";
734
+ }
735
+ static clone(node) {
736
+ return new _TweetNode(node.__id, node.__format, node.__key);
737
+ }
738
+ static importJSON(serializedNode) {
739
+ return $createTweetNode(serializedNode.id).updateFromJSON(serializedNode);
740
+ }
741
+ exportJSON() {
742
+ return __spreadProps(__spreadValues({}, super.exportJSON()), {
743
+ id: this.getId()
744
+ });
745
+ }
746
+ static importDOM() {
747
+ return {
748
+ div: (domNode) => {
749
+ if (!domNode.hasAttribute("data-lexical-tweet-id")) {
750
+ return null;
751
+ }
752
+ return {
753
+ conversion: $convertTweetElement,
754
+ priority: 2
755
+ };
756
+ }
757
+ };
758
+ }
759
+ exportDOM() {
760
+ const element = document.createElement("div");
761
+ element.setAttribute("data-lexical-tweet-id", this.__id);
762
+ const text = document.createTextNode(this.getTextContent());
763
+ element.append(text);
764
+ return { element };
765
+ }
766
+ constructor(id, format, key) {
767
+ super(format, key);
768
+ this.__id = id;
769
+ }
770
+ getId() {
771
+ return this.__id;
772
+ }
773
+ getTextContent() {
774
+ return `https://x.com/i/web/status/${this.__id}`;
775
+ }
776
+ decorate(editor, config) {
777
+ const embedBlockTheme = config.theme.embedBlock || {};
778
+ const className = {
779
+ base: embedBlockTheme.base || "",
780
+ focus: embedBlockTheme.focus || ""
781
+ };
782
+ return /* @__PURE__ */ jsx4(
783
+ TweetComponent,
784
+ {
785
+ className,
786
+ format: this.__format,
787
+ loadingComponent: "Loading...",
788
+ nodeKey: this.getKey(),
789
+ tweetID: this.__id
790
+ }
791
+ );
792
+ }
793
+ };
794
+ function $createTweetNode(tweetID) {
795
+ return new TweetNode(tweetID);
796
+ }
797
+ function $isTweetNode(node) {
798
+ return node instanceof TweetNode;
799
+ }
800
+
801
+ // src/components/editor/nodes/FigmaNode/FigmaNode.tsx
802
+ init_react_shim();
803
+ import { BlockWithAlignableContents as BlockWithAlignableContents3 } from "@lexical/react/LexicalBlockWithAlignableContents";
804
+ import {
805
+ DecoratorBlockNode as DecoratorBlockNode3
806
+ } from "@lexical/react/LexicalDecoratorBlockNode";
807
+ import { jsx as jsx5 } from "react/jsx-runtime";
808
+ function getFigmaEmbedUrl(documentID) {
809
+ const cleanId = (documentID || "").trim();
810
+ const figmaUrl = cleanId.startsWith("http") ? cleanId : `https://www.figma.com/file/${cleanId}`;
811
+ return `https://www.figma.com/embed?embed_host=notiq&url=${encodeURIComponent(figmaUrl)}`;
812
+ }
813
+ function FigmaComponent({
814
+ className,
815
+ format,
816
+ nodeKey,
817
+ documentID
818
+ }) {
819
+ const embedUrl = getFigmaEmbedUrl(documentID);
820
+ return /* @__PURE__ */ jsx5(
821
+ BlockWithAlignableContents3,
822
+ {
823
+ className,
824
+ format,
825
+ nodeKey,
826
+ children: /* @__PURE__ */ jsx5("div", { className: "relative my-4 aspect-video w-full max-w-3xl overflow-hidden rounded-2xl border border-border/80 bg-card shadow-sm", children: /* @__PURE__ */ jsx5(
827
+ "iframe",
828
+ {
829
+ className: "h-full w-full border-0",
830
+ src: embedUrl,
831
+ allowFullScreen: true,
832
+ title: "Figma Document",
833
+ loading: "lazy"
834
+ }
835
+ ) })
836
+ }
837
+ );
838
+ }
839
+ var FigmaNode = class _FigmaNode extends DecoratorBlockNode3 {
840
+ static getType() {
841
+ return "figma";
842
+ }
843
+ static clone(node) {
844
+ return new _FigmaNode(node.__id, node.__format, node.__key);
845
+ }
846
+ static importJSON(serializedNode) {
847
+ return $createFigmaNode(serializedNode.documentID).updateFromJSON(
848
+ serializedNode
849
+ );
850
+ }
851
+ exportJSON() {
852
+ return __spreadProps(__spreadValues({}, super.exportJSON()), {
853
+ documentID: this.__id
854
+ });
855
+ }
856
+ constructor(id, format, key) {
857
+ super(format, key);
858
+ this.__id = id;
859
+ }
860
+ updateDOM() {
861
+ return false;
862
+ }
863
+ getId() {
864
+ return this.__id;
865
+ }
866
+ getTextContent() {
867
+ return `https://www.figma.com/file/${this.__id}`;
868
+ }
869
+ decorate() {
870
+ return /* @__PURE__ */ jsx5(
871
+ FigmaComponent,
872
+ {
873
+ className: {
874
+ base: "",
875
+ focus: ""
876
+ },
877
+ format: this.__format,
878
+ nodeKey: this.getKey(),
879
+ documentID: this.__id
880
+ }
881
+ );
882
+ }
883
+ };
884
+ function $createFigmaNode(datasetID) {
885
+ return new FigmaNode(datasetID);
886
+ }
887
+ function $isFigmaNode(node) {
888
+ return node instanceof FigmaNode;
889
+ }
890
+
891
+ // src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts
892
+ init_react_shim();
893
+ import {
894
+ ElementNode
895
+ } from "lexical";
896
+ var CollapsibleContainerNode = class _CollapsibleContainerNode extends ElementNode {
897
+ constructor(open, key) {
898
+ super(key);
899
+ this.__open = open;
900
+ }
901
+ static getType() {
902
+ return "collapsible-container";
903
+ }
904
+ static clone(node) {
905
+ return new _CollapsibleContainerNode(node.__open, node.__key);
906
+ }
907
+ createDOM() {
908
+ const dom = document.createElement("details");
909
+ dom.classList.add("Collapsible__container");
910
+ dom.open = this.__open;
911
+ return dom;
912
+ }
913
+ updateDOM(prevNode, dom) {
914
+ if (prevNode.__open !== this.__open) {
915
+ dom.open = this.__open;
916
+ }
917
+ return false;
918
+ }
919
+ static importDOM() {
920
+ return {};
921
+ }
922
+ static importJSON() {
923
+ const node = $createCollapsibleContainerNode();
924
+ return node;
925
+ }
926
+ exportJSON() {
927
+ return __spreadProps(__spreadValues({}, super.exportJSON()), {
928
+ type: "collapsible-container",
929
+ version: 1
930
+ });
931
+ }
932
+ setOpen(open) {
933
+ const writable = this.getWritable();
934
+ writable.__open = open;
935
+ }
936
+ getOpen() {
937
+ return this.__open;
938
+ }
939
+ toggleOpen() {
940
+ this.setOpen(!this.getOpen());
941
+ }
942
+ };
943
+ function $createCollapsibleContainerNode() {
944
+ return new CollapsibleContainerNode(true);
945
+ }
946
+ function $isCollapsibleContainerNode(node) {
947
+ return node instanceof CollapsibleContainerNode;
948
+ }
949
+
950
+ // src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts
951
+ init_react_shim();
952
+ import {
953
+ ElementNode as ElementNode2
954
+ } from "lexical";
955
+ var CollapsibleContentNode = class _CollapsibleContentNode extends ElementNode2 {
956
+ static getType() {
957
+ return "collapsible-content";
958
+ }
959
+ static clone(node) {
960
+ return new _CollapsibleContentNode(node.__key);
961
+ }
962
+ createDOM() {
963
+ const dom = document.createElement("div");
964
+ dom.classList.add("Collapsible__content");
965
+ return dom;
966
+ }
967
+ updateDOM() {
968
+ return false;
969
+ }
970
+ static importDOM() {
971
+ return {};
972
+ }
973
+ static importJSON() {
974
+ return $createCollapsibleContentNode();
975
+ }
976
+ isShadowRoot() {
977
+ return true;
978
+ }
979
+ exportJSON() {
980
+ return __spreadProps(__spreadValues({}, super.exportJSON()), {
981
+ type: "collapsible-content",
982
+ version: 1
983
+ });
984
+ }
985
+ };
986
+ function $createCollapsibleContentNode() {
987
+ return new CollapsibleContentNode();
988
+ }
989
+ function $isCollapsibleContentNode(node) {
990
+ return node instanceof CollapsibleContentNode;
991
+ }
992
+
993
+ // src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts
994
+ init_react_shim();
995
+ import {
996
+ $createParagraphNode,
997
+ $isElementNode,
998
+ ElementNode as ElementNode3
999
+ } from "lexical";
1000
+ var CollapsibleTitleNode = class _CollapsibleTitleNode extends ElementNode3 {
1001
+ static getType() {
1002
+ return "collapsible-title";
1003
+ }
1004
+ static clone(node) {
1005
+ return new _CollapsibleTitleNode(node.__key);
1006
+ }
1007
+ createDOM() {
1008
+ const dom = document.createElement("summary");
1009
+ dom.classList.add("Collapsible__title");
1010
+ return dom;
1011
+ }
1012
+ updateDOM() {
1013
+ return false;
1014
+ }
1015
+ static importDOM() {
1016
+ return {};
1017
+ }
1018
+ static importJSON() {
1019
+ return $createCollapsibleTitleNode();
1020
+ }
1021
+ exportJSON() {
1022
+ return __spreadProps(__spreadValues({}, super.exportJSON()), {
1023
+ type: "collapsible-title",
1024
+ version: 1
1025
+ });
1026
+ }
1027
+ collapseAtStart(_selection) {
1028
+ this.getParentOrThrow().insertBefore(this);
1029
+ return true;
1030
+ }
1031
+ insertNewAfter() {
1032
+ const containerNode = this.getParentOrThrow();
1033
+ if (!$isCollapsibleContainerNode(containerNode)) {
1034
+ throw new Error(
1035
+ "CollapsibleTitleNode expects to be child of CollapsibleContainerNode"
1036
+ );
1037
+ }
1038
+ if (containerNode.getOpen()) {
1039
+ const contentNode = this.getNextSibling();
1040
+ if (!$isCollapsibleContentNode(contentNode)) {
1041
+ throw new Error(
1042
+ "CollapsibleTitleNode expects to have CollapsibleContentNode sibling"
1043
+ );
1044
+ }
1045
+ const firstChild = contentNode.getFirstChild();
1046
+ if ($isElementNode(firstChild)) {
1047
+ return firstChild;
1048
+ } else {
1049
+ const paragraph = $createParagraphNode();
1050
+ contentNode.append(paragraph);
1051
+ return paragraph;
1052
+ }
1053
+ } else {
1054
+ const paragraph = $createParagraphNode();
1055
+ containerNode.insertAfter(paragraph);
1056
+ return paragraph;
1057
+ }
1058
+ }
1059
+ };
1060
+ function $createCollapsibleTitleNode() {
1061
+ return new CollapsibleTitleNode();
1062
+ }
1063
+ function $isCollapsibleTitleNode(node) {
1064
+ return node instanceof CollapsibleTitleNode;
1065
+ }
1066
+
1067
+ // src/components/editor/utils/markdownTransformers.ts
1068
+ init_react_shim();
1069
+ import {
1070
+ $createHorizontalRuleNode,
1071
+ $isHorizontalRuleNode,
1072
+ HorizontalRuleNode
1073
+ } from "@lexical/react/LexicalHorizontalRuleNode";
1074
+ import {
1075
+ $convertFromMarkdownString,
1076
+ CHECK_LIST,
1077
+ TEXT_FORMAT_TRANSFORMERS,
1078
+ TEXT_MATCH_TRANSFORMERS,
1079
+ TRANSFORMERS
1080
+ } from "@lexical/markdown";
1081
+
1082
+ // src/components/editor/utils/excalidrawDiagramBuilder.ts
1083
+ init_react_shim();
1084
+ function makeBaseElement(id, type, x, y, width, height) {
1085
+ return {
1086
+ id,
1087
+ type,
1088
+ x,
1089
+ y,
1090
+ width,
1091
+ height,
1092
+ angle: 0,
1093
+ strokeColor: "#4f46e5",
1094
+ backgroundColor: "transparent",
1095
+ fillStyle: "solid",
1096
+ strokeWidth: 2,
1097
+ strokeStyle: "solid",
1098
+ roughness: 1,
1099
+ opacity: 100,
1100
+ groupIds: [],
1101
+ frameId: null,
1102
+ roundness: null,
1103
+ seed: Math.floor(Math.random() * 1e6) + 1,
1104
+ version: 1,
1105
+ versionNonce: Math.floor(Math.random() * 1e6) + 1,
1106
+ isDeleted: false,
1107
+ boundElements: null,
1108
+ updated: 1,
1109
+ link: null,
1110
+ locked: false
1111
+ };
1112
+ }
1113
+ function extractLabelText(raw) {
1114
+ if (typeof raw.label === "string" && raw.label.trim()) {
1115
+ return raw.label;
1116
+ }
1117
+ if (raw.label && typeof raw.label === "object" && typeof raw.label.text === "string") {
1118
+ const t = raw.label.text.trim();
1119
+ return t || null;
1120
+ }
1121
+ return null;
1122
+ }
1123
+ function normalizeExcalidrawElements(rawElements) {
1124
+ const result = [];
1125
+ const existingBoundContainers = /* @__PURE__ */ new Set();
1126
+ for (const item of rawElements) {
1127
+ if (item && typeof item === "object") {
1128
+ const rec = item;
1129
+ if (rec.type === "text" && typeof rec.containerId === "string") {
1130
+ existingBoundContainers.add(rec.containerId);
1131
+ }
1132
+ }
1133
+ }
1134
+ rawElements.forEach((item, idx) => {
1135
+ var _b, _c;
1136
+ if (!item || typeof item !== "object") return;
1137
+ const raw = item;
1138
+ const type = typeof raw.type === "string" ? raw.type : "rectangle";
1139
+ const id = typeof raw.id === "string" && raw.id ? raw.id : `el-${idx}`;
1140
+ const x = typeof raw.x === "number" ? raw.x : 60 + idx % 3 * 240;
1141
+ const y = typeof raw.y === "number" ? raw.y : 60 + Math.floor(idx / 3) * 140;
1142
+ const width = typeof raw.width === "number" ? raw.width : type === "arrow" || type === "line" ? 120 : 180;
1143
+ const height = typeof raw.height === "number" ? raw.height : type === "arrow" || type === "line" ? 0 : 64;
1144
+ const base = makeBaseElement(id, type, x, y, width, height);
1145
+ const _a = raw, { label: _ignoredLabel } = _a, restRaw = __objRest(_a, ["label"]);
1146
+ const normalized = __spreadProps(__spreadValues(__spreadValues({}, base), restRaw), {
1147
+ id,
1148
+ type,
1149
+ x,
1150
+ y,
1151
+ width,
1152
+ height
1153
+ });
1154
+ if (type === "rectangle" && normalized.roundness == null) {
1155
+ normalized.roundness = { type: 3 };
1156
+ }
1157
+ if (type === "text") {
1158
+ const textVal = typeof normalized.text === "string" ? normalized.text : extractLabelText(raw) || "";
1159
+ normalized.text = textVal;
1160
+ normalized.originalText = typeof normalized.originalText === "string" ? normalized.originalText : textVal;
1161
+ normalized.fontSize = typeof normalized.fontSize === "number" ? normalized.fontSize : 16;
1162
+ normalized.fontFamily = typeof normalized.fontFamily === "number" ? normalized.fontFamily : 1;
1163
+ normalized.textAlign = (_b = normalized.textAlign) != null ? _b : "center";
1164
+ normalized.verticalAlign = (_c = normalized.verticalAlign) != null ? _c : "middle";
1165
+ normalized.baseline = typeof normalized.baseline === "number" ? normalized.baseline : 18;
1166
+ if (!raw.strokeColor) {
1167
+ normalized.strokeColor = "#1e1b4b";
1168
+ }
1169
+ result.push(normalized);
1170
+ return;
1171
+ }
1172
+ if (type === "arrow" || type === "line") {
1173
+ if (!Array.isArray(normalized.points) || normalized.points.length < 2) {
1174
+ normalized.points = [
1175
+ [0, 0],
1176
+ [width || 120, height || 0]
1177
+ ];
1178
+ }
1179
+ if (normalized.startArrowhead === void 0) {
1180
+ normalized.startArrowhead = null;
1181
+ }
1182
+ if (normalized.endArrowhead === void 0) {
1183
+ normalized.endArrowhead = type === "arrow" ? "arrow" : null;
1184
+ }
1185
+ result.push(normalized);
1186
+ const labelText2 = extractLabelText(raw);
1187
+ if (labelText2) {
1188
+ const pts = normalized.points;
1189
+ const lastPt = pts[pts.length - 1] || [width, height];
1190
+ const midX = x + lastPt[0] / 2 - 40;
1191
+ const midY = y + lastPt[1] / 2 - 20;
1192
+ result.push(__spreadProps(__spreadValues({}, makeBaseElement(`${id}-label`, "text", midX, midY, 80, 20)), {
1193
+ strokeColor: "#4338ca",
1194
+ text: labelText2,
1195
+ fontSize: 13,
1196
+ fontFamily: 1,
1197
+ textAlign: "center",
1198
+ verticalAlign: "middle",
1199
+ baseline: 14,
1200
+ originalText: labelText2
1201
+ }));
1202
+ }
1203
+ return;
1204
+ }
1205
+ const labelText = extractLabelText(raw);
1206
+ if (labelText && !existingBoundContainers.has(id)) {
1207
+ const textId = `${id}-text`;
1208
+ const existingBound = Array.isArray(normalized.boundElements) ? [...normalized.boundElements] : [];
1209
+ existingBound.push({ id: textId, type: "text" });
1210
+ normalized.boundElements = existingBound;
1211
+ result.push(normalized);
1212
+ const textHeight = Math.max(24, labelText.split("\n").length * 22);
1213
+ result.push(__spreadProps(__spreadValues({}, makeBaseElement(
1214
+ textId,
1215
+ "text",
1216
+ x + 12,
1217
+ y + Math.max(8, (height - textHeight) / 2),
1218
+ Math.max(40, width - 24),
1219
+ textHeight
1220
+ )), {
1221
+ strokeColor: "#1e1b4b",
1222
+ text: labelText,
1223
+ fontSize: 16,
1224
+ fontFamily: 1,
1225
+ textAlign: "center",
1226
+ verticalAlign: "middle",
1227
+ baseline: 18,
1228
+ containerId: id,
1229
+ originalText: labelText
1230
+ }));
1231
+ return;
1232
+ }
1233
+ result.push(normalized);
1234
+ });
1235
+ return result;
1236
+ }
1237
+ function compileExcalidrawDiagram(rawJson) {
1238
+ try {
1239
+ const parsed = JSON.parse(rawJson.trim());
1240
+ if (Array.isArray(parsed)) {
1241
+ if (parsed.length === 0) return null;
1242
+ return JSON.stringify({
1243
+ appState: { viewBackgroundColor: "#ffffff" },
1244
+ elements: normalizeExcalidrawElements(parsed),
1245
+ files: {}
1246
+ });
1247
+ }
1248
+ if (parsed && Array.isArray(parsed.elements)) {
1249
+ if (parsed.elements.length === 0) return null;
1250
+ return JSON.stringify({
1251
+ appState: parsed.appState || { viewBackgroundColor: "#ffffff" },
1252
+ elements: normalizeExcalidrawElements(parsed.elements),
1253
+ files: parsed.files || {}
1254
+ });
1255
+ }
1256
+ if (!parsed || !Array.isArray(parsed.nodes) || parsed.nodes.length === 0) {
1257
+ return null;
1258
+ }
1259
+ const spec = parsed;
1260
+ const elements = [];
1261
+ const nodeBoxMap = /* @__PURE__ */ new Map();
1262
+ spec.nodes.forEach((node, idx) => {
1263
+ var _a, _b, _c, _d;
1264
+ const lines = node.label.split("\n");
1265
+ const maxLineLen = Math.max(...lines.map((l) => l.length), 1);
1266
+ const width = (_a = node.width) != null ? _a : Math.max(160, Math.min(340, maxLineLen * 10 + 44));
1267
+ const textHeight = Math.max(24, lines.length * 22);
1268
+ const height = (_b = node.height) != null ? _b : Math.max(64, lines.length * 24 + 28);
1269
+ const col = idx % 3;
1270
+ const row = Math.floor(idx / 3);
1271
+ const x = (_c = node.x) != null ? _c : 60 + col * 360;
1272
+ const y = (_d = node.y) != null ? _d : 60 + row * 155;
1273
+ const rectId = `node-rect-${idx}-${node.id}`;
1274
+ const textId = `node-text-${idx}-${node.id}`;
1275
+ nodeBoxMap.set(node.id, { x, y, width, height });
1276
+ elements.push(__spreadProps(__spreadValues({}, makeBaseElement(rectId, "rectangle", x, y, width, height)), {
1277
+ backgroundColor: node.color || "#eef2ff",
1278
+ roundness: { type: 3 },
1279
+ boundElements: [{ id: textId, type: "text" }]
1280
+ }));
1281
+ elements.push(__spreadProps(__spreadValues({}, makeBaseElement(
1282
+ textId,
1283
+ "text",
1284
+ x + 12,
1285
+ y + Math.max(8, (height - textHeight) / 2),
1286
+ width - 24,
1287
+ textHeight
1288
+ )), {
1289
+ strokeColor: "#1e1b4b",
1290
+ text: node.label,
1291
+ fontSize: 16,
1292
+ fontFamily: 1,
1293
+ textAlign: "center",
1294
+ verticalAlign: "middle",
1295
+ baseline: 18,
1296
+ containerId: rectId,
1297
+ originalText: node.label
1298
+ }));
1299
+ });
1300
+ (spec.edges || []).forEach((edge, idx) => {
1301
+ const fromBox = nodeBoxMap.get(edge.from);
1302
+ const toBox = nodeBoxMap.get(edge.to);
1303
+ if (!fromBox || !toBox) return;
1304
+ const fromCenterX = fromBox.x + fromBox.width / 2;
1305
+ const fromCenterY = fromBox.y + fromBox.height / 2;
1306
+ const toCenterX = toBox.x + toBox.width / 2;
1307
+ const toCenterY = toBox.y + toBox.height / 2;
1308
+ const horizontal = Math.abs(toCenterX - fromCenterX) >= Math.abs(toCenterY - fromCenterY);
1309
+ const startX = horizontal ? toCenterX >= fromCenterX ? fromBox.x + fromBox.width : fromBox.x : fromCenterX;
1310
+ const startY = horizontal ? fromCenterY : toCenterY >= fromCenterY ? fromBox.y + fromBox.height : fromBox.y;
1311
+ const endX = horizontal ? toCenterX >= fromCenterX ? toBox.x : toBox.x + toBox.width : toCenterX;
1312
+ const endY = horizontal ? toCenterY : toCenterY >= fromCenterY ? toBox.y : toBox.y + toBox.height;
1313
+ const dx = endX - startX;
1314
+ const dy = endY - startY;
1315
+ elements.push(__spreadProps(__spreadValues({}, makeBaseElement(
1316
+ `edge-${idx}`,
1317
+ "arrow",
1318
+ startX,
1319
+ startY,
1320
+ Math.abs(dx) || 1,
1321
+ Math.abs(dy) || 1
1322
+ )), {
1323
+ strokeColor: "#6366f1",
1324
+ points: [
1325
+ [0, 0],
1326
+ [dx, dy]
1327
+ ],
1328
+ startArrowhead: null,
1329
+ endArrowhead: "arrow"
1330
+ }));
1331
+ if (edge.label) {
1332
+ const midX = startX + dx / 2 - 40;
1333
+ const midY = startY + dy / 2 - 22;
1334
+ elements.push(__spreadProps(__spreadValues({}, makeBaseElement(`edge-label-${idx}`, "text", midX, midY, 80, 20)), {
1335
+ strokeColor: "#4338ca",
1336
+ text: edge.label,
1337
+ fontSize: 13,
1338
+ fontFamily: 1,
1339
+ textAlign: "center",
1340
+ verticalAlign: "middle",
1341
+ baseline: 14,
1342
+ originalText: edge.label
1343
+ }));
1344
+ }
1345
+ });
1346
+ return JSON.stringify({
1347
+ appState: { viewBackgroundColor: "#ffffff" },
1348
+ elements,
1349
+ files: {}
1350
+ });
1351
+ } catch (e) {
1352
+ return null;
1353
+ }
1354
+ }
1355
+
1356
+ // src/components/editor/utils/markdownTransformers.ts
1357
+ import {
1358
+ $createTableNode,
1359
+ $createTableRowNode,
1360
+ $createTableCellNode,
1361
+ TableNode,
1362
+ TableRowNode,
1363
+ TableCellNode,
1364
+ TableCellHeaderStates,
1365
+ $isTableNode,
1366
+ $isTableRowNode
1367
+ } from "@lexical/table";
1368
+ import { $getRoot, $createParagraphNode as $createParagraphNode2 } from "lexical";
1369
+ var HR_TRANSFORMER = {
1370
+ dependencies: [HorizontalRuleNode],
1371
+ export: (node) => $isHorizontalRuleNode(node) ? "---" : null,
1372
+ regExp: /^(---|\*\*\*|___)\s*$/,
1373
+ replace: (parentNode) => {
1374
+ const line = $createHorizontalRuleNode();
1375
+ parentNode.replace(line);
1376
+ },
1377
+ type: "element"
1378
+ };
1379
+ var IMAGE_TRANSFORMER = {
1380
+ dependencies: [ImageNode, InlineImageNode],
1381
+ export: (node) => {
1382
+ if ($isImageNode(node)) {
1383
+ return `![${node.getAltText() || "Image"}](${node.getSrc()})`;
1384
+ }
1385
+ if ($isInlineImageNode(node)) {
1386
+ return `![${node.__altText || "Image"}](${node.__src || ""})`;
1387
+ }
1388
+ return null;
1389
+ },
1390
+ regExp: /^!\[(.*?)\]\(((?:https?:\/\/|data:image\/).*?)\)$/,
1391
+ replace: (parentNode, _1, match) => {
1392
+ const [, altText, src] = match;
1393
+ const imageNode = $createImageNode({
1394
+ altText: altText || "Image",
1395
+ src,
1396
+ maxWidth: 800
1397
+ });
1398
+ parentNode.replace(imageNode);
1399
+ },
1400
+ type: "element"
1401
+ };
1402
+ var YOUTUBE_TRANSFORMER = {
1403
+ dependencies: [YouTubeNode],
1404
+ export: (node) => {
1405
+ if (!$isYouTubeNode(node)) return null;
1406
+ const id = node.getId();
1407
+ return `[![YouTube Video](https://img.youtube.com/vi/${id}/hqdefault.jpg)](https://www.youtube.com/watch?v=${id})
1408
+
1409
+ [\u25B6 Watch on YouTube](https://www.youtube.com/watch?v=${id})`;
1410
+ },
1411
+ regExp: /^(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})/,
1412
+ replace: (parentNode, _1, match) => {
1413
+ const videoId = match[1];
1414
+ if (videoId) {
1415
+ const youtubeNode = $createYouTubeNode(videoId);
1416
+ parentNode.replace(youtubeNode);
1417
+ }
1418
+ },
1419
+ type: "element"
1420
+ };
1421
+ var TWEET_TRANSFORMER = {
1422
+ dependencies: [TweetNode],
1423
+ export: (node) => {
1424
+ if (!$isTweetNode(node)) return null;
1425
+ const id = node.getId();
1426
+ return `> \u{1D54F} **Tweet** [View Post](https://x.com/i/web/status/${id})`;
1427
+ },
1428
+ regExp: /^(?:https?:\/\/)?(?:twitter\.com|x\.com)\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)/,
1429
+ replace: (parentNode, _1, match) => {
1430
+ const tweetId = match[2];
1431
+ if (tweetId) {
1432
+ const tweetNode = $createTweetNode(tweetId);
1433
+ parentNode.replace(tweetNode);
1434
+ }
1435
+ },
1436
+ type: "element"
1437
+ };
1438
+ var FIGMA_TRANSFORMER = {
1439
+ dependencies: [FigmaNode],
1440
+ export: (node) => {
1441
+ if (!$isFigmaNode(node)) return null;
1442
+ const id = node.getId();
1443
+ const url = id.startsWith("http") ? id : `https://www.figma.com/file/${id}`;
1444
+ return `[\u{1F4D0} Figma Design Embed](${url})`;
1445
+ },
1446
+ regExp: /^(?:https?:\/\/)?(?:www\.)?figma\.com\/(?:file|design)\/([a-zA-Z0-9]+)/,
1447
+ replace: (parentNode, _1, match) => {
1448
+ const figmaNode = $createFigmaNode(match[0]);
1449
+ parentNode.replace(figmaNode);
1450
+ },
1451
+ type: "element"
1452
+ };
1453
+ var EQUATION_TRANSFORMER = {
1454
+ dependencies: [EquationNode],
1455
+ export: (node) => {
1456
+ if (!$isEquationNode(node)) return null;
1457
+ const equation = node.__equation || "";
1458
+ const isInline = node.__inline;
1459
+ return isInline ? `$${equation}$` : `$$
1460
+ ${equation}
1461
+ $$`;
1462
+ },
1463
+ regExp: /^\$\$(.*?)\$\$$/,
1464
+ replace: (parentNode, _children, match) => {
1465
+ var _a;
1466
+ const equation = (_a = match[1]) == null ? void 0 : _a.trim();
1467
+ if (!equation) return;
1468
+ const paragraph = $createParagraphNode2();
1469
+ paragraph.append($createEquationNode(equation, false));
1470
+ parentNode.replace(paragraph);
1471
+ },
1472
+ type: "element"
1473
+ };
1474
+ var HINT_TRANSFORMER = {
1475
+ dependencies: [Hint],
1476
+ export: (node) => {
1477
+ if (!(node instanceof Hint)) return null;
1478
+ let text = "";
1479
+ try {
1480
+ const captionEditor = node.__caption;
1481
+ if (captionEditor == null ? void 0 : captionEditor.getEditorState) {
1482
+ text = captionEditor.getEditorState().read(() => $getRoot().getTextContent());
1483
+ }
1484
+ } catch (e) {
1485
+ text = "";
1486
+ }
1487
+ const variant = (node.__variant || "note").toUpperCase();
1488
+ return `> [!${variant}]
1489
+ > ${text.trim() || "Note"}`;
1490
+ },
1491
+ regExp: /^>\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|INFO|ERROR)\]\s*(.*)$/i,
1492
+ replace: (parentNode, _1, match) => {
1493
+ var _a;
1494
+ const rawTag = (match[1] || "note").toLowerCase();
1495
+ const tagMap = {
1496
+ note: "note",
1497
+ info: "note",
1498
+ tip: "tip",
1499
+ important: "important",
1500
+ warning: "warning",
1501
+ caution: "caution",
1502
+ error: "caution"
1503
+ };
1504
+ const variant = tagMap[rawTag] || "note";
1505
+ const hintNode = $createHintNode(variant);
1506
+ const content = (_a = match[2]) == null ? void 0 : _a.trim();
1507
+ if (content) {
1508
+ const nested = hintNode.__caption;
1509
+ if (nested == null ? void 0 : nested.update) {
1510
+ nested.update(
1511
+ () => {
1512
+ const root = $getRoot();
1513
+ root.clear();
1514
+ $convertFromMarkdownString(content, [
1515
+ ...TEXT_FORMAT_TRANSFORMERS,
1516
+ ...TEXT_MATCH_TRANSFORMERS
1517
+ ]);
1518
+ },
1519
+ { discrete: true }
1520
+ );
1521
+ }
1522
+ }
1523
+ parentNode.replace(hintNode);
1524
+ },
1525
+ type: "element"
1526
+ };
1527
+ var STEPPER_TRANSFORMER = {
1528
+ dependencies: [StepperNode],
1529
+ export: (node) => {
1530
+ if (!$isStepperNode(node)) return null;
1531
+ const steps = node.__steps || [];
1532
+ return steps.map((s, idx) => {
1533
+ var _a;
1534
+ let contentText = "";
1535
+ try {
1536
+ if ((_a = s.content) == null ? void 0 : _a.getEditorState) {
1537
+ contentText = s.content.getEditorState().read(() => $getRoot().getTextContent());
1538
+ }
1539
+ } catch (e) {
1540
+ }
1541
+ return `### Step ${idx + 1}: ${s.title || `Step ${idx + 1}`}
1542
+ ${contentText.trim()}`;
1543
+ }).join("\n\n");
1544
+ },
1545
+ regExp: /^###\s+Step\s+\d+:\s*(.*)$/,
1546
+ replace: () => {
1547
+ },
1548
+ type: "element"
1549
+ };
1550
+ var POLL_TRANSFORMER = {
1551
+ dependencies: [PollNode],
1552
+ export: (node) => {
1553
+ if (!$isPollNode(node)) return null;
1554
+ try {
1555
+ const json = node.exportJSON();
1556
+ const optionsStr = (json.options || []).map((opt) => `- [ ] ${opt.text} (${(opt.votes || []).length} votes)`).join("\n");
1557
+ return `### \u{1F4CA} Poll: ${json.question}
1558
+ ${optionsStr}`;
1559
+ } catch (e) {
1560
+ return null;
1561
+ }
1562
+ },
1563
+ regExp: /^###\s+📊\s+Poll:\s*(.*)$/,
1564
+ replace: () => {
1565
+ },
1566
+ type: "element"
1567
+ };
1568
+ var EXCALIDRAW_TRANSFORMER = {
1569
+ dependencies: [ExcalidrawNode],
1570
+ export: (node) => {
1571
+ if (!$isExcalidrawNode(node)) return null;
1572
+ return `\u{1F3A8} *[Excalidraw Diagram]*`;
1573
+ },
1574
+ regExp: /^🎨\s+\*\[Excalidraw Diagram\]\*$/,
1575
+ replace: () => {
1576
+ },
1577
+ type: "element"
1578
+ };
1579
+ var TABLE_TRANSFORMER = {
1580
+ dependencies: [TableNode, TableRowNode, TableCellNode],
1581
+ export: (node) => {
1582
+ if (!$isTableNode(node)) return null;
1583
+ const rows = node.getChildren();
1584
+ const mdLines = [];
1585
+ rows.forEach((row, rowIndex) => {
1586
+ if ($isTableRowNode(row)) {
1587
+ const cells = row.getChildren();
1588
+ const cellValues = cells.map((cell) => {
1589
+ return cell.getTextContent().replace(/\|/g, "\\|").trim() || " ";
1590
+ });
1591
+ mdLines.push(`| ${cellValues.join(" | ")} |`);
1592
+ if (rowIndex === 0) {
1593
+ const dividers = cells.map(() => "---");
1594
+ mdLines.push(`| ${dividers.join(" | ")} |`);
1595
+ }
1596
+ }
1597
+ });
1598
+ return mdLines.join("\n");
1599
+ },
1600
+ regExp: /^\|(.+)\|$/,
1601
+ replace: (parentNode, _1, match) => {
1602
+ const rawLine = match[1];
1603
+ const cells = rawLine.split("|").map((c) => c.trim());
1604
+ if (cells.every((c) => /^:?-{2,}:?$/.test(c))) {
1605
+ parentNode.remove();
1606
+ return;
1607
+ }
1608
+ const prev = parentNode.getPreviousSibling();
1609
+ const isHeaderRow = !$isTableNode(prev);
1610
+ const row = $createTableRowNode();
1611
+ for (const cellText of cells) {
1612
+ const cell = $createTableCellNode(
1613
+ isHeaderRow ? TableCellHeaderStates.ROW : TableCellHeaderStates.NO_STATUS
1614
+ );
1615
+ if (cellText) {
1616
+ $convertFromMarkdownString(
1617
+ cellText,
1618
+ [
1619
+ INLINE_EQUATION_TRANSFORMER,
1620
+ ...TEXT_FORMAT_TRANSFORMERS,
1621
+ ...TEXT_MATCH_TRANSFORMERS
1622
+ ],
1623
+ cell
1624
+ );
1625
+ } else {
1626
+ cell.append($createParagraphNode2());
1627
+ }
1628
+ row.append(cell);
1629
+ }
1630
+ if ($isTableNode(prev)) {
1631
+ prev.append(row);
1632
+ parentNode.remove();
1633
+ } else {
1634
+ const table = $createTableNode();
1635
+ table.append(row);
1636
+ parentNode.replace(table);
1637
+ }
1638
+ },
1639
+ type: "element"
1640
+ };
1641
+ var INLINE_EQUATION_TRANSFORMER = {
1642
+ dependencies: [EquationNode],
1643
+ export: (node) => {
1644
+ if (!$isEquationNode(node)) return null;
1645
+ return `$${node.getEquation()}$`;
1646
+ },
1647
+ importRegExp: new RegExp("(?<!\\$)\\$(?!\\s)([^$\\n]*?\\S)\\$"),
1648
+ regExp: new RegExp("(?<!\\$)\\$(?!\\s)([^$\\n]*?\\S)\\$$"),
1649
+ replace: (textNode, match) => {
1650
+ var _a;
1651
+ const equation = (_a = match[1]) == null ? void 0 : _a.trim();
1652
+ if (!equation) return;
1653
+ const eqNode = $createEquationNode(equation, true);
1654
+ textNode.replace(eqNode);
1655
+ },
1656
+ trigger: "$",
1657
+ type: "text-match"
1658
+ };
1659
+ var AUDIO_TRANSFORMER = {
1660
+ dependencies: [AudioNode],
1661
+ export: (node) => {
1662
+ if (!$isAudioNode(node)) return null;
1663
+ return `[\u{1F3B5} Audio: ${node.getTitle()}](${node.getSrc()})`;
1664
+ },
1665
+ regExp: /^\[🎵\s+Audio:\s*(.*?)\]\((https?:\/\/.*?)\)$/,
1666
+ replace: (parentNode, _1, match) => {
1667
+ const [, title, src] = match;
1668
+ const audioNode = $createAudioNode({
1669
+ src,
1670
+ title: title || "Audio Track"
1671
+ });
1672
+ parentNode.replace(audioNode);
1673
+ },
1674
+ type: "element"
1675
+ };
1676
+ var FILE_TRANSFORMER = {
1677
+ dependencies: [FileNode],
1678
+ export: (node) => {
1679
+ if (!$isFileNode(node)) return null;
1680
+ const sizeStr = node.getSize() ? ` (${node.getSize()})` : "";
1681
+ return `\u{1F4CE} [${node.getTitle()}${sizeStr}](${node.getUrl()})`;
1682
+ },
1683
+ regExp: /^📎\s+\[(.*?)(?:\s*\((.*?)\))?\]\((https?:\/\/.*?)\)$/,
1684
+ replace: (parentNode, _1, match) => {
1685
+ const [, title, size, url] = match;
1686
+ const fileNode = $createFileNode({
1687
+ url,
1688
+ title: title || "Attached File",
1689
+ size: size || void 0
1690
+ });
1691
+ parentNode.replace(fileNode);
1692
+ },
1693
+ type: "element"
1694
+ };
1695
+ var INLINE_IMAGE_TRANSFORMER = {
1696
+ dependencies: [InlineImageNode],
1697
+ export: (node) => {
1698
+ if (!$isInlineImageNode(node)) return null;
1699
+ const pos = node.getPosition();
1700
+ const prefix = pos ? `inline:${pos}:` : "inline:";
1701
+ return `![${prefix}${node.getAltText() || "Image"}](${node.getSrc()})`;
1702
+ },
1703
+ importRegExp: /!\[inline:(?:(left|right|full):)?([^\]]*?)\]\(((?:https?:\/\/|data:image\/)[^)\s]+)\)/,
1704
+ regExp: /!\[inline:(?:(left|right|full):)?([^\]]*?)\]\(((?:https?:\/\/|data:image\/)[^)\s]+)\)$/,
1705
+ replace: (textNode, match) => {
1706
+ const [, posRaw, altText, src] = match;
1707
+ if (!src) return;
1708
+ const position = posRaw === "left" || posRaw === "right" || posRaw === "full" ? posRaw : "left";
1709
+ const inlineImg = $createInlineImageNode({
1710
+ altText: (altText == null ? void 0 : altText.trim()) || "Inline Image",
1711
+ src,
1712
+ position,
1713
+ width: 280
1714
+ });
1715
+ textNode.replace(inlineImg);
1716
+ },
1717
+ trigger: ")",
1718
+ type: "text-match"
1719
+ };
1720
+ var EXCALIDRAW_BLOCK_TRANSFORMER = {
1721
+ dependencies: [ExcalidrawNode],
1722
+ export: (node) => {
1723
+ if (!$isExcalidrawNode(node)) return null;
1724
+ return `\`\`\`excalidraw
1725
+ ${node.__data || "[]"}
1726
+ \`\`\``;
1727
+ },
1728
+ regExpStart: /^```excalidraw\s*$/i,
1729
+ regExpEnd: /^```\s*$/,
1730
+ replace: (rootNode, _children, startMatch, _endMatch, linesInBetween, isImport) => {
1731
+ if (!startMatch || !linesInBetween) return;
1732
+ const rawJson = linesInBetween.join("\n").trim();
1733
+ const compiled = compileExcalidrawDiagram(rawJson);
1734
+ if (!compiled) return false;
1735
+ const excalidrawNode = $createExcalidrawNode(compiled);
1736
+ const paragraph = $createParagraphNode2();
1737
+ paragraph.append(excalidrawNode);
1738
+ if (isImport) {
1739
+ rootNode.append(paragraph);
1740
+ } else {
1741
+ rootNode.replace(paragraph);
1742
+ }
1743
+ },
1744
+ type: "multiline-element"
1745
+ };
1746
+ var NOTIQ_TRANSFORMERS = [
1747
+ EXCALIDRAW_BLOCK_TRANSFORMER,
1748
+ INLINE_IMAGE_TRANSFORMER,
1749
+ HR_TRANSFORMER,
1750
+ IMAGE_TRANSFORMER,
1751
+ YOUTUBE_TRANSFORMER,
1752
+ TWEET_TRANSFORMER,
1753
+ FIGMA_TRANSFORMER,
1754
+ EQUATION_TRANSFORMER,
1755
+ HINT_TRANSFORMER,
1756
+ STEPPER_TRANSFORMER,
1757
+ POLL_TRANSFORMER,
1758
+ EXCALIDRAW_TRANSFORMER,
1759
+ TABLE_TRANSFORMER,
1760
+ INLINE_EQUATION_TRANSFORMER,
1761
+ AUDIO_TRANSFORMER,
1762
+ FILE_TRANSFORMER,
1763
+ CHECK_LIST,
1764
+ ...TRANSFORMERS
1765
+ ];
1766
+
1767
+ export {
1768
+ InlineImageNode,
1769
+ $createInlineImageNode,
1770
+ $isInlineImageNode,
1771
+ YouTubeNode,
1772
+ $createYouTubeNode,
1773
+ TweetNode,
1774
+ $createTweetNode,
1775
+ FigmaNode,
1776
+ $createFigmaNode,
1777
+ CollapsibleContainerNode,
1778
+ $createCollapsibleContainerNode,
1779
+ $isCollapsibleContainerNode,
1780
+ CollapsibleContentNode,
1781
+ $createCollapsibleContentNode,
1782
+ $isCollapsibleContentNode,
1783
+ CollapsibleTitleNode,
1784
+ $createCollapsibleTitleNode,
1785
+ $isCollapsibleTitleNode,
1786
+ initialEditorState,
1787
+ safelySetEditorState,
1788
+ StepperNode,
1789
+ $isStepperNode,
1790
+ $createStepperNode,
1791
+ INSERT_STEPPER_COMMAND,
1792
+ StepperPlugin,
1793
+ NOTIQ_TRANSFORMERS
1794
+ };