@collabchron/notiq 0.3.0 → 1.0.1
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-YKYA4NB4.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 +67 -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,238 +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 {ElementNode, LexicalCommand, LexicalNode, NodeKey} from 'lexical';
|
|
10
|
-
|
|
11
|
-
import {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';
|
|
12
|
-
import {
|
|
13
|
-
$findMatchingParent,
|
|
14
|
-
$insertNodeToNearestRoot,
|
|
15
|
-
mergeRegister,
|
|
16
|
-
} from '@lexical/utils';
|
|
17
|
-
import {
|
|
18
|
-
$createParagraphNode,
|
|
19
|
-
$getNodeByKey,
|
|
20
|
-
$getSelection,
|
|
21
|
-
$isRangeSelection,
|
|
22
|
-
COMMAND_PRIORITY_EDITOR,
|
|
23
|
-
COMMAND_PRIORITY_LOW,
|
|
24
|
-
createCommand,
|
|
25
|
-
KEY_ARROW_DOWN_COMMAND,
|
|
26
|
-
KEY_ARROW_LEFT_COMMAND,
|
|
27
|
-
KEY_ARROW_RIGHT_COMMAND,
|
|
28
|
-
KEY_ARROW_UP_COMMAND,
|
|
29
|
-
} from 'lexical';
|
|
30
|
-
import {useEffect} from 'react';
|
|
31
|
-
|
|
32
|
-
import {
|
|
33
|
-
$createLayoutContainerNode,
|
|
34
|
-
$isLayoutContainerNode,
|
|
35
|
-
LayoutContainerNode,
|
|
36
|
-
} from '../../nodes/LayoutNode/LayoutContainerNode';
|
|
37
|
-
import {
|
|
38
|
-
$createLayoutItemNode,
|
|
39
|
-
$isLayoutItemNode,
|
|
40
|
-
LayoutItemNode,
|
|
41
|
-
} from '../../nodes/LayoutNode/LayoutItemNode';
|
|
42
|
-
|
|
43
|
-
export const INSERT_LAYOUT_COMMAND: LexicalCommand<string> =
|
|
44
|
-
createCommand<string>();
|
|
45
|
-
|
|
46
|
-
export const UPDATE_LAYOUT_COMMAND: LexicalCommand<{
|
|
47
|
-
template: string;
|
|
48
|
-
nodeKey: NodeKey;
|
|
49
|
-
}> = createCommand<{template: string; nodeKey: NodeKey}>();
|
|
50
|
-
|
|
51
|
-
export function LayoutPlugin(): null {
|
|
52
|
-
const [editor] = useLexicalComposerContext();
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (!editor.hasNodes([LayoutContainerNode, LayoutItemNode])) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
'LayoutPlugin: LayoutContainerNode, or LayoutItemNode not registered on editor',
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const $onEscape = (before: boolean) => {
|
|
61
|
-
const selection = $getSelection();
|
|
62
|
-
if (
|
|
63
|
-
$isRangeSelection(selection) &&
|
|
64
|
-
selection.isCollapsed() &&
|
|
65
|
-
selection.anchor.offset === 0
|
|
66
|
-
) {
|
|
67
|
-
const container = $findMatchingParent(
|
|
68
|
-
selection.anchor.getNode(),
|
|
69
|
-
$isLayoutContainerNode,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
if ($isLayoutContainerNode(container)) {
|
|
73
|
-
const parent = container.getParent<ElementNode>();
|
|
74
|
-
const child =
|
|
75
|
-
parent &&
|
|
76
|
-
(before
|
|
77
|
-
? parent.getFirstChild<LexicalNode>()
|
|
78
|
-
: parent?.getLastChild<LexicalNode>());
|
|
79
|
-
const descendant = before
|
|
80
|
-
? container.getFirstDescendant<LexicalNode>()?.getKey()
|
|
81
|
-
: container.getLastDescendant<LexicalNode>()?.getKey();
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
parent !== null &&
|
|
85
|
-
child === container &&
|
|
86
|
-
selection.anchor.key === descendant
|
|
87
|
-
) {
|
|
88
|
-
if (before) {
|
|
89
|
-
container.insertBefore($createParagraphNode());
|
|
90
|
-
} else {
|
|
91
|
-
container.insertAfter($createParagraphNode());
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return false;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const $fillLayoutItemIfEmpty = (node: LayoutItemNode) => {
|
|
101
|
-
if (node.isEmpty()) {
|
|
102
|
-
node.append($createParagraphNode());
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const $removeIsolatedLayoutItem = (node: LayoutItemNode): boolean => {
|
|
107
|
-
const parent = node.getParent<ElementNode>();
|
|
108
|
-
if (!$isLayoutContainerNode(parent)) {
|
|
109
|
-
const children = node.getChildren<LexicalNode>();
|
|
110
|
-
for (const child of children) {
|
|
111
|
-
node.insertBefore(child);
|
|
112
|
-
}
|
|
113
|
-
node.remove();
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
return mergeRegister(
|
|
120
|
-
// When layout is the last child pressing down/right arrow will insert paragraph
|
|
121
|
-
// below it to allow adding more content. It's similar what $insertBlockNode
|
|
122
|
-
// (mainly for decorators), except it'll always be possible to continue adding
|
|
123
|
-
// new content even if trailing paragraph is accidentally deleted
|
|
124
|
-
editor.registerCommand(
|
|
125
|
-
KEY_ARROW_DOWN_COMMAND,
|
|
126
|
-
() => $onEscape(false),
|
|
127
|
-
COMMAND_PRIORITY_LOW,
|
|
128
|
-
),
|
|
129
|
-
editor.registerCommand(
|
|
130
|
-
KEY_ARROW_RIGHT_COMMAND,
|
|
131
|
-
() => $onEscape(false),
|
|
132
|
-
COMMAND_PRIORITY_LOW,
|
|
133
|
-
),
|
|
134
|
-
// When layout is the first child pressing up/left arrow will insert paragraph
|
|
135
|
-
// above it to allow adding more content. It's similar what $insertBlockNode
|
|
136
|
-
// (mainly for decorators), except it'll always be possible to continue adding
|
|
137
|
-
// new content even if leading paragraph is accidentally deleted
|
|
138
|
-
editor.registerCommand(
|
|
139
|
-
KEY_ARROW_UP_COMMAND,
|
|
140
|
-
() => $onEscape(true),
|
|
141
|
-
COMMAND_PRIORITY_LOW,
|
|
142
|
-
),
|
|
143
|
-
editor.registerCommand(
|
|
144
|
-
KEY_ARROW_LEFT_COMMAND,
|
|
145
|
-
() => $onEscape(true),
|
|
146
|
-
COMMAND_PRIORITY_LOW,
|
|
147
|
-
),
|
|
148
|
-
editor.registerCommand(
|
|
149
|
-
INSERT_LAYOUT_COMMAND,
|
|
150
|
-
(template) => {
|
|
151
|
-
editor.update(() => {
|
|
152
|
-
const container = $createLayoutContainerNode(template);
|
|
153
|
-
const itemsCount = getItemsCountFromTemplate(template);
|
|
154
|
-
|
|
155
|
-
for (let i = 0; i < itemsCount; i++) {
|
|
156
|
-
container.append(
|
|
157
|
-
$createLayoutItemNode().append($createParagraphNode()),
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
$insertNodeToNearestRoot(container);
|
|
162
|
-
container.selectStart();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
return true;
|
|
166
|
-
},
|
|
167
|
-
COMMAND_PRIORITY_EDITOR,
|
|
168
|
-
),
|
|
169
|
-
editor.registerCommand(
|
|
170
|
-
UPDATE_LAYOUT_COMMAND,
|
|
171
|
-
({template, nodeKey}) => {
|
|
172
|
-
editor.update(() => {
|
|
173
|
-
const container = $getNodeByKey<LexicalNode>(nodeKey);
|
|
174
|
-
|
|
175
|
-
if (!$isLayoutContainerNode(container)) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const itemsCount = getItemsCountFromTemplate(template);
|
|
180
|
-
const prevItemsCount = getItemsCountFromTemplate(
|
|
181
|
-
container.getTemplateColumns(),
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
// Add or remove extra columns if new template does not match existing one
|
|
185
|
-
if (itemsCount > prevItemsCount) {
|
|
186
|
-
for (let i = prevItemsCount; i < itemsCount; i++) {
|
|
187
|
-
container.append(
|
|
188
|
-
$createLayoutItemNode().append($createParagraphNode()),
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
} else if (itemsCount < prevItemsCount) {
|
|
192
|
-
for (let i = prevItemsCount - 1; i >= itemsCount; i--) {
|
|
193
|
-
const layoutItem = container.getChildAtIndex<LexicalNode>(i);
|
|
194
|
-
|
|
195
|
-
if ($isLayoutItemNode(layoutItem)) {
|
|
196
|
-
layoutItem.remove();
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
container.setTemplateColumns(template);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
return true;
|
|
205
|
-
},
|
|
206
|
-
COMMAND_PRIORITY_EDITOR,
|
|
207
|
-
),
|
|
208
|
-
|
|
209
|
-
editor.registerNodeTransform(LayoutItemNode, (node) => {
|
|
210
|
-
// Structure enforcing transformers for each node type. In case nesting structure is not
|
|
211
|
-
// "Container > Item" it'll unwrap nodes and convert it back
|
|
212
|
-
// to regular content.
|
|
213
|
-
const isRemoved = $removeIsolatedLayoutItem(node);
|
|
214
|
-
|
|
215
|
-
if (!isRemoved) {
|
|
216
|
-
// Layout item should always have a child. this function will listen
|
|
217
|
-
// for any empty layout item and fill it with a paragraph node
|
|
218
|
-
$fillLayoutItemIfEmpty(node);
|
|
219
|
-
}
|
|
220
|
-
}),
|
|
221
|
-
editor.registerNodeTransform(LayoutContainerNode, (node) => {
|
|
222
|
-
const children = node.getChildren<LexicalNode>();
|
|
223
|
-
if (!children.every($isLayoutItemNode)) {
|
|
224
|
-
for (const child of children) {
|
|
225
|
-
node.insertBefore(child);
|
|
226
|
-
}
|
|
227
|
-
node.remove();
|
|
228
|
-
}
|
|
229
|
-
}),
|
|
230
|
-
);
|
|
231
|
-
}, [editor]);
|
|
232
|
-
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function getItemsCountFromTemplate(template: string): number {
|
|
237
|
-
return template.trim().split(/\s+/).length;
|
|
238
|
-
}
|
|
@@ -1,36 +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 {LinkPlugin as LexicalLinkPlugin} from '@lexical/react/LexicalLinkPlugin';
|
|
12
|
-
import * as React from 'react';
|
|
13
|
-
|
|
14
|
-
import {validateUrl} from '../../utils/url';
|
|
15
|
-
|
|
16
|
-
type Props = {
|
|
17
|
-
hasLinkAttributes?: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default function LinkPlugin({
|
|
21
|
-
hasLinkAttributes = false,
|
|
22
|
-
}: Props): JSX.Element {
|
|
23
|
-
return (
|
|
24
|
-
<LexicalLinkPlugin
|
|
25
|
-
validateUrl={validateUrl}
|
|
26
|
-
attributes={
|
|
27
|
-
hasLinkAttributes
|
|
28
|
-
? {
|
|
29
|
-
rel: 'noopener noreferrer',
|
|
30
|
-
target: '_blank',
|
|
31
|
-
}
|
|
32
|
-
: undefined
|
|
33
|
-
}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
2
|
-
import {
|
|
3
|
-
$getSelection,
|
|
4
|
-
$isRangeSelection,
|
|
5
|
-
COMMAND_PRIORITY_LOW,
|
|
6
|
-
createCommand,
|
|
7
|
-
EditorConfig,
|
|
8
|
-
ElementNode,
|
|
9
|
-
LexicalEditor,
|
|
10
|
-
LexicalNode,
|
|
11
|
-
NodeKey,
|
|
12
|
-
} from "lexical";
|
|
13
|
-
import { $insertNodeToNearestRoot } from "@lexical/utils";
|
|
14
|
-
import { useEffect } from "react";
|
|
15
|
-
|
|
16
|
-
// Utility function to fetch metadata from a URL
|
|
17
|
-
async function fetchMetadata(url: string) {
|
|
18
|
-
try {
|
|
19
|
-
const proxyUrl = "https://api.allorigins.win/get?url=";
|
|
20
|
-
const response = await fetch(`${proxyUrl}${encodeURIComponent(url)}`);
|
|
21
|
-
const data = await response.json();
|
|
22
|
-
|
|
23
|
-
// Extract the HTML content from the proxy response
|
|
24
|
-
const html = data.contents;
|
|
25
|
-
|
|
26
|
-
// Parse the HTML using DOMParser
|
|
27
|
-
const parser = new DOMParser();
|
|
28
|
-
const doc = parser.parseFromString(html, "text/html");
|
|
29
|
-
|
|
30
|
-
// Helper function to extract meta tag content
|
|
31
|
-
const getMetaTagContent = (property: string) => {
|
|
32
|
-
const element =
|
|
33
|
-
doc.querySelector(`meta[property="${property}"]`) ||
|
|
34
|
-
doc.querySelector(`meta[name="${property}"]`);
|
|
35
|
-
return element ? element.getAttribute("content") : null;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// Extract metadata
|
|
39
|
-
const metadata = {
|
|
40
|
-
title:
|
|
41
|
-
doc.querySelector("title")?.textContent ||
|
|
42
|
-
getMetaTagContent("og:title") ||
|
|
43
|
-
"No title",
|
|
44
|
-
description:
|
|
45
|
-
getMetaTagContent("og:description") ||
|
|
46
|
-
getMetaTagContent("description") ||
|
|
47
|
-
"No description",
|
|
48
|
-
image: getMetaTagContent("og:image") || undefined, // Use a valid fallback image URL
|
|
49
|
-
website: getMetaTagContent("og:site_name") || new URL(url).hostname, // Use hostname as fallback
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return metadata;
|
|
53
|
-
} catch (error) {
|
|
54
|
-
return {
|
|
55
|
-
title: "No title",
|
|
56
|
-
description: "No description",
|
|
57
|
-
image: undefined,
|
|
58
|
-
website: new URL(url).hostname,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export class LinkWithMetaDataNode extends ElementNode {
|
|
64
|
-
__url: string | null;
|
|
65
|
-
__metadata: {
|
|
66
|
-
title: string;
|
|
67
|
-
description: string;
|
|
68
|
-
image?: string | undefined |null;
|
|
69
|
-
website: string;
|
|
70
|
-
} | null = null;
|
|
71
|
-
__editor: LexicalEditor;
|
|
72
|
-
|
|
73
|
-
constructor(url: string | null, editor: LexicalEditor, key?: NodeKey) {
|
|
74
|
-
super(key);
|
|
75
|
-
this.__url = url;
|
|
76
|
-
this.__editor = editor; // Store the editor instance
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static clone(node: LinkWithMetaDataNode): LinkWithMetaDataNode {
|
|
80
|
-
return new LinkWithMetaDataNode(node.__url, node.__editor, node.__key);
|
|
81
|
-
}
|
|
82
|
-
static importJSON(serializedNode: any): LinkWithMetaDataNode {
|
|
83
|
-
const node = $createLinkNode(serializedNode.url, serializedNode.__editor);
|
|
84
|
-
node.__metadata = serializedNode.metadata;
|
|
85
|
-
node.__url = serializedNode.url
|
|
86
|
-
|
|
87
|
-
return node;
|
|
88
|
-
}
|
|
89
|
-
exportJSON() {
|
|
90
|
-
return {
|
|
91
|
-
...super.exportJSON(),
|
|
92
|
-
url: this.__url,
|
|
93
|
-
metadata: this.__metadata,
|
|
94
|
-
type: "link-with-metadata",
|
|
95
|
-
version: 1,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static getType(): string {
|
|
100
|
-
return "link-with-metadata";
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Method to update metadata
|
|
104
|
-
setMetadata(metadata: {
|
|
105
|
-
title: string;
|
|
106
|
-
description: string;
|
|
107
|
-
image?: string;
|
|
108
|
-
website: string;
|
|
109
|
-
}) {
|
|
110
|
-
const writable = this.getWritable();
|
|
111
|
-
writable.__metadata = metadata;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
createDOM(): HTMLElement {
|
|
115
|
-
const elementDIV = document.createElement("div");
|
|
116
|
-
elementDIV.className ="dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-50 border border-zinc-200 bg-white/90 text-zinc-950 shadow-md w-full cursor-pointer p-3 rounded-sm border flex flex-row items-center justify-between";
|
|
117
|
-
elementDIV.setAttribute("contenteditable", "false");
|
|
118
|
-
|
|
119
|
-
// Create a container for the left and right sections
|
|
120
|
-
const container = document.createElement("div");
|
|
121
|
-
container.className = "flex flex-row w-full max-sm:flex-col max-sm:gap-y-2 justify-between items-start gap-x-2";
|
|
122
|
-
|
|
123
|
-
// Conditionally create the left container for the image
|
|
124
|
-
if (this.__metadata?.image) {
|
|
125
|
-
const leftContainer = document.createElement("div");
|
|
126
|
-
leftContainer.className = "flex w-full h-full max-w-[250px] max-h-[100px] min-h-[100px] order-6";
|
|
127
|
-
|
|
128
|
-
// Create the image element
|
|
129
|
-
const image = document.createElement("img");
|
|
130
|
-
image.src = this.__metadata.image;
|
|
131
|
-
image.alt = `image for ${this.__metadata.title}`;
|
|
132
|
-
image.className = "w-full h-[100px] rounded-lg object-cover";
|
|
133
|
-
leftContainer.appendChild(image);
|
|
134
|
-
|
|
135
|
-
// Append the left container to the main container
|
|
136
|
-
container.appendChild(leftContainer);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Right container for the text content
|
|
140
|
-
const rightContainer = document.createElement("div");
|
|
141
|
-
rightContainer.className = "flex flex-col flex-1 w-full flex-wrap items-start space-y-4";
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// Create the title as a clickable link
|
|
146
|
-
const titleLink = document.createElement("a");
|
|
147
|
-
titleLink.className = "font-bold break-words hover:underline";
|
|
148
|
-
titleLink.href = this.__url || "#"; // Use the URL or a fallback
|
|
149
|
-
titleLink.textContent = this.__url || "No URL provided";
|
|
150
|
-
titleLink.target = "_blank"; // Open link in a new tab
|
|
151
|
-
rightContainer.appendChild(titleLink);
|
|
152
|
-
|
|
153
|
-
// Create the description small element
|
|
154
|
-
const descriptionSmall = document.createElement("small");
|
|
155
|
-
descriptionSmall.className = "font-[400] dark:text-gray-200 text-gray-500";
|
|
156
|
-
descriptionSmall.textContent =
|
|
157
|
-
this.__metadata?.description || "Loading metadata...";
|
|
158
|
-
rightContainer.appendChild(descriptionSmall);
|
|
159
|
-
|
|
160
|
-
// Create the source small element
|
|
161
|
-
const sourceSmall = document.createElement("small");
|
|
162
|
-
sourceSmall.className = "text-sm mt-4 font-[400] dark:text-gray-300 text-gray-500/50";
|
|
163
|
-
sourceSmall.textContent = this.__metadata?.website || "";
|
|
164
|
-
rightContainer.appendChild(sourceSmall);
|
|
165
|
-
|
|
166
|
-
// Append the right container to the main container
|
|
167
|
-
container.appendChild(rightContainer);
|
|
168
|
-
|
|
169
|
-
// Append the main container to the root div
|
|
170
|
-
elementDIV.appendChild(container);
|
|
171
|
-
|
|
172
|
-
// Fetch metadata and update the node
|
|
173
|
-
if (this.__url && !this.__metadata) {
|
|
174
|
-
fetchMetadata(this.__url)
|
|
175
|
-
.then((metadata) => {
|
|
176
|
-
// Use editor.update() to perform state updates
|
|
177
|
-
this.__editor.update(() => {
|
|
178
|
-
this.setMetadata(metadata);
|
|
179
|
-
});
|
|
180
|
-
})
|
|
181
|
-
.catch((error) => {
|
|
182
|
-
console.error("Error fetching metadata:", error);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return elementDIV;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
updateDOM(prevNode: LinkWithMetaDataNode, dom: HTMLElement): boolean {
|
|
190
|
-
// Check if metadata has changed
|
|
191
|
-
if (this.__metadata !== prevNode.__metadata) {
|
|
192
|
-
const container = dom.querySelector("div");
|
|
193
|
-
const image = dom.querySelector("img");
|
|
194
|
-
const titleLink = dom.querySelector("a");
|
|
195
|
-
const descriptionSmall = dom.querySelector("small:nth-of-type(1)");
|
|
196
|
-
const sourceSmall = dom.querySelector("small:nth-of-type(2)");
|
|
197
|
-
|
|
198
|
-
if (titleLink && descriptionSmall && sourceSmall) {
|
|
199
|
-
titleLink.href = this.__url || "#";
|
|
200
|
-
titleLink.textContent =
|
|
201
|
-
this.__metadata?.title || this.__url || "No URL provided";
|
|
202
|
-
descriptionSmall.textContent =
|
|
203
|
-
this.__metadata?.description || "Loading metadata...";
|
|
204
|
-
sourceSmall.textContent = this.__metadata?.website || "";
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Handle image updates
|
|
208
|
-
if (this.__metadata?.image) {
|
|
209
|
-
if (!image) {
|
|
210
|
-
const leftContainer = document.createElement("div");
|
|
211
|
-
leftContainer.className = "flex h-full flex-shrink-0 order-6";
|
|
212
|
-
|
|
213
|
-
const newImage = document.createElement("img");
|
|
214
|
-
newImage.src = this.__metadata.image;
|
|
215
|
-
newImage.alt = "Custom Image";
|
|
216
|
-
newImage.className = "w-24 min-h-24 max-[250px] h-[200px] rounded-lg object-fill";
|
|
217
|
-
leftContainer.appendChild(newImage);
|
|
218
|
-
|
|
219
|
-
// Insert the left container before the right container
|
|
220
|
-
container?.insertBefore(leftContainer, container.firstChild);
|
|
221
|
-
} else {
|
|
222
|
-
image.src = this.__metadata.image;
|
|
223
|
-
}
|
|
224
|
-
} else if (image) {
|
|
225
|
-
|
|
226
|
-
image.remove();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
export function $createLinkNode(
|
|
236
|
-
url: string | null,
|
|
237
|
-
editor: LexicalEditor
|
|
238
|
-
): LinkWithMetaDataNode {
|
|
239
|
-
return new LinkWithMetaDataNode(url, editor);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export function $isLinkNode(node: LexicalNode): node is LinkWithMetaDataNode {
|
|
243
|
-
return node instanceof LinkWithMetaDataNode;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export const TOGGLE_LINK_COMMAND_LinkWithMetaDataNode = createCommand<string | null>("toggleLink");
|
|
247
|
-
|
|
248
|
-
export function LinkWithMetaDataPlugin(): null {
|
|
249
|
-
const [editor] = useLexicalComposerContext();
|
|
250
|
-
|
|
251
|
-
useEffect(() => {
|
|
252
|
-
if (!editor.hasNodes([LinkWithMetaDataNode])) {
|
|
253
|
-
throw new Error("LinkWithMetaDataPlugin: LinkWithMetaDataNode not registered on editor");
|
|
254
|
-
}
|
|
255
|
-
}, [editor]);
|
|
256
|
-
|
|
257
|
-
editor.registerCommand(
|
|
258
|
-
TOGGLE_LINK_COMMAND_LinkWithMetaDataNode,
|
|
259
|
-
(url: string | null) => {
|
|
260
|
-
const selection = $getSelection();
|
|
261
|
-
if ($isRangeSelection(selection)) {
|
|
262
|
-
const linkNode = $createLinkNode(url, editor);
|
|
263
|
-
$insertNodeToNearestRoot(linkNode);
|
|
264
|
-
}
|
|
265
|
-
return true;
|
|
266
|
-
},
|
|
267
|
-
COMMAND_PRIORITY_LOW
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import type {JSX} from 'react';
|
|
3
|
-
|
|
4
|
-
import {MarkdownShortcutPlugin} from '@lexical/react/LexicalMarkdownShortcutPlugin';
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
|
|
7
|
-
import {PLAYGROUND_TRANSFORMERS} from '../MarkdownTransformers';
|
|
8
|
-
|
|
9
|
-
export default function MarkdownPlugin(): JSX.Element {
|
|
10
|
-
return <MarkdownShortcutPlugin transformers={PLAYGROUND_TRANSFORMERS} />;
|
|
11
|
-
}
|