@collabchron/notiq 0.3.0 → 1.0.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/LICENSE +21 -0
- package/README.md +230 -39
- package/dist/CodeActionMenuPlugin-EINOY4U4.mjs +15 -0
- package/dist/DynamicBlockComponent-NRQJ4WW4.mjs +161 -0
- package/dist/EquationComponent-CB6DFIHV.mjs +154 -0
- package/dist/ExcalidrawComponent-XW6646OH.mjs +528 -0
- package/dist/ExcalidrawPlugin-ZFHT62IF.mjs +14 -0
- package/dist/ExportPlugin-V2RLM63S.mjs +11 -0
- package/dist/FloatingLinkEditorPlugin-TRTCMSP4.mjs +12 -0
- package/dist/FloatingTextFormatToolbarPlugin-F2GY6LMI.mjs +30 -0
- package/dist/HintComponet-BRL6EAMS.mjs +217 -0
- package/dist/InlineImageComponent-UWIUWBHI.mjs +453 -0
- package/dist/MobileToolbar-BOOZAMQE.mjs +268 -0
- package/dist/SlashCommand-GMT5JI33.mjs +28 -0
- package/dist/StoryBuilderComponent-JGDBM5JU.mjs +562 -0
- package/{src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx → dist/TableCellActionMenuPlugin-PGK2K3VG.mjs} +667 -759
- package/{src/components/editor/plugins/TableHoverActionsPlugin/index.tsx → dist/TableHoverActionsPlugin-GJVE6VRW.mjs} +258 -314
- package/dist/TemplatePlugin-ZD3QEVTI.mjs +9 -0
- package/dist/ToolbarPlugin-7TOZRD2R.mjs +1547 -0
- package/dist/babel-JZ2EV6AX.mjs +7233 -0
- package/dist/background-color-XZTYLGO2.mjs +362 -0
- package/dist/block-format-YJCV2DIY.mjs +15 -0
- package/dist/chunk-2FNEAMSP.mjs +127 -0
- package/dist/chunk-3CPBODXA.mjs +84 -0
- package/dist/chunk-3G37YKTV.mjs +83 -0
- package/dist/chunk-3JVFG7ER.mjs +184 -0
- package/dist/chunk-456TN7IM.mjs +110 -0
- package/dist/chunk-4EXYCTGJ.mjs +27 -0
- package/{src/utils/getSelectedNode.ts → dist/chunk-4HBCVSE6.mjs} +26 -27
- package/dist/chunk-4MEDW3T6.mjs +125 -0
- package/dist/chunk-4VWFVWYP.mjs +36 -0
- package/dist/chunk-5BAKY5KN.mjs +84 -0
- package/dist/chunk-5QSNIVIG.mjs +333 -0
- package/dist/chunk-64Z3FI7T.mjs +37 -0
- package/{src/components/editor/nodes/Stepper/index.tsx → dist/chunk-6RNZQOH2.mjs} +214 -260
- package/dist/chunk-77KXU36M.mjs +64 -0
- package/dist/chunk-77UA6HYR.mjs +165 -0
- package/dist/chunk-7NZAPJ4G.mjs +102 -0
- package/dist/chunk-7VUMHWWL.mjs +152 -0
- package/dist/chunk-AMMKBSST.mjs +1256 -0
- package/dist/chunk-BIU7WTLX.mjs +95 -0
- package/dist/chunk-EGMI62PP.mjs +83 -0
- package/dist/chunk-EHNQD5KO.mjs +88 -0
- package/dist/chunk-FSM26655.mjs +37 -0
- package/{src/components/editor/nodes/Hint/index.tsx → dist/chunk-G53GLEAY.mjs} +158 -190
- package/dist/chunk-GK35L7UY.mjs +28 -0
- package/dist/chunk-GXYD4VZM.mjs +193 -0
- package/dist/chunk-GYIOYVCN.mjs +538 -0
- package/dist/chunk-GZPNVR7L.mjs +157 -0
- package/dist/chunk-JXDPPUJI.mjs +52 -0
- package/dist/chunk-K36V4SIW.mjs +141 -0
- package/dist/chunk-KJ6AJ44Q.mjs +128 -0
- package/dist/chunk-KJV3FAZ7.mjs +142 -0
- package/{src/components/editor/plugins/ImagesPlugin/index.tsx → dist/chunk-LGG4IUIA.mjs} +189 -222
- package/dist/chunk-LQN3CMKV.mjs +1906 -0
- package/dist/chunk-N3WN46VL.mjs +236 -0
- package/dist/chunk-PBD6LMLC.mjs +366 -0
- package/dist/chunk-POGRR73N.mjs +33 -0
- package/{src/components/editor/utils/editorFormatting.ts → dist/chunk-PZSUSXQG.mjs} +238 -282
- package/dist/chunk-QEIFVK5M.mjs +29 -0
- package/dist/chunk-QHIQKMVN.mjs +427 -0
- package/dist/chunk-TCYK7DM7.mjs +36 -0
- package/dist/chunk-TTHQCW5F.mjs +47 -0
- package/dist/chunk-U47ABU5Z.mjs +53 -0
- package/dist/chunk-WDG7J2DY.mjs +116 -0
- package/dist/chunk-WJRHXI2C.mjs +733 -0
- package/dist/chunk-XLER2DHM.mjs +357 -0
- package/dist/chunk-XWC4TK2N.mjs +315 -0
- package/dist/chunk-YHPNOWFH.mjs +15 -0
- package/dist/chunk-YKC3SO4Z.mjs +32 -0
- package/dist/chunk-YMBXLRW5.mjs +374 -0
- package/dist/chunk-YPHOEJ46.mjs +64 -0
- package/dist/chunk-YUDCJRJM.mjs +25 -0
- package/dist/chunk-Z4EWP7BI.mjs +65 -0
- package/dist/chunk-ZB5LZQKC.mjs +191 -0
- package/dist/chunk-ZJRKATOJ.mjs +65 -0
- package/dist/color-BPKOPQKN.mjs +12 -0
- package/dist/estree-XC56IUFX.mjs +4414 -0
- package/dist/font-FEZ3GKSF.mjs +13 -0
- package/dist/font-size-EK775WRH.mjs +15 -0
- package/dist/html-S3ACX7NI.mjs +2738 -0
- package/dist/image-2PJIAYAT.mjs +993 -0
- package/dist/index.d.mts +145 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.js +57855 -0
- package/dist/index.mjs +1790 -0
- package/dist/insert-gif-SAIDYURE.mjs +100 -0
- package/dist/insert-image-U3RJN3OW.mjs +259 -0
- package/dist/insert-node-5P2CRJ7S.mjs +201 -0
- package/dist/insert-poll-HCPM7MO6.mjs +33 -0
- package/dist/insert-table-24XYUS2W.mjs +66 -0
- package/dist/markdown-SNVBOSRA.mjs +3487 -0
- package/dist/poll-component-2R4MDLHS.mjs +303 -0
- package/dist/postcss-ONF3VDIM.mjs +5051 -0
- package/dist/standalone-EOIALU3M.mjs +2373 -0
- package/dist/stepper-FSARL6X6.mjs +304 -0
- package/dist/styles/notiq.css +1149 -0
- package/dist/text-align-VLECWO4H.mjs +118 -0
- package/dist/text-format-BG5WOOPZ.mjs +16 -0
- package/dist/typescript-AMPI6OVS.mjs +13135 -0
- package/package.json +66 -11
- package/src/styles/notiq.css +1149 -0
- package/src/styles/tailwind-plugin.ts +134 -0
- package/components.json +0 -21
- package/eslint.config.mjs +0 -16
- package/next.config.ts +0 -12
- package/postcss.config.mjs +0 -5
- package/public/file.svg +0 -1
- package/public/globe.svg +0 -1
- package/public/images/icons/plus.svg +0 -10
- package/public/next.svg +0 -1
- package/public/vercel.svg +0 -1
- package/public/window.svg +0 -1
- package/src/app/actions.ts +0 -2
- package/src/app/api/ai/route.ts +0 -175
- package/src/app/api/edgestore/[...edgestore]/route.ts +0 -28
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +0 -205
- package/src/app/layout.tsx +0 -38
- package/src/app/page.tsx +0 -12
- package/src/components/editor/Core.tsx +0 -220
- package/src/components/editor/hooks/instructions-messages.ts +0 -300
- package/src/components/editor/hooks/use-mobile.ts +0 -19
- package/src/components/editor/hooks/useReport.ts +0 -67
- package/src/components/editor/hooks/useResizeObservert.ts +0 -22
- package/src/components/editor/index.tsx +0 -39
- package/src/components/editor/lexical-on-change.tsx +0 -28
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts +0 -92
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts +0 -65
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts +0 -105
- package/src/components/editor/nodes/EquationNode/EquationComponent.tsx +0 -143
- package/src/components/editor/nodes/EquationNode/EquationNode.tsx +0 -170
- package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawComponent.tsx +0 -228
- package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawImage.tsx +0 -137
- package/src/components/editor/nodes/ExcalidrawNode/ImageResizer.tsx +0 -317
- package/src/components/editor/nodes/ExcalidrawNode/index.tsx +0 -204
- package/src/components/editor/nodes/FigmaNode/FigmaNode.tsx +0 -134
- package/src/components/editor/nodes/Hint/HintComponet.tsx +0 -221
- package/src/components/editor/nodes/ImageNode/index.tsx +0 -328
- package/src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx +0 -383
- package/src/components/editor/nodes/InlineImageNode/InlineImageNode.css +0 -94
- package/src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx +0 -309
- package/src/components/editor/nodes/LayoutNode/LayoutContainerNode.ts +0 -146
- package/src/components/editor/nodes/LayoutNode/LayoutItemNode.ts +0 -79
- package/src/components/editor/nodes/PollNode/index.tsx +0 -204
- package/src/components/editor/nodes/TweetNode/index.tsx +0 -214
- package/src/components/editor/nodes/index.ts +0 -81
- package/src/components/editor/plugins/AutoEmbedPlugin/index.tsx +0 -350
- package/src/components/editor/plugins/AutoLinkPlugin/index.tsx +0 -56
- package/src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx +0 -70
- package/src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx +0 -192
- package/src/components/editor/plugins/CodeActionMenuPlugin/index.tsx +0 -217
- package/src/components/editor/plugins/CodeActionMenuPlugin/utils.ts +0 -26
- package/src/components/editor/plugins/CodeHighlightPlugin/index.ts +0 -21
- package/src/components/editor/plugins/CollapsiblePlugin/Collapsible.css +0 -76
- package/src/components/editor/plugins/CollapsiblePlugin/index.ts +0 -228
- package/src/components/editor/plugins/DragDropPastePlugin/index.tsx +0 -44
- package/src/components/editor/plugins/DraggableBlockPlugin/index.tsx +0 -52
- package/src/components/editor/plugins/EquationsPlugin/index.tsx +0 -85
- package/src/components/editor/plugins/ExcalidrawPlugin/index.tsx +0 -98
- package/src/components/editor/plugins/FigmaPlugin/index.tsx +0 -42
- package/src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx +0 -445
- package/src/components/editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +0 -275
- package/src/components/editor/plugins/InlineImagePlugin/index.tsx +0 -351
- package/src/components/editor/plugins/LayoutPlugin/index.tsx +0 -238
- package/src/components/editor/plugins/LinkPlugin/index.tsx +0 -36
- package/src/components/editor/plugins/LinkWithMetaData/index.tsx +0 -271
- package/src/components/editor/plugins/MarkdownShortcutPlugin/index.tsx +0 -11
- package/src/components/editor/plugins/MarkdownTransformers/index.tsx +0 -304
- package/src/components/editor/plugins/PollPlugin/index.tsx +0 -49
- package/src/components/editor/plugins/ShortcutsPlugin/index.tsx +0 -180
- package/src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts +0 -253
- package/src/components/editor/plugins/SlashCommand/index.tsx +0 -621
- package/src/components/editor/plugins/SpeechToTextPlugin/index.ts +0 -127
- package/src/components/editor/plugins/TabFocusPlugin/index.ts +0 -58
- package/src/components/editor/plugins/TableCellResizer/index.tsx +0 -438
- package/src/components/editor/plugins/TablePlugin/index.tsx +0 -99
- package/src/components/editor/plugins/ToolbarPlugin/index.tsx +0 -522
- package/src/components/editor/plugins/TwitterPlugin/index.ts +0 -35
- package/src/components/editor/plugins/YouTubeNode/index.tsx +0 -179
- package/src/components/editor/plugins/YouTubePlugin/index.ts +0 -41
- package/src/components/editor/themes/editor-theme.ts +0 -113
- package/src/components/editor/themes/theme.css +0 -377
- package/src/components/editor/utils/ai.ts +0 -291
- package/src/components/editor/utils/canUseDOM.ts +0 -12
- package/src/components/editor/utils/environment.ts +0 -50
- package/src/components/editor/utils/extract-data.ts +0 -166
- package/src/components/editor/utils/getAllLexicalChildren.ts +0 -13
- package/src/components/editor/utils/getDOMRangeRect.ts +0 -27
- package/src/components/editor/utils/getSelectedNode.ts +0 -27
- package/src/components/editor/utils/gif.ts +0 -29
- package/src/components/editor/utils/invariant.ts +0 -15
- package/src/components/editor/utils/setFloatingElemPosition.ts +0 -51
- package/src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts +0 -40
- package/src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts +0 -51
- package/src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts +0 -15
- package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts +0 -114
- package/src/components/editor/utils/setNodePlaceholderFromSelection/styles.css +0 -6
- package/src/components/editor/utils/url.ts +0 -109
- package/src/components/editor/utils/useLayoutEffect.ts +0 -13
- package/src/components/providers/QueryProvider.tsx +0 -15
- package/src/components/providers/SharedHistoryContext.tsx +0 -28
- package/src/components/providers/ToolbarContext.tsx +0 -123
- package/src/components/providers/theme-provider.tsx +0 -11
- package/src/components/theme/ModeToggle.tsx +0 -40
- package/src/components/ui/FileInput.tsx +0 -40
- package/src/components/ui/Input.css +0 -32
- package/src/components/ui/Select.css +0 -42
- package/src/components/ui/Select.tsx +0 -36
- package/src/components/ui/TextInput.tsx +0 -48
- package/src/components/ui/ai/ai-button.tsx +0 -574
- package/src/components/ui/ai/border.tsx +0 -99
- package/src/components/ui/ai/placeholder-input-vanish.tsx +0 -282
- package/src/components/ui/button.tsx +0 -89
- package/src/components/ui/card.tsx +0 -76
- package/src/components/ui/checkbox.tsx +0 -30
- package/src/components/ui/command.tsx +0 -153
- package/src/components/ui/dialog/Dialog.css +0 -25
- package/src/components/ui/dialog/Dialog.tsx +0 -34
- package/src/components/ui/dialog.tsx +0 -122
- package/src/components/ui/drop-downs/background-color.tsx +0 -183
- package/src/components/ui/drop-downs/block-format.tsx +0 -159
- package/src/components/ui/drop-downs/code.tsx +0 -42
- package/src/components/ui/drop-downs/color.tsx +0 -177
- package/src/components/ui/drop-downs/font-size.tsx +0 -138
- package/src/components/ui/drop-downs/font.tsx +0 -155
- package/src/components/ui/drop-downs/index.tsx +0 -122
- package/src/components/ui/drop-downs/insert-node.tsx +0 -213
- package/src/components/ui/drop-downs/text-align.tsx +0 -123
- package/src/components/ui/drop-downs/text-format.tsx +0 -104
- package/src/components/ui/dropdown-menu.tsx +0 -201
- package/src/components/ui/equation/EquationEditor.css +0 -38
- package/src/components/ui/equation/EquationEditor.tsx +0 -56
- package/src/components/ui/equation/KatexEquationAlterer.css +0 -41
- package/src/components/ui/equation/KatexEquationAlterer.tsx +0 -83
- package/src/components/ui/equation/KatexRenderer.tsx +0 -66
- package/src/components/ui/excalidraw/ExcalidrawModal.css +0 -64
- package/src/components/ui/excalidraw/ExcalidrawModal.tsx +0 -234
- package/src/components/ui/excalidraw/Modal.css +0 -62
- package/src/components/ui/excalidraw/Modal.tsx +0 -110
- package/src/components/ui/hover-card.tsx +0 -29
- package/src/components/ui/image/error-image.tsx +0 -17
- package/src/components/ui/image/file-upload.tsx +0 -240
- package/src/components/ui/image/image-resizer.tsx +0 -297
- package/src/components/ui/image/image-toolbar.tsx +0 -264
- package/src/components/ui/image/index.tsx +0 -408
- package/src/components/ui/image/lazy-image.tsx +0 -68
- package/src/components/ui/image/lazy-video.tsx +0 -71
- package/src/components/ui/input.tsx +0 -22
- package/src/components/ui/models/custom-dialog.tsx +0 -320
- package/src/components/ui/models/insert-gif.tsx +0 -90
- package/src/components/ui/models/insert-image.tsx +0 -52
- package/src/components/ui/models/insert-poll.tsx +0 -29
- package/src/components/ui/models/insert-table.tsx +0 -62
- package/src/components/ui/models/use-model.tsx +0 -91
- package/src/components/ui/poll/poll-component.tsx +0 -304
- package/src/components/ui/popover.tsx +0 -33
- package/src/components/ui/progress.tsx +0 -28
- package/src/components/ui/scroll-area.tsx +0 -48
- package/src/components/ui/separator.tsx +0 -31
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/sonner.tsx +0 -31
- package/src/components/ui/stepper/step.tsx +0 -179
- package/src/components/ui/stepper/stepper.tsx +0 -89
- package/src/components/ui/textarea.tsx +0 -22
- package/src/components/ui/toggle.tsx +0 -71
- package/src/components/ui/tooltip.tsx +0 -32
- package/src/components/ui/write/text-format-floting-toolbar.tsx +0 -346
- package/src/lib/edgestore.ts +0 -9
- package/src/lib/pinecone-client.ts +0 -0
- package/src/lib/utils.ts +0 -6
- package/src/utils/docSerialization.ts +0 -77
- package/src/utils/emoji-list.ts +0 -16615
- package/src/utils/getDOMRangeRect.ts +0 -27
- package/src/utils/getThemeSelector.ts +0 -25
- package/src/utils/isMobileWidth.ts +0 -7
- package/src/utils/joinClasses.ts +0 -13
- package/src/utils/setFloatingElemPosition.ts +0 -74
- package/src/utils/setFloatingElemPositionForLinkEditor.ts +0 -46
- package/src/utils/swipe.ts +0 -127
- package/src/utils/url.ts +0 -38
- package/tsconfig.json +0 -27
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
2
|
-
import useLayoutEffectImpl from "./utils/useLayoutEffect";
|
|
3
|
-
import { setNodePlaceholderFromSelection } from "./utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection";
|
|
4
|
-
|
|
5
|
-
export function LexicalOnChangePlugin() {
|
|
6
|
-
const [editor] = useLexicalComposerContext();
|
|
7
|
-
|
|
8
|
-
useLayoutEffectImpl(() => {
|
|
9
|
-
const unregisterListener = editor.registerUpdateListener(
|
|
10
|
-
({ editorState, dirtyElements, dirtyLeaves, prevEditorState, tags }) => {
|
|
11
|
-
if (
|
|
12
|
-
(dirtyElements.size === 0 && dirtyLeaves.size === 0) ||
|
|
13
|
-
tags.has("history-merge") ||
|
|
14
|
-
prevEditorState.isEmpty()
|
|
15
|
-
) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
setNodePlaceholderFromSelection(editor);
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
return () => {
|
|
24
|
-
unregisterListener();
|
|
25
|
-
};
|
|
26
|
-
}, [editor]);
|
|
27
|
-
return <></>
|
|
28
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DOMConversionMap,
|
|
3
|
-
ElementNode,
|
|
4
|
-
LexicalNode,
|
|
5
|
-
NodeKey,
|
|
6
|
-
SerializedElementNode,
|
|
7
|
-
Spread
|
|
8
|
-
} from "lexical";
|
|
9
|
-
|
|
10
|
-
type SerializedCollapsibleContainerNode = Spread<
|
|
11
|
-
{
|
|
12
|
-
type: "collapsible-container";
|
|
13
|
-
version: 1;
|
|
14
|
-
},
|
|
15
|
-
SerializedElementNode
|
|
16
|
-
>;
|
|
17
|
-
|
|
18
|
-
export class CollapsibleContainerNode extends ElementNode {
|
|
19
|
-
__open: boolean;
|
|
20
|
-
|
|
21
|
-
constructor(open: boolean, key?: NodeKey) {
|
|
22
|
-
super(key);
|
|
23
|
-
this.__open = open;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static getType(): string {
|
|
27
|
-
return "collapsible-container";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static clone(node: CollapsibleContainerNode): CollapsibleContainerNode {
|
|
31
|
-
return new CollapsibleContainerNode(node.__open, node.__key);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
createDOM(): HTMLElement {
|
|
35
|
-
const dom = document.createElement("details");
|
|
36
|
-
dom.classList.add("Collapsible__container");
|
|
37
|
-
dom.open = this.__open;
|
|
38
|
-
return dom;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
updateDOM(
|
|
42
|
-
prevNode: CollapsibleContainerNode,
|
|
43
|
-
dom: HTMLDetailsElement
|
|
44
|
-
): boolean {
|
|
45
|
-
if (prevNode.__open !== this.__open) {
|
|
46
|
-
dom.open = this.__open;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static importDOM(): DOMConversionMap | null {
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
static importJSON(
|
|
57
|
-
): CollapsibleContainerNode {
|
|
58
|
-
const node = $createCollapsibleContainerNode();
|
|
59
|
-
return node;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
exportJSON(): SerializedCollapsibleContainerNode {
|
|
63
|
-
return {
|
|
64
|
-
...super.exportJSON(),
|
|
65
|
-
type: "collapsible-container",
|
|
66
|
-
version: 1
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
setOpen(open: boolean): void {
|
|
71
|
-
const writable = this.getWritable();
|
|
72
|
-
writable.__open = open;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
getOpen(): boolean {
|
|
76
|
-
return this.__open;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
toggleOpen(): void {
|
|
80
|
-
this.setOpen(!this.getOpen());
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function $createCollapsibleContainerNode(): CollapsibleContainerNode {
|
|
85
|
-
return new CollapsibleContainerNode(true);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function $isCollapsibleContainerNode(
|
|
89
|
-
node: LexicalNode | null | undefined
|
|
90
|
-
): node is CollapsibleContainerNode {
|
|
91
|
-
return node instanceof CollapsibleContainerNode;
|
|
92
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DOMConversionMap,
|
|
3
|
-
ElementNode,
|
|
4
|
-
LexicalNode,
|
|
5
|
-
SerializedElementNode,
|
|
6
|
-
Spread
|
|
7
|
-
} from "lexical";
|
|
8
|
-
|
|
9
|
-
type SerializedCollapsibleContentNode = Spread<
|
|
10
|
-
{
|
|
11
|
-
type: "collapsible-content";
|
|
12
|
-
version: 1;
|
|
13
|
-
},
|
|
14
|
-
SerializedElementNode
|
|
15
|
-
>;
|
|
16
|
-
|
|
17
|
-
export class CollapsibleContentNode extends ElementNode {
|
|
18
|
-
static getType(): string {
|
|
19
|
-
return "collapsible-content";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static clone(node: CollapsibleContentNode): CollapsibleContentNode {
|
|
23
|
-
return new CollapsibleContentNode(node.__key);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
createDOM(): HTMLElement {
|
|
27
|
-
const dom = document.createElement("div");
|
|
28
|
-
dom.classList.add("Collapsible__content");
|
|
29
|
-
return dom;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
updateDOM(): boolean {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static importDOM(): DOMConversionMap | null {
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static importJSON( ): CollapsibleContentNode {
|
|
41
|
-
return $createCollapsibleContentNode();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
isShadowRoot(): boolean {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
exportJSON(): SerializedCollapsibleContentNode {
|
|
49
|
-
return {
|
|
50
|
-
...super.exportJSON(),
|
|
51
|
-
type: "collapsible-content",
|
|
52
|
-
version: 1
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function $createCollapsibleContentNode(): CollapsibleContentNode {
|
|
58
|
-
return new CollapsibleContentNode();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function $isCollapsibleContentNode(
|
|
62
|
-
node: LexicalNode | null | undefined
|
|
63
|
-
): node is CollapsibleContentNode {
|
|
64
|
-
return node instanceof CollapsibleContentNode;
|
|
65
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
$createParagraphNode,
|
|
3
|
-
$isElementNode,
|
|
4
|
-
DOMConversionMap,
|
|
5
|
-
ElementNode,
|
|
6
|
-
LexicalNode,
|
|
7
|
-
RangeSelection,
|
|
8
|
-
SerializedElementNode,
|
|
9
|
-
Spread
|
|
10
|
-
} from "lexical";
|
|
11
|
-
|
|
12
|
-
import { $isCollapsibleContainerNode } from "./CollapsibleContainerNode";
|
|
13
|
-
import { $isCollapsibleContentNode } from "./CollapsibleContentNode";
|
|
14
|
-
|
|
15
|
-
type SerializedCollapsibleTitleNode = Spread<
|
|
16
|
-
{
|
|
17
|
-
type: "collapsible-title";
|
|
18
|
-
version: 1;
|
|
19
|
-
},
|
|
20
|
-
SerializedElementNode
|
|
21
|
-
>;
|
|
22
|
-
|
|
23
|
-
export class CollapsibleTitleNode extends ElementNode {
|
|
24
|
-
static getType(): string {
|
|
25
|
-
return "collapsible-title";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static clone(node: CollapsibleTitleNode): CollapsibleTitleNode {
|
|
29
|
-
return new CollapsibleTitleNode(node.__key);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
createDOM(): HTMLElement {
|
|
33
|
-
const dom = document.createElement("summary");
|
|
34
|
-
dom.classList.add("Collapsible__title");
|
|
35
|
-
return dom;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
updateDOM(): boolean {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static importDOM(): DOMConversionMap | null {
|
|
43
|
-
return {};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static importJSON(
|
|
47
|
-
): CollapsibleTitleNode {
|
|
48
|
-
return $createCollapsibleTitleNode();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
exportJSON(): SerializedCollapsibleTitleNode {
|
|
52
|
-
return {
|
|
53
|
-
...super.exportJSON(),
|
|
54
|
-
type: "collapsible-title",
|
|
55
|
-
version: 1
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
collapseAtStart(_selection: RangeSelection): boolean {
|
|
60
|
-
this.getParentOrThrow().insertBefore(this);
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
insertNewAfter(): ElementNode {
|
|
65
|
-
const containerNode = this.getParentOrThrow();
|
|
66
|
-
|
|
67
|
-
if (!$isCollapsibleContainerNode(containerNode)) {
|
|
68
|
-
throw new Error(
|
|
69
|
-
"CollapsibleTitleNode expects to be child of CollapsibleContainerNode"
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (containerNode.getOpen()) {
|
|
74
|
-
const contentNode = this.getNextSibling();
|
|
75
|
-
if (!$isCollapsibleContentNode(contentNode)) {
|
|
76
|
-
throw new Error(
|
|
77
|
-
"CollapsibleTitleNode expects to have CollapsibleContentNode sibling"
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const firstChild = contentNode.getFirstChild();
|
|
82
|
-
if ($isElementNode(firstChild)) {
|
|
83
|
-
return firstChild;
|
|
84
|
-
} else {
|
|
85
|
-
const paragraph = $createParagraphNode();
|
|
86
|
-
contentNode.append(paragraph);
|
|
87
|
-
return paragraph;
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
const paragraph = $createParagraphNode();
|
|
91
|
-
containerNode.insertAfter(paragraph);
|
|
92
|
-
return paragraph;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function $createCollapsibleTitleNode(): CollapsibleTitleNode {
|
|
98
|
-
return new CollapsibleTitleNode();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function $isCollapsibleTitleNode(
|
|
102
|
-
node: LexicalNode | null | undefined
|
|
103
|
-
): node is CollapsibleTitleNode {
|
|
104
|
-
return node instanceof CollapsibleTitleNode;
|
|
105
|
-
}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type {JSX} from 'react';
|
|
10
|
-
|
|
11
|
-
import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
|
|
12
|
-
import {useLexicalEditable} from '@lexical/react/useLexicalEditable';
|
|
13
|
-
import {mergeRegister} from '@lexical/utils';
|
|
14
|
-
import {
|
|
15
|
-
$getNodeByKey,
|
|
16
|
-
$getSelection,
|
|
17
|
-
$isNodeSelection,
|
|
18
|
-
COMMAND_PRIORITY_HIGH,
|
|
19
|
-
KEY_ESCAPE_COMMAND,
|
|
20
|
-
NodeKey,
|
|
21
|
-
SELECTION_CHANGE_COMMAND,
|
|
22
|
-
} from 'lexical';
|
|
23
|
-
import * as React from 'react';
|
|
24
|
-
import {useCallback, useEffect, useRef, useState} from 'react';
|
|
25
|
-
import {ErrorBoundary} from 'react-error-boundary';
|
|
26
|
-
import { $isEquationNode } from './EquationNode';
|
|
27
|
-
import KatexRenderer from '@/components/ui/equation/KatexRenderer';
|
|
28
|
-
import EquationEditor from '@/components/ui/equation/EquationEditor';
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
type EquationComponentProps = {
|
|
32
|
-
equation: string;
|
|
33
|
-
inline: boolean;
|
|
34
|
-
nodeKey: NodeKey;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default function EquationComponent({
|
|
38
|
-
equation,
|
|
39
|
-
inline,
|
|
40
|
-
nodeKey,
|
|
41
|
-
}: EquationComponentProps): JSX.Element {
|
|
42
|
-
const [editor] = useLexicalComposerContext();
|
|
43
|
-
const isEditable = useLexicalEditable();
|
|
44
|
-
const [equationValue, setEquationValue] = useState(equation);
|
|
45
|
-
const [showEquationEditor, setShowEquationEditor] = useState<boolean>(false);
|
|
46
|
-
const inputRef = useRef<HTMLTextAreaElement | HTMLInputElement>(null);
|
|
47
|
-
|
|
48
|
-
const onHide = useCallback(
|
|
49
|
-
(restoreSelection?: boolean) => {
|
|
50
|
-
setShowEquationEditor(false);
|
|
51
|
-
editor.update(() => {
|
|
52
|
-
const node = $getNodeByKey(nodeKey);
|
|
53
|
-
if ($isEquationNode(node)) {
|
|
54
|
-
node.setEquation(equationValue);
|
|
55
|
-
if (restoreSelection) {
|
|
56
|
-
node.selectNext(0, 0);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
[editor, equationValue, nodeKey],
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (!showEquationEditor && equationValue !== equation) {
|
|
66
|
-
setEquationValue(equation);
|
|
67
|
-
}
|
|
68
|
-
}, [showEquationEditor, equation, equationValue]);
|
|
69
|
-
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (!isEditable) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (showEquationEditor) {
|
|
75
|
-
return mergeRegister(
|
|
76
|
-
editor.registerCommand(
|
|
77
|
-
SELECTION_CHANGE_COMMAND,
|
|
78
|
-
(payload) => {
|
|
79
|
-
const activeElement = document.activeElement;
|
|
80
|
-
const inputElem = inputRef.current;
|
|
81
|
-
if (inputElem !== activeElement) {
|
|
82
|
-
onHide();
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
},
|
|
86
|
-
COMMAND_PRIORITY_HIGH,
|
|
87
|
-
),
|
|
88
|
-
editor.registerCommand(
|
|
89
|
-
KEY_ESCAPE_COMMAND,
|
|
90
|
-
(payload) => {
|
|
91
|
-
const activeElement = document.activeElement;
|
|
92
|
-
const inputElem = inputRef.current;
|
|
93
|
-
if (inputElem === activeElement) {
|
|
94
|
-
onHide(true);
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
return false;
|
|
98
|
-
},
|
|
99
|
-
COMMAND_PRIORITY_HIGH,
|
|
100
|
-
),
|
|
101
|
-
);
|
|
102
|
-
} else {
|
|
103
|
-
return editor.registerUpdateListener(({editorState}) => {
|
|
104
|
-
const isSelected = editorState.read(() => {
|
|
105
|
-
const selection = $getSelection();
|
|
106
|
-
return (
|
|
107
|
-
$isNodeSelection(selection) &&
|
|
108
|
-
selection.has(nodeKey) &&
|
|
109
|
-
selection.getNodes().length === 1
|
|
110
|
-
);
|
|
111
|
-
});
|
|
112
|
-
if (isSelected) {
|
|
113
|
-
setShowEquationEditor(true);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}, [editor, nodeKey, onHide, showEquationEditor, isEditable]);
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<>
|
|
121
|
-
{showEquationEditor && isEditable ? (
|
|
122
|
-
<EquationEditor
|
|
123
|
-
equation={equationValue}
|
|
124
|
-
setEquation={setEquationValue}
|
|
125
|
-
inline={inline}
|
|
126
|
-
ref={inputRef}
|
|
127
|
-
/>
|
|
128
|
-
) : (
|
|
129
|
-
<ErrorBoundary onError={(e) => editor._onError(e)} fallback={null}>
|
|
130
|
-
<KatexRenderer
|
|
131
|
-
equation={equationValue}
|
|
132
|
-
inline={inline}
|
|
133
|
-
onDoubleClick={() => {
|
|
134
|
-
if (isEditable) {
|
|
135
|
-
setShowEquationEditor(true);
|
|
136
|
-
}
|
|
137
|
-
}}
|
|
138
|
-
/>
|
|
139
|
-
</ErrorBoundary>
|
|
140
|
-
)}
|
|
141
|
-
</>
|
|
142
|
-
);
|
|
143
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
DOMConversionMap,
|
|
11
|
-
DOMConversionOutput,
|
|
12
|
-
EditorConfig,
|
|
13
|
-
LexicalNode,
|
|
14
|
-
NodeKey,
|
|
15
|
-
SerializedLexicalNode,
|
|
16
|
-
Spread,
|
|
17
|
-
} from 'lexical';
|
|
18
|
-
import type {JSX} from 'react';
|
|
19
|
-
|
|
20
|
-
import katex from 'katex';
|
|
21
|
-
import {$applyNodeReplacement, DecoratorNode, DOMExportOutput} from 'lexical';
|
|
22
|
-
import * as React from 'react';
|
|
23
|
-
|
|
24
|
-
const EquationComponent = React.lazy(() => import('./EquationComponent'));
|
|
25
|
-
|
|
26
|
-
export type SerializedEquationNode = Spread<
|
|
27
|
-
{
|
|
28
|
-
equation: string;
|
|
29
|
-
inline: boolean;
|
|
30
|
-
},
|
|
31
|
-
SerializedLexicalNode
|
|
32
|
-
>;
|
|
33
|
-
|
|
34
|
-
function $convertEquationElement(
|
|
35
|
-
domNode: HTMLElement,
|
|
36
|
-
): null | DOMConversionOutput {
|
|
37
|
-
let equation = domNode.getAttribute('data-lexical-equation');
|
|
38
|
-
const inline = domNode.getAttribute('data-lexical-inline') === 'true';
|
|
39
|
-
// Decode the equation from base64
|
|
40
|
-
equation = atob(equation || '');
|
|
41
|
-
if (equation) {
|
|
42
|
-
const node = $createEquationNode(equation, inline);
|
|
43
|
-
return {node};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export class EquationNode extends DecoratorNode<JSX.Element> {
|
|
50
|
-
__equation: string;
|
|
51
|
-
__inline: boolean;
|
|
52
|
-
|
|
53
|
-
static getType(): string {
|
|
54
|
-
return 'equation';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static clone(node: EquationNode): EquationNode {
|
|
58
|
-
return new EquationNode(node.__equation, node.__inline, node.__key);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
constructor(equation: string, inline?: boolean, key?: NodeKey) {
|
|
62
|
-
super(key);
|
|
63
|
-
this.__equation = equation;
|
|
64
|
-
this.__inline = inline ?? false;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static importJSON(serializedNode: SerializedEquationNode): EquationNode {
|
|
68
|
-
return $createEquationNode(
|
|
69
|
-
serializedNode.equation,
|
|
70
|
-
serializedNode.inline,
|
|
71
|
-
).updateFromJSON(serializedNode);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
exportJSON(): SerializedEquationNode {
|
|
75
|
-
return {
|
|
76
|
-
...super.exportJSON(),
|
|
77
|
-
equation: this.getEquation(),
|
|
78
|
-
inline: this.__inline,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
createDOM(_config: EditorConfig): HTMLElement {
|
|
83
|
-
const element = document.createElement(this.__inline ? 'span' : 'div');
|
|
84
|
-
// EquationNodes should implement `user-action:none` in their CSS to avoid issues with deletion on Android.
|
|
85
|
-
element.className = 'editor-equation';
|
|
86
|
-
return element;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
exportDOM(): DOMExportOutput {
|
|
90
|
-
const element = document.createElement(this.__inline ? 'span' : 'div');
|
|
91
|
-
// Encode the equation as base64 to avoid issues with special characters
|
|
92
|
-
const equation = btoa(this.__equation);
|
|
93
|
-
element.setAttribute('data-lexical-equation', equation);
|
|
94
|
-
element.setAttribute('data-lexical-inline', `${this.__inline}`);
|
|
95
|
-
katex.render(this.__equation, element, {
|
|
96
|
-
displayMode: !this.__inline, // true === block display //
|
|
97
|
-
errorColor: '#cc0000',
|
|
98
|
-
output: 'html',
|
|
99
|
-
strict: 'warn',
|
|
100
|
-
throwOnError: false,
|
|
101
|
-
trust: false,
|
|
102
|
-
});
|
|
103
|
-
return {element};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
static importDOM(): DOMConversionMap | null {
|
|
107
|
-
return {
|
|
108
|
-
div: (domNode: HTMLElement) => {
|
|
109
|
-
if (!domNode.hasAttribute('data-lexical-equation')) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
conversion: $convertEquationElement,
|
|
114
|
-
priority: 2,
|
|
115
|
-
};
|
|
116
|
-
},
|
|
117
|
-
span: (domNode: HTMLElement) => {
|
|
118
|
-
if (!domNode.hasAttribute('data-lexical-equation')) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
conversion: $convertEquationElement,
|
|
123
|
-
priority: 1,
|
|
124
|
-
};
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
updateDOM(prevNode: this): boolean {
|
|
130
|
-
// If the inline property changes, replace the element
|
|
131
|
-
return this.__inline !== prevNode.__inline;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
getTextContent(): string {
|
|
135
|
-
return this.__equation;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
getEquation(): string {
|
|
139
|
-
return this.__equation;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
setEquation(equation: string): void {
|
|
143
|
-
const writable = this.getWritable();
|
|
144
|
-
writable.__equation = equation;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
decorate(): JSX.Element {
|
|
148
|
-
return (
|
|
149
|
-
<EquationComponent
|
|
150
|
-
equation={this.__equation}
|
|
151
|
-
inline={this.__inline}
|
|
152
|
-
nodeKey={this.__key}
|
|
153
|
-
/>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function $createEquationNode(
|
|
159
|
-
equation = '',
|
|
160
|
-
inline = false,
|
|
161
|
-
): EquationNode {
|
|
162
|
-
const equationNode = new EquationNode(equation, inline);
|
|
163
|
-
return $applyNodeReplacement(equationNode);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export function $isEquationNode(
|
|
167
|
-
node: LexicalNode | null | undefined,
|
|
168
|
-
): node is EquationNode {
|
|
169
|
-
return node instanceof EquationNode;
|
|
170
|
-
}
|