@fde-desktop/fde-core 0.3.8 → 0.4.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.
Files changed (148) hide show
  1. package/README.md +419 -68
  2. package/dist/CalendarApp-CHLUCAI7.css +744 -0
  3. package/dist/CalendarApp-K7ZOUZ6C.js +2 -0
  4. package/dist/CalendarApp-OTGEERSS.cjs +8 -0
  5. package/dist/CodeServerApp-5KZGO7HL.css +75 -0
  6. package/dist/CodeServerApp-LUZFCQBI.js +3 -0
  7. package/dist/CodeServerApp-P3TMJPLY.cjs +9 -0
  8. package/dist/CreateItemApp-NAZMXOPK.cjs +14 -0
  9. package/dist/CreateItemApp-PQB5GTFG.css +107 -0
  10. package/dist/CreateItemApp-ZHCTSPQE.js +8 -0
  11. package/dist/DeviceInfoApp-R6YNVIGX.cjs +11 -0
  12. package/dist/DeviceInfoApp-YHCYAO6N.js +5 -0
  13. package/dist/DeviceInfoApp-ZSMRSITP.css +7 -0
  14. package/dist/FilesApp-AKCVRTXR.js +8 -0
  15. package/dist/FilesApp-E6L5W3T2.css +1817 -0
  16. package/dist/FilesApp-RW3Y6ILO.cjs +14 -0
  17. package/dist/ImageViewerApp-5UXNSW2O.js +11 -0
  18. package/dist/ImageViewerApp-N2Q7E7WZ.css +215 -0
  19. package/dist/ImageViewerApp-RRRRKSFN.cjs +17 -0
  20. package/dist/ImageViewerMenuBar-I3TFKQPS.cjs +14 -0
  21. package/dist/ImageViewerMenuBar-TV5C6TM2.js +5 -0
  22. package/dist/ImageViewerMenuBar-XLK4LIHW.css +56 -0
  23. package/dist/MenuEditApp-HUZRFEHE.js +9 -0
  24. package/dist/MenuEditApp-MCUHGTKQ.cjs +15 -0
  25. package/dist/MenuEditApp-YA6HSAMJ.css +94 -0
  26. package/dist/MenuEditMenuBar-7VHMZNRM.css +56 -0
  27. package/dist/MenuEditMenuBar-GF6L4PGZ.cjs +15 -0
  28. package/dist/MenuEditMenuBar-IUXFPZE5.js +6 -0
  29. package/dist/NotesApp-37BV33C6.js +10 -0
  30. package/dist/NotesApp-4EVUQEFZ.cjs +16 -0
  31. package/dist/NotesApp-TQ6IHDNX.css +302 -0
  32. package/dist/NotesMenuBar-25LKN3SE.cjs +15 -0
  33. package/dist/NotesMenuBar-MXLOX7OT.css +56 -0
  34. package/dist/NotesMenuBar-SRV3AIAL.js +6 -0
  35. package/dist/PdfApp-5VBDNRMC.cjs +16 -0
  36. package/dist/PdfApp-BUIC5U5H.css +206 -0
  37. package/dist/PdfApp-RH6MZZX5.js +10 -0
  38. package/dist/PdfMenuBar-NLZC6JHS.js +4 -0
  39. package/dist/PdfMenuBar-QUM72EE4.css +56 -0
  40. package/dist/PdfMenuBar-WBRTKMLN.cjs +13 -0
  41. package/dist/SettingsApp-5LDHEHYV.cjs +20 -0
  42. package/dist/SettingsApp-JVOSEFH3.css +283 -0
  43. package/dist/SettingsApp-X6764D7T.js +14 -0
  44. package/dist/SettingsMenuBar-5CBSSMVM.css +56 -0
  45. package/dist/SettingsMenuBar-VLT6TTCM.js +6 -0
  46. package/dist/SettingsMenuBar-Y5QEXDEO.cjs +15 -0
  47. package/dist/StorybookApp-NQ244BER.css +7 -0
  48. package/dist/StorybookApp-NZDV4X3Y.js +1 -0
  49. package/dist/StorybookApp-VF3KIMU3.cjs +7 -0
  50. package/dist/TerminalApp-CDGWRBFJ.cjs +10 -0
  51. package/dist/TerminalApp-EAATMIMX.css +77 -0
  52. package/dist/TerminalApp-GCKJCM55.js +4 -0
  53. package/dist/TerminalMenuBar-3J26O26Q.css +56 -0
  54. package/dist/TerminalMenuBar-7BH7MGNJ.cjs +14 -0
  55. package/dist/TerminalMenuBar-7JAEQUZ4.js +5 -0
  56. package/dist/UploaderApp-2WYRCUQV.js +10 -0
  57. package/dist/UploaderApp-6KV3TGCT.css +1817 -0
  58. package/dist/UploaderApp-EYFC36PM.cjs +16 -0
  59. package/dist/chunk-2FO445RM.cjs +449 -0
  60. package/dist/chunk-2PSTHGTD.cjs +42 -0
  61. package/dist/chunk-2RQX7QBP.cjs +148 -0
  62. package/dist/chunk-3IICBLEA.js +442 -0
  63. package/dist/chunk-43W6UDUZ.cjs +19 -0
  64. package/dist/chunk-4E45FBAH.js +223 -0
  65. package/dist/chunk-4MCFQPKY.js +444 -0
  66. package/dist/chunk-4OH5RPSQ.cjs +38 -0
  67. package/dist/chunk-4XURSNM4.js +43 -0
  68. package/dist/chunk-4ZCRYHL6.js +407 -0
  69. package/dist/chunk-54PYEQLK.js +283 -0
  70. package/dist/chunk-5C6IQE42.cjs +35 -0
  71. package/dist/chunk-5NOHYJNH.js +84 -0
  72. package/dist/chunk-5PYK5ASL.js +162 -0
  73. package/dist/chunk-5YH6AKEO.js +146 -0
  74. package/dist/chunk-657BJOY5.cjs +324 -0
  75. package/dist/chunk-6QOUYSEE.cjs +2303 -0
  76. package/dist/chunk-7SAFECOJ.js +215 -0
  77. package/dist/chunk-7Y7HB7FB.cjs +53 -0
  78. package/dist/chunk-ABIAPZ6S.cjs +45 -0
  79. package/dist/chunk-AQL372JF.cjs +219 -0
  80. package/dist/chunk-AXDUVZVP.cjs +88 -0
  81. package/dist/chunk-AYFNYHMP.js +541 -0
  82. package/dist/chunk-BDO6B7MZ.cjs +451 -0
  83. package/dist/chunk-BKXEA2BK.cjs +286 -0
  84. package/dist/chunk-BLV47DX2.js +47 -0
  85. package/dist/chunk-BQCD5RAF.cjs +48 -0
  86. package/dist/chunk-BQL3YXMV.js +17429 -0
  87. package/dist/chunk-C6BEZNAM.cjs +45 -0
  88. package/dist/chunk-CFWV2JMR.js +234 -0
  89. package/dist/chunk-CV5PUHAE.cjs +86 -0
  90. package/dist/chunk-D5MVFFID.js +42 -0
  91. package/dist/chunk-D7R55WWT.js +1601 -0
  92. package/dist/chunk-DMNF4CNN.cjs +49 -0
  93. package/dist/chunk-DWP2SYF7.js +55 -0
  94. package/dist/chunk-E55VXNLK.cjs +17498 -0
  95. package/dist/chunk-EAELL43F.js +42 -0
  96. package/dist/chunk-EUQLZW6P.js +48 -0
  97. package/dist/chunk-EX5V2ZTU.js +40 -0
  98. package/dist/chunk-FH4ILMKF.js +38 -0
  99. package/dist/chunk-FRHBM2U7.js +33 -0
  100. package/dist/chunk-FX2TPX3L.cjs +45 -0
  101. package/dist/chunk-GCYD6T52.js +32 -0
  102. package/dist/chunk-GRYCUBJZ.js +9 -0
  103. package/dist/chunk-HWHBSAUC.js +40 -0
  104. package/dist/chunk-ICUE6T7J.cjs +50 -0
  105. package/dist/chunk-IDHP3R4I.js +31 -0
  106. package/dist/chunk-IUOQPOEN.js +2293 -0
  107. package/dist/chunk-J7L2S2GT.cjs +34 -0
  108. package/dist/chunk-JEBKLIMU.cjs +123 -0
  109. package/dist/chunk-KQHICFX3.js +121 -0
  110. package/dist/chunk-LMJE6V4N.cjs +42 -0
  111. package/dist/chunk-MVDGM5Y4.js +68 -0
  112. package/dist/chunk-NVEGEK3N.js +31 -0
  113. package/dist/chunk-NWMSWRUD.js +2236 -0
  114. package/dist/chunk-ODXL6BR3.js +77 -0
  115. package/dist/chunk-OJIDKDKF.js +68 -0
  116. package/dist/chunk-PKPQA5NR.js +15 -0
  117. package/dist/chunk-PNDBLFJW.cjs +50 -0
  118. package/dist/chunk-PYTKNRGM.js +280 -0
  119. package/dist/chunk-Q3WA72BF.cjs +70 -0
  120. package/dist/chunk-QB72BLCJ.cjs +237 -0
  121. package/dist/chunk-QHBBLML3.js +86 -0
  122. package/dist/chunk-RDIDAZ3S.cjs +9 -0
  123. package/dist/chunk-RGJPRXYY.js +48 -0
  124. package/dist/chunk-RQ6OZRUW.cjs +41 -0
  125. package/dist/chunk-SBE4SZAN.cjs +226 -0
  126. package/dist/chunk-SYGUWGWK.cjs +2329 -0
  127. package/dist/chunk-TDZ43MUX.cjs +165 -0
  128. package/dist/chunk-TGWMOHAO.js +17 -0
  129. package/dist/chunk-U4RYIS6Z.cjs +548 -0
  130. package/dist/chunk-UIQCTAVM.cjs +59 -0
  131. package/dist/chunk-XVASHRCE.cjs +70 -0
  132. package/dist/chunk-XYSMVQQD.cjs +1608 -0
  133. package/dist/chunk-YAIWI4Z5.js +7 -0
  134. package/dist/chunk-YP2PLNOF.cjs +34 -0
  135. package/dist/chunk-YSOLW4FS.cjs +11 -0
  136. package/dist/chunk-YY6OUR2U.js +44 -0
  137. package/dist/chunk-YZWS7FDT.cjs +409 -0
  138. package/dist/chunk-Z5YGWL65.cjs +39 -0
  139. package/dist/chunk-ZBGWYTCU.cjs +83 -0
  140. package/dist/chunk-ZHB5Q2M6.js +36 -0
  141. package/dist/chunk-ZHNDXNL4.js +45 -0
  142. package/dist/chunk-ZX3EDZ5C.cjs +17 -0
  143. package/dist/index.cjs +4405 -5156
  144. package/dist/index.css +9192 -0
  145. package/dist/index.d.cts +1324 -762
  146. package/dist/index.d.ts +1324 -762
  147. package/dist/index.js +3648 -5038
  148. package/package.json +14 -6
@@ -0,0 +1,442 @@
1
+ import { useNotesStore } from './chunk-FH4ILMKF.js';
2
+ import { VscIcon_default } from './chunk-GRYCUBJZ.js';
3
+ import { useCloseInterceptor } from './chunk-ODXL6BR3.js';
4
+ import { FilePickerModal, FileSaveModal } from './chunk-4MCFQPKY.js';
5
+ import { TEXT_MIME_TYPES, useDesktopStore, resolveFileUrl } from './chunk-NWMSWRUD.js';
6
+ import { useState, useRef, useEffect, useCallback } from 'react';
7
+ import { useEditor, useEditorState, EditorContent } from '@tiptap/react';
8
+ import StarterKit from '@tiptap/starter-kit';
9
+ import { Markdown } from '@tiptap/markdown';
10
+ import { Extension } from '@tiptap/core';
11
+ import { useTranslation } from 'react-i18next';
12
+ import { create } from 'zustand';
13
+ import { persist, createJSONStorage } from 'zustand/middleware';
14
+ import { jsxs, jsx } from 'react/jsx-runtime';
15
+
16
+ var useAppTempMemoryStore = create()(
17
+ persist(
18
+ (set, get) => ({
19
+ snapshots: {},
20
+ setSnapshot: (appId, snapshot) => set((state) => ({ snapshots: { ...state.snapshots, [appId]: snapshot } })),
21
+ getSnapshot: (appId) => {
22
+ const { snapshots } = get();
23
+ return snapshots[appId] ?? null;
24
+ },
25
+ clearSnapshot: (appId) => set((state) => {
26
+ const rest = { ...state.snapshots };
27
+ delete rest[appId];
28
+ return { snapshots: rest };
29
+ })
30
+ }),
31
+ {
32
+ name: "fde-desktop:appTempMemory",
33
+ storage: createJSONStorage(() => localStorage)
34
+ }
35
+ )
36
+ );
37
+
38
+ // src/components/Apps/NotesApp/NotesApp.module.css
39
+ var NotesApp_default = {};
40
+ var ACCEPTED_MD_TYPES = [...TEXT_MIME_TYPES];
41
+ var ClearMarksOnEnter = Extension.create({
42
+ name: "clearMarksOnEnter",
43
+ addKeyboardShortcuts() {
44
+ return {
45
+ Enter: ({ editor }) => {
46
+ const { state, dispatch } = editor.view;
47
+ const { selection, schema } = state;
48
+ const { $from, empty } = selection;
49
+ if (!empty || $from.parent.type !== schema.nodes.paragraph) return false;
50
+ const tr = state.tr.split($from.pos).setStoredMarks([]);
51
+ dispatch(tr);
52
+ return true;
53
+ }
54
+ };
55
+ }
56
+ });
57
+ var WELCOME_URL = "Desktop/NotesAppWelcome.md";
58
+ var NotesApp = ({ window, notifyReady }) => {
59
+ const { t } = useTranslation("notes");
60
+ const win = window;
61
+ const windowId = win?.id;
62
+ const appId = windowId ? `notesApp-${windowId}` : "notesApp";
63
+ const contentData = win?.contentData;
64
+ const [fileName, setFileName] = useState(contentData?.initialName ?? t("untitled"));
65
+ const [saveModalOpen, setSaveModalOpen] = useState(false);
66
+ const pendingSaveMode = useRef("save");
67
+ const [fileId, setFileId] = useState(contentData?.fileId ?? null);
68
+ const contentSnapshotRef = useRef(contentData?.initialContent ?? "");
69
+ const [isDirty, setIsDirty] = useState(false);
70
+ const contentLoaded = useNotesStore((s) => s.states[windowId ?? ""]?.contentLoaded ?? false);
71
+ const setContentLoaded = useNotesStore((s) => s.setContentLoaded);
72
+ useEffect(() => {
73
+ if (!windowId) return;
74
+ useNotesStore.getState().reset(windowId);
75
+ }, [windowId]);
76
+ useEffect(() => {
77
+ if (!windowId) return;
78
+ useNotesStore.getState().setIsDirty(windowId, isDirty);
79
+ }, [windowId, isDirty]);
80
+ const createFile = useDesktopStore((state) => state.createFile);
81
+ const updateFile = useDesktopStore((state) => state.updateFile);
82
+ const fsNodes = useDesktopStore((state) => state.fsNodes);
83
+ const editor = useEditor({
84
+ extensions: [StarterKit, Markdown, ClearMarksOnEnter],
85
+ content: contentData?.initialContent ?? "",
86
+ contentType: "markdown",
87
+ shouldRerenderOnTransaction: false,
88
+ onCreate: () => {
89
+ const initial = editor?.getMarkdown() ?? "";
90
+ contentSnapshotRef.current = initial;
91
+ if (appId) {
92
+ useAppTempMemoryStore.getState().setSnapshot(appId, initial);
93
+ }
94
+ },
95
+ onUpdate: () => {
96
+ const current = editor?.getMarkdown() ?? "";
97
+ const dirty = current !== (contentSnapshotRef.current ?? "");
98
+ setIsDirty(dirty);
99
+ if (!dirty && appId) {
100
+ useAppTempMemoryStore.getState().setSnapshot(appId, current);
101
+ }
102
+ }
103
+ });
104
+ useEffect(() => {
105
+ if (!fileId || !editor || contentLoaded) return;
106
+ const node = fsNodes.find((n) => n.id === fileId);
107
+ if (!node || node.type !== "file") return;
108
+ const fileNode = node;
109
+ if (fileNode.content && fileNode.content !== (contentSnapshotRef.current ?? "")) {
110
+ contentSnapshotRef.current = fileNode.content;
111
+ if (appId) {
112
+ useAppTempMemoryStore.getState().setSnapshot(appId, fileNode.content);
113
+ }
114
+ editor.commands.setContent(fileNode.content, { emitUpdate: false, contentType: "markdown" });
115
+ setContentLoaded(windowId, true);
116
+ }
117
+ }, [fileId, editor, appId, fsNodes, contentLoaded, windowId, setContentLoaded]);
118
+ useEffect(() => {
119
+ if (!editor || !windowId || contentLoaded) return;
120
+ let cancelled = false;
121
+ const abortController = new AbortController();
122
+ const loadContent = async () => {
123
+ try {
124
+ if (contentData?.initialContent) {
125
+ if (!cancelled) {
126
+ editor.commands.setContent(contentData.initialContent, {
127
+ emitUpdate: false,
128
+ contentType: "markdown"
129
+ });
130
+ setContentLoaded(windowId, true);
131
+ }
132
+ return;
133
+ }
134
+ if (contentData?.url) {
135
+ const content = await resolveFileUrl(contentData.url, abortController.signal);
136
+ if (!cancelled && content) {
137
+ editor.commands.setContent(content, { emitUpdate: false, contentType: "markdown" });
138
+ setContentLoaded(windowId, true);
139
+ }
140
+ return;
141
+ }
142
+ if (contentData?.fileId) {
143
+ return;
144
+ }
145
+ const base = import.meta.env.BASE_URL;
146
+ const response = await fetch(`${base}${WELCOME_URL}`, { signal: abortController.signal });
147
+ if (!cancelled && response.ok) {
148
+ const content = await response.text();
149
+ editor.commands.setContent(content, { emitUpdate: false, contentType: "markdown" });
150
+ setContentLoaded(windowId, true);
151
+ }
152
+ } catch (error) {
153
+ if (!cancelled && error instanceof Error && error.name !== "AbortError") {
154
+ console.warn("Failed to load content:", error);
155
+ }
156
+ }
157
+ };
158
+ loadContent();
159
+ return () => {
160
+ cancelled = true;
161
+ abortController.abort();
162
+ };
163
+ }, [editor, contentData, windowId, contentLoaded, setContentLoaded]);
164
+ const getMarkdown = useCallback(() => {
165
+ if (!editor) return "";
166
+ return editor.getMarkdown();
167
+ }, [editor]);
168
+ const handleNew = useCallback(() => {
169
+ editor?.commands.setContent("", { emitUpdate: false, contentType: "markdown" });
170
+ setFileId(null);
171
+ setFileName("untitled.md");
172
+ contentSnapshotRef.current = "";
173
+ setIsDirty(false);
174
+ if (windowId) {
175
+ setContentLoaded(windowId, true);
176
+ }
177
+ }, [editor, windowId, setContentLoaded]);
178
+ const handleSave = useCallback(() => {
179
+ if (!editor) return;
180
+ if (fileId) {
181
+ updateFile(fileId, getMarkdown());
182
+ contentSnapshotRef.current = getMarkdown();
183
+ setIsDirty(false);
184
+ } else {
185
+ pendingSaveMode.current = "save";
186
+ setSaveModalOpen(true);
187
+ }
188
+ }, [editor, getMarkdown, updateFile, fileId]);
189
+ const handleSaveAs = useCallback(() => {
190
+ if (!editor) return;
191
+ pendingSaveMode.current = "saveAs";
192
+ setSaveModalOpen(true);
193
+ }, [editor]);
194
+ const handleSaveConfirm = useCallback(
195
+ async ({ parentId, name }) => {
196
+ if (!editor) return;
197
+ const content = getMarkdown();
198
+ if (pendingSaveMode.current === "saveAs" || !fileId) {
199
+ const file = await createFile(name, content, parentId);
200
+ setFileId(file.id);
201
+ setFileName(file.name);
202
+ } else {
203
+ await updateFile(fileId, content);
204
+ }
205
+ contentSnapshotRef.current = content;
206
+ setIsDirty(false);
207
+ setSaveModalOpen(false);
208
+ },
209
+ [editor, getMarkdown, createFile, updateFile, fileId]
210
+ );
211
+ const [pickerOpen, setPickerOpen] = useState(false);
212
+ const handleFileSelected = useCallback(
213
+ (node) => {
214
+ setFileId(node.id);
215
+ setFileName(node.name);
216
+ contentSnapshotRef.current = node.content ?? "";
217
+ setIsDirty(false);
218
+ setPickerOpen(false);
219
+ const url = node.url;
220
+ if (url) {
221
+ resolveFileUrl(url).then((md) => {
222
+ if (md) {
223
+ editor?.commands.setContent(md, { emitUpdate: false, contentType: "markdown" });
224
+ if (windowId) setContentLoaded(windowId, true);
225
+ }
226
+ });
227
+ } else if (node.content) {
228
+ editor?.commands.setContent(node.content, { emitUpdate: false, contentType: "markdown" });
229
+ if (windowId) setContentLoaded(windowId, true);
230
+ }
231
+ },
232
+ [editor, windowId, setContentLoaded]
233
+ );
234
+ const setPickerOpenCallback = useCallback(() => setPickerOpen(true), []);
235
+ useEffect(() => {
236
+ const actions = { new: handleNew, save: handleSave, saveAs: handleSaveAs };
237
+ notifyReady?.({
238
+ ...win?.contentData ?? {},
239
+ actions,
240
+ setPickerOpen: setPickerOpenCallback,
241
+ isDirty
242
+ });
243
+ }, [handleNew, handleSave, handleSaveAs, win, notifyReady, setPickerOpenCallback, isDirty]);
244
+ const isDirtyGetter = useCallback(() => {
245
+ const current = editor?.getMarkdown() ?? "";
246
+ return current !== (contentSnapshotRef.current ?? "");
247
+ }, [editor]);
248
+ useCloseInterceptor({
249
+ isDirtyGetter,
250
+ windowId,
251
+ onDiscard: () => {
252
+ if (!editor) return;
253
+ const snapshot = contentSnapshotRef.current ?? "";
254
+ editor.commands.setContent(snapshot, { emitUpdate: false, contentType: "markdown" });
255
+ setIsDirty(false);
256
+ },
257
+ onSave: handleSave
258
+ });
259
+ const editorState = useEditorState({
260
+ editor,
261
+ selector: (ctx) => ({
262
+ canUndo: ctx.editor?.can().undo() ?? false,
263
+ canRedo: ctx.editor?.can().redo() ?? false,
264
+ isBold: ctx.editor?.isActive("bold") ?? false,
265
+ isItalic: ctx.editor?.isActive("italic") ?? false,
266
+ isStrike: ctx.editor?.isActive("strike") ?? false,
267
+ isCode: ctx.editor?.isActive("code") ?? false,
268
+ isH1: ctx.editor?.isActive("heading", { level: 1 }) ?? false,
269
+ isH2: ctx.editor?.isActive("heading", { level: 2 }) ?? false,
270
+ isBulletList: ctx.editor?.isActive("bulletList") ?? false,
271
+ isOrderedList: ctx.editor?.isActive("orderedList") ?? false,
272
+ isBlockquote: ctx.editor?.isActive("blockquote") ?? false,
273
+ isCodeBlock: ctx.editor?.isActive("codeBlock") ?? false
274
+ })
275
+ });
276
+ return /* @__PURE__ */ jsxs("div", { className: NotesApp_default.container, "data-windowid": win?.id, children: [
277
+ /* @__PURE__ */ jsxs("div", { className: NotesApp_default.toolbar, role: "toolbar", "aria-label": t("toolbar.formatting"), children: [
278
+ /* @__PURE__ */ jsx(
279
+ "button",
280
+ {
281
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isBold ? NotesApp_default.active : ""}`,
282
+ onClick: () => editor?.chain().focus().toggleBold().run(),
283
+ disabled: !editor?.can().chain().focus().toggleBold().run(),
284
+ title: t("toolbar.bold"),
285
+ "aria-label": t("toolbar.bold"),
286
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscBold" })
287
+ }
288
+ ),
289
+ /* @__PURE__ */ jsx(
290
+ "button",
291
+ {
292
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isItalic ? NotesApp_default.active : ""}`,
293
+ onClick: () => editor?.chain().focus().toggleItalic().run(),
294
+ disabled: !editor?.can().chain().focus().toggleItalic().run(),
295
+ title: t("toolbar.italic"),
296
+ "aria-label": t("toolbar.italic"),
297
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscItalic" })
298
+ }
299
+ ),
300
+ /* @__PURE__ */ jsx(
301
+ "button",
302
+ {
303
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isStrike ? NotesApp_default.active : ""}`,
304
+ onClick: () => editor?.chain().focus().toggleStrike().run(),
305
+ disabled: !editor?.can().chain().focus().toggleStrike().run(),
306
+ title: t("toolbar.strikethrough"),
307
+ "aria-label": t("toolbar.strikethrough"),
308
+ children: /* @__PURE__ */ jsx("s", { children: "S" })
309
+ }
310
+ ),
311
+ /* @__PURE__ */ jsx(
312
+ "button",
313
+ {
314
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isCode ? NotesApp_default.active : ""}`,
315
+ onClick: () => editor?.chain().focus().toggleCode().run(),
316
+ disabled: !editor?.can().chain().focus().toggleCode().run(),
317
+ title: t("toolbar.inlineCode"),
318
+ "aria-label": t("toolbar.inlineCode"),
319
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscCode" })
320
+ }
321
+ ),
322
+ /* @__PURE__ */ jsx("span", { className: NotesApp_default.separator }),
323
+ /* @__PURE__ */ jsx(
324
+ "button",
325
+ {
326
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isH1 ? NotesApp_default.active : ""}`,
327
+ onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
328
+ title: t("toolbar.heading1"),
329
+ "aria-label": t("toolbar.heading1"),
330
+ children: /* @__PURE__ */ jsx("strong", { children: "H1" })
331
+ }
332
+ ),
333
+ /* @__PURE__ */ jsx(
334
+ "button",
335
+ {
336
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isH2 ? NotesApp_default.active : ""}`,
337
+ onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
338
+ title: t("toolbar.heading2"),
339
+ "aria-label": t("toolbar.heading2"),
340
+ children: /* @__PURE__ */ jsx("strong", { children: "H2" })
341
+ }
342
+ ),
343
+ /* @__PURE__ */ jsx("span", { className: NotesApp_default.separator }),
344
+ /* @__PURE__ */ jsx(
345
+ "button",
346
+ {
347
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isBulletList ? NotesApp_default.active : ""}`,
348
+ onClick: () => editor?.chain().focus().toggleBulletList().run(),
349
+ title: t("toolbar.bulletList"),
350
+ "aria-label": t("toolbar.bulletList"),
351
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscListUnordered" })
352
+ }
353
+ ),
354
+ /* @__PURE__ */ jsx(
355
+ "button",
356
+ {
357
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isOrderedList ? NotesApp_default.active : ""}`,
358
+ onClick: () => editor?.chain().focus().toggleOrderedList().run(),
359
+ title: t("toolbar.orderedList"),
360
+ "aria-label": t("toolbar.orderedList"),
361
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscListOrdered" })
362
+ }
363
+ ),
364
+ /* @__PURE__ */ jsx("span", { className: NotesApp_default.separator }),
365
+ /* @__PURE__ */ jsx(
366
+ "button",
367
+ {
368
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isBlockquote ? NotesApp_default.active : ""}`,
369
+ onClick: () => editor?.chain().focus().toggleBlockquote().run(),
370
+ title: t("toolbar.blockquote"),
371
+ "aria-label": t("toolbar.blockquote"),
372
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscQuote" })
373
+ }
374
+ ),
375
+ /* @__PURE__ */ jsx(
376
+ "button",
377
+ {
378
+ className: `${NotesApp_default.toolbarBtn} ${editorState?.isCodeBlock ? NotesApp_default.active : ""}`,
379
+ onClick: () => editor?.chain().focus().toggleCodeBlock().run(),
380
+ title: t("toolbar.codeBlock"),
381
+ "aria-label": t("toolbar.codeBlock"),
382
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscTerminal" })
383
+ }
384
+ ),
385
+ /* @__PURE__ */ jsx(
386
+ "button",
387
+ {
388
+ className: NotesApp_default.toolbarBtn,
389
+ onClick: () => editor?.chain().focus().setHorizontalRule().run(),
390
+ title: t("toolbar.horizontalRule"),
391
+ "aria-label": t("toolbar.horizontalRule"),
392
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscHorizontalRule" })
393
+ }
394
+ ),
395
+ /* @__PURE__ */ jsx("span", { className: NotesApp_default.separator }),
396
+ /* @__PURE__ */ jsx(
397
+ "button",
398
+ {
399
+ className: NotesApp_default.toolbarBtn,
400
+ onClick: () => editor?.chain().focus().undo().run(),
401
+ disabled: !editorState?.canUndo,
402
+ title: t("common:actions.undo"),
403
+ "aria-label": t("common:actions.undo"),
404
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscDiscard" })
405
+ }
406
+ ),
407
+ /* @__PURE__ */ jsx(
408
+ "button",
409
+ {
410
+ className: NotesApp_default.toolbarBtn,
411
+ onClick: () => editor?.chain().focus().redo().run(),
412
+ disabled: !editorState?.canRedo,
413
+ title: t("common:actions.redo"),
414
+ "aria-label": t("common:actions.redo"),
415
+ children: /* @__PURE__ */ jsx(VscIcon_default, { name: "VscRedo" })
416
+ }
417
+ )
418
+ ] }),
419
+ /* @__PURE__ */ jsx(EditorContent, { editor, className: NotesApp_default.editorContent }),
420
+ /* @__PURE__ */ jsx(
421
+ FilePickerModal,
422
+ {
423
+ opened: pickerOpen,
424
+ acceptedMimeTypes: ACCEPTED_MD_TYPES,
425
+ onConfirm: handleFileSelected,
426
+ onCancel: () => setPickerOpen(false)
427
+ }
428
+ ),
429
+ /* @__PURE__ */ jsx(
430
+ FileSaveModal,
431
+ {
432
+ opened: saveModalOpen,
433
+ initialName: fileName,
434
+ onConfirm: handleSaveConfirm,
435
+ onCancel: () => setSaveModalOpen(false)
436
+ }
437
+ )
438
+ ] });
439
+ };
440
+ var NotesApp_default2 = NotesApp;
441
+
442
+ export { NotesApp_default2 as NotesApp_default, useAppTempMemoryStore };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+
5
+ // src/components/Apps/StorybookApp/StorybookApp.module.css
6
+ var StorybookApp_default = {};
7
+ var STORYBOOK_URL = "https://frannunpal.github.io/storybook/";
8
+ var StorybookApp = () => /* @__PURE__ */ jsxRuntime.jsx(
9
+ "iframe",
10
+ {
11
+ src: STORYBOOK_URL,
12
+ className: StorybookApp_default.frame,
13
+ title: "Storybook",
14
+ "aria-label": "Storybook component explorer"
15
+ }
16
+ );
17
+ var StorybookApp_default2 = StorybookApp;
18
+
19
+ exports.StorybookApp_default = StorybookApp_default2;
@@ -0,0 +1,223 @@
1
+ import { useFcIconElement } from './chunk-YY6OUR2U.js';
2
+ import { Select, NumberInput, TextInput, Tooltip, Slider, Switch, Menu } from './chunk-BQL3YXMV.js';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import { useState } from 'react';
5
+
6
+ var DirtyIndicator = ({ size = 16 }) => {
7
+ const icon = useFcIconElement("FcSynchronize", { size });
8
+ return /* @__PURE__ */ jsx(
9
+ "span",
10
+ {
11
+ style: {
12
+ color: "orange",
13
+ fontWeight: "bold",
14
+ marginLeft: "8px",
15
+ display: "flex",
16
+ alignItems: "center"
17
+ },
18
+ title: "Unsaved changes",
19
+ children: icon
20
+ }
21
+ );
22
+ };
23
+ var DirtyIndicator_default = DirtyIndicator;
24
+
25
+ // src/components/AppMenuBar/AppMenuBar.module.css
26
+ var AppMenuBar_default = {};
27
+ var ICON_PROPS = { size: 16, style: { display: "block" } };
28
+ var FcIcon = ({ name }) => useFcIconElement(name, ICON_PROPS);
29
+ var MenuDropdownElement = ({
30
+ label,
31
+ icon,
32
+ items,
33
+ rightSection
34
+ }) => {
35
+ const [opened, setOpened] = useState(false);
36
+ const TriggerIcon = () => useFcIconElement(icon ?? "", ICON_PROPS);
37
+ return /* @__PURE__ */ jsxs(
38
+ Menu,
39
+ {
40
+ opened,
41
+ onClose: () => setOpened(false),
42
+ withinPortal: true,
43
+ keepMounted: true,
44
+ closeOnItemClick: true,
45
+ closeOnEscape: true,
46
+ closeOnClickOutside: true,
47
+ position: "bottom-start",
48
+ children: [
49
+ /* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsxs("button", { className: AppMenuBar_default.menuTrigger, onClick: () => setOpened((o) => !o), children: [
50
+ icon && /* @__PURE__ */ jsx(TriggerIcon, {}),
51
+ /* @__PURE__ */ jsx("span", { children: label }),
52
+ rightSection && /* @__PURE__ */ jsx("span", { style: { marginLeft: "auto" }, children: rightSection })
53
+ ] }) }),
54
+ /* @__PURE__ */ jsx(Menu.Dropdown, { children: items.map((item, idx) => {
55
+ if (item.type === "divider") {
56
+ return /* @__PURE__ */ jsx(Menu.Divider, {}, idx);
57
+ }
58
+ if (item.type === "slider") {
59
+ return /* @__PURE__ */ jsx(Menu.Item, { closeMenuOnClick: false, children: /* @__PURE__ */ jsxs("div", { style: { minWidth: 120 }, children: [
60
+ item.label && /* @__PURE__ */ jsx("div", { style: { marginBottom: 4 }, children: item.label }),
61
+ /* @__PURE__ */ jsx(
62
+ Slider,
63
+ {
64
+ min: item.min,
65
+ max: item.max,
66
+ value: item.value,
67
+ onChange: item.onChange,
68
+ size: "sm"
69
+ }
70
+ )
71
+ ] }) }, idx);
72
+ }
73
+ return /* @__PURE__ */ jsx(
74
+ Menu.Item,
75
+ {
76
+ disabled: item.disabled,
77
+ onClick: item.onClick,
78
+ leftSection: item.icon ? /* @__PURE__ */ jsx(FcIcon, { name: item.icon }) : void 0,
79
+ children: item.label
80
+ },
81
+ idx
82
+ );
83
+ }) })
84
+ ]
85
+ }
86
+ );
87
+ };
88
+ var AppMenuBar = ({ elements }) => {
89
+ const [sliderStates, setSliderStates] = useState({});
90
+ const setSliderState = (idx, state) => {
91
+ setSliderStates((prev) => ({
92
+ ...prev,
93
+ [idx]: { ...prev[idx] ?? { isHovered: false, isDragging: false }, ...state }
94
+ }));
95
+ };
96
+ return /* @__PURE__ */ jsx("div", { className: AppMenuBar_default.root, role: "menubar", "aria-label": "Application menu", children: elements.map((el, idx) => {
97
+ switch (el.type) {
98
+ case "menu":
99
+ return /* @__PURE__ */ jsx(
100
+ MenuDropdownElement,
101
+ {
102
+ label: el.label,
103
+ icon: el.icon,
104
+ items: el.items,
105
+ rightSection: el.rightSection
106
+ },
107
+ idx
108
+ );
109
+ case "combobox":
110
+ return /* @__PURE__ */ jsx("div", { className: AppMenuBar_default.element, children: /* @__PURE__ */ jsx(
111
+ Select,
112
+ {
113
+ data: el.options,
114
+ value: el.value,
115
+ onChange: (v) => v && el.onChange(v),
116
+ placeholder: el.label,
117
+ size: "sm",
118
+ className: AppMenuBar_default.select,
119
+ comboboxProps: { withinPortal: true }
120
+ }
121
+ ) }, idx);
122
+ case "switch":
123
+ return /* @__PURE__ */ jsx("div", { className: AppMenuBar_default.element, children: /* @__PURE__ */ jsx(
124
+ Switch,
125
+ {
126
+ label: el.label,
127
+ checked: el.checked,
128
+ onChange: (e) => el.onChange(e.currentTarget.checked),
129
+ size: "sm"
130
+ }
131
+ ) }, idx);
132
+ case "slider": {
133
+ const sliderState = sliderStates[idx] ?? { isHovered: false, isDragging: false };
134
+ const isTooltipOpen = sliderState.isHovered || sliderState.isDragging;
135
+ const labelFormat = el.labelFormat ?? ((val) => String(val));
136
+ return /* @__PURE__ */ jsx(
137
+ Tooltip,
138
+ {
139
+ label: labelFormat(el.value),
140
+ position: "bottom",
141
+ withArrow: true,
142
+ opened: isTooltipOpen,
143
+ children: /* @__PURE__ */ jsxs(
144
+ "div",
145
+ {
146
+ className: AppMenuBar_default.element,
147
+ onMouseEnter: () => setSliderState(idx, { isHovered: true }),
148
+ onMouseLeave: () => setSliderState(idx, { isHovered: false }),
149
+ children: [
150
+ el.label && /* @__PURE__ */ jsx("span", { className: AppMenuBar_default.sliderLabel, children: el.label }),
151
+ /* @__PURE__ */ jsx(
152
+ Slider,
153
+ {
154
+ min: el.min,
155
+ max: el.max,
156
+ value: el.value,
157
+ onChange: (val) => {
158
+ el.onChange(val);
159
+ setSliderState(idx, { isDragging: true });
160
+ },
161
+ onChangeEnd: (val) => {
162
+ el.onChange(val);
163
+ setSliderState(idx, { isDragging: false });
164
+ },
165
+ size: "sm",
166
+ className: AppMenuBar_default.slider,
167
+ marks: el.marks
168
+ }
169
+ )
170
+ ]
171
+ }
172
+ )
173
+ },
174
+ idx
175
+ );
176
+ }
177
+ case "text-input":
178
+ return /* @__PURE__ */ jsx("div", { className: AppMenuBar_default.element, children: /* @__PURE__ */ jsx(
179
+ TextInput,
180
+ {
181
+ placeholder: el.placeholder,
182
+ value: el.value,
183
+ onChange: (e) => el.onChange(e.currentTarget.value),
184
+ size: "sm",
185
+ className: AppMenuBar_default.textInput
186
+ }
187
+ ) }, idx);
188
+ case "number-input":
189
+ return /* @__PURE__ */ jsx("div", { className: AppMenuBar_default.element, children: /* @__PURE__ */ jsx(
190
+ NumberInput,
191
+ {
192
+ label: el.label,
193
+ value: el.value,
194
+ onChange: (v) => el.onChange(typeof v === "number" ? v : 0),
195
+ min: el.min,
196
+ max: el.max,
197
+ step: el.step ?? 1,
198
+ placeholder: el.placeholder,
199
+ size: "sm",
200
+ className: AppMenuBar_default.numberInput
201
+ }
202
+ ) }, idx);
203
+ case "select":
204
+ return /* @__PURE__ */ jsx("div", { className: AppMenuBar_default.element, children: /* @__PURE__ */ jsx(
205
+ Select,
206
+ {
207
+ label: el.label,
208
+ data: el.options,
209
+ value: el.value,
210
+ onChange: (v) => v && el.onChange(v),
211
+ size: "sm",
212
+ className: AppMenuBar_default.select,
213
+ comboboxProps: { withinPortal: true }
214
+ }
215
+ ) }, idx);
216
+ case "dirty-indicator":
217
+ return /* @__PURE__ */ jsx("span", { style: { marginLeft: "auto" }, children: /* @__PURE__ */ jsx(DirtyIndicator_default, {}) }, idx);
218
+ }
219
+ }) });
220
+ };
221
+ var AppMenuBar_default2 = AppMenuBar;
222
+
223
+ export { AppMenuBar_default2 as AppMenuBar_default, DirtyIndicator_default };