@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,759 +1,667 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
$
|
|
31
|
-
$
|
|
32
|
-
$
|
|
33
|
-
$
|
|
34
|
-
$
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} from "lexical";
|
|
41
|
-
import
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} from "
|
|
55
|
-
import {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
);
|
|
140
|
-
const [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
$
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
editor.update(() => {
|
|
282
|
-
$
|
|
283
|
-
});
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
(
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
clearTableSelection();
|
|
358
|
-
});
|
|
359
|
-
}, [editor, tableCellNode, clearTableSelection]);
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
},
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
let
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
menu.classList.toggle(
|
|
669
|
-
"table-cell-action-button-container--active",
|
|
670
|
-
enabled
|
|
671
|
-
);
|
|
672
|
-
menu.classList.toggle(
|
|
673
|
-
"table-cell-action-button-container--inactive",
|
|
674
|
-
!enabled
|
|
675
|
-
);
|
|
676
|
-
if (enabled) {
|
|
677
|
-
const tableCellRect = tableCellParentNodeDOM.getBoundingClientRect();
|
|
678
|
-
const anchorRect = anchorElem.getBoundingClientRect();
|
|
679
|
-
const top = tableCellRect.top - anchorRect.top;
|
|
680
|
-
const left = tableCellRect.right - anchorRect.left;
|
|
681
|
-
menu.style.transform = `translate(${left}px, ${top}px)`;
|
|
682
|
-
}
|
|
683
|
-
}, [editor, anchorElem]);
|
|
684
|
-
|
|
685
|
-
useEffect(() => {
|
|
686
|
-
// We call the $moveMenu callback every time the selection changes,
|
|
687
|
-
// once up front, and once after each mouseUp
|
|
688
|
-
let timeoutId: ReturnType<typeof setTimeout> | undefined = undefined;
|
|
689
|
-
const callback = () => {
|
|
690
|
-
timeoutId = undefined;
|
|
691
|
-
editor.getEditorState().read($moveMenu);
|
|
692
|
-
};
|
|
693
|
-
const delayedCallback = () => {
|
|
694
|
-
if (timeoutId === undefined) {
|
|
695
|
-
timeoutId = setTimeout(callback, 0);
|
|
696
|
-
}
|
|
697
|
-
return false;
|
|
698
|
-
};
|
|
699
|
-
return mergeRegister(
|
|
700
|
-
editor.registerUpdateListener(delayedCallback),
|
|
701
|
-
editor.registerCommand(
|
|
702
|
-
SELECTION_CHANGE_COMMAND,
|
|
703
|
-
delayedCallback,
|
|
704
|
-
COMMAND_PRIORITY_CRITICAL
|
|
705
|
-
),
|
|
706
|
-
editor.registerRootListener((rootElement, prevRootElement) => {
|
|
707
|
-
if (prevRootElement) {
|
|
708
|
-
prevRootElement.removeEventListener("mouseup", delayedCallback);
|
|
709
|
-
}
|
|
710
|
-
if (rootElement) {
|
|
711
|
-
rootElement.addEventListener("mouseup", delayedCallback);
|
|
712
|
-
delayedCallback();
|
|
713
|
-
}
|
|
714
|
-
}),
|
|
715
|
-
() => clearTimeout(timeoutId)
|
|
716
|
-
);
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
const prevTableCellDOM = useRef(tableCellNode);
|
|
720
|
-
|
|
721
|
-
useEffect(() => {
|
|
722
|
-
prevTableCellDOM.current = tableCellNode;
|
|
723
|
-
}, [prevTableCellDOM, tableCellNode]);
|
|
724
|
-
|
|
725
|
-
return (
|
|
726
|
-
<div
|
|
727
|
-
className=" absolute top-1 left-1 will-change-transform"
|
|
728
|
-
ref={menuButtonRef}
|
|
729
|
-
>
|
|
730
|
-
{tableCellNode != null && (
|
|
731
|
-
<TableActionMenu
|
|
732
|
-
contextRef={menuRootRef}
|
|
733
|
-
tableCellNode={tableCellNode}
|
|
734
|
-
cellMerge={cellMerge}
|
|
735
|
-
/>
|
|
736
|
-
)}
|
|
737
|
-
</div>
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
export default function TableActionMenuPlugin({
|
|
742
|
-
anchorElem = document.body,
|
|
743
|
-
cellMerge = false,
|
|
744
|
-
}: {
|
|
745
|
-
anchorElem?: HTMLElement;
|
|
746
|
-
cellMerge?: boolean;
|
|
747
|
-
}): null | ReactPortal {
|
|
748
|
-
const isEditable = useLexicalEditable();
|
|
749
|
-
|
|
750
|
-
return createPortal(
|
|
751
|
-
isEditable ? (
|
|
752
|
-
<TableCellActionMenuContainer
|
|
753
|
-
anchorElem={anchorElem}
|
|
754
|
-
cellMerge={cellMerge}
|
|
755
|
-
/>
|
|
756
|
-
) : null,
|
|
757
|
-
anchorElem
|
|
758
|
-
);
|
|
759
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
DropDown
|
|
3
|
+
} from "./chunk-EGMI62PP.mjs";
|
|
4
|
+
import "./chunk-KJ6AJ44Q.mjs";
|
|
5
|
+
import "./chunk-64Z3FI7T.mjs";
|
|
6
|
+
import {
|
|
7
|
+
useModal
|
|
8
|
+
} from "./chunk-5QSNIVIG.mjs";
|
|
9
|
+
import "./chunk-WDG7J2DY.mjs";
|
|
10
|
+
import "./chunk-BIU7WTLX.mjs";
|
|
11
|
+
import "./chunk-YHPNOWFH.mjs";
|
|
12
|
+
import {
|
|
13
|
+
init_react_shim
|
|
14
|
+
} from "./chunk-77KXU36M.mjs";
|
|
15
|
+
|
|
16
|
+
// src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx
|
|
17
|
+
init_react_shim();
|
|
18
|
+
import { Compact } from "@uiw/react-color";
|
|
19
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
20
|
+
import { useLexicalEditable } from "@lexical/react/useLexicalEditable";
|
|
21
|
+
import {
|
|
22
|
+
$deleteTableColumn__EXPERIMENTAL,
|
|
23
|
+
$deleteTableRow__EXPERIMENTAL,
|
|
24
|
+
$getNodeTriplet,
|
|
25
|
+
$getTableCellNodeFromLexicalNode,
|
|
26
|
+
$getTableColumnIndexFromTableCellNode,
|
|
27
|
+
$getTableNodeFromLexicalNodeOrThrow,
|
|
28
|
+
$getTableRowIndexFromTableCellNode,
|
|
29
|
+
$insertTableColumn__EXPERIMENTAL,
|
|
30
|
+
$insertTableRow__EXPERIMENTAL,
|
|
31
|
+
$isTableCellNode,
|
|
32
|
+
$isTableRowNode,
|
|
33
|
+
$isTableSelection,
|
|
34
|
+
$unmergeCell,
|
|
35
|
+
getTableElement,
|
|
36
|
+
getTableObserverFromTableElement,
|
|
37
|
+
TableCellHeaderStates,
|
|
38
|
+
TableCellNode
|
|
39
|
+
} from "@lexical/table";
|
|
40
|
+
import { mergeRegister } from "@lexical/utils";
|
|
41
|
+
import {
|
|
42
|
+
$createParagraphNode,
|
|
43
|
+
$getRoot,
|
|
44
|
+
$getSelection,
|
|
45
|
+
$isElementNode,
|
|
46
|
+
$isParagraphNode,
|
|
47
|
+
$isRangeSelection,
|
|
48
|
+
$isTextNode,
|
|
49
|
+
COMMAND_PRIORITY_CRITICAL,
|
|
50
|
+
getDOMSelection,
|
|
51
|
+
SELECTION_CHANGE_COMMAND
|
|
52
|
+
} from "lexical";
|
|
53
|
+
import * as React2 from "react";
|
|
54
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
55
|
+
import { createPortal } from "react-dom";
|
|
56
|
+
|
|
57
|
+
// src/components/editor/utils/invariant.ts
|
|
58
|
+
init_react_shim();
|
|
59
|
+
function invariant(cond, message) {
|
|
60
|
+
if (cond) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
throw new Error(
|
|
64
|
+
"Internal Lexical error: invariant() is meant to be replaced at compile time. There is no runtime version. Error: " + message
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx
|
|
69
|
+
import {
|
|
70
|
+
Menu,
|
|
71
|
+
Merge,
|
|
72
|
+
PaintBucket,
|
|
73
|
+
Split,
|
|
74
|
+
Table,
|
|
75
|
+
TableColumnsSplit,
|
|
76
|
+
TableRowsSplit,
|
|
77
|
+
Trash
|
|
78
|
+
} from "lucide-react";
|
|
79
|
+
function computeSelectionCount(selection) {
|
|
80
|
+
const selectionShape = selection.getShape();
|
|
81
|
+
return {
|
|
82
|
+
columns: selectionShape.toX - selectionShape.fromX + 1,
|
|
83
|
+
rows: selectionShape.toY - selectionShape.fromY + 1
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function $canUnmerge() {
|
|
87
|
+
const selection = $getSelection();
|
|
88
|
+
if ($isRangeSelection(selection) && !selection.isCollapsed() || $isTableSelection(selection) && !selection.anchor.is(selection.focus) || !$isRangeSelection(selection) && !$isTableSelection(selection)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
const [cell] = $getNodeTriplet(selection.anchor);
|
|
92
|
+
return cell.__colSpan > 1 || cell.__rowSpan > 1;
|
|
93
|
+
}
|
|
94
|
+
function $cellContainsEmptyParagraph(cell) {
|
|
95
|
+
if (cell.getChildrenSize() !== 1) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
const firstChild = cell.getFirstChildOrThrow();
|
|
99
|
+
if (!$isParagraphNode(firstChild) || !firstChild.isEmpty()) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
function $selectLastDescendant(node) {
|
|
105
|
+
const lastDescendant = node.getLastDescendant();
|
|
106
|
+
if ($isTextNode(lastDescendant)) {
|
|
107
|
+
lastDescendant.select();
|
|
108
|
+
} else if ($isElementNode(lastDescendant)) {
|
|
109
|
+
lastDescendant.selectEnd();
|
|
110
|
+
} else if (lastDescendant !== null) {
|
|
111
|
+
lastDescendant.selectNext();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function currentCellBackgroundColor(editor) {
|
|
115
|
+
return editor.getEditorState().read(() => {
|
|
116
|
+
const selection = $getSelection();
|
|
117
|
+
if ($isRangeSelection(selection) || $isTableSelection(selection)) {
|
|
118
|
+
const [cell] = $getNodeTriplet(selection.anchor);
|
|
119
|
+
if ($isTableCellNode(cell)) {
|
|
120
|
+
return cell.getBackgroundColor();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function TableActionMenu({
|
|
127
|
+
tableCellNode: _tableCellNode,
|
|
128
|
+
contextRef,
|
|
129
|
+
cellMerge
|
|
130
|
+
}) {
|
|
131
|
+
const [editor] = useLexicalComposerContext();
|
|
132
|
+
const dropDownRef = useRef(null);
|
|
133
|
+
const [tableCellNode, updateTableCellNode] = useState(_tableCellNode);
|
|
134
|
+
const [selectionCounts, updateSelectionCounts] = useState({
|
|
135
|
+
columns: 1,
|
|
136
|
+
rows: 1
|
|
137
|
+
});
|
|
138
|
+
const [canMergeCells, setCanMergeCells] = useState(false);
|
|
139
|
+
const [canUnmergeCell, setCanUnmergeCell] = useState(false);
|
|
140
|
+
const [backgroundColor, setBackgroundColor] = useState(
|
|
141
|
+
() => currentCellBackgroundColor(editor) || ""
|
|
142
|
+
);
|
|
143
|
+
const [model, showModal] = useModal();
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
return editor.registerMutationListener(
|
|
146
|
+
TableCellNode,
|
|
147
|
+
(nodeMutations) => {
|
|
148
|
+
const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === "updated";
|
|
149
|
+
if (nodeUpdated) {
|
|
150
|
+
editor.getEditorState().read(() => {
|
|
151
|
+
updateTableCellNode(tableCellNode.getLatest());
|
|
152
|
+
});
|
|
153
|
+
setBackgroundColor(currentCellBackgroundColor(editor) || "");
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{ skipInitialization: true }
|
|
157
|
+
);
|
|
158
|
+
}, [editor, tableCellNode]);
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
editor.getEditorState().read(() => {
|
|
161
|
+
const selection = $getSelection();
|
|
162
|
+
if ($isTableSelection(selection)) {
|
|
163
|
+
const currentSelectionCounts = computeSelectionCount(selection);
|
|
164
|
+
updateSelectionCounts(computeSelectionCount(selection));
|
|
165
|
+
setCanMergeCells(
|
|
166
|
+
currentSelectionCounts.columns > 1 || currentSelectionCounts.rows > 1
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
setCanUnmergeCell($canUnmerge());
|
|
170
|
+
});
|
|
171
|
+
}, [editor]);
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
const menuButtonElement = contextRef.current;
|
|
174
|
+
const dropDownElement = dropDownRef.current;
|
|
175
|
+
const rootElement = editor.getRootElement();
|
|
176
|
+
if (menuButtonElement != null && dropDownElement != null && rootElement != null) {
|
|
177
|
+
const rootEleRect = rootElement.getBoundingClientRect();
|
|
178
|
+
const menuButtonRect = menuButtonElement.getBoundingClientRect();
|
|
179
|
+
dropDownElement.style.opacity = "1";
|
|
180
|
+
const dropDownElementRect = dropDownElement.getBoundingClientRect();
|
|
181
|
+
const margin = 5;
|
|
182
|
+
let leftPosition = menuButtonRect.right + margin;
|
|
183
|
+
if (leftPosition + dropDownElementRect.width > window.innerWidth || leftPosition + dropDownElementRect.width > rootEleRect.right) {
|
|
184
|
+
const position = menuButtonRect.left - dropDownElementRect.width - margin;
|
|
185
|
+
leftPosition = (position < 0 ? margin : position) + window.pageXOffset;
|
|
186
|
+
}
|
|
187
|
+
dropDownElement.style.left = `${leftPosition + window.pageXOffset}px`;
|
|
188
|
+
let topPosition = menuButtonRect.top;
|
|
189
|
+
if (topPosition + dropDownElementRect.height > window.innerHeight) {
|
|
190
|
+
const position = menuButtonRect.bottom - dropDownElementRect.height;
|
|
191
|
+
topPosition = (position < 0 ? margin : position) + window.pageYOffset;
|
|
192
|
+
}
|
|
193
|
+
dropDownElement.style.top = `${topPosition + +window.pageYOffset}px`;
|
|
194
|
+
}
|
|
195
|
+
}, [contextRef, dropDownRef, editor]);
|
|
196
|
+
const clearTableSelection = useCallback(() => {
|
|
197
|
+
editor.update(() => {
|
|
198
|
+
if (tableCellNode.isAttached()) {
|
|
199
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
200
|
+
const tableElement = getTableElement(
|
|
201
|
+
tableNode,
|
|
202
|
+
editor.getElementByKey(tableNode.getKey())
|
|
203
|
+
);
|
|
204
|
+
invariant(
|
|
205
|
+
tableElement !== null,
|
|
206
|
+
"TableActionMenu: Expected to find tableElement in DOM"
|
|
207
|
+
);
|
|
208
|
+
const tableObserver = getTableObserverFromTableElement(tableElement);
|
|
209
|
+
if (tableObserver !== null) {
|
|
210
|
+
tableObserver.$clearHighlight();
|
|
211
|
+
}
|
|
212
|
+
tableNode.markDirty();
|
|
213
|
+
updateTableCellNode(tableCellNode.getLatest());
|
|
214
|
+
}
|
|
215
|
+
const rootNode = $getRoot();
|
|
216
|
+
rootNode.selectStart();
|
|
217
|
+
});
|
|
218
|
+
}, [editor, tableCellNode]);
|
|
219
|
+
const mergeTableCellsAtSelection = () => {
|
|
220
|
+
editor.update(() => {
|
|
221
|
+
const selection = $getSelection();
|
|
222
|
+
if ($isTableSelection(selection)) {
|
|
223
|
+
const { columns, rows } = computeSelectionCount(selection);
|
|
224
|
+
const nodes = selection.getNodes();
|
|
225
|
+
let firstCell = null;
|
|
226
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
227
|
+
const node = nodes[i];
|
|
228
|
+
if ($isTableCellNode(node)) {
|
|
229
|
+
if (firstCell === null) {
|
|
230
|
+
node.setColSpan(columns).setRowSpan(rows);
|
|
231
|
+
firstCell = node;
|
|
232
|
+
const isEmpty = $cellContainsEmptyParagraph(node);
|
|
233
|
+
let firstChild;
|
|
234
|
+
if (isEmpty && $isParagraphNode(firstChild = node.getFirstChild())) {
|
|
235
|
+
firstChild.remove();
|
|
236
|
+
}
|
|
237
|
+
} else if ($isTableCellNode(firstCell)) {
|
|
238
|
+
const isEmpty = $cellContainsEmptyParagraph(node);
|
|
239
|
+
if (!isEmpty) {
|
|
240
|
+
firstCell.append(...node.getChildren());
|
|
241
|
+
}
|
|
242
|
+
node.remove();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (firstCell !== null) {
|
|
247
|
+
if (firstCell.getChildrenSize() === 0) {
|
|
248
|
+
firstCell.append($createParagraphNode());
|
|
249
|
+
}
|
|
250
|
+
$selectLastDescendant(firstCell);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
const unmergeTableCellsAtSelection = () => {
|
|
256
|
+
editor.update(() => {
|
|
257
|
+
$unmergeCell();
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
const insertTableRowAtSelection = useCallback(
|
|
261
|
+
(shouldInsertAfter) => {
|
|
262
|
+
editor.update(() => {
|
|
263
|
+
for (let i = 0; i < selectionCounts.rows; i++) {
|
|
264
|
+
$insertTableRow__EXPERIMENTAL(shouldInsertAfter);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
[editor, selectionCounts.rows]
|
|
269
|
+
);
|
|
270
|
+
const insertTableColumnAtSelection = useCallback(
|
|
271
|
+
(shouldInsertAfter) => {
|
|
272
|
+
editor.update(() => {
|
|
273
|
+
for (let i = 0; i < selectionCounts.columns; i++) {
|
|
274
|
+
$insertTableColumn__EXPERIMENTAL(shouldInsertAfter);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
},
|
|
278
|
+
[editor, selectionCounts.columns]
|
|
279
|
+
);
|
|
280
|
+
const deleteTableRowAtSelection = useCallback(() => {
|
|
281
|
+
editor.update(() => {
|
|
282
|
+
$deleteTableRow__EXPERIMENTAL();
|
|
283
|
+
});
|
|
284
|
+
}, [editor]);
|
|
285
|
+
const deleteTableAtSelection = useCallback(() => {
|
|
286
|
+
editor.update(() => {
|
|
287
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
288
|
+
tableNode.remove();
|
|
289
|
+
clearTableSelection();
|
|
290
|
+
});
|
|
291
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
292
|
+
const deleteTableColumnAtSelection = useCallback(() => {
|
|
293
|
+
editor.update(() => {
|
|
294
|
+
$deleteTableColumn__EXPERIMENTAL();
|
|
295
|
+
});
|
|
296
|
+
}, [editor]);
|
|
297
|
+
const toggleTableRowIsHeader = useCallback(() => {
|
|
298
|
+
editor.update(() => {
|
|
299
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
300
|
+
const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode);
|
|
301
|
+
const tableRows = tableNode.getChildren();
|
|
302
|
+
if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
|
|
303
|
+
throw new Error("Expected table cell to be inside of table row.");
|
|
304
|
+
}
|
|
305
|
+
const tableRow = tableRows[tableRowIndex];
|
|
306
|
+
if (!$isTableRowNode(tableRow)) {
|
|
307
|
+
throw new Error("Expected table row");
|
|
308
|
+
}
|
|
309
|
+
const newStyle = tableCellNode.getHeaderStyles() ^ TableCellHeaderStates.ROW;
|
|
310
|
+
tableRow.getChildren().forEach((tableCell) => {
|
|
311
|
+
if (!$isTableCellNode(tableCell)) {
|
|
312
|
+
throw new Error("Expected table cell");
|
|
313
|
+
}
|
|
314
|
+
tableCell.setHeaderStyles(newStyle, TableCellHeaderStates.ROW);
|
|
315
|
+
});
|
|
316
|
+
clearTableSelection();
|
|
317
|
+
});
|
|
318
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
319
|
+
const toggleTableColumnIsHeader = useCallback(() => {
|
|
320
|
+
editor.update(() => {
|
|
321
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
322
|
+
const tableColumnIndex = $getTableColumnIndexFromTableCellNode(tableCellNode);
|
|
323
|
+
const tableRows = tableNode.getChildren();
|
|
324
|
+
const maxRowsLength = Math.max(
|
|
325
|
+
...tableRows.map((row) => row.getChildren().length)
|
|
326
|
+
);
|
|
327
|
+
if (tableColumnIndex >= maxRowsLength || tableColumnIndex < 0) {
|
|
328
|
+
throw new Error("Expected table cell to be inside of table row.");
|
|
329
|
+
}
|
|
330
|
+
const newStyle = tableCellNode.getHeaderStyles() ^ TableCellHeaderStates.COLUMN;
|
|
331
|
+
for (let r = 0; r < tableRows.length; r++) {
|
|
332
|
+
const tableRow = tableRows[r];
|
|
333
|
+
if (!$isTableRowNode(tableRow)) {
|
|
334
|
+
throw new Error("Expected table row");
|
|
335
|
+
}
|
|
336
|
+
const tableCells = tableRow.getChildren();
|
|
337
|
+
if (tableColumnIndex >= tableCells.length) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
const tableCell = tableCells[tableColumnIndex];
|
|
341
|
+
if (!$isTableCellNode(tableCell)) {
|
|
342
|
+
throw new Error("Expected table cell");
|
|
343
|
+
}
|
|
344
|
+
tableCell.setHeaderStyles(newStyle, TableCellHeaderStates.COLUMN);
|
|
345
|
+
}
|
|
346
|
+
clearTableSelection();
|
|
347
|
+
});
|
|
348
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
349
|
+
const toggleRowStriping = useCallback(() => {
|
|
350
|
+
editor.update(() => {
|
|
351
|
+
if (tableCellNode.isAttached()) {
|
|
352
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);
|
|
353
|
+
if (tableNode) {
|
|
354
|
+
tableNode.setRowStriping(!tableNode.getRowStriping());
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
clearTableSelection();
|
|
358
|
+
});
|
|
359
|
+
}, [editor, tableCellNode, clearTableSelection]);
|
|
360
|
+
const handleCellBackgroundColor = useCallback(
|
|
361
|
+
(value) => {
|
|
362
|
+
editor.update(() => {
|
|
363
|
+
const selection = $getSelection();
|
|
364
|
+
if ($isRangeSelection(selection) || $isTableSelection(selection)) {
|
|
365
|
+
const [cell] = $getNodeTriplet(selection.anchor);
|
|
366
|
+
if ($isTableCellNode(cell)) {
|
|
367
|
+
cell.setBackgroundColor(value);
|
|
368
|
+
}
|
|
369
|
+
if ($isTableSelection(selection)) {
|
|
370
|
+
const nodes = selection.getNodes();
|
|
371
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
372
|
+
const node = nodes[i];
|
|
373
|
+
if ($isTableCellNode(node)) {
|
|
374
|
+
node.setBackgroundColor(value);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
[editor]
|
|
382
|
+
);
|
|
383
|
+
const commands = React2.useMemo(
|
|
384
|
+
() => [
|
|
385
|
+
{
|
|
386
|
+
label: "Background",
|
|
387
|
+
func: () => {
|
|
388
|
+
showModal(
|
|
389
|
+
"Background",
|
|
390
|
+
"Select color",
|
|
391
|
+
(onClose) => /* @__PURE__ */ React2.createElement(
|
|
392
|
+
Compact,
|
|
393
|
+
{
|
|
394
|
+
style: { background: "transparent", width: "100%" },
|
|
395
|
+
color: backgroundColor,
|
|
396
|
+
onChange: (color) => {
|
|
397
|
+
handleCellBackgroundColor(color.hex);
|
|
398
|
+
onClose();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
),
|
|
402
|
+
true
|
|
403
|
+
);
|
|
404
|
+
},
|
|
405
|
+
icon: /* @__PURE__ */ React2.createElement(PaintBucket, null),
|
|
406
|
+
style: { backgroundColor: `${currentCellBackgroundColor(editor)}` }
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
label: "Insert Row Above",
|
|
410
|
+
func: () => insertTableRowAtSelection(false),
|
|
411
|
+
icon: /* @__PURE__ */ React2.createElement(TableRowsSplit, null)
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
label: "Insert Row Below",
|
|
415
|
+
func: () => insertTableRowAtSelection(true),
|
|
416
|
+
icon: /* @__PURE__ */ React2.createElement(TableRowsSplit, null)
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
label: "Insert Column Left",
|
|
420
|
+
func: () => insertTableColumnAtSelection(false),
|
|
421
|
+
icon: /* @__PURE__ */ React2.createElement(TableColumnsSplit, null)
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
label: "Insert Column Right",
|
|
425
|
+
func: () => insertTableColumnAtSelection(true),
|
|
426
|
+
icon: /* @__PURE__ */ React2.createElement(TableColumnsSplit, null)
|
|
427
|
+
},
|
|
428
|
+
{ label: "Delete Row", func: deleteTableRowAtSelection, icon: /* @__PURE__ */ React2.createElement(Trash, null) },
|
|
429
|
+
{
|
|
430
|
+
label: "Delete Column",
|
|
431
|
+
func: deleteTableColumnAtSelection,
|
|
432
|
+
icon: /* @__PURE__ */ React2.createElement(Trash, null)
|
|
433
|
+
},
|
|
434
|
+
{ label: "Delete Table", func: deleteTableAtSelection, icon: /* @__PURE__ */ React2.createElement(Trash, null) },
|
|
435
|
+
{
|
|
436
|
+
label: "Toggle Row Header",
|
|
437
|
+
func: toggleTableRowIsHeader,
|
|
438
|
+
icon: /* @__PURE__ */ React2.createElement(Table, null)
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
label: "Toggle Column Header",
|
|
442
|
+
func: toggleTableColumnIsHeader,
|
|
443
|
+
icon: /* @__PURE__ */ React2.createElement(Table, null)
|
|
444
|
+
},
|
|
445
|
+
{ label: "Toggle Striping", func: toggleRowStriping, icon: /* @__PURE__ */ React2.createElement(Table, null) }
|
|
446
|
+
],
|
|
447
|
+
[
|
|
448
|
+
currentCellBackgroundColor(editor),
|
|
449
|
+
canMergeCells,
|
|
450
|
+
canUnmergeCell,
|
|
451
|
+
insertTableRowAtSelection,
|
|
452
|
+
insertTableColumnAtSelection,
|
|
453
|
+
deleteTableRowAtSelection,
|
|
454
|
+
deleteTableColumnAtSelection,
|
|
455
|
+
deleteTableAtSelection,
|
|
456
|
+
toggleTableRowIsHeader,
|
|
457
|
+
toggleTableColumnIsHeader,
|
|
458
|
+
toggleRowStriping,
|
|
459
|
+
backgroundColor,
|
|
460
|
+
editor,
|
|
461
|
+
tableCellNode,
|
|
462
|
+
cellMerge,
|
|
463
|
+
selectionCounts
|
|
464
|
+
]
|
|
465
|
+
);
|
|
466
|
+
if (cellMerge) {
|
|
467
|
+
if (canMergeCells) {
|
|
468
|
+
commands.push({
|
|
469
|
+
label: "Merge Cells",
|
|
470
|
+
func: mergeTableCellsAtSelection,
|
|
471
|
+
icon: /* @__PURE__ */ React2.createElement(Merge, null)
|
|
472
|
+
});
|
|
473
|
+
} else if (canUnmergeCell) {
|
|
474
|
+
commands.push({
|
|
475
|
+
label: "Unmerge Cells",
|
|
476
|
+
func: unmergeTableCellsAtSelection,
|
|
477
|
+
icon: /* @__PURE__ */ React2.createElement(Split, null)
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
482
|
+
DropDown,
|
|
483
|
+
{
|
|
484
|
+
values: commands,
|
|
485
|
+
TriggerLabel: /* @__PURE__ */ React2.createElement(Menu, { className: "w-4 h-4 " }),
|
|
486
|
+
TriggerClassName: {
|
|
487
|
+
height: "24px",
|
|
488
|
+
padding: "0px 4px",
|
|
489
|
+
position: "absolute",
|
|
490
|
+
top: 0,
|
|
491
|
+
right: "10px"
|
|
492
|
+
},
|
|
493
|
+
ShowChevronsUpDown: false,
|
|
494
|
+
triggerVariants: "ghost",
|
|
495
|
+
disabled: false
|
|
496
|
+
}
|
|
497
|
+
), model);
|
|
498
|
+
}
|
|
499
|
+
function TableCellActionMenuContainer({
|
|
500
|
+
anchorElem,
|
|
501
|
+
cellMerge
|
|
502
|
+
}) {
|
|
503
|
+
const [editor] = useLexicalComposerContext();
|
|
504
|
+
const menuButtonRef = useRef(null);
|
|
505
|
+
const menuRootRef = useRef(null);
|
|
506
|
+
const [tableCellNode, setTableMenuCellNode] = useState(
|
|
507
|
+
null
|
|
508
|
+
);
|
|
509
|
+
const $moveMenu = useCallback(() => {
|
|
510
|
+
const menu = menuButtonRef.current;
|
|
511
|
+
const selection = $getSelection();
|
|
512
|
+
const nativeSelection = getDOMSelection(editor._window);
|
|
513
|
+
let activeElement;
|
|
514
|
+
if (typeof window !== "undefined") {
|
|
515
|
+
activeElement = document == null ? void 0 : document.activeElement;
|
|
516
|
+
}
|
|
517
|
+
function disable() {
|
|
518
|
+
if (menu) {
|
|
519
|
+
menu.classList.remove("table-cell-action-button-container--active");
|
|
520
|
+
menu.classList.add("table-cell-action-button-container--inactive");
|
|
521
|
+
}
|
|
522
|
+
setTableMenuCellNode(null);
|
|
523
|
+
}
|
|
524
|
+
if (selection == null || menu == null) {
|
|
525
|
+
return disable();
|
|
526
|
+
}
|
|
527
|
+
const rootElement = editor.getRootElement();
|
|
528
|
+
let tableObserver = null;
|
|
529
|
+
let tableCellParentNodeDOM = null;
|
|
530
|
+
if ($isRangeSelection(selection) && rootElement !== null && nativeSelection !== null && rootElement.contains(nativeSelection.anchorNode)) {
|
|
531
|
+
const tableCellNodeFromSelection = $getTableCellNodeFromLexicalNode(
|
|
532
|
+
selection.anchor.getNode()
|
|
533
|
+
);
|
|
534
|
+
if (tableCellNodeFromSelection == null) {
|
|
535
|
+
return disable();
|
|
536
|
+
}
|
|
537
|
+
tableCellParentNodeDOM = editor.getElementByKey(
|
|
538
|
+
tableCellNodeFromSelection.getKey()
|
|
539
|
+
);
|
|
540
|
+
if (tableCellParentNodeDOM == null || !tableCellNodeFromSelection.isAttached()) {
|
|
541
|
+
return disable();
|
|
542
|
+
}
|
|
543
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(
|
|
544
|
+
tableCellNodeFromSelection
|
|
545
|
+
);
|
|
546
|
+
const tableElement = getTableElement(
|
|
547
|
+
tableNode,
|
|
548
|
+
editor.getElementByKey(tableNode.getKey())
|
|
549
|
+
);
|
|
550
|
+
invariant(
|
|
551
|
+
tableElement !== null,
|
|
552
|
+
"TableActionMenu: Expected to find tableElement in DOM"
|
|
553
|
+
);
|
|
554
|
+
tableObserver = getTableObserverFromTableElement(tableElement);
|
|
555
|
+
setTableMenuCellNode(tableCellNodeFromSelection);
|
|
556
|
+
} else if ($isTableSelection(selection)) {
|
|
557
|
+
const anchorNode = $getTableCellNodeFromLexicalNode(
|
|
558
|
+
selection.anchor.getNode()
|
|
559
|
+
);
|
|
560
|
+
invariant(
|
|
561
|
+
$isTableCellNode(anchorNode),
|
|
562
|
+
"TableSelection anchorNode must be a TableCellNode"
|
|
563
|
+
);
|
|
564
|
+
const tableNode = $getTableNodeFromLexicalNodeOrThrow(anchorNode);
|
|
565
|
+
const tableElement = getTableElement(
|
|
566
|
+
tableNode,
|
|
567
|
+
editor.getElementByKey(tableNode.getKey())
|
|
568
|
+
);
|
|
569
|
+
invariant(
|
|
570
|
+
tableElement !== null,
|
|
571
|
+
"TableActionMenu: Expected to find tableElement in DOM"
|
|
572
|
+
);
|
|
573
|
+
tableObserver = getTableObserverFromTableElement(tableElement);
|
|
574
|
+
tableCellParentNodeDOM = editor.getElementByKey(anchorNode.getKey());
|
|
575
|
+
} else if (!activeElement) {
|
|
576
|
+
return disable();
|
|
577
|
+
}
|
|
578
|
+
if (tableObserver === null || tableCellParentNodeDOM === null) {
|
|
579
|
+
return disable();
|
|
580
|
+
}
|
|
581
|
+
const enabled = !tableObserver || !tableObserver.isSelecting;
|
|
582
|
+
menu.classList.toggle(
|
|
583
|
+
"table-cell-action-button-container--active",
|
|
584
|
+
enabled
|
|
585
|
+
);
|
|
586
|
+
menu.classList.toggle(
|
|
587
|
+
"table-cell-action-button-container--inactive",
|
|
588
|
+
!enabled
|
|
589
|
+
);
|
|
590
|
+
if (enabled) {
|
|
591
|
+
const tableCellRect = tableCellParentNodeDOM.getBoundingClientRect();
|
|
592
|
+
const anchorRect = anchorElem.getBoundingClientRect();
|
|
593
|
+
const top = tableCellRect.top - anchorRect.top;
|
|
594
|
+
const left = tableCellRect.right - anchorRect.left;
|
|
595
|
+
menu.style.transform = `translate(${left}px, ${top}px)`;
|
|
596
|
+
}
|
|
597
|
+
}, [editor, anchorElem]);
|
|
598
|
+
useEffect(() => {
|
|
599
|
+
let timeoutId = void 0;
|
|
600
|
+
const callback = () => {
|
|
601
|
+
timeoutId = void 0;
|
|
602
|
+
editor.getEditorState().read($moveMenu);
|
|
603
|
+
};
|
|
604
|
+
const delayedCallback = () => {
|
|
605
|
+
if (timeoutId === void 0) {
|
|
606
|
+
timeoutId = setTimeout(callback, 0);
|
|
607
|
+
}
|
|
608
|
+
return false;
|
|
609
|
+
};
|
|
610
|
+
return mergeRegister(
|
|
611
|
+
editor.registerUpdateListener(delayedCallback),
|
|
612
|
+
editor.registerCommand(
|
|
613
|
+
SELECTION_CHANGE_COMMAND,
|
|
614
|
+
delayedCallback,
|
|
615
|
+
COMMAND_PRIORITY_CRITICAL
|
|
616
|
+
),
|
|
617
|
+
editor.registerRootListener((rootElement, prevRootElement) => {
|
|
618
|
+
if (prevRootElement) {
|
|
619
|
+
prevRootElement.removeEventListener("mouseup", delayedCallback);
|
|
620
|
+
}
|
|
621
|
+
if (rootElement) {
|
|
622
|
+
rootElement.addEventListener("mouseup", delayedCallback);
|
|
623
|
+
delayedCallback();
|
|
624
|
+
}
|
|
625
|
+
}),
|
|
626
|
+
() => clearTimeout(timeoutId)
|
|
627
|
+
);
|
|
628
|
+
});
|
|
629
|
+
const prevTableCellDOM = useRef(tableCellNode);
|
|
630
|
+
useEffect(() => {
|
|
631
|
+
prevTableCellDOM.current = tableCellNode;
|
|
632
|
+
}, [prevTableCellDOM, tableCellNode]);
|
|
633
|
+
return /* @__PURE__ */ React2.createElement(
|
|
634
|
+
"div",
|
|
635
|
+
{
|
|
636
|
+
className: " absolute top-1 left-1 will-change-transform",
|
|
637
|
+
ref: menuButtonRef
|
|
638
|
+
},
|
|
639
|
+
tableCellNode != null && /* @__PURE__ */ React2.createElement(
|
|
640
|
+
TableActionMenu,
|
|
641
|
+
{
|
|
642
|
+
contextRef: menuRootRef,
|
|
643
|
+
tableCellNode,
|
|
644
|
+
cellMerge
|
|
645
|
+
}
|
|
646
|
+
)
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
function TableActionMenuPlugin({
|
|
650
|
+
anchorElem = document.body,
|
|
651
|
+
cellMerge = false
|
|
652
|
+
}) {
|
|
653
|
+
const isEditable = useLexicalEditable();
|
|
654
|
+
return createPortal(
|
|
655
|
+
isEditable ? /* @__PURE__ */ React2.createElement(
|
|
656
|
+
TableCellActionMenuContainer,
|
|
657
|
+
{
|
|
658
|
+
anchorElem,
|
|
659
|
+
cellMerge
|
|
660
|
+
}
|
|
661
|
+
) : null,
|
|
662
|
+
anchorElem
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
export {
|
|
666
|
+
TableActionMenuPlugin as default
|
|
667
|
+
};
|