@collabchron/notiq 1.1.12 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AICommandBarPlugin-ZEC755KY.mjs +27 -0
- package/dist/{AIDialog-RHRYHSVN.mjs → AIDialog-HJW6PQPR.mjs} +11 -12
- package/dist/{AudioComponent-CKLMLB5T.mjs → AudioComponent-W5XMZPQB.mjs} +10 -6
- package/dist/{DynamicBlockComponent-2LOADZUX.mjs → DynamicBlockComponent-CHRL2GAQ.mjs} +7 -6
- package/dist/{EquationComponent-4NFG55NQ.mjs → EquationComponent-GNQHG53L.mjs} +26 -7
- package/dist/{ExcalidrawComponent-BMSYIPP6.mjs → ExcalidrawComponent-POMYXDSG.mjs} +33 -6
- package/dist/{FileComponent-Y56MX5QD.mjs → FileComponent-EOVCH4V5.mjs} +9 -5
- package/dist/{HintComponet-ET7M2Q7S.mjs → HintComponet-QXL5ESND.mjs} +32 -8
- package/dist/{InlineImageComponent-FVTA4LXZ.mjs → InlineImageComponent-KDN3VGZC.mjs} +8 -3
- package/dist/{StoryBuilderComponent-JN4ZPZOW.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +8 -9
- package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
- package/dist/chunk-5CJZC5IB.mjs +9086 -0
- package/dist/{chunk-FO7M3X2B.mjs → chunk-6NK5DONB.mjs} +1 -1
- package/dist/{chunk-N6ILV6NF.mjs → chunk-ACW4DLVO.mjs} +21 -7
- package/dist/chunk-BCGD2YXP.mjs +574 -0
- package/dist/{chunk-TC3IISJZ.mjs → chunk-BTR3TPIN.mjs} +18 -5
- package/dist/{chunk-ZYJ7KABY.mjs → chunk-CQCS5YPS.mjs} +3 -5
- package/dist/{chunk-T2UBAZ66.mjs → chunk-D4UBNSUW.mjs} +1 -1
- package/dist/{chunk-KNW2CGIP.mjs → chunk-DBRZIA43.mjs} +4 -1
- package/dist/{chunk-CDAMHK63.mjs → chunk-GJK2L7ZM.mjs} +23 -2
- package/dist/{chunk-ELBTVBTS.mjs → chunk-IKYVBTCJ.mjs} +43 -20
- package/dist/chunk-IXRA5D53.mjs +10447 -0
- package/dist/{chunk-W6VQSFE5.mjs → chunk-J2CEQXG4.mjs} +1 -1
- package/dist/{chunk-43Z4Z2KD.mjs → chunk-JTNLN4JI.mjs} +1 -1
- package/dist/{chunk-OE5JRLCN.mjs → chunk-ONOHG5NB.mjs} +6 -4
- package/dist/{chunk-QNIY45SF.mjs → chunk-OO42URWA.mjs} +27 -6
- package/dist/chunk-PBVRSNGU.mjs +129 -0
- package/dist/chunk-QCS57TIF.mjs +1794 -0
- package/dist/chunk-RNEIJRUS.mjs +60 -0
- package/dist/chunk-TJPTGECP.mjs +1556 -0
- package/dist/{chunk-XYMXGU4T.mjs → chunk-TMYRA2W4.mjs} +1 -1
- package/dist/{chunk-ZFV2HGD3.mjs → chunk-UNEFOZTS.mjs} +1 -1
- package/dist/chunk-X4NI7EQS.mjs +282 -0
- package/dist/{chunk-5D4JF3ZZ.mjs → chunk-XAJ4GACN.mjs} +171 -49
- package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
- package/dist/components/editor/index.d.ts +1 -1
- package/dist/components/editor/nodes/EquationNode/EquationNode.d.ts +1 -0
- package/dist/components/editor/nodes/Hint/index.d.ts +2 -1
- package/dist/components/editor/plugins/AICommandBarPlugin/index.d.ts +73 -1
- package/dist/components/editor/plugins/DraggableBlockPlugin/index.d.ts +25 -3
- package/dist/components/editor/plugins/InlineCopilotPlugin/index.d.ts +16 -3
- package/dist/components/editor/plugins/LinkWithMetaData/index.d.ts +20 -25
- package/dist/components/editor/plugins/MarkdownPastePlugin/index.d.ts +5 -0
- package/dist/components/editor/plugins/MarkdownTransformers/index.d.ts +2 -0
- package/dist/components/editor/plugins/SlashCommand/index.d.ts +18 -1
- package/dist/components/editor/plugins/SmartTypographyPlugin/index.d.ts +26 -0
- package/dist/components/editor/utils/aiStream.d.ts +27 -0
- package/dist/components/editor/utils/excalidrawDiagramBuilder.d.ts +29 -0
- package/dist/components/editor/utils/markdownTransformers.d.ts +4 -1
- package/dist/components/editor/utils/url.d.ts +16 -4
- package/dist/components/providers/AIContext.d.ts +8 -0
- package/dist/components/ui/equation/equationTypography.d.ts +23 -0
- package/dist/core/extension.d.ts +3 -1
- package/dist/core/extensions/blocks-kit.d.ts +22 -1
- package/dist/core/extensions/copilot-and-collab.d.ts +15 -1
- package/dist/core/react/NotiqContent.d.ts +4 -1
- package/dist/core/react/index.d.ts +1 -0
- package/dist/core/react/node-renderers.d.ts +73 -0
- package/dist/core.js +15429 -13116
- package/dist/core.mjs +47 -39
- package/dist/hooks/instructions-messages.d.ts +13 -4
- package/dist/{image-QPB2CVXP.mjs → image-AL6PHM2A.mjs} +17 -12
- package/dist/index.js +15526 -13194
- package/dist/index.mjs +64 -60
- package/dist/{insert-audio-I3PD6JFS.mjs → insert-audio-CRWR7EO5.mjs} +4 -6
- package/dist/{insert-file-PHR7XL4V.mjs → insert-file-I73AZW3L.mjs} +4 -6
- package/dist/{insert-gif-R5ZO4JHC.mjs → insert-gif-KWRC3ACT.mjs} +1 -1
- package/dist/{insert-image-PLBZELHK.mjs → insert-image-XIY6BGW5.mjs} +4 -3
- package/dist/{insert-poll-6BCIFY5G.mjs → insert-poll-J5YVZNZ4.mjs} +4 -3
- package/dist/{insert-table-ZRJP6X52.mjs → insert-table-OIMJRFFK.mjs} +1 -1
- package/dist/{poll-component-VHMM5KKZ.mjs → poll-component-TVHXIKGQ.mjs} +3 -2
- package/dist/react.js +14747 -12554
- package/dist/react.mjs +40 -38
- package/dist/{stepper-KNITDVLG.mjs → stepper-ILF7YXTO.mjs} +63 -73
- package/dist/styles/notiq.css +1 -1
- package/package.json +2 -2
- package/src/styles/notiq.css +20 -0
- package/dist/AICommandBarPlugin-TADJ3X2Y.mjs +0 -12
- package/dist/CodeActionMenuPlugin-FGH6HZLL.mjs +0 -14
- package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
- package/dist/CollaboratorsBar-AMPIAUOY.mjs +0 -20
- package/dist/CommentsPlugin-SDJJTUGK.mjs +0 -19
- package/dist/ExcalidrawPlugin-QLPGJPSX.mjs +0 -14
- package/dist/ExportPlugin-MJHYKQZJ.mjs +0 -43
- package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
- package/dist/FloatingTextFormatToolbarPlugin-BXCPN3KD.mjs +0 -45
- package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
- package/dist/MobileToolbar-KV5DX4ED.mjs +0 -982
- package/dist/SlashCommand-SPR7G5EI.mjs +0 -39
- package/dist/TableCellActionMenuPlugin-YWBA64J7.mjs +0 -838
- package/dist/TableHoverActionsPlugin-2EIXHEXN.mjs +0 -265
- package/dist/TemplatePlugin-HNTPEXBB.mjs +0 -9
- package/dist/ToolbarPlugin-F52PVNXU.mjs +0 -823
- package/dist/VersionHistoryPlugin-YWGCREKA.mjs +0 -371
- package/dist/background-color-RW5JYLMG.mjs +0 -425
- package/dist/block-format-TODFREE2.mjs +0 -14
- package/dist/chunk-22ZIL6NH.mjs +0 -88
- package/dist/chunk-2LNT36RL.mjs +0 -555
- package/dist/chunk-37LC44W3.mjs +0 -2677
- package/dist/chunk-3IILA3IP.mjs +0 -28
- package/dist/chunk-4DVIYZVB.mjs +0 -193
- package/dist/chunk-4FFTOZGJ.mjs +0 -103
- package/dist/chunk-4UMUPCDK.mjs +0 -68
- package/dist/chunk-6D6QLRYR.mjs +0 -238
- package/dist/chunk-6FQFPPLG.mjs +0 -785
- package/dist/chunk-ACV47ZKE.mjs +0 -201
- package/dist/chunk-BGV62GC2.mjs +0 -26
- package/dist/chunk-C4JWLBYN.mjs +0 -132
- package/dist/chunk-CLRSETYQ.mjs +0 -431
- package/dist/chunk-D3IOUQFR.mjs +0 -441
- package/dist/chunk-EEBA6OAH.mjs +0 -59
- package/dist/chunk-EIZMKFHF.mjs +0 -32
- package/dist/chunk-ENH2IOHI.mjs +0 -1828
- package/dist/chunk-EVPWKNE4.mjs +0 -27
- package/dist/chunk-HOZ4QRFV.mjs +0 -536
- package/dist/chunk-IAFCQV3Z.mjs +0 -349
- package/dist/chunk-J6ZUY5BY.mjs +0 -202
- package/dist/chunk-K5OAFEVY.mjs +0 -191
- package/dist/chunk-KXRLARGI.mjs +0 -26
- package/dist/chunk-LBGM4VVZ.mjs +0 -409
- package/dist/chunk-LLGVCM7M.mjs +0 -809
- package/dist/chunk-LU2XWLOE.mjs +0 -219
- package/dist/chunk-LVRJM45C.mjs +0 -171
- package/dist/chunk-MSAO3YFB.mjs +0 -144
- package/dist/chunk-N3KDPSRI.mjs +0 -496
- package/dist/chunk-OXWTZV3U.mjs +0 -174
- package/dist/chunk-PD5K4AGP.mjs +0 -64
- package/dist/chunk-PFH63ZU4.mjs +0 -33
- package/dist/chunk-R7WFRENU.mjs +0 -262
- package/dist/chunk-RAVYEEIC.mjs +0 -36
- package/dist/chunk-RJQTA6HG.mjs +0 -358
- package/dist/chunk-SAOJHVPE.mjs +0 -153
- package/dist/chunk-SYUCM5G5.mjs +0 -111
- package/dist/chunk-VGAX6YEY.mjs +0 -399
- package/dist/chunk-VNDDDXGH.mjs +0 -682
- package/dist/chunk-WUVIQCX7.mjs +0 -944
- package/dist/chunk-XNJNT6PC.mjs +0 -1701
- package/dist/chunk-XYLTLGY5.mjs +0 -775
- package/dist/chunk-ZKZ7MLSS.mjs +0 -165
- package/dist/color-S55XFDYQ.mjs +0 -13
- package/dist/font-IJKFR4BM.mjs +0 -12
- package/dist/font-size-3HMJHKO2.mjs +0 -15
- package/dist/insert-node-DGCZBGKG.mjs +0 -243
- package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
- package/dist/text-align-TEB4S52S.mjs +0 -121
- package/dist/text-format-T3IY7FBI.mjs +0 -15
package/dist/chunk-K5OAFEVY.mjs
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_react_shim
|
|
3
|
-
} from "./chunk-WYCFGRFJ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts
|
|
6
|
-
init_react_shim();
|
|
7
|
-
|
|
8
|
-
// src/components/editor/utils/environment.ts
|
|
9
|
-
init_react_shim();
|
|
10
|
-
|
|
11
|
-
// src/components/editor/utils/canUseDOM.ts
|
|
12
|
-
init_react_shim();
|
|
13
|
-
var CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
14
|
-
|
|
15
|
-
// src/components/editor/utils/environment.ts
|
|
16
|
-
var documentMode = CAN_USE_DOM && "documentMode" in document ? document.documentMode : null;
|
|
17
|
-
var IS_APPLE = CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
18
|
-
var IS_FIREFOX = CAN_USE_DOM && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
|
|
19
|
-
var CAN_USE_BEFORE_INPUT = CAN_USE_DOM && "InputEvent" in window && !documentMode ? "getTargetRanges" in new window.InputEvent("input") : false;
|
|
20
|
-
var IS_SAFARI = CAN_USE_DOM && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
|
|
21
|
-
var IS_IOS = CAN_USE_DOM && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
|
22
|
-
var IS_ANDROID = CAN_USE_DOM && /Android/.test(navigator.userAgent);
|
|
23
|
-
var IS_CHROME = CAN_USE_DOM && /^(?=.*Chrome).*/i.test(navigator.userAgent);
|
|
24
|
-
var IS_APPLE_WEBKIT = CAN_USE_DOM && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !IS_CHROME;
|
|
25
|
-
|
|
26
|
-
// src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts
|
|
27
|
-
var SHORTCUTS = Object.freeze({
|
|
28
|
-
// (Ctrl|⌘) + (Alt|Option) + <key> shortcuts
|
|
29
|
-
NORMAL: IS_APPLE ? "\u2318+Opt+0" : "Ctrl+Alt+0",
|
|
30
|
-
HEADING1: IS_APPLE ? "\u2318+Opt+1" : "Ctrl+Alt+1",
|
|
31
|
-
HEADING2: IS_APPLE ? "\u2318+Opt+2" : "Ctrl+Alt+2",
|
|
32
|
-
HEADING3: IS_APPLE ? "\u2318+Opt+3" : "Ctrl+Alt+3",
|
|
33
|
-
BULLET_LIST: IS_APPLE ? "\u2318+Opt+4" : "Ctrl+Alt+4",
|
|
34
|
-
NUMBERED_LIST: IS_APPLE ? "\u2318+Opt+5" : "Ctrl+Alt+5",
|
|
35
|
-
CHECK_LIST: IS_APPLE ? "\u2318+Opt+6" : "Ctrl+Alt+6",
|
|
36
|
-
CODE_BLOCK: IS_APPLE ? "\u2318+Opt+C" : "Ctrl+Alt+C",
|
|
37
|
-
QUOTE: IS_APPLE ? "\u2318+Opt+Q" : "Ctrl+Alt+Q",
|
|
38
|
-
// (Ctrl|⌘) + Shift + <key> shortcuts
|
|
39
|
-
INCREASE_FONT_SIZE: IS_APPLE ? "\u2318+Shift+." : "Ctrl+Shift+.",
|
|
40
|
-
DECREASE_FONT_SIZE: IS_APPLE ? "\u2318+Shift+," : "Ctrl+Shift+,",
|
|
41
|
-
INSERT_CODE_BLOCK: IS_APPLE ? "\u2318+Shift+C" : "Ctrl+Shift+C",
|
|
42
|
-
STRIKETHROUGH: IS_APPLE ? "\u2318+Shift+S" : "Ctrl+Shift+S",
|
|
43
|
-
LOWERCASE: IS_APPLE ? "\u2318+Shift+1" : "Ctrl+Shift+1",
|
|
44
|
-
UPPERCASE: IS_APPLE ? "\u2318+Shift+2" : "Ctrl+Shift+2",
|
|
45
|
-
CAPITALIZE: IS_APPLE ? "\u2318+Shift+3" : "Ctrl+Shift+3",
|
|
46
|
-
CENTER_ALIGN: IS_APPLE ? "\u2318+Shift+E" : "Ctrl+Shift+E",
|
|
47
|
-
JUSTIFY_ALIGN: IS_APPLE ? "\u2318+Shift+J" : "Ctrl+Shift+J",
|
|
48
|
-
LEFT_ALIGN: IS_APPLE ? "\u2318+Shift+L" : "Ctrl+Shift+L",
|
|
49
|
-
RIGHT_ALIGN: IS_APPLE ? "\u2318+Shift+R" : "Ctrl+Shift+R",
|
|
50
|
-
// (Ctrl|⌘) + <key> shortcuts
|
|
51
|
-
SUBSCRIPT: IS_APPLE ? "\u2318+," : "Ctrl+,",
|
|
52
|
-
SUPERSCRIPT: IS_APPLE ? "\u2318+." : "Ctrl+.",
|
|
53
|
-
INDENT: IS_APPLE ? "\u2318+]" : "Ctrl+]",
|
|
54
|
-
OUTDENT: IS_APPLE ? "\u2318+[" : "Ctrl+[",
|
|
55
|
-
CLEAR_FORMATTING: IS_APPLE ? "\u2318+\\" : "Ctrl+\\",
|
|
56
|
-
REDO: IS_APPLE ? "\u2318+Shift+Z" : "Ctrl+Y",
|
|
57
|
-
UNDO: IS_APPLE ? "\u2318+Z" : "Ctrl+Z",
|
|
58
|
-
BOLD: IS_APPLE ? "\u2318+B" : "Ctrl+B",
|
|
59
|
-
ITALIC: IS_APPLE ? "\u2318+I" : "Ctrl+I",
|
|
60
|
-
UNDERLINE: IS_APPLE ? "\u2318+U" : "Ctrl+U",
|
|
61
|
-
INSERT_LINK: IS_APPLE ? "\u2318+K" : "Ctrl+K"
|
|
62
|
-
});
|
|
63
|
-
function controlOrMeta(metaKey, ctrlKey) {
|
|
64
|
-
return IS_APPLE ? metaKey : ctrlKey;
|
|
65
|
-
}
|
|
66
|
-
function isFormatParagraph(event) {
|
|
67
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
68
|
-
return (code === "Numpad0" || code === "Digit0") && !shiftKey && altKey && controlOrMeta(metaKey, ctrlKey);
|
|
69
|
-
}
|
|
70
|
-
function isFormatHeading(event) {
|
|
71
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
72
|
-
const keyNumber = code[code.length - 1];
|
|
73
|
-
return ["1", "2", "3"].includes(keyNumber) && !shiftKey && altKey && controlOrMeta(metaKey, ctrlKey);
|
|
74
|
-
}
|
|
75
|
-
function isFormatBulletList(event) {
|
|
76
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
77
|
-
return (code === "Numpad4" || code === "Digit4") && !shiftKey && altKey && controlOrMeta(metaKey, ctrlKey);
|
|
78
|
-
}
|
|
79
|
-
function isFormatNumberedList(event) {
|
|
80
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
81
|
-
return (code === "Numpad5" || code === "Digit5") && !shiftKey && altKey && controlOrMeta(metaKey, ctrlKey);
|
|
82
|
-
}
|
|
83
|
-
function isFormatCheckList(event) {
|
|
84
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
85
|
-
return (code === "Numpad6" || code === "Digit6") && !shiftKey && altKey && controlOrMeta(metaKey, ctrlKey);
|
|
86
|
-
}
|
|
87
|
-
function isFormatCode(event) {
|
|
88
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
89
|
-
return code === "KeyC" && !shiftKey && altKey && controlOrMeta(metaKey, ctrlKey);
|
|
90
|
-
}
|
|
91
|
-
function isFormatQuote(event) {
|
|
92
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
93
|
-
return code === "KeyQ" && !shiftKey && altKey && controlOrMeta(metaKey, ctrlKey);
|
|
94
|
-
}
|
|
95
|
-
function isLowercase(event) {
|
|
96
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
97
|
-
return (code === "Numpad1" || code === "Digit1") && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
98
|
-
}
|
|
99
|
-
function isUppercase(event) {
|
|
100
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
101
|
-
return (code === "Numpad2" || code === "Digit2") && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
102
|
-
}
|
|
103
|
-
function isCapitalize(event) {
|
|
104
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
105
|
-
return (code === "Numpad3" || code === "Digit3") && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
106
|
-
}
|
|
107
|
-
function isStrikeThrough(event) {
|
|
108
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
109
|
-
return code === "KeyS" && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
110
|
-
}
|
|
111
|
-
function isIndent(event) {
|
|
112
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
113
|
-
return code === "BracketRight" && !shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
114
|
-
}
|
|
115
|
-
function isOutdent(event) {
|
|
116
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
117
|
-
return code === "BracketLeft" && !shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
118
|
-
}
|
|
119
|
-
function isCenterAlign(event) {
|
|
120
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
121
|
-
return code === "KeyE" && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
122
|
-
}
|
|
123
|
-
function isLeftAlign(event) {
|
|
124
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
125
|
-
return code === "KeyL" && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
126
|
-
}
|
|
127
|
-
function isRightAlign(event) {
|
|
128
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
129
|
-
return code === "KeyR" && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
130
|
-
}
|
|
131
|
-
function isJustifyAlign(event) {
|
|
132
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
133
|
-
return code === "KeyJ" && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
134
|
-
}
|
|
135
|
-
function isSubscript(event) {
|
|
136
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
137
|
-
return code === "Comma" && !shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
138
|
-
}
|
|
139
|
-
function isSuperscript(event) {
|
|
140
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
141
|
-
return code === "Period" && !shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
142
|
-
}
|
|
143
|
-
function isInsertCodeBlock(event) {
|
|
144
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
145
|
-
return code === "KeyC" && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
146
|
-
}
|
|
147
|
-
function isIncreaseFontSize(event) {
|
|
148
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
149
|
-
return code === "Period" && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
150
|
-
}
|
|
151
|
-
function isDecreaseFontSize(event) {
|
|
152
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
153
|
-
return code === "Comma" && shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
154
|
-
}
|
|
155
|
-
function isClearFormatting(event) {
|
|
156
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
157
|
-
return code === "Backslash" && !shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
158
|
-
}
|
|
159
|
-
function isInsertLink(event) {
|
|
160
|
-
const { code, shiftKey, altKey, metaKey, ctrlKey } = event;
|
|
161
|
-
return code === "KeyK" && !shiftKey && !altKey && controlOrMeta(metaKey, ctrlKey);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export {
|
|
165
|
-
CAN_USE_DOM,
|
|
166
|
-
SHORTCUTS,
|
|
167
|
-
isFormatParagraph,
|
|
168
|
-
isFormatHeading,
|
|
169
|
-
isFormatBulletList,
|
|
170
|
-
isFormatNumberedList,
|
|
171
|
-
isFormatCheckList,
|
|
172
|
-
isFormatCode,
|
|
173
|
-
isFormatQuote,
|
|
174
|
-
isLowercase,
|
|
175
|
-
isUppercase,
|
|
176
|
-
isCapitalize,
|
|
177
|
-
isStrikeThrough,
|
|
178
|
-
isIndent,
|
|
179
|
-
isOutdent,
|
|
180
|
-
isCenterAlign,
|
|
181
|
-
isLeftAlign,
|
|
182
|
-
isRightAlign,
|
|
183
|
-
isJustifyAlign,
|
|
184
|
-
isSubscript,
|
|
185
|
-
isSuperscript,
|
|
186
|
-
isInsertCodeBlock,
|
|
187
|
-
isIncreaseFontSize,
|
|
188
|
-
isDecreaseFontSize,
|
|
189
|
-
isClearFormatting,
|
|
190
|
-
isInsertLink
|
|
191
|
-
};
|
package/dist/chunk-KXRLARGI.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_react_shim
|
|
3
|
-
} from "./chunk-WYCFGRFJ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/components/editor/utils/getSelectedNode.ts
|
|
6
|
-
init_react_shim();
|
|
7
|
-
import { $isAtNodeEnd } from "@lexical/selection";
|
|
8
|
-
function getSelectedNode(selection) {
|
|
9
|
-
const anchor = selection.anchor;
|
|
10
|
-
const focus = selection.focus;
|
|
11
|
-
const anchorNode = selection.anchor.getNode();
|
|
12
|
-
const focusNode = selection.focus.getNode();
|
|
13
|
-
if (anchorNode === focusNode) {
|
|
14
|
-
return anchorNode;
|
|
15
|
-
}
|
|
16
|
-
const isBackward = selection.isBackward();
|
|
17
|
-
if (isBackward) {
|
|
18
|
-
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
19
|
-
} else {
|
|
20
|
-
return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
getSelectedNode
|
|
26
|
-
};
|
package/dist/chunk-LBGM4VVZ.mjs
DELETED
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LayoutContainerNode,
|
|
3
|
-
LayoutItemNode
|
|
4
|
-
} from "./chunk-XYLTLGY5.mjs";
|
|
5
|
-
import {
|
|
6
|
-
CollapsibleContainerNode,
|
|
7
|
-
CollapsibleContentNode,
|
|
8
|
-
CollapsibleTitleNode
|
|
9
|
-
} from "./chunk-4DVIYZVB.mjs";
|
|
10
|
-
import {
|
|
11
|
-
InlineImageNode,
|
|
12
|
-
StepperNode
|
|
13
|
-
} from "./chunk-LLGVCM7M.mjs";
|
|
14
|
-
import {
|
|
15
|
-
FigmaNode,
|
|
16
|
-
TweetNode,
|
|
17
|
-
YouTubeNode
|
|
18
|
-
} from "./chunk-VGAX6YEY.mjs";
|
|
19
|
-
import {
|
|
20
|
-
PollNode
|
|
21
|
-
} from "./chunk-N6ILV6NF.mjs";
|
|
22
|
-
import {
|
|
23
|
-
StoryBuilderNode
|
|
24
|
-
} from "./chunk-T2UBAZ66.mjs";
|
|
25
|
-
import {
|
|
26
|
-
DynamicBlockNode
|
|
27
|
-
} from "./chunk-43Z4Z2KD.mjs";
|
|
28
|
-
import {
|
|
29
|
-
AudioNode
|
|
30
|
-
} from "./chunk-XYMXGU4T.mjs";
|
|
31
|
-
import {
|
|
32
|
-
FileNode
|
|
33
|
-
} from "./chunk-ZFV2HGD3.mjs";
|
|
34
|
-
import {
|
|
35
|
-
ImageNode
|
|
36
|
-
} from "./chunk-ELBTVBTS.mjs";
|
|
37
|
-
import {
|
|
38
|
-
ExcalidrawNode
|
|
39
|
-
} from "./chunk-QNIY45SF.mjs";
|
|
40
|
-
import {
|
|
41
|
-
EquationNode
|
|
42
|
-
} from "./chunk-KNW2CGIP.mjs";
|
|
43
|
-
import {
|
|
44
|
-
Hint
|
|
45
|
-
} from "./chunk-7QRJVZQY.mjs";
|
|
46
|
-
import {
|
|
47
|
-
__spreadProps,
|
|
48
|
-
__spreadValues,
|
|
49
|
-
init_react_shim
|
|
50
|
-
} from "./chunk-WYCFGRFJ.mjs";
|
|
51
|
-
|
|
52
|
-
// src/components/editor/plugins/LinkWithMetaData/index.tsx
|
|
53
|
-
init_react_shim();
|
|
54
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
55
|
-
import {
|
|
56
|
-
$getSelection,
|
|
57
|
-
$isRangeSelection,
|
|
58
|
-
COMMAND_PRIORITY_LOW,
|
|
59
|
-
createCommand,
|
|
60
|
-
ElementNode
|
|
61
|
-
} from "lexical";
|
|
62
|
-
import { $insertNodeToNearestRoot } from "@lexical/utils";
|
|
63
|
-
import { useEffect } from "react";
|
|
64
|
-
async function fetchMetadata(url) {
|
|
65
|
-
var _a;
|
|
66
|
-
try {
|
|
67
|
-
const proxyUrl = "https://api.allorigins.win/get?url=";
|
|
68
|
-
const response = await fetch(`${proxyUrl}${encodeURIComponent(url)}`);
|
|
69
|
-
const data = await response.json();
|
|
70
|
-
const html = data.contents;
|
|
71
|
-
const parser = new DOMParser();
|
|
72
|
-
const doc = parser.parseFromString(html, "text/html");
|
|
73
|
-
const getMetaTagContent = (property) => {
|
|
74
|
-
const element = doc.querySelector(`meta[property="${property}"]`) || doc.querySelector(`meta[name="${property}"]`);
|
|
75
|
-
return element ? element.getAttribute("content") : null;
|
|
76
|
-
};
|
|
77
|
-
const metadata = {
|
|
78
|
-
title: ((_a = doc.querySelector("title")) == null ? void 0 : _a.textContent) || getMetaTagContent("og:title") || "No title",
|
|
79
|
-
description: getMetaTagContent("og:description") || getMetaTagContent("description") || "No description",
|
|
80
|
-
image: getMetaTagContent("og:image") || void 0,
|
|
81
|
-
// Use a valid fallback image URL
|
|
82
|
-
website: getMetaTagContent("og:site_name") || new URL(url).hostname
|
|
83
|
-
// Use hostname as fallback
|
|
84
|
-
};
|
|
85
|
-
return metadata;
|
|
86
|
-
} catch (error) {
|
|
87
|
-
return {
|
|
88
|
-
title: "No title",
|
|
89
|
-
description: "No description",
|
|
90
|
-
image: void 0,
|
|
91
|
-
website: new URL(url).hostname
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
var LinkWithMetaDataNode = class _LinkWithMetaDataNode extends ElementNode {
|
|
96
|
-
constructor(url, editor, key) {
|
|
97
|
-
super(key);
|
|
98
|
-
this.__metadata = null;
|
|
99
|
-
this.__url = url;
|
|
100
|
-
this.__editor = editor;
|
|
101
|
-
}
|
|
102
|
-
static clone(node) {
|
|
103
|
-
return new _LinkWithMetaDataNode(node.__url, node.__editor, node.__key);
|
|
104
|
-
}
|
|
105
|
-
static importJSON(serializedNode) {
|
|
106
|
-
const node = $createLinkNode(serializedNode.url, serializedNode.__editor);
|
|
107
|
-
node.__metadata = serializedNode.metadata;
|
|
108
|
-
node.__url = serializedNode.url;
|
|
109
|
-
return node;
|
|
110
|
-
}
|
|
111
|
-
exportJSON() {
|
|
112
|
-
return __spreadProps(__spreadValues({}, super.exportJSON()), {
|
|
113
|
-
url: this.__url,
|
|
114
|
-
metadata: this.__metadata,
|
|
115
|
-
type: "link-with-metadata",
|
|
116
|
-
version: 1
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
static getType() {
|
|
120
|
-
return "link-with-metadata";
|
|
121
|
-
}
|
|
122
|
-
// Method to update metadata
|
|
123
|
-
setMetadata(metadata) {
|
|
124
|
-
const writable = this.getWritable();
|
|
125
|
-
writable.__metadata = metadata;
|
|
126
|
-
}
|
|
127
|
-
createDOM() {
|
|
128
|
-
var _a, _b, _c;
|
|
129
|
-
const elementDIV = document.createElement("div");
|
|
130
|
-
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";
|
|
131
|
-
elementDIV.setAttribute("contenteditable", "false");
|
|
132
|
-
const container = document.createElement("div");
|
|
133
|
-
container.className = "flex flex-row w-full max-sm:flex-col max-sm:gap-y-2 justify-between items-start gap-x-2";
|
|
134
|
-
if ((_a = this.__metadata) == null ? void 0 : _a.image) {
|
|
135
|
-
const leftContainer = document.createElement("div");
|
|
136
|
-
leftContainer.className = "flex w-full h-full max-w-[250px] max-h-[100px] min-h-[100px] order-6";
|
|
137
|
-
const image = document.createElement("img");
|
|
138
|
-
image.src = this.__metadata.image;
|
|
139
|
-
image.alt = `image for ${this.__metadata.title}`;
|
|
140
|
-
image.className = "w-full h-[100px] rounded-lg object-cover";
|
|
141
|
-
leftContainer.appendChild(image);
|
|
142
|
-
container.appendChild(leftContainer);
|
|
143
|
-
}
|
|
144
|
-
const rightContainer = document.createElement("div");
|
|
145
|
-
rightContainer.className = "flex flex-col flex-1 w-full flex-wrap items-start space-y-4";
|
|
146
|
-
const titleLink = document.createElement("a");
|
|
147
|
-
titleLink.className = "font-bold break-words hover:underline";
|
|
148
|
-
titleLink.href = this.__url || "#";
|
|
149
|
-
titleLink.textContent = this.__url || "No URL provided";
|
|
150
|
-
titleLink.target = "_blank";
|
|
151
|
-
rightContainer.appendChild(titleLink);
|
|
152
|
-
const descriptionSmall = document.createElement("small");
|
|
153
|
-
descriptionSmall.className = "font-[400] dark:text-gray-200 text-gray-500";
|
|
154
|
-
descriptionSmall.textContent = ((_b = this.__metadata) == null ? void 0 : _b.description) || "Loading metadata...";
|
|
155
|
-
rightContainer.appendChild(descriptionSmall);
|
|
156
|
-
const sourceSmall = document.createElement("small");
|
|
157
|
-
sourceSmall.className = "text-sm mt-4 font-[400] dark:text-gray-300 text-gray-500/50";
|
|
158
|
-
sourceSmall.textContent = ((_c = this.__metadata) == null ? void 0 : _c.website) || "";
|
|
159
|
-
rightContainer.appendChild(sourceSmall);
|
|
160
|
-
container.appendChild(rightContainer);
|
|
161
|
-
elementDIV.appendChild(container);
|
|
162
|
-
if (this.__url && !this.__metadata) {
|
|
163
|
-
fetchMetadata(this.__url).then((metadata) => {
|
|
164
|
-
this.__editor.update(() => {
|
|
165
|
-
this.setMetadata(metadata);
|
|
166
|
-
});
|
|
167
|
-
}).catch((error) => {
|
|
168
|
-
console.error("Error fetching metadata:", error);
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
return elementDIV;
|
|
172
|
-
}
|
|
173
|
-
updateDOM(prevNode, dom) {
|
|
174
|
-
var _a, _b, _c, _d;
|
|
175
|
-
if (this.__metadata !== prevNode.__metadata) {
|
|
176
|
-
const container = dom.querySelector("div");
|
|
177
|
-
const image = dom.querySelector("img");
|
|
178
|
-
const titleLink = dom.querySelector("a");
|
|
179
|
-
const descriptionSmall = dom.querySelector("small:nth-of-type(1)");
|
|
180
|
-
const sourceSmall = dom.querySelector("small:nth-of-type(2)");
|
|
181
|
-
if (titleLink && descriptionSmall && sourceSmall) {
|
|
182
|
-
titleLink.href = this.__url || "#";
|
|
183
|
-
titleLink.textContent = ((_a = this.__metadata) == null ? void 0 : _a.title) || this.__url || "No URL provided";
|
|
184
|
-
descriptionSmall.textContent = ((_b = this.__metadata) == null ? void 0 : _b.description) || "Loading metadata...";
|
|
185
|
-
sourceSmall.textContent = ((_c = this.__metadata) == null ? void 0 : _c.website) || "";
|
|
186
|
-
}
|
|
187
|
-
if ((_d = this.__metadata) == null ? void 0 : _d.image) {
|
|
188
|
-
if (!image) {
|
|
189
|
-
const leftContainer = document.createElement("div");
|
|
190
|
-
leftContainer.className = "flex h-full flex-shrink-0 order-6";
|
|
191
|
-
const newImage = document.createElement("img");
|
|
192
|
-
newImage.src = this.__metadata.image;
|
|
193
|
-
newImage.alt = "Custom Image";
|
|
194
|
-
newImage.className = "w-24 min-h-24 max-[250px] h-[200px] rounded-lg object-fill";
|
|
195
|
-
leftContainer.appendChild(newImage);
|
|
196
|
-
container == null ? void 0 : container.insertBefore(leftContainer, container.firstChild);
|
|
197
|
-
} else {
|
|
198
|
-
image.src = this.__metadata.image;
|
|
199
|
-
}
|
|
200
|
-
} else if (image) {
|
|
201
|
-
image.remove();
|
|
202
|
-
}
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
function $createLinkNode(url, editor) {
|
|
209
|
-
return new LinkWithMetaDataNode(url, editor);
|
|
210
|
-
}
|
|
211
|
-
var TOGGLE_LINK_COMMAND_LinkWithMetaDataNode = createCommand("toggleLink");
|
|
212
|
-
function LinkWithMetaDataPlugin() {
|
|
213
|
-
const [editor] = useLexicalComposerContext();
|
|
214
|
-
useEffect(() => {
|
|
215
|
-
if (!editor.hasNodes([LinkWithMetaDataNode])) {
|
|
216
|
-
throw new Error("LinkWithMetaDataPlugin: LinkWithMetaDataNode not registered on editor");
|
|
217
|
-
}
|
|
218
|
-
}, [editor]);
|
|
219
|
-
editor.registerCommand(
|
|
220
|
-
TOGGLE_LINK_COMMAND_LinkWithMetaDataNode,
|
|
221
|
-
(url) => {
|
|
222
|
-
const selection = $getSelection();
|
|
223
|
-
if ($isRangeSelection(selection)) {
|
|
224
|
-
const linkNode = $createLinkNode(url, editor);
|
|
225
|
-
$insertNodeToNearestRoot(linkNode);
|
|
226
|
-
}
|
|
227
|
-
return true;
|
|
228
|
-
},
|
|
229
|
-
COMMAND_PRIORITY_LOW
|
|
230
|
-
);
|
|
231
|
-
return null;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// src/components/editor/nodes/index.ts
|
|
235
|
-
init_react_shim();
|
|
236
|
-
import { CodeHighlightNode, CodeNode } from "@lexical/code";
|
|
237
|
-
import { AutoLinkNode, LinkNode } from "@lexical/link";
|
|
238
|
-
import { ListItemNode, ListNode } from "@lexical/list";
|
|
239
|
-
import { MarkNode } from "@lexical/mark";
|
|
240
|
-
import { OverflowNode } from "@lexical/overflow";
|
|
241
|
-
import { HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
242
|
-
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
243
|
-
import { TableCellNode, TableNode, TableRowNode } from "@lexical/table";
|
|
244
|
-
var nodes = [
|
|
245
|
-
HeadingNode,
|
|
246
|
-
ListNode,
|
|
247
|
-
ListItemNode,
|
|
248
|
-
QuoteNode,
|
|
249
|
-
CodeNode,
|
|
250
|
-
TableNode,
|
|
251
|
-
TableCellNode,
|
|
252
|
-
TableRowNode,
|
|
253
|
-
CodeHighlightNode,
|
|
254
|
-
StepperNode,
|
|
255
|
-
AutoLinkNode,
|
|
256
|
-
YouTubeNode,
|
|
257
|
-
Hint,
|
|
258
|
-
TweetNode,
|
|
259
|
-
LinkNode,
|
|
260
|
-
OverflowNode,
|
|
261
|
-
HorizontalRuleNode,
|
|
262
|
-
MarkNode,
|
|
263
|
-
ImageNode,
|
|
264
|
-
PollNode,
|
|
265
|
-
LayoutItemNode,
|
|
266
|
-
LayoutContainerNode,
|
|
267
|
-
CollapsibleContainerNode,
|
|
268
|
-
CollapsibleContentNode,
|
|
269
|
-
CollapsibleTitleNode,
|
|
270
|
-
LinkWithMetaDataNode,
|
|
271
|
-
InlineImageNode,
|
|
272
|
-
ExcalidrawNode,
|
|
273
|
-
FigmaNode,
|
|
274
|
-
EquationNode,
|
|
275
|
-
StoryBuilderNode,
|
|
276
|
-
DynamicBlockNode,
|
|
277
|
-
AudioNode,
|
|
278
|
-
FileNode
|
|
279
|
-
];
|
|
280
|
-
var nestedNodes = [
|
|
281
|
-
HeadingNode,
|
|
282
|
-
ListNode,
|
|
283
|
-
ListItemNode,
|
|
284
|
-
LinkNode,
|
|
285
|
-
CodeHighlightNode,
|
|
286
|
-
QuoteNode,
|
|
287
|
-
CodeNode,
|
|
288
|
-
LinkWithMetaDataNode,
|
|
289
|
-
ImageNode,
|
|
290
|
-
InlineImageNode,
|
|
291
|
-
ExcalidrawNode,
|
|
292
|
-
FigmaNode,
|
|
293
|
-
EquationNode,
|
|
294
|
-
StoryBuilderNode,
|
|
295
|
-
DynamicBlockNode,
|
|
296
|
-
AudioNode,
|
|
297
|
-
FileNode
|
|
298
|
-
];
|
|
299
|
-
var nodes_default = nodes;
|
|
300
|
-
|
|
301
|
-
// src/components/editor/plugins/AutoLinkPlugin/index.tsx
|
|
302
|
-
init_react_shim();
|
|
303
|
-
import { useLexicalComposerContext as useLexicalComposerContext2 } from "@lexical/react/LexicalComposerContext";
|
|
304
|
-
import { useEffect as useEffect2 } from "react";
|
|
305
|
-
import { $getSelection as $getSelection2, $isRangeSelection as $isRangeSelection2 } from "lexical";
|
|
306
|
-
import { $isCodeHighlightNode } from "@lexical/code";
|
|
307
|
-
var URL_REGEX = new RegExp("((https?:\\/\\/(www\\.)?)|(www\\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])");
|
|
308
|
-
function LexicalAutoLinkPlugin() {
|
|
309
|
-
const [editor] = useLexicalComposerContext2();
|
|
310
|
-
useEffect2(() => {
|
|
311
|
-
const handlePaste = (event) => {
|
|
312
|
-
var _a;
|
|
313
|
-
const pastedText = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
|
|
314
|
-
if (pastedText && URL_REGEX.test(pastedText)) {
|
|
315
|
-
event.preventDefault();
|
|
316
|
-
pastedText.split(" ").map((TEXT) => {
|
|
317
|
-
if (URL_REGEX.test(TEXT)) {
|
|
318
|
-
editor.update(() => {
|
|
319
|
-
const selection = $getSelection2();
|
|
320
|
-
if ($isRangeSelection2(selection)) {
|
|
321
|
-
const node = selection.anchor.getNode();
|
|
322
|
-
if (!$isCodeHighlightNode(node)) {
|
|
323
|
-
if (node && node.getTextContent() === TEXT) {
|
|
324
|
-
node.remove();
|
|
325
|
-
}
|
|
326
|
-
editor.dispatchCommand(TOGGLE_LINK_COMMAND_LinkWithMetaDataNode, TEXT);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
const rootElement = editor.getRootElement();
|
|
335
|
-
if (rootElement) {
|
|
336
|
-
rootElement.addEventListener("paste", handlePaste);
|
|
337
|
-
}
|
|
338
|
-
return () => {
|
|
339
|
-
if (rootElement) {
|
|
340
|
-
rootElement.removeEventListener("paste", handlePaste);
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
}, [editor]);
|
|
344
|
-
return null;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// src/components/editor/plugins/CodeHighlightPlugin/index.ts
|
|
348
|
-
init_react_shim();
|
|
349
|
-
import { CodeNode as CodeNode2 } from "@lexical/code";
|
|
350
|
-
import {
|
|
351
|
-
loadCodeTheme,
|
|
352
|
-
registerCodeHighlighting,
|
|
353
|
-
ShikiTokenizer
|
|
354
|
-
} from "@lexical/code-shiki";
|
|
355
|
-
import { useLexicalComposerContext as useLexicalComposerContext3 } from "@lexical/react/LexicalComposerContext";
|
|
356
|
-
import { $nodesOfType } from "lexical";
|
|
357
|
-
import { useTheme } from "next-themes";
|
|
358
|
-
import { useEffect as useEffect3, useRef, useState } from "react";
|
|
359
|
-
var DARK_CODE_THEME = "github-dark";
|
|
360
|
-
var LIGHT_CODE_THEME = "github-light";
|
|
361
|
-
function CodeHighlightPlugin() {
|
|
362
|
-
const [editor] = useLexicalComposerContext3();
|
|
363
|
-
let resolvedTheme;
|
|
364
|
-
try {
|
|
365
|
-
const themeContext = useTheme();
|
|
366
|
-
resolvedTheme = themeContext == null ? void 0 : themeContext.resolvedTheme;
|
|
367
|
-
} catch (e) {
|
|
368
|
-
}
|
|
369
|
-
const [mounted, setMounted] = useState(false);
|
|
370
|
-
useEffect3(() => {
|
|
371
|
-
setMounted(true);
|
|
372
|
-
}, []);
|
|
373
|
-
const isDark = mounted ? resolvedTheme === "dark" || typeof document !== "undefined" && document.documentElement.classList.contains("dark") : typeof document !== "undefined" && document.documentElement.classList.contains("dark");
|
|
374
|
-
const activeTheme = isDark ? DARK_CODE_THEME : LIGHT_CODE_THEME;
|
|
375
|
-
const tokenizerRef = useRef(__spreadProps(__spreadValues({}, ShikiTokenizer), {
|
|
376
|
-
defaultTheme: activeTheme
|
|
377
|
-
}));
|
|
378
|
-
tokenizerRef.current.defaultTheme = activeTheme;
|
|
379
|
-
useEffect3(() => {
|
|
380
|
-
loadCodeTheme(DARK_CODE_THEME);
|
|
381
|
-
loadCodeTheme(LIGHT_CODE_THEME);
|
|
382
|
-
}, []);
|
|
383
|
-
useEffect3(() => {
|
|
384
|
-
return registerCodeHighlighting(editor, tokenizerRef.current);
|
|
385
|
-
}, [editor]);
|
|
386
|
-
useEffect3(() => {
|
|
387
|
-
editor.update(() => {
|
|
388
|
-
const codeNodes = $nodesOfType(CodeNode2);
|
|
389
|
-
for (const node of codeNodes) {
|
|
390
|
-
const currentTheme = node.getTheme();
|
|
391
|
-
if (!currentTheme || currentTheme === DARK_CODE_THEME || currentTheme === LIGHT_CODE_THEME || currentTheme === "one-light" || currentTheme === "one-dark-pro" || currentTheme === "poimandres") {
|
|
392
|
-
if (currentTheme !== activeTheme) {
|
|
393
|
-
node.setTheme(activeTheme);
|
|
394
|
-
node.markDirty();
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
}, [editor, activeTheme]);
|
|
400
|
-
return null;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
export {
|
|
404
|
-
LinkWithMetaDataPlugin,
|
|
405
|
-
nestedNodes,
|
|
406
|
-
nodes_default,
|
|
407
|
-
LexicalAutoLinkPlugin,
|
|
408
|
-
CodeHighlightPlugin
|
|
409
|
-
};
|