@book.dev/ui 1.60.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/LICENSE +21 -0
- package/dist/EmojiGrid-xK5mPJPo.js +205 -0
- package/dist/blockeditor/BlockEditor.d.ts +68 -0
- package/dist/blockeditor/CodeBlockView.d.ts +19 -0
- package/dist/blockeditor/InlineToolbar.d.ts +18 -0
- package/dist/blockeditor/LinkPicker.d.ts +16 -0
- package/dist/blockeditor/MentionMenu.d.ts +14 -0
- package/dist/blockeditor/PresentBlocks.d.ts +21 -0
- package/dist/blockeditor/RichTextEditor.d.ts +29 -0
- package/dist/blockeditor/SlashMenu.d.ts +49 -0
- package/dist/blockeditor/TextBlockView.d.ts +9 -0
- package/dist/blockeditor/__tests__/LinkPicker.test.d.ts +1 -0
- package/dist/blockeditor/__tests__/SlashMenu.test.d.ts +1 -0
- package/dist/blockeditor/__tests__/aiApply.test.d.ts +1 -0
- package/dist/blockeditor/__tests__/groupLock.test.d.ts +1 -0
- package/dist/blockeditor/__tests__/highlight.test.d.ts +1 -0
- package/dist/blockeditor/__tests__/mergeUp.test.d.ts +1 -0
- package/dist/blockeditor/__tests__/present.test.d.ts +1 -0
- package/dist/blockeditor/aiBlocks.d.ts +9 -0
- package/dist/blockeditor/colors.d.ts +23 -0
- package/dist/blockeditor/exportBlocks.d.ts +25 -0
- package/dist/blockeditor/highlight.d.ts +25 -0
- package/dist/blockeditor/index.d.ts +8 -0
- package/dist/blockeditor/kit/KitFrame.d.ts +95 -0
- package/dist/blockeditor/kit/KitSettings.d.ts +18 -0
- package/dist/blockeditor/kit/OptionsEditor.d.ts +8 -0
- package/dist/blockeditor/kit/__tests__/chartMath.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/dataflow.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/exportKit.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/exportKit2.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/groupSync.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/inputs2Render.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/inputs2Scope.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/inputsRender.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/kitConfig.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/kitPanel.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/options.test.d.ts +1 -0
- package/dist/blockeditor/kit/__tests__/scope.test.d.ts +1 -0
- package/dist/blockeditor/kit/cards.d.ts +51 -0
- package/dist/blockeditor/kit/chartMath.d.ts +62 -0
- package/dist/blockeditor/kit/charts.d.ts +27 -0
- package/dist/blockeditor/kit/completion.d.ts +45 -0
- package/dist/blockeditor/kit/dataflow.d.ts +68 -0
- package/dist/blockeditor/kit/groupSync.d.ts +23 -0
- package/dist/blockeditor/kit/index.d.ts +11 -0
- package/dist/blockeditor/kit/inputs.d.ts +135 -0
- package/dist/blockeditor/kit/inputs2.d.ts +86 -0
- package/dist/blockeditor/kit/kitConfig.d.ts +5 -0
- package/dist/blockeditor/kit/kitPanel.d.ts +31 -0
- package/dist/blockeditor/kit/lock.d.ts +12 -0
- package/dist/blockeditor/kit/options.d.ts +60 -0
- package/dist/blockeditor/kit/progress.d.ts +20 -0
- package/dist/blockeditor/kit/scope.d.ts +100 -0
- package/dist/blockeditor/model.d.ts +236 -0
- package/dist/blockeditor/present.d.ts +18 -0
- package/dist/blockeditor/provider.d.ts +16 -0
- package/dist/blockeditor/reactiveBlocks.d.ts +2 -0
- package/dist/blockeditor/registry.d.ts +38 -0
- package/dist/blockeditor/richtext.d.ts +48 -0
- package/dist/blockeditor/useBlockEditor.d.ts +45 -0
- package/dist/components/AboutDialog.d.ts +9 -0
- package/dist/components/AgentPanel.d.ts +2 -0
- package/dist/components/AiBridgeHost.d.ts +14 -0
- package/dist/components/AiSearchDialog.d.ts +8 -0
- package/dist/components/AiSettings.d.ts +7 -0
- package/dist/components/AppearanceSettings.d.ts +3 -0
- package/dist/components/BackForwardCluster.d.ts +1 -0
- package/dist/components/BackupSettings.d.ts +2 -0
- package/dist/components/BreadcrumbCluster.d.ts +1 -0
- package/dist/components/ColorSchemeMenu.d.ts +1 -0
- package/dist/components/CommandMenu.d.ts +1 -0
- package/dist/components/CommandToggle.d.ts +3 -0
- package/dist/components/DocumentArea.d.ts +8 -0
- package/dist/components/Drawer.d.ts +7 -0
- package/dist/components/EmojiGrid.d.ts +16 -0
- package/dist/components/EmojiPickerHost.d.ts +8 -0
- package/dist/components/ExtensionsSettings.d.ts +7 -0
- package/dist/components/FavoritesNav.d.ts +8 -0
- package/dist/components/GeneralSettings.d.ts +2 -0
- package/dist/components/GlobalShortcuts.d.ts +9 -0
- package/dist/components/HomeButton.d.ts +2 -0
- package/dist/components/IconPicker.d.ts +17 -0
- package/dist/components/NavBar.d.ts +1 -0
- package/dist/components/NavContextMenu.d.ts +7 -0
- package/dist/components/PageActionsCluster.d.ts +9 -0
- package/dist/components/PageAppearanceHost.d.ts +9 -0
- package/dist/components/PageContextMenu.d.ts +17 -0
- package/dist/components/PageCover.d.ts +18 -0
- package/dist/components/PageHeaderControls.d.ts +13 -0
- package/dist/components/PageIcon.d.ts +16 -0
- package/dist/components/PageProperties.d.ts +53 -0
- package/dist/components/PluginBoot.d.ts +2 -0
- package/dist/components/PresentMode.d.ts +7 -0
- package/dist/components/ProfileAvatar.d.ts +17 -0
- package/dist/components/ProfileMenu.d.ts +6 -0
- package/dist/components/Settings.d.ts +7 -0
- package/dist/components/SettingsButton.d.ts +2 -0
- package/dist/components/SettingsPanel.d.ts +14 -0
- package/dist/components/SideNav.d.ts +1 -0
- package/dist/components/SideNavToggle.d.ts +3 -0
- package/dist/components/SidebarSections.d.ts +17 -0
- package/dist/components/SplitPane.d.ts +9 -0
- package/dist/components/TemplateGallery.d.ts +8 -0
- package/dist/components/TitlebarTabs.d.ts +10 -0
- package/dist/components/TrashDialog.d.ts +7 -0
- package/dist/components/WindowActionsCluster.d.ts +6 -0
- package/dist/components/WindowControls.d.ts +6 -0
- package/dist/components/WindowTitle.d.ts +7 -0
- package/dist/components/WorkspaceInfo.d.ts +6 -0
- package/dist/components/WorkspaceNavigationTree.d.ts +14 -0
- package/dist/components/WorkspaceSelectMenu.d.ts +10 -0
- package/dist/components/__tests__/AppearanceSettings.test.d.ts +1 -0
- package/dist/components/__tests__/PageIcon.test.d.ts +1 -0
- package/dist/components/__tests__/SettingsPanel.test.d.ts +1 -0
- package/dist/components/__tests__/buildTree.test.d.ts +1 -0
- package/dist/components/__tests__/profileAvatar.test.d.ts +1 -0
- package/dist/components/appearance/AppearanceControls.d.ts +33 -0
- package/dist/components/appearance/PageCustomiseBody.d.ts +29 -0
- package/dist/components/brand/OpenBookLogo.d.ts +11 -0
- package/dist/components/brand/index.d.ts +1 -0
- package/dist/components/database/DatabaseCard.d.ts +36 -0
- package/dist/components/database/DatabasePicker.d.ts +12 -0
- package/dist/components/database/DatabaseRowProperties.d.ts +13 -0
- package/dist/components/database/DatabaseView.d.ts +9 -0
- package/dist/components/database/InlineDatabaseBlock.d.ts +3 -0
- package/dist/components/database/__tests__/InlineDatabaseBlock.test.d.ts +1 -0
- package/dist/components/database/databaseCells.d.ts +57 -0
- package/dist/components/database/databaseCharts.d.ts +28 -0
- package/dist/components/database/databaseColors.d.ts +12 -0
- package/dist/components/database/databaseGraph.d.ts +16 -0
- package/dist/components/database/databaseLayouts.d.ts +84 -0
- package/dist/components/database/databaseMap.d.ts +21 -0
- package/dist/components/database/databaseMapLeaflet.d.ts +26 -0
- package/dist/components/database/databaseMenus.d.ts +97 -0
- package/dist/components/database/databaseTimeline.d.ts +27 -0
- package/dist/components/database/geocode.d.ts +24 -0
- package/dist/components/database/useDatabase.d.ts +129 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/review/BlockReviewMarkers.d.ts +19 -0
- package/dist/components/review/CommentThread.d.ts +20 -0
- package/dist/components/review/ReviewPaneBody.d.ts +12 -0
- package/dist/components/review/SuggestHost.d.ts +13 -0
- package/dist/components/review/SuggestionCard.d.ts +21 -0
- package/dist/components/review/__tests__/review.test.d.ts +1 -0
- package/dist/components/review/useReview.d.ts +27 -0
- package/dist/components/settings/AccountSettings.d.ts +6 -0
- package/dist/components/settings/AdminSettings.d.ts +2 -0
- package/dist/components/settings/ConnectionSettings.d.ts +7 -0
- package/dist/components/settings/CustomisationSettings.d.ts +2 -0
- package/dist/components/settings/ProfileSettings.d.ts +2 -0
- package/dist/components/settings/primitives.d.ts +47 -0
- package/dist/components/settings/stubs.d.ts +8 -0
- package/dist/components/ui/__tests__/kbd.test.d.ts +1 -0
- package/dist/components/ui/__tests__/markdown.test.d.ts +1 -0
- package/dist/components/ui/__tests__/select.test.d.ts +1 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/command.d.ts +86 -0
- package/dist/components/ui/context-menu.d.ts +24 -0
- package/dist/components/ui/dialog.d.ts +18 -0
- package/dist/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/components/ui/icon-button.d.ts +16 -0
- package/dist/components/ui/input.d.ts +9 -0
- package/dist/components/ui/kbd.d.ts +31 -0
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/markdown.d.ts +19 -0
- package/dist/components/ui/navigation-menu.d.ts +12 -0
- package/dist/components/ui/popover.d.ts +6 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/select.d.ts +42 -0
- package/dist/components/ui/skeleton.d.ts +6 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tree.d.ts +37 -0
- package/dist/components/useAppCommands.d.ts +25 -0
- package/dist/data/DataProvider.d.ts +30 -0
- package/dist/data/index.d.ts +1 -0
- package/dist/databaseMapLeaflet-8LYcHcR6.js +87 -0
- package/dist/export/__tests__/chartNormalize.test.d.ts +1 -0
- package/dist/export/__tests__/export.test.d.ts +1 -0
- package/dist/export/__tests__/exportReactive.test.d.ts +1 -0
- package/dist/export/chartNormalize.d.ts +22 -0
- package/dist/export/chartSvg.d.ts +2 -0
- package/dist/export/documentModel.d.ts +136 -0
- package/dist/export/exportSite.d.ts +40 -0
- package/dist/export/format.d.ts +2 -0
- package/dist/export/kitChart.d.ts +21 -0
- package/dist/export/toHtml.d.ts +25 -0
- package/dist/export/toMarkdown.d.ts +7 -0
- package/dist/export/toPdf.d.ts +14 -0
- package/dist/exportBlocks-33D7P_8Q.js +987 -0
- package/dist/exportSite-DlRm4u7W.js +50 -0
- package/dist/format-CLQoRoYP.js +1646 -0
- package/dist/i18n/__tests__/i18n.test.d.ts +1 -0
- package/dist/i18n/index.d.ts +24 -0
- package/dist/i18n/messages/de.d.ts +2 -0
- package/dist/i18n/messages/en.d.ts +977 -0
- package/dist/i18n/messages/ja.d.ts +2 -0
- package/dist/i18n/messages/zh.d.ts +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +20915 -0
- package/dist/layouts/DefaultLayout.d.ts +4 -0
- package/dist/layouts/index.d.ts +1 -0
- package/dist/lib/__tests__/accountClient.test.d.ts +1 -0
- package/dist/lib/__tests__/backlinks.test.d.ts +1 -0
- package/dist/lib/__tests__/backupBundle.test.d.ts +1 -0
- package/dist/lib/__tests__/blockExport.test.d.ts +1 -0
- package/dist/lib/__tests__/blockModel.test.d.ts +1 -0
- package/dist/lib/__tests__/databaseFormula.test.d.ts +1 -0
- package/dist/lib/__tests__/databaseTypes.test.d.ts +1 -0
- package/dist/lib/__tests__/favorites.test.d.ts +1 -0
- package/dist/lib/__tests__/homePage.test.d.ts +1 -0
- package/dist/lib/__tests__/hud.test.d.ts +1 -0
- package/dist/lib/__tests__/icons.test.d.ts +1 -0
- package/dist/lib/__tests__/mixedContent.test.d.ts +1 -0
- package/dist/lib/__tests__/pageAppearance.test.d.ts +1 -0
- package/dist/lib/__tests__/pageIcon.test.d.ts +1 -0
- package/dist/lib/__tests__/pageLayout.test.d.ts +1 -0
- package/dist/lib/__tests__/pageSaveStatus.test.d.ts +1 -0
- package/dist/lib/__tests__/pageTheme.test.d.ts +1 -0
- package/dist/lib/__tests__/parentGrouping.test.d.ts +1 -0
- package/dist/lib/__tests__/pluginSdk.test.d.ts +1 -0
- package/dist/lib/__tests__/recents.test.d.ts +1 -0
- package/dist/lib/__tests__/relations.test.d.ts +1 -0
- package/dist/lib/__tests__/templates.test.d.ts +1 -0
- package/dist/lib/__tests__/textMerge.test.d.ts +1 -0
- package/dist/lib/__tests__/themes.test.d.ts +1 -0
- package/dist/lib/__tests__/treeMove.test.d.ts +1 -0
- package/dist/lib/aiBridge.d.ts +67 -0
- package/dist/lib/aiFeatures.d.ts +31 -0
- package/dist/lib/aiSettingsNav.d.ts +14 -0
- package/dist/lib/backupBundle.d.ts +23 -0
- package/dist/lib/bookFolderTransfer.d.ts +15 -0
- package/dist/lib/download.d.ts +10 -0
- package/dist/lib/editorChrome.d.ts +14 -0
- package/dist/lib/emoji.d.ts +10 -0
- package/dist/lib/emojiData.d.ts +21 -0
- package/dist/lib/emojiPicker.d.ts +31 -0
- package/dist/lib/favorites.d.ts +11 -0
- package/dist/lib/homePage.d.ts +53 -0
- package/dist/lib/hud.d.ts +70 -0
- package/dist/lib/iconRecents.d.ts +3 -0
- package/dist/lib/iconValue.d.ts +19 -0
- package/dist/lib/lucideIcons.d.ts +21 -0
- package/dist/lib/openDocs.d.ts +5 -0
- package/dist/lib/pageActions.d.ts +17 -0
- package/dist/lib/pageAppearance.d.ts +20 -0
- package/dist/lib/pageCover.d.ts +21 -0
- package/dist/lib/pageCustomise.d.ts +6 -0
- package/dist/lib/pageDocActions.d.ts +20 -0
- package/dist/lib/pageFont.d.ts +25 -0
- package/dist/lib/pageFullWidth.d.ts +10 -0
- package/dist/lib/pageIcon.d.ts +25 -0
- package/dist/lib/pageLinks.d.ts +41 -0
- package/dist/lib/pageSaveStatus.d.ts +14 -0
- package/dist/lib/pageTheme.d.ts +15 -0
- package/dist/lib/pageThemePresets.d.ts +23 -0
- package/dist/lib/recents.d.ts +9 -0
- package/dist/lib/reviewPane.d.ts +23 -0
- package/dist/lib/selection.d.ts +2 -0
- package/dist/lib/shortcuts.d.ts +79 -0
- package/dist/lib/sidebarStyles.d.ts +10 -0
- package/dist/lib/suggestBridge.d.ts +33 -0
- package/dist/lib/textMerge.d.ts +19 -0
- package/dist/lib/themes.d.ts +137 -0
- package/dist/lib/treeMove.d.ts +24 -0
- package/dist/lib/useModifierHeld.d.ts +1 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lucideIcons-B6pmC-WQ.js +5003 -0
- package/dist/model-CBxw8JNb.js +734 -0
- package/dist/pageIcon-BWTy7hAh.js +32 -0
- package/dist/plugins/__tests__/host.test.d.ts +1 -0
- package/dist/plugins/__tests__/loader.test.d.ts +1 -0
- package/dist/plugins/__tests__/pagePlugin.test.d.ts +1 -0
- package/dist/plugins/api.d.ts +67 -0
- package/dist/plugins/commandRegistry.d.ts +15 -0
- package/dist/plugins/host.d.ts +32 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/loader.d.ts +19 -0
- package/dist/plugins/pagePlugin.d.ts +21 -0
- package/dist/providers/AccountProvider.d.ts +67 -0
- package/dist/providers/ConfirmProvider.d.ts +30 -0
- package/dist/providers/ForwardingProvider.d.ts +23 -0
- package/dist/providers/HudProvider.d.ts +9 -0
- package/dist/providers/I18nProvider.d.ts +23 -0
- package/dist/providers/NavigationProvider.d.ts +89 -0
- package/dist/providers/PlatformLibraryProvider.d.ts +107 -0
- package/dist/providers/PreferencesProvider.d.ts +47 -0
- package/dist/providers/ThemeProvider.d.ts +26 -0
- package/dist/providers/WorkspaceProvider.d.ts +40 -0
- package/dist/providers/__tests__/PreferencesProvider.test.d.ts +1 -0
- package/dist/providers/__tests__/extractToken.test.d.ts +1 -0
- package/dist/providers/__tests__/windowModel.test.d.ts +1 -0
- package/dist/providers/index.d.ts +10 -0
- package/dist/providers/windowModel.d.ts +69 -0
- package/dist/screens/BlockPageDocument.d.ts +4 -0
- package/dist/screens/ConnectedPageDocument.d.ts +14 -0
- package/dist/screens/DataflowView.d.ts +2 -0
- package/dist/screens/HomeScreen.d.ts +7 -0
- package/dist/screens/index.d.ts +3 -0
- package/dist/screens/pageChrome.d.ts +46 -0
- package/dist/style.css +3 -0
- package/dist/toHtml-BoPr8Ce4.js +394 -0
- package/dist/toPdf-DGtKQSRA.js +133 -0
- package/package.json +94 -0
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
import { shortId as e } from "@book.dev/sdk";
|
|
2
|
+
import * as t from "yjs";
|
|
3
|
+
//#region src/blockeditor/model.ts
|
|
4
|
+
var n = new Set([
|
|
5
|
+
"paragraph",
|
|
6
|
+
"heading",
|
|
7
|
+
"list",
|
|
8
|
+
"todo",
|
|
9
|
+
"quote",
|
|
10
|
+
"callout",
|
|
11
|
+
"code",
|
|
12
|
+
"notes",
|
|
13
|
+
"cell"
|
|
14
|
+
]), r = new Set([
|
|
15
|
+
"columns",
|
|
16
|
+
"column",
|
|
17
|
+
"table",
|
|
18
|
+
"row",
|
|
19
|
+
"group",
|
|
20
|
+
"tabs",
|
|
21
|
+
"tab",
|
|
22
|
+
"accordion",
|
|
23
|
+
"accordionsection"
|
|
24
|
+
]);
|
|
25
|
+
function i(a) {
|
|
26
|
+
let o = new t.Map();
|
|
27
|
+
if (o.set("id", a.id ?? e("b")), o.set("type", a.type), n.has(a.type)) {
|
|
28
|
+
let e = new t.Text();
|
|
29
|
+
if (typeof a.text == "string") a.text && e.insert(0, a.text);
|
|
30
|
+
else if (a.text) {
|
|
31
|
+
let t = 0;
|
|
32
|
+
for (let n of a.text) e.insert(t, n.t, n.a ?? {}), t += n.t.length;
|
|
33
|
+
}
|
|
34
|
+
o.set("text", e);
|
|
35
|
+
}
|
|
36
|
+
if (a.props && Object.keys(a.props).length > 0) {
|
|
37
|
+
let e = new t.Map();
|
|
38
|
+
for (let [t, n] of Object.entries(a.props)) e.set(t, n);
|
|
39
|
+
o.set("props", e);
|
|
40
|
+
}
|
|
41
|
+
if (r.has(a.type)) {
|
|
42
|
+
let e = new t.Array();
|
|
43
|
+
a.children && e.push(a.children.map(i)), o.set("children", e);
|
|
44
|
+
}
|
|
45
|
+
return o;
|
|
46
|
+
}
|
|
47
|
+
function a(e) {
|
|
48
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return null;
|
|
49
|
+
let t = e, n = { type: typeof t.type == "string" && t.type ? t.type : "paragraph" };
|
|
50
|
+
if (typeof t.id == "string" && (n.id = t.id), typeof t.text == "string") n.text = t.text;
|
|
51
|
+
else if (Array.isArray(t.text)) {
|
|
52
|
+
let e = [];
|
|
53
|
+
for (let n of t.text) {
|
|
54
|
+
if (!n || typeof n != "object") continue;
|
|
55
|
+
let t = n;
|
|
56
|
+
e.push({
|
|
57
|
+
t: String(t.t ?? ""),
|
|
58
|
+
...t.a && typeof t.a == "object" ? { a: t.a } : {}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
e.length > 0 && (n.text = e);
|
|
62
|
+
}
|
|
63
|
+
if (t.props && typeof t.props == "object" && !Array.isArray(t.props) && (n.props = t.props), Array.isArray(t.children)) {
|
|
64
|
+
let e = t.children.map(a).filter((e) => e !== null);
|
|
65
|
+
e.length > 0 && (n.children = e);
|
|
66
|
+
}
|
|
67
|
+
return n;
|
|
68
|
+
}
|
|
69
|
+
function o(e) {
|
|
70
|
+
let n = new t.Doc(), r = s(n);
|
|
71
|
+
return n.transact(() => {
|
|
72
|
+
r.push((e && e.length > 0 ? e : [{ type: "paragraph" }]).map(i));
|
|
73
|
+
}), n;
|
|
74
|
+
}
|
|
75
|
+
function s(e) {
|
|
76
|
+
return e.getArray("blocks");
|
|
77
|
+
}
|
|
78
|
+
function c(e, n = "seed") {
|
|
79
|
+
let r = (e, t) => e.map((e, n) => ({
|
|
80
|
+
...e,
|
|
81
|
+
id: e.id ?? `${t}-${n}`,
|
|
82
|
+
children: e.children ? r(e.children, `${t}-${n}`) : void 0
|
|
83
|
+
})), a = new t.Doc();
|
|
84
|
+
a.clientID = 1, s(a).push(r(e.length > 0 ? e : [{ type: "paragraph" }], n).map(i));
|
|
85
|
+
let o = new t.Doc();
|
|
86
|
+
return t.applyUpdate(o, t.encodeStateAsUpdate(a)), a.destroy(), o;
|
|
87
|
+
}
|
|
88
|
+
var l = (e) => e.get("id"), u = (e) => e.get("type"), d = (e) => e.get("text"), f = (e) => e.get("children");
|
|
89
|
+
function p(e, t) {
|
|
90
|
+
let n = e.toString();
|
|
91
|
+
if (n === t) return;
|
|
92
|
+
let r = 0, i = Math.min(n.length, t.length);
|
|
93
|
+
for (; r < i && n[r] === t[r];) r += 1;
|
|
94
|
+
let a = n.length, o = t.length;
|
|
95
|
+
for (; a > r && o > r && n[a - 1] === t[o - 1];) --a, --o;
|
|
96
|
+
a > r && e.delete(r, a - r), o > r && e.insert(r, t.slice(r, o));
|
|
97
|
+
}
|
|
98
|
+
function m(e, t) {
|
|
99
|
+
return e.get("props")?.get(t);
|
|
100
|
+
}
|
|
101
|
+
function h(e, n, r) {
|
|
102
|
+
let i = e.get("props");
|
|
103
|
+
i || (i = new t.Map(), e.set("props", i)), r === void 0 ? i.delete(n) : i.set(n, r);
|
|
104
|
+
}
|
|
105
|
+
function* g(e) {
|
|
106
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
107
|
+
let n = e.get(t);
|
|
108
|
+
yield {
|
|
109
|
+
block: n,
|
|
110
|
+
parent: e,
|
|
111
|
+
index: t
|
|
112
|
+
};
|
|
113
|
+
let r = f(n);
|
|
114
|
+
r && (yield* g(r));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function _(e, t) {
|
|
118
|
+
for (let n of g(s(e))) if (l(n.block) === t) return n;
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
function v(e, t = !1) {
|
|
122
|
+
return i(y(e, t));
|
|
123
|
+
}
|
|
124
|
+
function y(e, t) {
|
|
125
|
+
let n = V(e), r = (e) => ({
|
|
126
|
+
id: t ? void 0 : e.id,
|
|
127
|
+
type: e.type,
|
|
128
|
+
text: e.text,
|
|
129
|
+
props: e.props,
|
|
130
|
+
children: e.children?.map(r)
|
|
131
|
+
});
|
|
132
|
+
return r(n);
|
|
133
|
+
}
|
|
134
|
+
function b(t, n, r, a) {
|
|
135
|
+
let o = a.id ?? e("b"), s = i({
|
|
136
|
+
...a,
|
|
137
|
+
id: o
|
|
138
|
+
});
|
|
139
|
+
return t.transact(() => n.insert(Math.max(0, Math.min(r, n.length)), [s]), "local"), o;
|
|
140
|
+
}
|
|
141
|
+
function x(e, t) {
|
|
142
|
+
e.transact(() => {
|
|
143
|
+
let n = _(e, t);
|
|
144
|
+
n && n.parent.delete(n.index, 1), j(e), M(e);
|
|
145
|
+
}, "local");
|
|
146
|
+
}
|
|
147
|
+
function S(e, n, r, i) {
|
|
148
|
+
e.transact(() => {
|
|
149
|
+
let a = _(e, n);
|
|
150
|
+
if (!a) return;
|
|
151
|
+
let o = r === null ? s(e) : f(_(e, r)?.block);
|
|
152
|
+
if (!o) return;
|
|
153
|
+
if (r !== null) {
|
|
154
|
+
for (let e of g(f(a.block) ?? new t.Array())) if (l(e.block) === r) return;
|
|
155
|
+
if (r === n) return;
|
|
156
|
+
}
|
|
157
|
+
let c = v(a.block), u = a.parent === o;
|
|
158
|
+
a.parent.delete(a.index, 1);
|
|
159
|
+
let d = i;
|
|
160
|
+
u && a.index < i && --d, o.insert(Math.max(0, Math.min(d, o.length)), [c]), j(e), M(e);
|
|
161
|
+
}, "local");
|
|
162
|
+
}
|
|
163
|
+
function C(t, n, r, a) {
|
|
164
|
+
let o = null;
|
|
165
|
+
return t.transact(() => {
|
|
166
|
+
let s = _(t, n);
|
|
167
|
+
if (!s) return;
|
|
168
|
+
let c = d(s.block);
|
|
169
|
+
if (!c) return;
|
|
170
|
+
let l = c.toDelta(), f = [], p = 0;
|
|
171
|
+
for (let e of l) {
|
|
172
|
+
let t = p + e.insert.length;
|
|
173
|
+
if (t > r) {
|
|
174
|
+
let t = Math.max(0, r - p);
|
|
175
|
+
f.push({
|
|
176
|
+
t: e.insert.slice(t),
|
|
177
|
+
a: e.attributes
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
p = t;
|
|
181
|
+
}
|
|
182
|
+
c.length > r && c.delete(r, c.length - r);
|
|
183
|
+
let h = u(s.block), g = a ?? (h === "list" || h === "todo" ? h : "paragraph"), v = g === u(s.block) && g === "list" ? { kind: m(s.block, "kind") ?? "bullet" } : void 0;
|
|
184
|
+
o = e("b"), s.parent.insert(s.index + 1, [i({
|
|
185
|
+
id: o,
|
|
186
|
+
type: g,
|
|
187
|
+
text: f,
|
|
188
|
+
props: v
|
|
189
|
+
})]);
|
|
190
|
+
}, "local"), o;
|
|
191
|
+
}
|
|
192
|
+
function w(e, t) {
|
|
193
|
+
let n = null;
|
|
194
|
+
return e.transact(() => {
|
|
195
|
+
let r = _(e, t);
|
|
196
|
+
if (!r || r.index === 0) return;
|
|
197
|
+
let i = r.parent.get(r.index - 1), a = d(i), o = d(r.block);
|
|
198
|
+
if (!a || !o) return;
|
|
199
|
+
let s = a.length, c = o.toDelta(), u = s;
|
|
200
|
+
for (let e of c) a.insert(u, e.insert, e.attributes ?? {}), u += e.insert.length;
|
|
201
|
+
r.parent.delete(r.index, 1), n = {
|
|
202
|
+
id: l(i),
|
|
203
|
+
offset: s
|
|
204
|
+
};
|
|
205
|
+
}, "local"), n;
|
|
206
|
+
}
|
|
207
|
+
function T(e, r, i, a) {
|
|
208
|
+
e.transact(() => {
|
|
209
|
+
let o = _(e, r);
|
|
210
|
+
if (o && (o.block.set("type", i), n.has(i) && !d(o.block) && o.block.set("text", new t.Text()), a)) for (let [e, t] of Object.entries(a)) h(o.block, e, t);
|
|
211
|
+
}, "local");
|
|
212
|
+
}
|
|
213
|
+
function E(e, r) {
|
|
214
|
+
if (r.type && (e.set("type", r.type), n.has(r.type) && !d(e) && e.set("text", new t.Text())), r.props) for (let [t, n] of Object.entries(r.props)) h(e, t, n);
|
|
215
|
+
}
|
|
216
|
+
function D(e) {
|
|
217
|
+
let t = e.length;
|
|
218
|
+
if (t === 0) return;
|
|
219
|
+
let n = Math.floor(12 / t), r = 12 - n * t;
|
|
220
|
+
for (let i = 0; i < t; i += 1) h(e.get(i), "span", n + +(r > 0)), r > 0 && --r;
|
|
221
|
+
}
|
|
222
|
+
function O(e, t, n, r) {
|
|
223
|
+
e.transact(() => {
|
|
224
|
+
let a = _(e, t), o = _(e, n);
|
|
225
|
+
if (!a || !o || t === n || u(a.block) === "columns" || u(a.block) === "column") return;
|
|
226
|
+
let s = y(a.block, !1), c = k(e, o.parent);
|
|
227
|
+
if (c && u(c) === "column") {
|
|
228
|
+
let t = k(e, _(e, l(c)).parent), n = t ? f(t) : void 0;
|
|
229
|
+
if (!t || !n || n.length >= 6) return;
|
|
230
|
+
let o = A(n, l(c));
|
|
231
|
+
a.parent.delete(a.index, 1);
|
|
232
|
+
let u = r === "left" ? o : o + 1;
|
|
233
|
+
n.insert(u, [i({
|
|
234
|
+
type: "column",
|
|
235
|
+
children: [s]
|
|
236
|
+
})]), D(n), j(e), M(e);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
a.parent.delete(a.index, 1);
|
|
240
|
+
let d = _(e, n);
|
|
241
|
+
if (!d) return;
|
|
242
|
+
let p = y(d.block, !1), m = i({
|
|
243
|
+
type: "columns",
|
|
244
|
+
children: [{
|
|
245
|
+
type: "column",
|
|
246
|
+
children: [r === "left" ? s : p]
|
|
247
|
+
}, {
|
|
248
|
+
type: "column",
|
|
249
|
+
children: [r === "left" ? p : s]
|
|
250
|
+
}]
|
|
251
|
+
});
|
|
252
|
+
d.parent.delete(d.index, 1), d.parent.insert(d.index, [m]), j(e), M(e);
|
|
253
|
+
}, "local");
|
|
254
|
+
}
|
|
255
|
+
function k(e, t) {
|
|
256
|
+
if (t === s(e)) return null;
|
|
257
|
+
for (let n of g(s(e))) if (f(n.block) === t) return n.block;
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
function A(e, t) {
|
|
261
|
+
for (let n = 0; n < e.length; n += 1) if (l(e.get(n)) === t) return n;
|
|
262
|
+
return -1;
|
|
263
|
+
}
|
|
264
|
+
function j(e) {
|
|
265
|
+
let t = !0;
|
|
266
|
+
for (; t;) {
|
|
267
|
+
t = !1;
|
|
268
|
+
for (let n of g(s(e))) {
|
|
269
|
+
let e = u(n.block);
|
|
270
|
+
if (e === "column" && (f(n.block)?.length ?? 0) === 0) {
|
|
271
|
+
n.parent.delete(n.index, 1), t = !0;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
if (e === "columns") {
|
|
275
|
+
let e = f(n.block);
|
|
276
|
+
if (e.length === 0) {
|
|
277
|
+
n.parent.delete(n.index, 1), t = !0;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
if (e.length === 1) {
|
|
281
|
+
let r = f(e.get(0)), i = [];
|
|
282
|
+
for (let e = 0; e < r.length; e += 1) i.push(v(r.get(e)));
|
|
283
|
+
n.parent.delete(n.index, 1), n.parent.insert(n.index, i), t = !0;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function M(e) {
|
|
291
|
+
let t = s(e);
|
|
292
|
+
t.length === 0 && t.push([i({ type: "paragraph" })]);
|
|
293
|
+
}
|
|
294
|
+
function N(e, t) {
|
|
295
|
+
return {
|
|
296
|
+
type: "table",
|
|
297
|
+
props: { header: !0 },
|
|
298
|
+
children: Array.from({ length: e }, () => ({
|
|
299
|
+
type: "row",
|
|
300
|
+
children: Array.from({ length: t }, () => ({ type: "cell" }))
|
|
301
|
+
}))
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function P(e, t, n) {
|
|
305
|
+
e.transact(() => {
|
|
306
|
+
let r = _(e, t);
|
|
307
|
+
if (!r) return;
|
|
308
|
+
let a = f(r.block), o = a.length > 0 ? f(a.get(0))?.length ?? 1 : 1;
|
|
309
|
+
a.insert(Math.max(0, Math.min(n, a.length)), [i({
|
|
310
|
+
type: "row",
|
|
311
|
+
children: Array.from({ length: o }, () => ({ type: "cell" }))
|
|
312
|
+
})]);
|
|
313
|
+
}, "local");
|
|
314
|
+
}
|
|
315
|
+
function F(e, t, n) {
|
|
316
|
+
e.transact(() => {
|
|
317
|
+
let r = _(e, t);
|
|
318
|
+
if (!r) return;
|
|
319
|
+
let a = f(r.block);
|
|
320
|
+
for (let e = 0; e < a.length; e += 1) {
|
|
321
|
+
let t = f(a.get(e));
|
|
322
|
+
t.insert(Math.max(0, Math.min(n, t.length)), [i({ type: "cell" })]);
|
|
323
|
+
}
|
|
324
|
+
}, "local");
|
|
325
|
+
}
|
|
326
|
+
function I(e, t, n) {
|
|
327
|
+
e.transact(() => {
|
|
328
|
+
let r = _(e, t);
|
|
329
|
+
if (!r) return;
|
|
330
|
+
let i = f(r.block);
|
|
331
|
+
n < 0 || n >= i.length || (i.length === 1 ? B(e, t) : i.delete(n, 1));
|
|
332
|
+
}, "local");
|
|
333
|
+
}
|
|
334
|
+
function L(e, t, n) {
|
|
335
|
+
e.transact(() => {
|
|
336
|
+
let r = _(e, t);
|
|
337
|
+
if (!r) return;
|
|
338
|
+
let i = f(r.block), a = i.length > 0 ? f(i.get(0))?.length ?? 0 : 0;
|
|
339
|
+
if (!(n < 0 || n >= a)) {
|
|
340
|
+
if (a === 1) {
|
|
341
|
+
B(e, t);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
for (let e = 0; e < i.length; e += 1) {
|
|
345
|
+
let t = f(i.get(e));
|
|
346
|
+
n < t.length && t.delete(n, 1);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}, "local");
|
|
350
|
+
}
|
|
351
|
+
function R(e, t) {
|
|
352
|
+
let n = _(e, t);
|
|
353
|
+
if (!n || u(n.block) !== "cell") return null;
|
|
354
|
+
let r = k(e, n.parent);
|
|
355
|
+
if (!r) return null;
|
|
356
|
+
let i = _(e, l(r));
|
|
357
|
+
if (!i) return null;
|
|
358
|
+
let a = k(e, i.parent);
|
|
359
|
+
if (!a || u(a) !== "table") return null;
|
|
360
|
+
let o = f(a);
|
|
361
|
+
return {
|
|
362
|
+
table: a,
|
|
363
|
+
row: i.index,
|
|
364
|
+
col: n.index,
|
|
365
|
+
rows: o.length,
|
|
366
|
+
cols: f(r).length
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function z(e, t, n) {
|
|
370
|
+
let r = R(e, t);
|
|
371
|
+
if (!r) return null;
|
|
372
|
+
let { row: i, col: a } = r;
|
|
373
|
+
if (n === "next" ? (a += 1, a >= r.cols && (a = 0, i += 1)) : n === "prev" ? (--a, a < 0 && (a = r.cols - 1, --i)) : i += n === "down" ? 1 : -1, i < 0 || i >= r.rows) return null;
|
|
374
|
+
let o = f(f(r.table).get(i));
|
|
375
|
+
return a < 0 || a >= o.length ? null : l(o.get(a));
|
|
376
|
+
}
|
|
377
|
+
function B(e, t) {
|
|
378
|
+
let n = _(e, t);
|
|
379
|
+
n && n.parent.delete(n.index, 1), M(e);
|
|
380
|
+
}
|
|
381
|
+
function V(e) {
|
|
382
|
+
let t = {
|
|
383
|
+
id: l(e),
|
|
384
|
+
type: u(e)
|
|
385
|
+
}, n = d(e);
|
|
386
|
+
n && (t.text = n.toDelta().map((e) => ({
|
|
387
|
+
t: e.insert,
|
|
388
|
+
...e.attributes && Object.keys(e.attributes).length > 0 ? { a: e.attributes } : {}
|
|
389
|
+
})));
|
|
390
|
+
let r = e.get("props");
|
|
391
|
+
r && r.size > 0 && (t.props = Object.fromEntries(r.entries()));
|
|
392
|
+
let i = f(e);
|
|
393
|
+
return i && (t.children = i.map(V)), t;
|
|
394
|
+
}
|
|
395
|
+
function H(e) {
|
|
396
|
+
return s(e).map(V);
|
|
397
|
+
}
|
|
398
|
+
function U(e) {
|
|
399
|
+
return d(e)?.toString() ?? "";
|
|
400
|
+
}
|
|
401
|
+
function W(e) {
|
|
402
|
+
let n = t.encodeStateAsUpdate(e), r = "";
|
|
403
|
+
for (let e = 0; e < n.length; e += 1) r += String.fromCharCode(n[e]);
|
|
404
|
+
return {
|
|
405
|
+
v: 1,
|
|
406
|
+
update: btoa(r),
|
|
407
|
+
blocks: H(e)
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function G(e) {
|
|
411
|
+
if (e?.update) try {
|
|
412
|
+
let n = atob(e.update), r = new Uint8Array(n.length);
|
|
413
|
+
for (let e = 0; e < n.length; e += 1) r[e] = n.charCodeAt(e);
|
|
414
|
+
let i = new t.Doc();
|
|
415
|
+
return t.applyUpdate(i, r), M(i), i;
|
|
416
|
+
} catch {}
|
|
417
|
+
return e?.blocks && e.blocks.length > 0 ? o(e.blocks.map(K)) : o();
|
|
418
|
+
}
|
|
419
|
+
function K(e) {
|
|
420
|
+
return {
|
|
421
|
+
id: e.id,
|
|
422
|
+
type: e.type,
|
|
423
|
+
text: e.text,
|
|
424
|
+
props: e.props,
|
|
425
|
+
children: e.children?.map(K)
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function q(e) {
|
|
429
|
+
if (typeof document > "u") return [{ t: e.replace(/<[^>]+>/g, "") }];
|
|
430
|
+
let t = document.createElement("div");
|
|
431
|
+
t.innerHTML = e;
|
|
432
|
+
let n = [], r = (e, t) => {
|
|
433
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
434
|
+
let r = e.textContent ?? "";
|
|
435
|
+
r && n.push({
|
|
436
|
+
t: r,
|
|
437
|
+
...Object.keys(t).length > 0 ? { a: t } : {}
|
|
438
|
+
});
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
if (!(e instanceof HTMLElement)) return;
|
|
442
|
+
let i = { ...t }, a = e.tagName.toLowerCase();
|
|
443
|
+
if ((a === "b" || a === "strong") && (i.b = !0), (a === "i" || a === "em") && (i.i = !0), a === "u" && (i.u = !0), (a === "s" || a === "del") && (i.s = !0), a === "code" && (i.c = !0), a === "a") {
|
|
444
|
+
let t = e.getAttribute("data-page-id");
|
|
445
|
+
t ? i.m = t : e.getAttribute("href") && (i.a = e.getAttribute("href"));
|
|
446
|
+
}
|
|
447
|
+
if (a === "br") {
|
|
448
|
+
n.push({ t: "\n" });
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
e.childNodes.forEach((e) => r(e, i));
|
|
452
|
+
};
|
|
453
|
+
return t.childNodes.forEach((e) => r(e, {})), n;
|
|
454
|
+
}
|
|
455
|
+
function J(e) {
|
|
456
|
+
if (typeof document > "u") return [{
|
|
457
|
+
type: "paragraph",
|
|
458
|
+
text: e.replace(/<[^>]+>/g, "")
|
|
459
|
+
}];
|
|
460
|
+
let t = document.createElement("div");
|
|
461
|
+
t.innerHTML = e;
|
|
462
|
+
let n = [], r = (e, t) => {
|
|
463
|
+
e.querySelectorAll(":scope > li").forEach((e) => {
|
|
464
|
+
let i = e.querySelector(":scope > input[type=\"checkbox\"]"), a = e.cloneNode(!0);
|
|
465
|
+
a.querySelectorAll("ul, ol, input").forEach((e) => e.remove());
|
|
466
|
+
let o = q(a.innerHTML);
|
|
467
|
+
i ? n.push({
|
|
468
|
+
type: "todo",
|
|
469
|
+
text: o,
|
|
470
|
+
props: i.checked ? { checked: !0 } : void 0
|
|
471
|
+
}) : n.push({
|
|
472
|
+
type: "list",
|
|
473
|
+
text: o,
|
|
474
|
+
props: { kind: t }
|
|
475
|
+
}), e.querySelectorAll(":scope > ul").forEach((e) => r(e, "bullet")), e.querySelectorAll(":scope > ol").forEach((e) => r(e, "number"));
|
|
476
|
+
});
|
|
477
|
+
}, i = (e) => {
|
|
478
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
479
|
+
let t = (e.textContent ?? "").trim();
|
|
480
|
+
t && n.push({
|
|
481
|
+
type: "paragraph",
|
|
482
|
+
text: [{ t }]
|
|
483
|
+
});
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
if (!(e instanceof HTMLElement)) return;
|
|
487
|
+
let t = e.tagName.toLowerCase();
|
|
488
|
+
switch (t) {
|
|
489
|
+
case "h1":
|
|
490
|
+
case "h2":
|
|
491
|
+
case "h3":
|
|
492
|
+
case "h4":
|
|
493
|
+
case "h5":
|
|
494
|
+
case "h6":
|
|
495
|
+
n.push({
|
|
496
|
+
type: "heading",
|
|
497
|
+
text: q(e.innerHTML),
|
|
498
|
+
props: { level: Math.min(3, Number(t[1])) }
|
|
499
|
+
});
|
|
500
|
+
return;
|
|
501
|
+
case "p":
|
|
502
|
+
n.push({
|
|
503
|
+
type: "paragraph",
|
|
504
|
+
text: q(e.innerHTML)
|
|
505
|
+
});
|
|
506
|
+
return;
|
|
507
|
+
case "ul":
|
|
508
|
+
r(e, "bullet");
|
|
509
|
+
return;
|
|
510
|
+
case "ol":
|
|
511
|
+
r(e, "number");
|
|
512
|
+
return;
|
|
513
|
+
case "blockquote":
|
|
514
|
+
n.push({
|
|
515
|
+
type: "quote",
|
|
516
|
+
text: q(e.innerHTML)
|
|
517
|
+
});
|
|
518
|
+
return;
|
|
519
|
+
case "pre":
|
|
520
|
+
n.push({
|
|
521
|
+
type: "code",
|
|
522
|
+
text: e.textContent ?? ""
|
|
523
|
+
});
|
|
524
|
+
return;
|
|
525
|
+
case "hr":
|
|
526
|
+
n.push({ type: "divider" });
|
|
527
|
+
return;
|
|
528
|
+
case "table": {
|
|
529
|
+
let t = [...e.querySelectorAll("tr")].map((e) => [...e.querySelectorAll("td, th")].map((e) => q(e.innerHTML)));
|
|
530
|
+
t.length > 0 && n.push({
|
|
531
|
+
type: "table",
|
|
532
|
+
props: { header: e.querySelector("th") !== null },
|
|
533
|
+
children: t.map((e) => ({
|
|
534
|
+
type: "row",
|
|
535
|
+
children: e.map((e) => ({
|
|
536
|
+
type: "cell",
|
|
537
|
+
text: e
|
|
538
|
+
}))
|
|
539
|
+
}))
|
|
540
|
+
});
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
case "div":
|
|
544
|
+
case "section":
|
|
545
|
+
case "article":
|
|
546
|
+
case "body":
|
|
547
|
+
e.childNodes.forEach(i);
|
|
548
|
+
return;
|
|
549
|
+
case "br":
|
|
550
|
+
case "style":
|
|
551
|
+
case "script":
|
|
552
|
+
case "meta": return;
|
|
553
|
+
default: {
|
|
554
|
+
let t = q(e.outerHTML);
|
|
555
|
+
t.some((e) => e.t.trim()) && n.push({
|
|
556
|
+
type: "paragraph",
|
|
557
|
+
text: t
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
return t.childNodes.forEach(i), n;
|
|
563
|
+
}
|
|
564
|
+
function Y(e, t) {
|
|
565
|
+
return e.replace(/__C__\{([^}]+)\}__/g, (e, n) => t.get(n) ?? `missing_${String(n).replace(/\W/g, "_")}`).replace(/@([A-Za-z_][\w]*)/g, "$1");
|
|
566
|
+
}
|
|
567
|
+
function X(e, t = {}) {
|
|
568
|
+
let n = new Map(t.values ?? []), r = new Map((t.names ?? []).map(([e, t]) => [t, e])), i = [];
|
|
569
|
+
for (let a of e) {
|
|
570
|
+
let e = a.data ?? {};
|
|
571
|
+
switch (a.type) {
|
|
572
|
+
case "paragraph":
|
|
573
|
+
i.push({
|
|
574
|
+
type: "paragraph",
|
|
575
|
+
text: q(String(e.text ?? ""))
|
|
576
|
+
});
|
|
577
|
+
break;
|
|
578
|
+
case "header":
|
|
579
|
+
i.push({
|
|
580
|
+
type: "heading",
|
|
581
|
+
text: q(String(e.text ?? "")),
|
|
582
|
+
props: { level: Math.min(3, Number(e.level ?? 2)) }
|
|
583
|
+
});
|
|
584
|
+
break;
|
|
585
|
+
case "quote":
|
|
586
|
+
i.push({
|
|
587
|
+
type: "quote",
|
|
588
|
+
text: q(String(e.text ?? ""))
|
|
589
|
+
});
|
|
590
|
+
break;
|
|
591
|
+
case "callout":
|
|
592
|
+
i.push({
|
|
593
|
+
type: "callout",
|
|
594
|
+
text: q(String(e.text ?? "")),
|
|
595
|
+
props: { variant: String(e.variant ?? "info") }
|
|
596
|
+
});
|
|
597
|
+
break;
|
|
598
|
+
case "code":
|
|
599
|
+
i.push({
|
|
600
|
+
type: "code",
|
|
601
|
+
text: String(e.code ?? ""),
|
|
602
|
+
props: e.language ? { language: String(e.language) } : void 0
|
|
603
|
+
});
|
|
604
|
+
break;
|
|
605
|
+
case "delimiter":
|
|
606
|
+
case "divider":
|
|
607
|
+
i.push({ type: "divider" });
|
|
608
|
+
break;
|
|
609
|
+
case "list": {
|
|
610
|
+
let t = e.style === "ordered" ? "number" : "bullet", n = e.items ?? [];
|
|
611
|
+
for (let e of n) {
|
|
612
|
+
let n = typeof e == "string" ? e : String(e.content ?? "");
|
|
613
|
+
i.push({
|
|
614
|
+
type: "list",
|
|
615
|
+
text: q(n),
|
|
616
|
+
props: { kind: t }
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
case "checklist": {
|
|
622
|
+
let t = e.items ?? [];
|
|
623
|
+
for (let e of t) i.push({
|
|
624
|
+
type: "todo",
|
|
625
|
+
text: q(String(e.text ?? "")),
|
|
626
|
+
props: e.checked ? { checked: !0 } : void 0
|
|
627
|
+
});
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
case "table": {
|
|
631
|
+
let t = e.content ?? [];
|
|
632
|
+
t.length > 0 && i.push({
|
|
633
|
+
type: "table",
|
|
634
|
+
props: { header: !!e.withHeadings },
|
|
635
|
+
children: t.map((e) => ({
|
|
636
|
+
type: "row",
|
|
637
|
+
children: e.map((e) => ({
|
|
638
|
+
type: "cell",
|
|
639
|
+
text: q(e)
|
|
640
|
+
}))
|
|
641
|
+
}))
|
|
642
|
+
});
|
|
643
|
+
break;
|
|
644
|
+
}
|
|
645
|
+
case "toc": break;
|
|
646
|
+
case "accordion":
|
|
647
|
+
e.title && i.push({
|
|
648
|
+
type: "heading",
|
|
649
|
+
text: q(String(e.title)),
|
|
650
|
+
props: { level: 3 }
|
|
651
|
+
}), e.content && i.push({
|
|
652
|
+
type: "paragraph",
|
|
653
|
+
text: q(String(e.content))
|
|
654
|
+
});
|
|
655
|
+
break;
|
|
656
|
+
case "button": {
|
|
657
|
+
let t = String(e.url ?? ""), n = String(e.label ?? "") || t;
|
|
658
|
+
(t || n) && i.push({
|
|
659
|
+
type: "paragraph",
|
|
660
|
+
text: [{
|
|
661
|
+
t: n,
|
|
662
|
+
...t ? { a: { a: t } } : {}
|
|
663
|
+
}]
|
|
664
|
+
});
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
case "subpage": {
|
|
668
|
+
let n = typeof e.pageId == "string" ? e.pageId : "";
|
|
669
|
+
if (n) {
|
|
670
|
+
let r = t.pageLabels?.get(n), a = e.kind === "database" ? "🗃" : "📄";
|
|
671
|
+
i.push({
|
|
672
|
+
type: "paragraph",
|
|
673
|
+
text: [{
|
|
674
|
+
t: `${a} ${r ?? (e.kind === "database" ? "Sub-database" : "Sub-page")}`,
|
|
675
|
+
a: { m: n }
|
|
676
|
+
}]
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
case "database": {
|
|
682
|
+
let n = typeof e.pageId == "string" ? e.pageId : "";
|
|
683
|
+
if (n) {
|
|
684
|
+
let e = t.pageLabels?.get(n);
|
|
685
|
+
i.push({
|
|
686
|
+
type: "dbview",
|
|
687
|
+
props: {
|
|
688
|
+
pageId: n,
|
|
689
|
+
name: e ?? "Inline database"
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
case "slider": {
|
|
696
|
+
let t = typeof e.cellId == "string" ? e.cellId : "", a = n.get(t);
|
|
697
|
+
i.push({
|
|
698
|
+
type: "slider",
|
|
699
|
+
props: {
|
|
700
|
+
name: String(e.name ?? r.get(t) ?? "x"),
|
|
701
|
+
min: Number(e.min ?? 0),
|
|
702
|
+
max: Number(e.max ?? 100),
|
|
703
|
+
value: typeof a == "number" ? a : Number(e.initial ?? 50)
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
case "expr":
|
|
709
|
+
i.push({
|
|
710
|
+
type: "formula",
|
|
711
|
+
props: { source: Y(String(e.source ?? ""), r) }
|
|
712
|
+
});
|
|
713
|
+
break;
|
|
714
|
+
case "chart":
|
|
715
|
+
i.push({
|
|
716
|
+
type: "callout",
|
|
717
|
+
text: "Chart block — not yet supported in the new editor.",
|
|
718
|
+
props: { variant: "warn" }
|
|
719
|
+
});
|
|
720
|
+
break;
|
|
721
|
+
default: {
|
|
722
|
+
let t = typeof e.text == "string" ? e.text : "";
|
|
723
|
+
t && i.push({
|
|
724
|
+
type: "paragraph",
|
|
725
|
+
text: q(t)
|
|
726
|
+
});
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return i.length > 0 ? i : [{ type: "paragraph" }];
|
|
732
|
+
}
|
|
733
|
+
//#endregion
|
|
734
|
+
export { p as A, N as C, k as D, S as E, I as F, F as I, P as L, h as M, C as N, E as O, L as P, T as R, i as S, X as T, O as _, m as a, J as b, u as c, v as d, a as f, H as g, G as h, U as i, s as j, x as k, z as l, c as m, f as n, d as o, o as p, l as r, V as s, n as t, R as u, W as v, w, b as x, _ as y, g as z };
|