@bendyline/docblocks-react 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/dist/ExportDialog-VYATD5UC.js +9 -0
- package/dist/{ExportToolbarControls-D2YDWOXW.js → ExportToolbarControls-5HUE3LSX.js} +206 -42
- package/dist/{GitToolbarControl-LMIR4R7I.js → GitToolbarControl-FW3BZFXV.js} +62 -44
- package/dist/{GitUI-KGF5MSNV.js → GitUI-GMH3PAYL.js} +225 -141
- package/dist/{LazyEditorShell-EF2BWRXU.js → LazyEditorShell-RF54B5UD.js} +0 -1
- package/dist/ShareDialog-PAMOQQFB.js +212 -0
- package/dist/chunk-3CZ27FOA.js +359 -0
- package/dist/chunk-3QSZY74C.js +255 -0
- package/{src/Export/export-destination.ts → dist/chunk-BI7NVU6T.js} +16 -15
- package/dist/{chunk-VHDP4IPL.js → chunk-BPGEBGAN.js} +0 -1
- package/dist/{chunk-DD4VFJQI.js → chunk-EBWYGTN7.js} +2 -1
- package/dist/{chunk-ZI56BNB7.js → chunk-GHQ4X7KM.js} +27 -7
- package/dist/{chunk-5A4KEWKT.js → chunk-HFYPTTCH.js} +0 -1
- package/dist/chunk-LG6HAWCK.js +109 -0
- package/dist/chunk-TFMO7EVO.js +88 -0
- package/dist/{chunk-4XXSWN3T.js → chunk-YBEYTVU2.js} +0 -1
- package/dist/editor.d.ts +5 -4
- package/dist/editor.js +8 -70
- package/dist/export/index.d.ts +24 -8
- package/dist/export/index.js +10 -6
- package/dist/index.d.ts +355 -21
- package/dist/index.js +6419 -21
- package/dist/run-export-Z5BVFLIR.js +9 -0
- package/dist/settings/index.d.ts +9 -1
- package/dist/settings/index.js +6 -5
- package/package.json +18 -13
- package/src/styles/docblocks.css +985 -35
- package/dist/AppMenu/AppMenu.d.ts +0 -53
- package/dist/AppMenu/AppMenu.d.ts.map +0 -1
- package/dist/AppMenu/AppMenu.js +0 -67
- package/dist/AppMenu/AppMenu.js.map +0 -1
- package/dist/AppMenu/index.d.ts +0 -3
- package/dist/AppMenu/index.d.ts.map +0 -1
- package/dist/AppMenu/index.js +0 -2
- package/dist/AppMenu/index.js.map +0 -1
- package/dist/DocBlocksShell/DocBlocksShell.d.ts +0 -49
- package/dist/DocBlocksShell/DocBlocksShell.d.ts.map +0 -1
- package/dist/DocBlocksShell/DocBlocksShell.js +0 -2730
- package/dist/DocBlocksShell/DocBlocksShell.js.map +0 -1
- package/dist/DocBlocksShell/LazyEditorShell.d.ts +0 -3
- package/dist/DocBlocksShell/LazyEditorShell.d.ts.map +0 -1
- package/dist/DocBlocksShell/LazyEditorShell.js +0 -3
- package/dist/DocBlocksShell/LazyEditorShell.js.map +0 -1
- package/dist/DocBlocksShell/UpdateAvailableNotice.d.ts +0 -13
- package/dist/DocBlocksShell/UpdateAvailableNotice.d.ts.map +0 -1
- package/dist/DocBlocksShell/UpdateAvailableNotice.js +0 -16
- package/dist/DocBlocksShell/UpdateAvailableNotice.js.map +0 -1
- package/dist/DocBlocksShell/document-title.d.ts +0 -3
- package/dist/DocBlocksShell/document-title.d.ts.map +0 -1
- package/dist/DocBlocksShell/document-title.js +0 -17
- package/dist/DocBlocksShell/document-title.js.map +0 -1
- package/dist/DocBlocksShell/index.d.ts +0 -3
- package/dist/DocBlocksShell/index.d.ts.map +0 -1
- package/dist/DocBlocksShell/index.js +0 -2
- package/dist/DocBlocksShell/index.js.map +0 -1
- package/dist/DocBlocksShell/workspace-authority-barrier.d.ts +0 -14
- package/dist/DocBlocksShell/workspace-authority-barrier.d.ts.map +0 -1
- package/dist/DocBlocksShell/workspace-authority-barrier.js +0 -23
- package/dist/DocBlocksShell/workspace-authority-barrier.js.map +0 -1
- package/dist/Export/DeferredExportToolbarControls.d.ts +0 -5
- package/dist/Export/DeferredExportToolbarControls.d.ts.map +0 -1
- package/dist/Export/DeferredExportToolbarControls.js +0 -10
- package/dist/Export/DeferredExportToolbarControls.js.map +0 -1
- package/dist/Export/ExportDialog.d.ts +0 -25
- package/dist/Export/ExportDialog.d.ts.map +0 -1
- package/dist/Export/ExportDialog.js +0 -160
- package/dist/Export/ExportDialog.js.map +0 -1
- package/dist/Export/ExportToolbarControls.d.ts +0 -37
- package/dist/Export/ExportToolbarControls.d.ts.map +0 -1
- package/dist/Export/ExportToolbarControls.js +0 -285
- package/dist/Export/ExportToolbarControls.js.map +0 -1
- package/dist/Export/export-destination.d.ts +0 -3
- package/dist/Export/export-destination.d.ts.map +0 -1
- package/dist/Export/export-destination.js +0 -32
- package/dist/Export/export-destination.js.map +0 -1
- package/dist/Export/export-options.d.ts +0 -53
- package/dist/Export/export-options.d.ts.map +0 -1
- package/dist/Export/export-options.js +0 -49
- package/dist/Export/export-options.js.map +0 -1
- package/dist/Export/index.d.ts +0 -10
- package/dist/Export/index.d.ts.map +0 -1
- package/dist/Export/index.js +0 -6
- package/dist/Export/index.js.map +0 -1
- package/dist/Export/public-api.d.ts +0 -12
- package/dist/Export/public-api.d.ts.map +0 -1
- package/dist/Export/public-api.js +0 -9
- package/dist/Export/public-api.js.map +0 -1
- package/dist/Export/run-export.d.ts +0 -10
- package/dist/Export/run-export.d.ts.map +0 -1
- package/dist/Export/run-export.js +0 -313
- package/dist/Export/run-export.js.map +0 -1
- package/dist/Export/transform-summaries.d.ts +0 -7
- package/dist/Export/transform-summaries.d.ts.map +0 -1
- package/dist/Export/transform-summaries.js +0 -6
- package/dist/Export/transform-summaries.js.map +0 -1
- package/dist/ExportDialog-MEUISWZX.js +0 -9
- package/dist/ExportDialog-MEUISWZX.js.map +0 -1
- package/dist/ExportToolbarControls-D2YDWOXW.js.map +0 -1
- package/dist/FileExplorer/FileExplorer.d.ts +0 -43
- package/dist/FileExplorer/FileExplorer.d.ts.map +0 -1
- package/dist/FileExplorer/FileExplorer.js +0 -315
- package/dist/FileExplorer/FileExplorer.js.map +0 -1
- package/dist/FileExplorer/FileTreeNode.d.ts +0 -39
- package/dist/FileExplorer/FileTreeNode.d.ts.map +0 -1
- package/dist/FileExplorer/FileTreeNode.js +0 -131
- package/dist/FileExplorer/FileTreeNode.js.map +0 -1
- package/dist/FileExplorer/index.d.ts +0 -6
- package/dist/FileExplorer/index.d.ts.map +0 -1
- package/dist/FileExplorer/index.js +0 -4
- package/dist/FileExplorer/index.js.map +0 -1
- package/dist/FileExplorer/useFileTree.d.ts +0 -37
- package/dist/FileExplorer/useFileTree.d.ts.map +0 -1
- package/dist/FileExplorer/useFileTree.js +0 -284
- package/dist/FileExplorer/useFileTree.js.map +0 -1
- package/dist/Git/GitAuthGuidanceDialog.d.ts +0 -18
- package/dist/Git/GitAuthGuidanceDialog.d.ts.map +0 -1
- package/dist/Git/GitAuthGuidanceDialog.js +0 -27
- package/dist/Git/GitAuthGuidanceDialog.js.map +0 -1
- package/dist/Git/GitBranchesDialog.d.ts +0 -13
- package/dist/Git/GitBranchesDialog.d.ts.map +0 -1
- package/dist/Git/GitBranchesDialog.js +0 -59
- package/dist/Git/GitBranchesDialog.js.map +0 -1
- package/dist/Git/GitCloneDialog.d.ts +0 -14
- package/dist/Git/GitCloneDialog.d.ts.map +0 -1
- package/dist/Git/GitCloneDialog.js +0 -79
- package/dist/Git/GitCloneDialog.js.map +0 -1
- package/dist/Git/GitCommitDialog.d.ts +0 -12
- package/dist/Git/GitCommitDialog.d.ts.map +0 -1
- package/dist/Git/GitCommitDialog.js +0 -38
- package/dist/Git/GitCommitDialog.js.map +0 -1
- package/dist/Git/GitConflictsDialog.d.ts +0 -12
- package/dist/Git/GitConflictsDialog.d.ts.map +0 -1
- package/dist/Git/GitConflictsDialog.js +0 -17
- package/dist/Git/GitConflictsDialog.js.map +0 -1
- package/dist/Git/GitContext.d.ts +0 -89
- package/dist/Git/GitContext.d.ts.map +0 -1
- package/dist/Git/GitContext.js +0 -15
- package/dist/Git/GitContext.js.map +0 -1
- package/dist/Git/GitDiffDialog.d.ts +0 -20
- package/dist/Git/GitDiffDialog.d.ts.map +0 -1
- package/dist/Git/GitDiffDialog.js +0 -100
- package/dist/Git/GitDiffDialog.js.map +0 -1
- package/dist/Git/GitDiffView.d.ts +0 -23
- package/dist/Git/GitDiffView.d.ts.map +0 -1
- package/dist/Git/GitDiffView.js +0 -77
- package/dist/Git/GitDiffView.js.map +0 -1
- package/dist/Git/GitHistoryDialog.d.ts +0 -15
- package/dist/Git/GitHistoryDialog.d.ts.map +0 -1
- package/dist/Git/GitHistoryDialog.js +0 -107
- package/dist/Git/GitHistoryDialog.js.map +0 -1
- package/dist/Git/GitStatusBar.d.ts +0 -8
- package/dist/Git/GitStatusBar.d.ts.map +0 -1
- package/dist/Git/GitStatusBar.js +0 -49
- package/dist/Git/GitStatusBar.js.map +0 -1
- package/dist/Git/GitToolbarControl.d.ts +0 -15
- package/dist/Git/GitToolbarControl.d.ts.map +0 -1
- package/dist/Git/GitToolbarControl.js +0 -51
- package/dist/Git/GitToolbarControl.js.map +0 -1
- package/dist/Git/GitUI.d.ts +0 -14
- package/dist/Git/GitUI.d.ts.map +0 -1
- package/dist/Git/GitUI.js +0 -21
- package/dist/Git/GitUI.js.map +0 -1
- package/dist/Git/commit-selection.d.ts +0 -22
- package/dist/Git/commit-selection.d.ts.map +0 -1
- package/dist/Git/commit-selection.js +0 -47
- package/dist/Git/commit-selection.js.map +0 -1
- package/dist/Git/git-clone-utils.d.ts +0 -8
- package/dist/Git/git-clone-utils.d.ts.map +0 -1
- package/dist/Git/git-clone-utils.js +0 -26
- package/dist/Git/git-clone-utils.js.map +0 -1
- package/dist/Git/git-status.d.ts +0 -24
- package/dist/Git/git-status.d.ts.map +0 -1
- package/dist/Git/git-status.js +0 -105
- package/dist/Git/git-status.js.map +0 -1
- package/dist/Git/useGit.d.ts +0 -15
- package/dist/Git/useGit.d.ts.map +0 -1
- package/dist/Git/useGit.js +0 -206
- package/dist/Git/useGit.js.map +0 -1
- package/dist/Git/useGitStatus.d.ts +0 -17
- package/dist/Git/useGitStatus.d.ts.map +0 -1
- package/dist/Git/useGitStatus.js +0 -63
- package/dist/Git/useGitStatus.js.map +0 -1
- package/dist/GitToolbarControl-LMIR4R7I.js.map +0 -1
- package/dist/GitUI-KGF5MSNV.js.map +0 -1
- package/dist/LazyEditorShell-EF2BWRXU.js.map +0 -1
- package/dist/Settings/Settings.d.ts +0 -23
- package/dist/Settings/Settings.d.ts.map +0 -1
- package/dist/Settings/Settings.js +0 -22
- package/dist/Settings/Settings.js.map +0 -1
- package/dist/Settings/public-api.d.ts +0 -3
- package/dist/Settings/public-api.d.ts.map +0 -1
- package/dist/Settings/public-api.js +0 -2
- package/dist/Settings/public-api.js.map +0 -1
- package/dist/WorkspacePicker/WorkspacePicker.d.ts +0 -22
- package/dist/WorkspacePicker/WorkspacePicker.d.ts.map +0 -1
- package/dist/WorkspacePicker/WorkspacePicker.js +0 -74
- package/dist/WorkspacePicker/WorkspacePicker.js.map +0 -1
- package/dist/WorkspacePicker/WorkspaceSettingsButton.d.ts +0 -11
- package/dist/WorkspacePicker/WorkspaceSettingsButton.d.ts.map +0 -1
- package/dist/WorkspacePicker/WorkspaceSettingsButton.js +0 -27
- package/dist/WorkspacePicker/WorkspaceSettingsButton.js.map +0 -1
- package/dist/WorkspacePicker/WorkspaceSettingsDialog.d.ts +0 -20
- package/dist/WorkspacePicker/WorkspaceSettingsDialog.d.ts.map +0 -1
- package/dist/WorkspacePicker/WorkspaceSettingsDialog.js +0 -36
- package/dist/WorkspacePicker/WorkspaceSettingsDialog.js.map +0 -1
- package/dist/WorkspacePicker/index.d.ts +0 -3
- package/dist/WorkspacePicker/index.d.ts.map +0 -1
- package/dist/WorkspacePicker/index.js +0 -2
- package/dist/WorkspacePicker/index.js.map +0 -1
- package/dist/chunk-3SAXDU2U.js +0 -157
- package/dist/chunk-3SAXDU2U.js.map +0 -1
- package/dist/chunk-4XXSWN3T.js.map +0 -1
- package/dist/chunk-5A4KEWKT.js.map +0 -1
- package/dist/chunk-AOVTHZU7.js +0 -321
- package/dist/chunk-AOVTHZU7.js.map +0 -1
- package/dist/chunk-DD4VFJQI.js.map +0 -1
- package/dist/chunk-GSNZSCIK.js +0 -55
- package/dist/chunk-GSNZSCIK.js.map +0 -1
- package/dist/chunk-VHDP4IPL.js.map +0 -1
- package/dist/chunk-ZI56BNB7.js.map +0 -1
- package/dist/components/Dialog.d.ts +0 -22
- package/dist/components/Dialog.d.ts.map +0 -1
- package/dist/components/Dialog.js +0 -33
- package/dist/components/Dialog.js.map +0 -1
- package/dist/editor.d.ts.map +0 -1
- package/dist/editor.js.map +0 -1
- package/dist/export/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -3
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -2
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/useDocumentSession.d.ts +0 -16
- package/dist/hooks/useDocumentSession.d.ts.map +0 -1
- package/dist/hooks/useDocumentSession.js +0 -18
- package/dist/hooks/useDocumentSession.js.map +0 -1
- package/dist/icons.d.ts +0 -12
- package/dist/icons.d.ts.map +0 -1
- package/dist/icons.js +0 -28
- package/dist/icons.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/preferences/theme.d.ts +0 -18
- package/dist/preferences/theme.d.ts.map +0 -1
- package/dist/preferences/theme.js +0 -63
- package/dist/preferences/theme.js.map +0 -1
- package/dist/preferences/versioning.d.ts +0 -27
- package/dist/preferences/versioning.d.ts.map +0 -1
- package/dist/preferences/versioning.js +0 -62
- package/dist/preferences/versioning.js.map +0 -1
- package/dist/provider-lease.d.ts +0 -10
- package/dist/provider-lease.d.ts.map +0 -1
- package/dist/provider-lease.js +0 -42
- package/dist/provider-lease.js.map +0 -1
- package/dist/run-export-ICTZITXC.js +0 -10
- package/dist/run-export-ICTZITXC.js.map +0 -1
- package/dist/settings/index.js.map +0 -1
- package/src/AppMenu/AppMenu.tsx +0 -334
- package/src/AppMenu/index.ts +0 -2
- package/src/DocBlocksShell/DocBlocksShell.tsx +0 -3398
- package/src/DocBlocksShell/LazyEditorShell.ts +0 -2
- package/src/DocBlocksShell/UpdateAvailableNotice.tsx +0 -60
- package/src/DocBlocksShell/document-title.ts +0 -19
- package/src/DocBlocksShell/index.ts +0 -2
- package/src/DocBlocksShell/workspace-authority-barrier.ts +0 -26
- package/src/Export/DeferredExportToolbarControls.tsx +0 -23
- package/src/Export/ExportDialog.tsx +0 -437
- package/src/Export/ExportToolbarControls.tsx +0 -511
- package/src/Export/export-options.ts +0 -99
- package/src/Export/index.ts +0 -19
- package/src/Export/public-api.ts +0 -17
- package/src/Export/run-export.ts +0 -374
- package/src/Export/transform-summaries.ts +0 -14
- package/src/FileExplorer/FileExplorer.tsx +0 -528
- package/src/FileExplorer/FileTreeNode.tsx +0 -306
- package/src/FileExplorer/index.ts +0 -5
- package/src/FileExplorer/useFileTree.ts +0 -352
- package/src/Git/GitAuthGuidanceDialog.tsx +0 -84
- package/src/Git/GitBranchesDialog.tsx +0 -144
- package/src/Git/GitCloneDialog.tsx +0 -200
- package/src/Git/GitCommitDialog.tsx +0 -119
- package/src/Git/GitConflictsDialog.tsx +0 -62
- package/src/Git/GitContext.tsx +0 -88
- package/src/Git/GitDiffDialog.tsx +0 -147
- package/src/Git/GitDiffView.tsx +0 -105
- package/src/Git/GitHistoryDialog.tsx +0 -195
- package/src/Git/GitStatusBar.tsx +0 -157
- package/src/Git/GitToolbarControl.tsx +0 -123
- package/src/Git/GitUI.tsx +0 -68
- package/src/Git/commit-selection.ts +0 -63
- package/src/Git/git-clone-utils.ts +0 -23
- package/src/Git/git-status.ts +0 -113
- package/src/Git/useGit.ts +0 -279
- package/src/Git/useGitStatus.ts +0 -78
- package/src/Settings/Settings.tsx +0 -118
- package/src/Settings/public-api.ts +0 -8
- package/src/WorkspacePicker/WorkspacePicker.tsx +0 -191
- package/src/WorkspacePicker/WorkspaceSettingsButton.tsx +0 -88
- package/src/WorkspacePicker/WorkspaceSettingsDialog.tsx +0 -121
- package/src/WorkspacePicker/index.ts +0 -2
- package/src/components/Dialog.tsx +0 -81
- package/src/editor.ts +0 -72
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useDocumentSession.ts +0 -37
- package/src/icons.tsx +0 -48
- package/src/index.ts +0 -61
- package/src/preferences/theme.ts +0 -67
- package/src/preferences/versioning.ts +0 -69
- package/src/provider-lease.ts +0 -52
- package/src/types/pwa-dom.d.ts +0 -31
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Dialog
|
|
3
|
+
} from "./chunk-LG6HAWCK.js";
|
|
4
|
+
|
|
5
|
+
// src/preferences/theme.ts
|
|
6
|
+
var ACCENT_COLORS = [
|
|
7
|
+
"brown",
|
|
8
|
+
"green",
|
|
9
|
+
"blue",
|
|
10
|
+
"purple",
|
|
11
|
+
"maroon",
|
|
12
|
+
"orange",
|
|
13
|
+
"gray"
|
|
14
|
+
];
|
|
15
|
+
var DB_CHROME_COLORS = {
|
|
16
|
+
light: "#f3eede",
|
|
17
|
+
dark: "#262219"
|
|
18
|
+
};
|
|
19
|
+
var THEME_STORAGE_KEY = "docblocks:themePreference";
|
|
20
|
+
var ACCENT_STORAGE_KEY = "docblocks:accentColor";
|
|
21
|
+
function loadThemePreference() {
|
|
22
|
+
try {
|
|
23
|
+
const raw = localStorage.getItem(THEME_STORAGE_KEY);
|
|
24
|
+
if (raw === "light" || raw === "dark" || raw === "auto") return raw;
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
return "auto";
|
|
28
|
+
}
|
|
29
|
+
function saveThemePreference(value) {
|
|
30
|
+
try {
|
|
31
|
+
localStorage.setItem(THEME_STORAGE_KEY, value);
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function loadAccentColor() {
|
|
36
|
+
try {
|
|
37
|
+
const raw = localStorage.getItem(ACCENT_STORAGE_KEY);
|
|
38
|
+
if (ACCENT_COLORS.some((color) => color === raw)) return raw;
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
return "brown";
|
|
42
|
+
}
|
|
43
|
+
function saveAccentColor(value) {
|
|
44
|
+
try {
|
|
45
|
+
localStorage.setItem(ACCENT_STORAGE_KEY, value);
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/preferences/write-canvas.ts
|
|
51
|
+
var WRITE_CANVAS_TEXT_SIZE_MIN = 12;
|
|
52
|
+
var WRITE_CANVAS_TEXT_SIZE_MAX = 32;
|
|
53
|
+
var WRITE_CANVAS_LINE_SPACING_MIN = 1.2;
|
|
54
|
+
var WRITE_CANVAS_LINE_SPACING_MAX = 2.4;
|
|
55
|
+
var DEFAULT_WRITE_CANVAS_PREFERENCES = {
|
|
56
|
+
textSize: 16,
|
|
57
|
+
lineSpacing: 1.7
|
|
58
|
+
};
|
|
59
|
+
var WRITE_CANVAS_STORAGE_KEY = "docblocks:writeCanvasSettings";
|
|
60
|
+
function loadWriteCanvasPreferences() {
|
|
61
|
+
try {
|
|
62
|
+
const raw = localStorage.getItem(WRITE_CANVAS_STORAGE_KEY);
|
|
63
|
+
if (!raw) return { ...DEFAULT_WRITE_CANVAS_PREFERENCES };
|
|
64
|
+
const stored = JSON.parse(raw);
|
|
65
|
+
if (!isRecord(stored)) return { ...DEFAULT_WRITE_CANVAS_PREFERENCES };
|
|
66
|
+
return {
|
|
67
|
+
textSize: numberInRange(
|
|
68
|
+
stored.textSize,
|
|
69
|
+
WRITE_CANVAS_TEXT_SIZE_MIN,
|
|
70
|
+
WRITE_CANVAS_TEXT_SIZE_MAX
|
|
71
|
+
) ? stored.textSize : DEFAULT_WRITE_CANVAS_PREFERENCES.textSize,
|
|
72
|
+
lineSpacing: numberInRange(
|
|
73
|
+
stored.lineSpacing,
|
|
74
|
+
WRITE_CANVAS_LINE_SPACING_MIN,
|
|
75
|
+
WRITE_CANVAS_LINE_SPACING_MAX
|
|
76
|
+
) ? stored.lineSpacing : DEFAULT_WRITE_CANVAS_PREFERENCES.lineSpacing
|
|
77
|
+
};
|
|
78
|
+
} catch {
|
|
79
|
+
return { ...DEFAULT_WRITE_CANVAS_PREFERENCES };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function saveWriteCanvasPreferences(value) {
|
|
83
|
+
try {
|
|
84
|
+
localStorage.setItem(WRITE_CANVAS_STORAGE_KEY, JSON.stringify(value));
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function numberInRange(value, min, max) {
|
|
89
|
+
return typeof value === "number" && Number.isFinite(value) && value >= min && value <= max;
|
|
90
|
+
}
|
|
91
|
+
function isRecord(value) {
|
|
92
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/Settings/Settings.tsx
|
|
96
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
97
|
+
var ACCENT_LABELS = {
|
|
98
|
+
brown: "Brown",
|
|
99
|
+
green: "Green",
|
|
100
|
+
blue: "Blue",
|
|
101
|
+
purple: "Purple",
|
|
102
|
+
maroon: "Maroon",
|
|
103
|
+
orange: "Orange",
|
|
104
|
+
gray: "Gray"
|
|
105
|
+
};
|
|
106
|
+
function SettingsDialog({ title = "Settings", onClose, children }) {
|
|
107
|
+
return /* @__PURE__ */ jsx(Dialog, { title, onClose, size: "wide", children });
|
|
108
|
+
}
|
|
109
|
+
function ThemeSettings({ value, onChange, name = "theme" }) {
|
|
110
|
+
return /* @__PURE__ */ jsxs("fieldset", { className: "db-settings-fieldset", children: [
|
|
111
|
+
/* @__PURE__ */ jsx("legend", { className: "db-settings-legend", children: "Theme" }),
|
|
112
|
+
/* @__PURE__ */ jsxs("label", { className: "db-settings-radio", children: [
|
|
113
|
+
/* @__PURE__ */ jsx(
|
|
114
|
+
"input",
|
|
115
|
+
{
|
|
116
|
+
type: "radio",
|
|
117
|
+
name,
|
|
118
|
+
value: "auto",
|
|
119
|
+
checked: value === "auto",
|
|
120
|
+
onChange: () => onChange("auto")
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
"System default"
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ jsxs("label", { className: "db-settings-radio", children: [
|
|
126
|
+
/* @__PURE__ */ jsx(
|
|
127
|
+
"input",
|
|
128
|
+
{
|
|
129
|
+
type: "radio",
|
|
130
|
+
name,
|
|
131
|
+
value: "light",
|
|
132
|
+
checked: value === "light",
|
|
133
|
+
onChange: () => onChange("light")
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
"Light"
|
|
137
|
+
] }),
|
|
138
|
+
/* @__PURE__ */ jsxs("label", { className: "db-settings-radio", children: [
|
|
139
|
+
/* @__PURE__ */ jsx(
|
|
140
|
+
"input",
|
|
141
|
+
{
|
|
142
|
+
type: "radio",
|
|
143
|
+
name,
|
|
144
|
+
value: "dark",
|
|
145
|
+
checked: value === "dark",
|
|
146
|
+
onChange: () => onChange("dark")
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
"Dark"
|
|
150
|
+
] })
|
|
151
|
+
] });
|
|
152
|
+
}
|
|
153
|
+
function AccentColorSettings({
|
|
154
|
+
value,
|
|
155
|
+
onChange,
|
|
156
|
+
name = "accent-color"
|
|
157
|
+
}) {
|
|
158
|
+
return /* @__PURE__ */ jsxs("fieldset", { className: "db-settings-fieldset", children: [
|
|
159
|
+
/* @__PURE__ */ jsx("legend", { className: "db-settings-legend", children: "Accent color" }),
|
|
160
|
+
/* @__PURE__ */ jsx("p", { className: "db-settings-hint", children: "Used in both light and dark appearances." }),
|
|
161
|
+
/* @__PURE__ */ jsx("div", { className: "db-settings-accent-grid", children: ACCENT_COLORS.map((color) => /* @__PURE__ */ jsxs(
|
|
162
|
+
"label",
|
|
163
|
+
{
|
|
164
|
+
className: `db-settings-accent${value === color ? " db-settings-accent--selected" : ""}`,
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ jsx(
|
|
167
|
+
"input",
|
|
168
|
+
{
|
|
169
|
+
className: "db-settings-accent-input",
|
|
170
|
+
type: "radio",
|
|
171
|
+
name,
|
|
172
|
+
value: color,
|
|
173
|
+
checked: value === color,
|
|
174
|
+
onChange: () => onChange(color)
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
"span",
|
|
179
|
+
{
|
|
180
|
+
className: `db-settings-accent-swatch db-settings-accent-swatch--${color}`,
|
|
181
|
+
"aria-hidden": "true"
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsx("span", { children: ACCENT_LABELS[color] })
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
color
|
|
188
|
+
)) })
|
|
189
|
+
] });
|
|
190
|
+
}
|
|
191
|
+
function WriteCanvasSettingsControls({ value, onChange }) {
|
|
192
|
+
return /* @__PURE__ */ jsxs("fieldset", { className: "db-settings-fieldset", children: [
|
|
193
|
+
/* @__PURE__ */ jsx("legend", { className: "db-settings-legend", children: "Write canvas" }),
|
|
194
|
+
/* @__PURE__ */ jsx("p", { className: "db-settings-hint", children: "Adjust the writing view without changing the document or its exported text." }),
|
|
195
|
+
/* @__PURE__ */ jsxs("label", { className: "db-settings-slider", children: [
|
|
196
|
+
/* @__PURE__ */ jsxs("span", { className: "db-settings-slider-header", children: [
|
|
197
|
+
/* @__PURE__ */ jsx("span", { children: "Text size" }),
|
|
198
|
+
/* @__PURE__ */ jsxs("output", { className: "db-settings-slider-value", "aria-hidden": "true", children: [
|
|
199
|
+
value.textSize,
|
|
200
|
+
"px"
|
|
201
|
+
] })
|
|
202
|
+
] }),
|
|
203
|
+
/* @__PURE__ */ jsx(
|
|
204
|
+
"input",
|
|
205
|
+
{
|
|
206
|
+
type: "range",
|
|
207
|
+
min: WRITE_CANVAS_TEXT_SIZE_MIN,
|
|
208
|
+
max: WRITE_CANVAS_TEXT_SIZE_MAX,
|
|
209
|
+
step: 1,
|
|
210
|
+
value: value.textSize,
|
|
211
|
+
"aria-label": "Text size",
|
|
212
|
+
"aria-valuetext": `${value.textSize} pixels`,
|
|
213
|
+
onChange: (event) => onChange({ ...value, textSize: Number(event.currentTarget.value) })
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
] }),
|
|
217
|
+
/* @__PURE__ */ jsxs("label", { className: "db-settings-slider", children: [
|
|
218
|
+
/* @__PURE__ */ jsxs("span", { className: "db-settings-slider-header", children: [
|
|
219
|
+
/* @__PURE__ */ jsx("span", { children: "Line spacing" }),
|
|
220
|
+
/* @__PURE__ */ jsx("output", { className: "db-settings-slider-value", "aria-hidden": "true", children: formatLineSpacing(value.lineSpacing) })
|
|
221
|
+
] }),
|
|
222
|
+
/* @__PURE__ */ jsx(
|
|
223
|
+
"input",
|
|
224
|
+
{
|
|
225
|
+
type: "range",
|
|
226
|
+
min: WRITE_CANVAS_LINE_SPACING_MIN,
|
|
227
|
+
max: WRITE_CANVAS_LINE_SPACING_MAX,
|
|
228
|
+
step: 0.1,
|
|
229
|
+
value: value.lineSpacing,
|
|
230
|
+
"aria-label": "Line spacing",
|
|
231
|
+
"aria-valuetext": `${value.lineSpacing} times`,
|
|
232
|
+
onChange: (event) => onChange({ ...value, lineSpacing: Number(event.currentTarget.value) })
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
] })
|
|
236
|
+
] });
|
|
237
|
+
}
|
|
238
|
+
function formatLineSpacing(value) {
|
|
239
|
+
return `${value.toFixed(1).replace(/\.0$/, "")}\xD7`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export {
|
|
243
|
+
DEFAULT_WRITE_CANVAS_PREFERENCES,
|
|
244
|
+
loadWriteCanvasPreferences,
|
|
245
|
+
saveWriteCanvasPreferences,
|
|
246
|
+
DB_CHROME_COLORS,
|
|
247
|
+
loadThemePreference,
|
|
248
|
+
saveThemePreference,
|
|
249
|
+
loadAccentColor,
|
|
250
|
+
saveAccentColor,
|
|
251
|
+
SettingsDialog,
|
|
252
|
+
ThemeSettings,
|
|
253
|
+
AccentColorSettings,
|
|
254
|
+
WriteCanvasSettingsControls
|
|
255
|
+
};
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/Export/export-destination.ts
|
|
2
|
+
function updateExportTargetExtension(targetPath, suggestedFilename) {
|
|
3
3
|
const nextExtension = extensionOf(suggestedFilename);
|
|
4
4
|
if (!nextExtension) return targetPath;
|
|
5
5
|
if (!targetPath.trim()) return suggestedFilename;
|
|
6
|
-
|
|
7
6
|
const suffixIndex = firstSuffixIndex(targetPath);
|
|
8
7
|
const pathPart = suffixIndex === -1 ? targetPath : targetPath.slice(0, suffixIndex);
|
|
9
|
-
const suffix = suffixIndex === -1 ?
|
|
10
|
-
const separatorIndex = Math.max(pathPart.lastIndexOf(
|
|
11
|
-
const dotIndex = pathPart.lastIndexOf(
|
|
8
|
+
const suffix = suffixIndex === -1 ? "" : targetPath.slice(suffixIndex);
|
|
9
|
+
const separatorIndex = Math.max(pathPart.lastIndexOf("/"), pathPart.lastIndexOf("\\"));
|
|
10
|
+
const dotIndex = pathPart.lastIndexOf(".");
|
|
12
11
|
const stem = dotIndex > separatorIndex ? pathPart.slice(0, dotIndex) : pathPart;
|
|
13
12
|
return `${stem}${nextExtension}${suffix}`;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
function extensionOf(value: string): string {
|
|
14
|
+
function extensionOf(value) {
|
|
17
15
|
const suffixIndex = firstSuffixIndex(value);
|
|
18
16
|
const pathPart = suffixIndex === -1 ? value : value.slice(0, suffixIndex);
|
|
19
|
-
const separatorIndex = Math.max(pathPart.lastIndexOf(
|
|
20
|
-
const dotIndex = pathPart.lastIndexOf(
|
|
21
|
-
return dotIndex > separatorIndex ? pathPart.slice(dotIndex) :
|
|
17
|
+
const separatorIndex = Math.max(pathPart.lastIndexOf("/"), pathPart.lastIndexOf("\\"));
|
|
18
|
+
const dotIndex = pathPart.lastIndexOf(".");
|
|
19
|
+
return dotIndex > separatorIndex ? pathPart.slice(dotIndex) : "";
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const fragment = value.indexOf('#');
|
|
21
|
+
function firstSuffixIndex(value) {
|
|
22
|
+
const query = value.indexOf("?");
|
|
23
|
+
const fragment = value.indexOf("#");
|
|
27
24
|
if (query === -1) return fragment;
|
|
28
25
|
if (fragment === -1) return query;
|
|
29
26
|
return Math.min(query, fragment);
|
|
30
27
|
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
updateExportTargetExtension
|
|
31
|
+
};
|
|
@@ -3,6 +3,7 @@ var FORMAT_LABELS = {
|
|
|
3
3
|
docx: "Word Document (.docx)",
|
|
4
4
|
pdf: "PDF (.pdf)",
|
|
5
5
|
pptx: "PowerPoint (.pptx)",
|
|
6
|
+
epub: "EPUB e-book (.epub)",
|
|
6
7
|
md: "Markdown (.md)",
|
|
7
8
|
html: "HTML (.html)"
|
|
8
9
|
};
|
|
@@ -10,6 +11,7 @@ var FORMAT_EXTENSIONS = {
|
|
|
10
11
|
docx: ".docx",
|
|
11
12
|
pdf: ".pdf",
|
|
12
13
|
pptx: ".pptx",
|
|
14
|
+
epub: ".epub",
|
|
13
15
|
md: ".md",
|
|
14
16
|
html: ".html"
|
|
15
17
|
};
|
|
@@ -48,4 +50,3 @@ export {
|
|
|
48
50
|
loadLastExportOptions,
|
|
49
51
|
saveExportOptions
|
|
50
52
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-DD4VFJQI.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FORMAT_EXTENSIONS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EBWYGTN7.js";
|
|
4
4
|
|
|
5
5
|
// src/Export/run-export.ts
|
|
6
6
|
import { parseMarkdown } from "@bendyline/squisq/markdown";
|
|
@@ -8,6 +8,7 @@ var MIME_TYPES = {
|
|
|
8
8
|
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
9
9
|
pdf: "application/pdf",
|
|
10
10
|
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
11
|
+
epub: "application/epub+zip",
|
|
11
12
|
md: "text/markdown",
|
|
12
13
|
html: "text/html"
|
|
13
14
|
};
|
|
@@ -38,7 +39,7 @@ function buildExportFilename(selectedFile, options) {
|
|
|
38
39
|
}
|
|
39
40
|
return base + FORMAT_EXTENSIONS[options.format];
|
|
40
41
|
}
|
|
41
|
-
async function runExport(markdown, selectedFile, options, mediaContainer, saveBlob) {
|
|
42
|
+
async function runExport(markdown, selectedFile, options, mediaContainer, saveBlob, converterOverrides = {}) {
|
|
42
43
|
const filename = buildFilename(selectedFile, options.format);
|
|
43
44
|
const themeId = options.themeId !== "standard" ? options.themeId : void 0;
|
|
44
45
|
if (options.format === "md") {
|
|
@@ -66,19 +67,29 @@ async function runExport(markdown, selectedFile, options, mediaContainer, saveBl
|
|
|
66
67
|
await saveExportBlob(new Blob([buf], { type: MIME_TYPES.pdf }), filename, saveBlob);
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
70
|
+
if (options.format === "epub") {
|
|
71
|
+
const { markdownDocToEpub } = await import("@bendyline/squisq-formats/epub");
|
|
72
|
+
const images = mediaContainer ? await resolveImageData(doc, mediaContainer) : void 0;
|
|
73
|
+
const buf = await markdownDocToEpub(doc, { themeId, images });
|
|
74
|
+
await saveExportBlob(new Blob([buf], { type: MIME_TYPES.epub }), filename, saveBlob);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
69
77
|
if (options.format === "pptx") {
|
|
70
|
-
const
|
|
78
|
+
const pptxModule = converterOverrides.docToPptx ? Promise.resolve({ docToPptx: converterOverrides.docToPptx }) : import("@bendyline/squisq-formats/pptx");
|
|
79
|
+
const [{ markdownToDoc }, { applyTransform }, { buildPreviewDoc }, { docToPptx }] = await Promise.all([
|
|
71
80
|
import("@bendyline/squisq/doc"),
|
|
72
81
|
import("@bendyline/squisq/transform"),
|
|
73
|
-
import("@bendyline/squisq-
|
|
82
|
+
import("@bendyline/squisq-editor-react"),
|
|
83
|
+
pptxModule
|
|
74
84
|
]);
|
|
75
85
|
const baseDoc = markdownToDoc(doc);
|
|
76
86
|
const transformed = applyTransform(baseDoc, options.transformStyle);
|
|
77
|
-
const enrichedDoc = transformed.doc;
|
|
87
|
+
const enrichedDoc = buildPreviewDoc(transformed.doc);
|
|
78
88
|
if (themeId) {
|
|
79
89
|
enrichedDoc.themeId = themeId;
|
|
80
90
|
}
|
|
81
|
-
const
|
|
91
|
+
const images = mediaContainer ? await resolveImageData(doc, mediaContainer) : void 0;
|
|
92
|
+
const buf = await docToPptx(enrichedDoc, { themeId, images });
|
|
82
93
|
await saveExportBlob(new Blob([buf], { type: MIME_TYPES.pptx }), filename, saveBlob);
|
|
83
94
|
return;
|
|
84
95
|
}
|
|
@@ -242,6 +253,16 @@ async function resolveImages(doc, container) {
|
|
|
242
253
|
}
|
|
243
254
|
return map;
|
|
244
255
|
}
|
|
256
|
+
async function resolveImageData(doc, container) {
|
|
257
|
+
const urls = collectMarkdownImageUrls(doc);
|
|
258
|
+
const map = /* @__PURE__ */ new Map();
|
|
259
|
+
for (const url of urls) {
|
|
260
|
+
if (map.has(url) || isExternalUrl(url)) continue;
|
|
261
|
+
const data = await container.readFile(url);
|
|
262
|
+
if (data) map.set(url, data);
|
|
263
|
+
}
|
|
264
|
+
return map;
|
|
265
|
+
}
|
|
245
266
|
function basenameForBundle(selectedFile) {
|
|
246
267
|
const clean = selectedFile.replace(/^\/+/, "");
|
|
247
268
|
const idx = clean.lastIndexOf("/");
|
|
@@ -267,4 +288,3 @@ export {
|
|
|
267
288
|
buildExportFilename,
|
|
268
289
|
runExport
|
|
269
290
|
};
|
|
270
|
-
//# sourceMappingURL=chunk-ZI56BNB7.js.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/components/Dialog.tsx
|
|
2
|
+
import { useCallback, useEffect, useId, useRef } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
function Dialog({
|
|
5
|
+
title,
|
|
6
|
+
onClose,
|
|
7
|
+
size = "default",
|
|
8
|
+
children,
|
|
9
|
+
footer,
|
|
10
|
+
initialFocusRef,
|
|
11
|
+
closeOnBackdrop = true,
|
|
12
|
+
className,
|
|
13
|
+
bodyClassName,
|
|
14
|
+
footerClassName
|
|
15
|
+
}) {
|
|
16
|
+
const closeButtonRef = useRef(null);
|
|
17
|
+
const dialogRef = useRef(null);
|
|
18
|
+
const titleId = useId();
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const onKey = (e) => {
|
|
21
|
+
if (e.key === "Escape") {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
onClose();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (e.key !== "Tab") return;
|
|
27
|
+
const dialog = dialogRef.current;
|
|
28
|
+
if (!dialog) return;
|
|
29
|
+
const focusable = [...dialog.querySelectorAll(FOCUSABLE_SELECTOR)].filter(
|
|
30
|
+
(element) => !element.hasAttribute("disabled") && element.getAttribute("aria-hidden") !== "true"
|
|
31
|
+
);
|
|
32
|
+
if (focusable.length === 0) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
dialog.focus();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const first = focusable[0];
|
|
38
|
+
const last = focusable[focusable.length - 1];
|
|
39
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
last.focus();
|
|
42
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
first.focus();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
window.addEventListener("keydown", onKey);
|
|
48
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
49
|
+
}, [onClose]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
52
|
+
const target = initialFocusRef?.current ?? closeButtonRef.current;
|
|
53
|
+
target?.focus();
|
|
54
|
+
return () => {
|
|
55
|
+
if (previousFocus?.isConnected) previousFocus.focus();
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
const handleBackdropClick = useCallback(
|
|
59
|
+
(e) => {
|
|
60
|
+
if (closeOnBackdrop && e.target === e.currentTarget) onClose();
|
|
61
|
+
},
|
|
62
|
+
[closeOnBackdrop, onClose]
|
|
63
|
+
);
|
|
64
|
+
const sizeClass = size === "wide" ? "db-dialog--wide" : size === "full" ? "db-dialog--full" : "";
|
|
65
|
+
const panelClassName = ["db-dialog", sizeClass, className].filter(Boolean).join(" ");
|
|
66
|
+
const bodyClasses = ["db-dialog-body", bodyClassName].filter(Boolean).join(" ");
|
|
67
|
+
const footerClasses = ["db-dialog-footer", footerClassName].filter(Boolean).join(" ");
|
|
68
|
+
return /* @__PURE__ */ jsx("div", { className: "db-dialog-overlay", onClick: handleBackdropClick, children: /* @__PURE__ */ jsxs(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
ref: dialogRef,
|
|
72
|
+
className: panelClassName,
|
|
73
|
+
role: "dialog",
|
|
74
|
+
"aria-modal": "true",
|
|
75
|
+
"aria-labelledby": titleId,
|
|
76
|
+
tabIndex: -1,
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ jsxs("div", { className: "db-dialog-header", children: [
|
|
79
|
+
/* @__PURE__ */ jsx("h2", { id: titleId, className: "db-dialog-title", children: title }),
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
"button",
|
|
82
|
+
{
|
|
83
|
+
ref: closeButtonRef,
|
|
84
|
+
type: "button",
|
|
85
|
+
className: "db-dialog-close",
|
|
86
|
+
onClick: onClose,
|
|
87
|
+
"aria-label": "Close",
|
|
88
|
+
children: "\xD7"
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
] }),
|
|
92
|
+
/* @__PURE__ */ jsx("div", { className: bodyClasses, children }),
|
|
93
|
+
footer && /* @__PURE__ */ jsx("div", { className: footerClasses, children: footer })
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
) });
|
|
97
|
+
}
|
|
98
|
+
var FOCUSABLE_SELECTOR = [
|
|
99
|
+
"a[href]",
|
|
100
|
+
"button",
|
|
101
|
+
"input",
|
|
102
|
+
"select",
|
|
103
|
+
"textarea",
|
|
104
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
105
|
+
].join(",");
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
Dialog
|
|
109
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/Git/useMenuKeyboard.ts
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
function useMenuKeyboard(open, setOpen) {
|
|
4
|
+
const menuRef = useRef(null);
|
|
5
|
+
const triggerRef = useRef(null);
|
|
6
|
+
const pendingFocusRef = useRef("none");
|
|
7
|
+
const items = useCallback(
|
|
8
|
+
() => [...menuRef.current?.querySelectorAll('[role="menuitem"]') ?? []].filter(
|
|
9
|
+
(item) => !item.disabled
|
|
10
|
+
),
|
|
11
|
+
[]
|
|
12
|
+
);
|
|
13
|
+
const focusItem = useCallback(
|
|
14
|
+
(index) => {
|
|
15
|
+
const all = items();
|
|
16
|
+
if (all.length === 0) return;
|
|
17
|
+
all[(index % all.length + all.length) % all.length]?.focus({ preventScroll: true });
|
|
18
|
+
},
|
|
19
|
+
[items]
|
|
20
|
+
);
|
|
21
|
+
const closeMenu = useCallback(
|
|
22
|
+
(returnFocus) => {
|
|
23
|
+
pendingFocusRef.current = "none";
|
|
24
|
+
setOpen(false);
|
|
25
|
+
if (returnFocus) triggerRef.current?.focus();
|
|
26
|
+
},
|
|
27
|
+
[setOpen]
|
|
28
|
+
);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!open || pendingFocusRef.current === "none") return;
|
|
31
|
+
const where = pendingFocusRef.current;
|
|
32
|
+
pendingFocusRef.current = "none";
|
|
33
|
+
focusItem(where === "last" ? items().length - 1 : 0);
|
|
34
|
+
}, [open, focusItem, items]);
|
|
35
|
+
const handleTriggerKeyDown = useCallback(
|
|
36
|
+
(event) => {
|
|
37
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
pendingFocusRef.current = event.key === "ArrowUp" ? "last" : "first";
|
|
40
|
+
setOpen(true);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
44
|
+
if (!open) pendingFocusRef.current = "first";
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[open, setOpen]
|
|
48
|
+
);
|
|
49
|
+
const handleMenuKeyDown = useCallback(
|
|
50
|
+
(event) => {
|
|
51
|
+
if (event.key === "Escape" || event.key === "Tab") {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
closeMenu(true);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const all = items();
|
|
58
|
+
if (all.length === 0) return;
|
|
59
|
+
const current = all.indexOf(document.activeElement);
|
|
60
|
+
switch (event.key) {
|
|
61
|
+
case "ArrowDown":
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
focusItem(current + 1);
|
|
64
|
+
break;
|
|
65
|
+
case "ArrowUp":
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
focusItem(current - 1);
|
|
68
|
+
break;
|
|
69
|
+
case "Home":
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
focusItem(0);
|
|
72
|
+
break;
|
|
73
|
+
case "End":
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
focusItem(all.length - 1);
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
[closeMenu, focusItem, items]
|
|
82
|
+
);
|
|
83
|
+
return { menuRef, triggerRef, handleMenuKeyDown, handleTriggerKeyDown, closeMenu };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
useMenuKeyboard
|
|
88
|
+
};
|
package/dist/editor.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Hosts pick one prompt for each mounted document generation and pass it to
|
|
4
4
|
* Squisq, so the copy remains stable while that document is open.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
declare const EMPTY_DOCUMENT_PROMPTS: readonly ["Start typing your content, or drop images on top of me...", "Write anything -- paste markdown, drag in images, or just start typing...", "Type away. Markdown syntax works too...", "Chapter 1 begins here...", "Once upon a time...", "A blank page. Exciting, isn't it?", "The first word is always the hardest...", "Plot twist: this is where it all starts...", "Write something the future you will thank you for...", "Begin at the beginning...", "Let's begin.", "We can be heroes...", "Here comes the sun...", "And so it begins...", "Let it be, let it be...", "Don't stop believing...", "Started from the bottom...", "This is the start of something new...", "Ground control to Major Tom...", "Come as you are...", "Every new beginning...", "Hello, is it me you're looking for?", "Imagine all the people...", "Anything you want, you got it...", "Rise above...", "Do you have the time...", "Here we are now, entertain us...", "All the small things...", "Should I stay or should I go?", "I am a patient boy -- I wait, I wait, I wait...", "Destination unknown...", "Easy like Sunday morning...", "Dance, dance, dance to the radio...", "New day rising...", "Visit the world...", "Positive mental attitude...", "Better I sing than I cry...", "Disconnect for a minute...", "We need new noise...", "Shoot the moon...", "I'll surprise you sometime -- I'll come around...", "Coming out of my cage, and doing just fine...", "Throw me to the wolves -- I'll come back, leading the pack...", "There comes a time -- no excuses...", "It's up to me now, turn on the bright lights...", "Do what you want...", "Fingers crossed...", "This is the start of how it all ends...", "It has to start somewhere, it has to start sometime -- what better place than here? what better time than now?", "I know myself, and I'll begin again...", "Dig me out, dig me in...", "Everybody's full of sugar, honey, ice and tea...", "Take time with a wounded hand, 'cause it likes to heal...", "Grab a brush and put on a little makeup...", "Amber is the color of your energy...", "Wait -- they don't love it like I love it...", "A world's been buried, where love is the law; a you-topia..."];
|
|
7
|
+
type EmptyDocumentPrompt = (typeof EMPTY_DOCUMENT_PROMPTS)[number];
|
|
8
8
|
/** Pick a prompt using the supplied random source, or `Math.random`. */
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
declare function pickEmptyDocumentPrompt(random?: () => number): EmptyDocumentPrompt;
|
|
10
|
+
|
|
11
|
+
export { EMPTY_DOCUMENT_PROMPTS, type EmptyDocumentPrompt, pickEmptyDocumentPrompt };
|