@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-ACV47ZKE.mjs
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
$createCollapsibleContainerNode,
|
|
3
|
-
$createCollapsibleContentNode,
|
|
4
|
-
$createCollapsibleTitleNode,
|
|
5
|
-
$isCollapsibleContainerNode,
|
|
6
|
-
$isCollapsibleContentNode,
|
|
7
|
-
$isCollapsibleTitleNode,
|
|
8
|
-
CollapsibleContainerNode,
|
|
9
|
-
CollapsibleContentNode,
|
|
10
|
-
CollapsibleTitleNode
|
|
11
|
-
} from "./chunk-4DVIYZVB.mjs";
|
|
12
|
-
import {
|
|
13
|
-
init_react_shim
|
|
14
|
-
} from "./chunk-WYCFGRFJ.mjs";
|
|
15
|
-
|
|
16
|
-
// src/components/editor/plugins/CollapsiblePlugin/index.ts
|
|
17
|
-
init_react_shim();
|
|
18
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
19
|
-
import { $findMatchingParent, mergeRegister } from "@lexical/utils";
|
|
20
|
-
import {
|
|
21
|
-
$createParagraphNode,
|
|
22
|
-
$getNodeByKey,
|
|
23
|
-
$getPreviousSelection,
|
|
24
|
-
$getSelection,
|
|
25
|
-
$isElementNode,
|
|
26
|
-
$isRangeSelection,
|
|
27
|
-
$setSelection,
|
|
28
|
-
COMMAND_PRIORITY_EDITOR,
|
|
29
|
-
COMMAND_PRIORITY_LOW,
|
|
30
|
-
createCommand,
|
|
31
|
-
DELETE_CHARACTER_COMMAND,
|
|
32
|
-
INSERT_PARAGRAPH_COMMAND,
|
|
33
|
-
KEY_ARROW_DOWN_COMMAND
|
|
34
|
-
} from "lexical";
|
|
35
|
-
import { useEffect } from "react";
|
|
36
|
-
var INSERT_COLLAPSIBLE_COMMAND = createCommand();
|
|
37
|
-
var TOGGLE_COLLAPSIBLE_COMMAND = createCommand();
|
|
38
|
-
function CollapsiblePlugin() {
|
|
39
|
-
const [editor] = useLexicalComposerContext();
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (!editor.hasNodes([
|
|
42
|
-
CollapsibleContainerNode,
|
|
43
|
-
CollapsibleTitleNode,
|
|
44
|
-
CollapsibleContentNode
|
|
45
|
-
])) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
"CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor"
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
return mergeRegister(
|
|
51
|
-
// Structure enforcing transformers for each node type. In case nesting structure is not
|
|
52
|
-
// "Container > Title + Content" it'll unwrap nodes and convert it back
|
|
53
|
-
// to regular content.
|
|
54
|
-
editor.registerNodeTransform(CollapsibleContentNode, (node) => {
|
|
55
|
-
const parent = node.getParent();
|
|
56
|
-
if (!$isCollapsibleContainerNode(parent)) {
|
|
57
|
-
const children = node.getChildren();
|
|
58
|
-
for (const child of children) {
|
|
59
|
-
node.insertAfter(child);
|
|
60
|
-
}
|
|
61
|
-
node.remove();
|
|
62
|
-
}
|
|
63
|
-
}),
|
|
64
|
-
editor.registerNodeTransform(CollapsibleTitleNode, (node) => {
|
|
65
|
-
const parent = node.getParent();
|
|
66
|
-
if (!$isCollapsibleContainerNode(parent)) {
|
|
67
|
-
node.replace($createParagraphNode().append(...node.getChildren()));
|
|
68
|
-
}
|
|
69
|
-
}),
|
|
70
|
-
editor.registerNodeTransform(CollapsibleContainerNode, (node) => {
|
|
71
|
-
const children = node.getChildren();
|
|
72
|
-
if (children.length !== 2 || !$isCollapsibleTitleNode(children[0]) || !$isCollapsibleContentNode(children[1])) {
|
|
73
|
-
for (const child of children) {
|
|
74
|
-
node.insertAfter(child);
|
|
75
|
-
}
|
|
76
|
-
node.remove();
|
|
77
|
-
}
|
|
78
|
-
}),
|
|
79
|
-
// This handles the case when container is collapsed and we delete its previous sibling
|
|
80
|
-
// into it, it would cause collapsed content deleted (since it's display: none, and selection
|
|
81
|
-
// swallows it when deletes single char). Instead we expand container, which is although
|
|
82
|
-
// not perfect, but avoids bigger problem
|
|
83
|
-
editor.registerCommand(
|
|
84
|
-
DELETE_CHARACTER_COMMAND,
|
|
85
|
-
() => {
|
|
86
|
-
const selection = $getSelection();
|
|
87
|
-
if (!$isRangeSelection(selection) || !selection.isCollapsed() || selection.anchor.offset !== 0) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
const anchorNode = selection.anchor.getNode();
|
|
91
|
-
const topLevelElement = anchorNode.getTopLevelElement();
|
|
92
|
-
if (topLevelElement === null) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
const container = topLevelElement.getPreviousSibling();
|
|
96
|
-
if (!$isCollapsibleContainerNode(container) || container.getOpen()) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
container.setOpen(true);
|
|
100
|
-
return true;
|
|
101
|
-
},
|
|
102
|
-
COMMAND_PRIORITY_LOW
|
|
103
|
-
),
|
|
104
|
-
// When collapsible is the last child pressing down arrow will insert paragraph
|
|
105
|
-
// below it to allow adding more content. It's similar what $insertBlockNode
|
|
106
|
-
// (mainly for decorators), except it'll always be possible to continue adding
|
|
107
|
-
// new content even if trailing paragraph is accidentally deleted
|
|
108
|
-
editor.registerCommand(
|
|
109
|
-
KEY_ARROW_DOWN_COMMAND,
|
|
110
|
-
() => {
|
|
111
|
-
const selection = $getSelection();
|
|
112
|
-
if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
const container = $findMatchingParent(
|
|
116
|
-
selection.anchor.getNode(),
|
|
117
|
-
$isCollapsibleContainerNode
|
|
118
|
-
);
|
|
119
|
-
if (container === null) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
const parent = container.getParent();
|
|
123
|
-
if (parent !== null && parent.getLastChild() === container) {
|
|
124
|
-
parent.append($createParagraphNode());
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
},
|
|
128
|
-
COMMAND_PRIORITY_LOW
|
|
129
|
-
),
|
|
130
|
-
// Handling CMD+Enter to toggle collapsible element collapsed state
|
|
131
|
-
editor.registerCommand(
|
|
132
|
-
INSERT_PARAGRAPH_COMMAND,
|
|
133
|
-
() => {
|
|
134
|
-
var _a;
|
|
135
|
-
const windowEvent = (_a = editor._window) == null ? void 0 : _a.event;
|
|
136
|
-
if (windowEvent && (windowEvent.ctrlKey || windowEvent.metaKey) && windowEvent.key === "Enter") {
|
|
137
|
-
const selection = $getPreviousSelection();
|
|
138
|
-
if ($isRangeSelection(selection) && selection.isCollapsed()) {
|
|
139
|
-
const parent = $findMatchingParent(
|
|
140
|
-
selection.anchor.getNode(),
|
|
141
|
-
(node) => $isElementNode(node) && !node.isInline()
|
|
142
|
-
);
|
|
143
|
-
if ($isCollapsibleTitleNode(parent)) {
|
|
144
|
-
const container = parent.getParent();
|
|
145
|
-
if ($isCollapsibleContainerNode(container)) {
|
|
146
|
-
container.toggleOpen();
|
|
147
|
-
$setSelection(selection.clone());
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return false;
|
|
154
|
-
},
|
|
155
|
-
COMMAND_PRIORITY_LOW
|
|
156
|
-
),
|
|
157
|
-
editor.registerCommand(
|
|
158
|
-
INSERT_COLLAPSIBLE_COMMAND,
|
|
159
|
-
() => {
|
|
160
|
-
editor.update(() => {
|
|
161
|
-
const selection = $getSelection();
|
|
162
|
-
if (!$isRangeSelection(selection)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const title = $createCollapsibleTitleNode();
|
|
166
|
-
const content = $createCollapsibleContentNode().append(
|
|
167
|
-
$createParagraphNode()
|
|
168
|
-
);
|
|
169
|
-
const container = $createCollapsibleContainerNode().append(
|
|
170
|
-
title,
|
|
171
|
-
content
|
|
172
|
-
);
|
|
173
|
-
selection.insertNodes([container]);
|
|
174
|
-
title.selectStart();
|
|
175
|
-
});
|
|
176
|
-
return true;
|
|
177
|
-
},
|
|
178
|
-
COMMAND_PRIORITY_EDITOR
|
|
179
|
-
),
|
|
180
|
-
editor.registerCommand(
|
|
181
|
-
TOGGLE_COLLAPSIBLE_COMMAND,
|
|
182
|
-
(key) => {
|
|
183
|
-
editor.update(() => {
|
|
184
|
-
const containerNode = $getNodeByKey(key);
|
|
185
|
-
if ($isCollapsibleContainerNode(containerNode)) {
|
|
186
|
-
containerNode.toggleOpen();
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
return true;
|
|
190
|
-
},
|
|
191
|
-
COMMAND_PRIORITY_EDITOR
|
|
192
|
-
)
|
|
193
|
-
);
|
|
194
|
-
}, [editor]);
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export {
|
|
199
|
-
INSERT_COLLAPSIBLE_COMMAND,
|
|
200
|
-
CollapsiblePlugin
|
|
201
|
-
};
|
package/dist/chunk-BGV62GC2.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
init_react_shim
|
|
3
|
-
} from "./chunk-WYCFGRFJ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/components/providers/AIContext.tsx
|
|
6
|
-
init_react_shim();
|
|
7
|
-
import React, { createContext, useContext } from "react";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
var AIContext = createContext({
|
|
10
|
-
apiEndpoint: "/api/ai"
|
|
11
|
-
});
|
|
12
|
-
var useAI = () => useContext(AIContext);
|
|
13
|
-
var AIProvider = ({
|
|
14
|
-
config,
|
|
15
|
-
children
|
|
16
|
-
}) => {
|
|
17
|
-
const value = React.useMemo(() => ({
|
|
18
|
-
apiEndpoint: (config == null ? void 0 : config.apiEndpoint) || "/api/ai"
|
|
19
|
-
}), [config]);
|
|
20
|
-
return /* @__PURE__ */ jsx(AIContext.Provider, { value, children });
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
useAI,
|
|
25
|
-
AIProvider
|
|
26
|
-
};
|
package/dist/chunk-C4JWLBYN.mjs
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SHORTCUTS
|
|
3
|
-
} from "./chunk-K5OAFEVY.mjs";
|
|
4
|
-
import {
|
|
5
|
-
updateFontSize,
|
|
6
|
-
updateFontSizeInSelection
|
|
7
|
-
} from "./chunk-6D6QLRYR.mjs";
|
|
8
|
-
import {
|
|
9
|
-
MAX_ALLOWED_FONT_SIZE,
|
|
10
|
-
MIN_ALLOWED_FONT_SIZE
|
|
11
|
-
} from "./chunk-4FFTOZGJ.mjs";
|
|
12
|
-
import {
|
|
13
|
-
Input
|
|
14
|
-
} from "./chunk-5NRAXWYA.mjs";
|
|
15
|
-
import {
|
|
16
|
-
Button
|
|
17
|
-
} from "./chunk-OE5JRLCN.mjs";
|
|
18
|
-
import {
|
|
19
|
-
cn
|
|
20
|
-
} from "./chunk-JHXDLYEV.mjs";
|
|
21
|
-
import {
|
|
22
|
-
init_react_shim
|
|
23
|
-
} from "./chunk-WYCFGRFJ.mjs";
|
|
24
|
-
|
|
25
|
-
// src/components/ui/drop-downs/font-size.tsx
|
|
26
|
-
init_react_shim();
|
|
27
|
-
import * as React from "react";
|
|
28
|
-
import { Minus, Plus } from "lucide-react";
|
|
29
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
30
|
-
function parseAllowedFontSize(input) {
|
|
31
|
-
const match = input.match(/^(\d+(?:\.\d+)?)px$/);
|
|
32
|
-
if (match) {
|
|
33
|
-
const n = Number(match[1]);
|
|
34
|
-
if (n >= MIN_ALLOWED_FONT_SIZE && n <= MAX_ALLOWED_FONT_SIZE) {
|
|
35
|
-
return input;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return "";
|
|
39
|
-
}
|
|
40
|
-
function FontSize({
|
|
41
|
-
selectionFontSize,
|
|
42
|
-
disabled,
|
|
43
|
-
editor,
|
|
44
|
-
className,
|
|
45
|
-
classNameContent
|
|
46
|
-
}) {
|
|
47
|
-
const [inputValue, setInputValue] = React.useState(selectionFontSize);
|
|
48
|
-
const [inputChangeFlag, setInputChangeFlag] = React.useState(false);
|
|
49
|
-
const handleKeyPress = (e) => {
|
|
50
|
-
const inputValueNumber = Number(inputValue);
|
|
51
|
-
if (e.key === "Tab") {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (["e", "E", "+", "-"].includes(e.key) || isNaN(inputValueNumber)) {
|
|
55
|
-
e.preventDefault();
|
|
56
|
-
setInputValue("");
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
setInputChangeFlag(true);
|
|
60
|
-
if (e.key === "Enter" || e.key === "Escape") {
|
|
61
|
-
e.preventDefault();
|
|
62
|
-
updateFontSizeByInputValue(inputValueNumber);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const handleInputBlur = () => {
|
|
66
|
-
if (inputValue !== "" && inputChangeFlag) {
|
|
67
|
-
const inputValueNumber = Number(inputValue);
|
|
68
|
-
updateFontSizeByInputValue(inputValueNumber);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const updateFontSizeByInputValue = (inputValueNumber) => {
|
|
72
|
-
let updatedFontSize = inputValueNumber;
|
|
73
|
-
if (inputValueNumber > MAX_ALLOWED_FONT_SIZE) {
|
|
74
|
-
updatedFontSize = MAX_ALLOWED_FONT_SIZE;
|
|
75
|
-
} else if (inputValueNumber < MIN_ALLOWED_FONT_SIZE) {
|
|
76
|
-
updatedFontSize = MIN_ALLOWED_FONT_SIZE;
|
|
77
|
-
}
|
|
78
|
-
setInputValue(String(updatedFontSize));
|
|
79
|
-
updateFontSizeInSelection(editor, String(updatedFontSize) + "px", null);
|
|
80
|
-
setInputChangeFlag(false);
|
|
81
|
-
};
|
|
82
|
-
React.useEffect(() => {
|
|
83
|
-
setInputValue(selectionFontSize);
|
|
84
|
-
}, [selectionFontSize]);
|
|
85
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-row items-center gap-1", classNameContent), children: [
|
|
86
|
-
/* @__PURE__ */ jsx(
|
|
87
|
-
Button,
|
|
88
|
-
{
|
|
89
|
-
type: "button",
|
|
90
|
-
className: cn("h-7 min-w-[29px] w-[29px] px-[6px] border-none cursor-pointer", className),
|
|
91
|
-
tip: `decrement ${SHORTCUTS.INCREASE_FONT_SIZE}`,
|
|
92
|
-
disabled: disabled || selectionFontSize !== "" && Number(inputValue) <= MIN_ALLOWED_FONT_SIZE,
|
|
93
|
-
variant: "outline",
|
|
94
|
-
size: "Toolbar",
|
|
95
|
-
onClick: () => updateFontSize(editor, 2 /* decrement */, inputValue),
|
|
96
|
-
children: /* @__PURE__ */ jsx(Minus, { className: "w-[15px] h-[15px]" })
|
|
97
|
-
}
|
|
98
|
-
),
|
|
99
|
-
/* @__PURE__ */ jsx(
|
|
100
|
-
Input,
|
|
101
|
-
{
|
|
102
|
-
type: "number",
|
|
103
|
-
value: inputValue,
|
|
104
|
-
disabled,
|
|
105
|
-
className: cn("h-7 min-w-[29px] w-[29px] px-[6px] border-none cursor-text", className),
|
|
106
|
-
min: MIN_ALLOWED_FONT_SIZE,
|
|
107
|
-
max: MAX_ALLOWED_FONT_SIZE,
|
|
108
|
-
onChange: (e) => setInputValue(e.target.value),
|
|
109
|
-
onKeyDown: handleKeyPress,
|
|
110
|
-
onBlur: handleInputBlur
|
|
111
|
-
}
|
|
112
|
-
),
|
|
113
|
-
/* @__PURE__ */ jsx(
|
|
114
|
-
Button,
|
|
115
|
-
{
|
|
116
|
-
type: "button",
|
|
117
|
-
tip: `increment ${SHORTCUTS.DECREASE_FONT_SIZE}`,
|
|
118
|
-
className: cn("h-7 min-w-[29px] w-[29px] px-[6px] border-none cursor-pointer", className),
|
|
119
|
-
disabled: disabled || selectionFontSize !== "" && Number(inputValue) >= MAX_ALLOWED_FONT_SIZE,
|
|
120
|
-
variant: "outline",
|
|
121
|
-
size: "Toolbar",
|
|
122
|
-
onClick: () => updateFontSize(editor, 1 /* increment */, inputValue),
|
|
123
|
-
children: /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4" })
|
|
124
|
-
}
|
|
125
|
-
)
|
|
126
|
-
] });
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export {
|
|
130
|
-
parseAllowedFontSize,
|
|
131
|
-
FontSize
|
|
132
|
-
};
|