@collabchron/notiq 1.1.11 → 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-2WZUFWSC.mjs → AIDialog-HJW6PQPR.mjs} +12 -13
- 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-SIMURTCA.mjs → ExcalidrawComponent-POMYXDSG.mjs} +34 -7
- 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-WQSNFPMM.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +9 -10
- package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
- package/dist/chunk-5CJZC5IB.mjs +9086 -0
- package/dist/{chunk-MW6MAUY3.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-XAVQAXOJ.mjs → chunk-CQCS5YPS.mjs} +3 -5
- package/dist/{chunk-YTLUQJE2.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-GYYLZ3MQ.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-XZXGYNTY.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-XAJ4GACN.mjs +746 -0
- package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
- package/dist/components/editor/Core.d.ts +15 -2
- package/dist/components/editor/index.d.ts +16 -5
- 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/index.d.ts +2 -1
- package/dist/core/react/NotiqContent.d.ts +4 -1
- package/dist/core/react/NotiqEditor.d.ts +8 -8
- package/dist/core/react/index.d.ts +1 -0
- package/dist/core/react/node-renderers.d.ts +73 -0
- package/dist/core/types.d.ts +1 -0
- package/dist/core.js +18136 -9084
- package/dist/core.mjs +58 -44
- package/dist/hooks/instructions-messages.d.ts +13 -4
- package/dist/{image-TPW7PZZK.mjs → image-AL6PHM2A.mjs} +18 -13
- package/dist/index.js +15180 -12858
- package/dist/index.mjs +121 -1641
- package/dist/{insert-audio-C66RZRKY.mjs → insert-audio-CRWR7EO5.mjs} +6 -8
- package/dist/{insert-file-3DTGRO7W.mjs → insert-file-I73AZW3L.mjs} +6 -8
- package/dist/{insert-gif-FIMCCBAI.mjs → insert-gif-KWRC3ACT.mjs} +4 -4
- package/dist/{insert-image-CZV6HWQZ.mjs → insert-image-XIY6BGW5.mjs} +6 -5
- 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 +17933 -9531
- package/dist/react.mjs +41 -34
- package/dist/{stepper-4AO5XMO7.mjs → stepper-ILF7YXTO.mjs} +64 -74
- 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-MRKY67ED.mjs +0 -14
- package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
- package/dist/CollaboratorsBar-TMKBOBJI.mjs +0 -20
- package/dist/CommentsPlugin-5M4RD6YO.mjs +0 -19
- package/dist/ExcalidrawPlugin-2SGPIQ6U.mjs +0 -14
- package/dist/ExportPlugin-OKZOLBGS.mjs +0 -42
- package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
- package/dist/FloatingTextFormatToolbarPlugin-SO5VON7Q.mjs +0 -45
- package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
- package/dist/MobileToolbar-JKP2MLQJ.mjs +0 -984
- package/dist/SlashCommand-2TNOOUBM.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-IIAOU4P5.mjs +0 -35
- package/dist/VersionHistoryPlugin-23MAZB4G.mjs +0 -371
- package/dist/background-color-OZJCBYCT.mjs +0 -425
- package/dist/block-format-MTSIXWID.mjs +0 -14
- package/dist/chunk-2KESP7OU.mjs +0 -809
- package/dist/chunk-3AHNLIME.mjs +0 -1701
- 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-6SRMKQSD.mjs +0 -682
- package/dist/chunk-ACV47ZKE.mjs +0 -201
- package/dist/chunk-AYNKORDO.mjs +0 -6
- package/dist/chunk-BGV62GC2.mjs +0 -26
- package/dist/chunk-D3IOUQFR.mjs +0 -441
- package/dist/chunk-EEBA6OAH.mjs +0 -59
- package/dist/chunk-EIZMKFHF.mjs +0 -32
- package/dist/chunk-EVPWKNE4.mjs +0 -27
- package/dist/chunk-FMJ7DGWP.mjs +0 -144
- package/dist/chunk-FYLRS4BG.mjs +0 -88
- package/dist/chunk-HOZ4QRFV.mjs +0 -536
- package/dist/chunk-IAFCQV3Z.mjs +0 -349
- package/dist/chunk-IU2N42JJ.mjs +0 -1763
- package/dist/chunk-J6ZUY5BY.mjs +0 -202
- package/dist/chunk-K5OAFEVY.mjs +0 -191
- package/dist/chunk-KDA7ZYMJ.mjs +0 -431
- package/dist/chunk-KXRLARGI.mjs +0 -26
- package/dist/chunk-LAUAYRPC.mjs +0 -944
- package/dist/chunk-LLCP7NVE.mjs +0 -449
- package/dist/chunk-LU2XWLOE.mjs +0 -219
- package/dist/chunk-MPTE332I.mjs +0 -787
- package/dist/chunk-MTQZWJHR.mjs +0 -111
- package/dist/chunk-OXWTZV3U.mjs +0 -174
- package/dist/chunk-PD5K4AGP.mjs +0 -64
- package/dist/chunk-PFH63ZU4.mjs +0 -33
- package/dist/chunk-PHRVYPVM.mjs +0 -808
- 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-VGAX6YEY.mjs +0 -399
- package/dist/chunk-W6GAJXUS.mjs +0 -334
- package/dist/chunk-XYDBUQ6Z.mjs +0 -1978
- package/dist/chunk-XYT6XM5S.mjs +0 -496
- package/dist/chunk-YDDBQZ77.mjs +0 -409
- package/dist/chunk-YE7M2VKR.mjs +0 -132
- package/dist/chunk-Z6JAFF55.mjs +0 -555
- package/dist/chunk-ZKZ7MLSS.mjs +0 -165
- package/dist/color-23323E3B.mjs +0 -13
- package/dist/font-IJKFR4BM.mjs +0 -12
- package/dist/font-size-GTL6UVQL.mjs +0 -15
- package/dist/insert-node-MA3FXEYN.mjs +0 -245
- package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
- package/dist/text-align-CSDLJUDA.mjs +0 -121
- package/dist/text-format-6L5N3CHZ.mjs +0 -15
package/dist/chunk-J6ZUY5BY.mjs
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCollab
|
|
3
|
-
} from "./chunk-RJQTA6HG.mjs";
|
|
4
|
-
import {
|
|
5
|
-
init_react_shim
|
|
6
|
-
} from "./chunk-WYCFGRFJ.mjs";
|
|
7
|
-
|
|
8
|
-
// src/components/providers/VersionHistoryContext.tsx
|
|
9
|
-
init_react_shim();
|
|
10
|
-
import {
|
|
11
|
-
createContext,
|
|
12
|
-
useContext,
|
|
13
|
-
useState,
|
|
14
|
-
useEffect,
|
|
15
|
-
useCallback,
|
|
16
|
-
useMemo
|
|
17
|
-
} from "react";
|
|
18
|
-
import { toast } from "sonner";
|
|
19
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
20
|
-
var VersionHistoryContext = createContext(null);
|
|
21
|
-
var useVersionHistory = () => {
|
|
22
|
-
const context = useContext(VersionHistoryContext);
|
|
23
|
-
if (!context) {
|
|
24
|
-
throw new Error("useVersionHistory must be used within a VersionHistoryProvider");
|
|
25
|
-
}
|
|
26
|
-
return context;
|
|
27
|
-
};
|
|
28
|
-
var VersionHistoryProviderInternal = ({ children }) => {
|
|
29
|
-
const { provider, username, cursorColor, avatar } = useCollab();
|
|
30
|
-
const [versions, setVersions] = useState([]);
|
|
31
|
-
const [previewVersion, setPreviewVersion] = useState(null);
|
|
32
|
-
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
|
33
|
-
const [isNameModalOpen, setIsNameModalOpen] = useState(false);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const doc = provider == null ? void 0 : provider.doc;
|
|
36
|
-
if (!doc) return;
|
|
37
|
-
const yVersions = doc.getArray("notiq-version-history");
|
|
38
|
-
const syncFromYjs = () => {
|
|
39
|
-
try {
|
|
40
|
-
const raw = yVersions.toArray();
|
|
41
|
-
const parsed = raw.map((item) => {
|
|
42
|
-
if (typeof item === "string") {
|
|
43
|
-
try {
|
|
44
|
-
return JSON.parse(item);
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return item;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return item;
|
|
50
|
-
});
|
|
51
|
-
parsed.sort((a, b) => b.timestamp - a.timestamp);
|
|
52
|
-
setVersions(parsed);
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.warn("[Notiq VersionHistory] Failed to parse versions:", err);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
syncFromYjs();
|
|
58
|
-
yVersions.observeDeep(syncFromYjs);
|
|
59
|
-
return () => {
|
|
60
|
-
yVersions.unobserveDeep(syncFromYjs);
|
|
61
|
-
};
|
|
62
|
-
}, [provider == null ? void 0 : provider.doc]);
|
|
63
|
-
const author = useMemo(
|
|
64
|
-
() => ({
|
|
65
|
-
name: username,
|
|
66
|
-
color: cursorColor,
|
|
67
|
-
avatar
|
|
68
|
-
}),
|
|
69
|
-
[username, cursorColor, avatar]
|
|
70
|
-
);
|
|
71
|
-
const calculateWordCount = (editorState) => {
|
|
72
|
-
var _a;
|
|
73
|
-
try {
|
|
74
|
-
if (!((_a = editorState == null ? void 0 : editorState.root) == null ? void 0 : _a.children)) return 0;
|
|
75
|
-
let text = "";
|
|
76
|
-
const walk = (node) => {
|
|
77
|
-
if (node.text) text += " " + node.text;
|
|
78
|
-
if (node.children) node.children.forEach(walk);
|
|
79
|
-
};
|
|
80
|
-
walk(editorState.root);
|
|
81
|
-
const words = text.trim().split(/\s+/).filter(Boolean);
|
|
82
|
-
return words.length;
|
|
83
|
-
} catch (e) {
|
|
84
|
-
return 0;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const createCheckpoint = useCallback(
|
|
88
|
-
(title, customEditorState, isNamed = false) => {
|
|
89
|
-
if (!customEditorState) return "";
|
|
90
|
-
const versionId = `v-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
91
|
-
const wordCount = calculateWordCount(customEditorState);
|
|
92
|
-
const newVersion = {
|
|
93
|
-
id: versionId,
|
|
94
|
-
title: (title == null ? void 0 : title.trim()) || `Revision by ${author.name}`,
|
|
95
|
-
timestamp: Date.now(),
|
|
96
|
-
author,
|
|
97
|
-
editorState: customEditorState,
|
|
98
|
-
wordCount,
|
|
99
|
-
isNamed
|
|
100
|
-
};
|
|
101
|
-
const doc = provider == null ? void 0 : provider.doc;
|
|
102
|
-
if (doc) {
|
|
103
|
-
const yVersions = doc.getArray("notiq-version-history");
|
|
104
|
-
doc.transact(() => {
|
|
105
|
-
yVersions.push([JSON.stringify(newVersion)]);
|
|
106
|
-
});
|
|
107
|
-
} else {
|
|
108
|
-
setVersions((prev) => [newVersion, ...prev]);
|
|
109
|
-
}
|
|
110
|
-
if (isNamed) {
|
|
111
|
-
toast.success("Version saved", {
|
|
112
|
-
description: `Snapshot "${newVersion.title}" created.`
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return versionId;
|
|
116
|
-
},
|
|
117
|
-
[author, provider == null ? void 0 : provider.doc]
|
|
118
|
-
);
|
|
119
|
-
const restoreVersion = useCallback(
|
|
120
|
-
(version) => {
|
|
121
|
-
if (typeof window !== "undefined") {
|
|
122
|
-
window.dispatchEvent(
|
|
123
|
-
new CustomEvent("notiq:restore-version", {
|
|
124
|
-
detail: version
|
|
125
|
-
})
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
setPreviewVersion(null);
|
|
129
|
-
setIsDrawerOpen(false);
|
|
130
|
-
toast.success("Version restored", {
|
|
131
|
-
description: `Document restored to "${version.title}".`
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
[]
|
|
135
|
-
);
|
|
136
|
-
const deleteVersion = useCallback(
|
|
137
|
-
(versionId) => {
|
|
138
|
-
const doc = provider == null ? void 0 : provider.doc;
|
|
139
|
-
if (doc) {
|
|
140
|
-
const yVersions = doc.getArray("notiq-version-history");
|
|
141
|
-
doc.transact(() => {
|
|
142
|
-
const raw = yVersions.toArray();
|
|
143
|
-
const targetIndex = raw.findIndex((item) => {
|
|
144
|
-
const parsed = typeof item === "string" ? JSON.parse(item) : item;
|
|
145
|
-
return parsed.id === versionId;
|
|
146
|
-
});
|
|
147
|
-
if (targetIndex !== -1) {
|
|
148
|
-
yVersions.delete(targetIndex, 1);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
} else {
|
|
152
|
-
setVersions((prev) => prev.filter((v) => v.id !== versionId));
|
|
153
|
-
}
|
|
154
|
-
if ((previewVersion == null ? void 0 : previewVersion.id) === versionId) {
|
|
155
|
-
setPreviewVersion(null);
|
|
156
|
-
}
|
|
157
|
-
toast.info("Version snapshot deleted");
|
|
158
|
-
},
|
|
159
|
-
[previewVersion == null ? void 0 : previewVersion.id, provider == null ? void 0 : provider.doc]
|
|
160
|
-
);
|
|
161
|
-
const toggleDrawer = useCallback(() => {
|
|
162
|
-
setIsDrawerOpen((prev) => !prev);
|
|
163
|
-
}, []);
|
|
164
|
-
const value = useMemo(
|
|
165
|
-
() => ({
|
|
166
|
-
versions,
|
|
167
|
-
previewVersion,
|
|
168
|
-
setPreviewVersion,
|
|
169
|
-
isDrawerOpen,
|
|
170
|
-
setIsDrawerOpen,
|
|
171
|
-
toggleDrawer,
|
|
172
|
-
isNameModalOpen,
|
|
173
|
-
setIsNameModalOpen,
|
|
174
|
-
createCheckpoint,
|
|
175
|
-
restoreVersion,
|
|
176
|
-
deleteVersion
|
|
177
|
-
}),
|
|
178
|
-
[
|
|
179
|
-
versions,
|
|
180
|
-
previewVersion,
|
|
181
|
-
isDrawerOpen,
|
|
182
|
-
toggleDrawer,
|
|
183
|
-
isNameModalOpen,
|
|
184
|
-
createCheckpoint,
|
|
185
|
-
restoreVersion,
|
|
186
|
-
deleteVersion
|
|
187
|
-
]
|
|
188
|
-
);
|
|
189
|
-
return /* @__PURE__ */ jsx(VersionHistoryContext.Provider, { value, children });
|
|
190
|
-
};
|
|
191
|
-
var VersionHistoryProvider = ({ children }) => {
|
|
192
|
-
const existing = useContext(VersionHistoryContext);
|
|
193
|
-
if (existing) {
|
|
194
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
195
|
-
}
|
|
196
|
-
return /* @__PURE__ */ jsx(VersionHistoryProviderInternal, { children });
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
export {
|
|
200
|
-
useVersionHistory,
|
|
201
|
-
VersionHistoryProvider
|
|
202
|
-
};
|
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
|
-
};
|