@threadlabs/looma 0.1.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/README.md +21 -0
- package/dist/chunk-G53JEAQK.js +94 -0
- package/dist/chunk-OF57X5AR.js +10 -0
- package/dist/chunk-UL7UIUJZ.js +20 -0
- package/dist/chunk-YK4MTZGJ.js +1580 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/events-TcQIzpNv.js +19 -0
- package/dist/cjs/id-CYbKpaYr.js +9 -0
- package/dist/cjs/index-D07f6BOw.js +1569 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/looma.cjs.js +25 -0
- package/dist/cjs/manager-BOpVXb92.js +93 -0
- package/dist/cjs/ui-avatar-group.cjs.entry.js +51 -0
- package/dist/cjs/ui-avatar.cjs.entry.js +50 -0
- package/dist/cjs/ui-badge.cjs.entry.js +19 -0
- package/dist/cjs/ui-button.cjs.entry.js +62 -0
- package/dist/cjs/ui-checkbox.cjs.entry.js +91 -0
- package/dist/cjs/ui-context-menu.cjs.entry.js +201 -0
- package/dist/cjs/ui-dialog.cjs.entry.js +93 -0
- package/dist/cjs/ui-disclosure.cjs.entry.js +109 -0
- package/dist/cjs/ui-floating-action-button.cjs.entry.js +20 -0
- package/dist/cjs/ui-form-field.cjs.entry.js +59 -0
- package/dist/cjs/ui-icon-button.cjs.entry.js +21 -0
- package/dist/cjs/ui-input.cjs.entry.js +101 -0
- package/dist/cjs/ui-menu-item.cjs.entry.js +19 -0
- package/dist/cjs/ui-menu.cjs.entry.js +96 -0
- package/dist/cjs/ui-popover.cjs.entry.js +92 -0
- package/dist/cjs/ui-radio-group.cjs.entry.js +134 -0
- package/dist/cjs/ui-radio.cjs.entry.js +85 -0
- package/dist/cjs/ui-search-result-row.cjs.entry.js +47 -0
- package/dist/cjs/ui-search-shell.cjs.entry.js +39 -0
- package/dist/cjs/ui-select.cjs.entry.js +100 -0
- package/dist/cjs/ui-switch.cjs.entry.js +65 -0
- package/dist/cjs/ui-tabs.cjs.entry.js +117 -0
- package/dist/cjs/ui-textarea.cjs.entry.js +106 -0
- package/dist/cjs/ui-toast-region.cjs.entry.js +67 -0
- package/dist/cjs/ui-tooltip.cjs.entry.js +133 -0
- package/dist/cjs/ui-top-bar.cjs.entry.js +43 -0
- package/dist/collection/collection-manifest.json +38 -0
- package/dist/collection/components/ui-avatar/ui-avatar.css +35 -0
- package/dist/collection/components/ui-avatar/ui-avatar.js +130 -0
- package/dist/collection/components/ui-avatar-group/ui-avatar-group.css +32 -0
- package/dist/collection/components/ui-avatar-group/ui-avatar-group.js +103 -0
- package/dist/collection/components/ui-badge/ui-badge.css +74 -0
- package/dist/collection/components/ui-badge/ui-badge.js +62 -0
- package/dist/collection/components/ui-button/ui-button.css +101 -0
- package/dist/collection/components/ui-button/ui-button.js +127 -0
- package/dist/collection/components/ui-checkbox/ui-checkbox.css +24 -0
- package/dist/collection/components/ui-checkbox/ui-checkbox.js +223 -0
- package/dist/collection/components/ui-context-menu/ui-context-menu.css +17 -0
- package/dist/collection/components/ui-context-menu/ui-context-menu.js +272 -0
- package/dist/collection/components/ui-dialog/ui-dialog.css +65 -0
- package/dist/collection/components/ui-dialog/ui-dialog.js +185 -0
- package/dist/collection/components/ui-disclosure/ui-disclosure.css +7 -0
- package/dist/collection/components/ui-disclosure/ui-disclosure.js +182 -0
- package/dist/collection/components/ui-floating-action-button/ui-floating-action-button.css +70 -0
- package/dist/collection/components/ui-floating-action-button/ui-floating-action-button.js +85 -0
- package/dist/collection/components/ui-form-field/ui-form-field.css +21 -0
- package/dist/collection/components/ui-form-field/ui-form-field.js +125 -0
- package/dist/collection/components/ui-icon-button/ui-icon-button.css +92 -0
- package/dist/collection/components/ui-icon-button/ui-icon-button.js +106 -0
- package/dist/collection/components/ui-input/ui-input.css +46 -0
- package/dist/collection/components/ui-input/ui-input.js +213 -0
- package/dist/collection/components/ui-menu/ui-menu.css +37 -0
- package/dist/collection/components/ui-menu/ui-menu.js +149 -0
- package/dist/collection/components/ui-menu-item/ui-menu-item.css +26 -0
- package/dist/collection/components/ui-menu-item/ui-menu-item.js +64 -0
- package/dist/collection/components/ui-popover/ui-popover.css +8 -0
- package/dist/collection/components/ui-popover/ui-popover.js +144 -0
- package/dist/collection/components/ui-radio/ui-radio.css +22 -0
- package/dist/collection/components/ui-radio/ui-radio.js +213 -0
- package/dist/collection/components/ui-radio-group/ui-radio-group.css +10 -0
- package/dist/collection/components/ui-radio-group/ui-radio-group.js +247 -0
- package/dist/collection/components/ui-search-result-row/ui-search-result-row.css +80 -0
- package/dist/collection/components/ui-search-result-row/ui-search-result-row.js +100 -0
- package/dist/collection/components/ui-search-shell/ui-search-shell.css +61 -0
- package/dist/collection/components/ui-search-shell/ui-search-shell.js +46 -0
- package/dist/collection/components/ui-select/ui-select.css +62 -0
- package/dist/collection/components/ui-select/ui-select.js +212 -0
- package/dist/collection/components/ui-switch/ui-switch.css +63 -0
- package/dist/collection/components/ui-switch/ui-switch.js +177 -0
- package/dist/collection/components/ui-tabs/ui-tabs.css +65 -0
- package/dist/collection/components/ui-tabs/ui-tabs.js +190 -0
- package/dist/collection/components/ui-textarea/ui-textarea.css +48 -0
- package/dist/collection/components/ui-textarea/ui-textarea.js +238 -0
- package/dist/collection/components/ui-toast-region/ui-toast-region.css +52 -0
- package/dist/collection/components/ui-toast-region/ui-toast-region.js +100 -0
- package/dist/collection/components/ui-tooltip/ui-tooltip.css +14 -0
- package/dist/collection/components/ui-tooltip/ui-tooltip.js +205 -0
- package/dist/collection/components/ui-top-bar/ui-top-bar.css +43 -0
- package/dist/collection/components/ui-top-bar/ui-top-bar.js +52 -0
- package/dist/collection/overlay/manager.js +90 -0
- package/dist/collection/utils/events.js +13 -0
- package/dist/collection/utils/id.js +5 -0
- package/dist/collection/utils/initials.js +11 -0
- package/dist/components/index.d.ts +88 -0
- package/dist/components/index.js +1 -0
- package/dist/components/p-CIA4RyEp.js +1 -0
- package/dist/components/p-CR7f2MQC.js +1 -0
- package/dist/components/p-JwSoedEO.js +1 -0
- package/dist/components/p-WvL4iAhX.js +1 -0
- package/dist/components/p-hgBUJRDa.js +1 -0
- package/dist/components/ui-avatar-group.d.ts +11 -0
- package/dist/components/ui-avatar-group.js +1 -0
- package/dist/components/ui-avatar.d.ts +11 -0
- package/dist/components/ui-avatar.js +1 -0
- package/dist/components/ui-badge.d.ts +11 -0
- package/dist/components/ui-badge.js +1 -0
- package/dist/components/ui-button.d.ts +11 -0
- package/dist/components/ui-button.js +1 -0
- package/dist/components/ui-checkbox.d.ts +11 -0
- package/dist/components/ui-checkbox.js +1 -0
- package/dist/components/ui-context-menu.d.ts +11 -0
- package/dist/components/ui-context-menu.js +1 -0
- package/dist/components/ui-dialog.d.ts +11 -0
- package/dist/components/ui-dialog.js +1 -0
- package/dist/components/ui-disclosure.d.ts +11 -0
- package/dist/components/ui-disclosure.js +1 -0
- package/dist/components/ui-floating-action-button.d.ts +11 -0
- package/dist/components/ui-floating-action-button.js +1 -0
- package/dist/components/ui-form-field.d.ts +11 -0
- package/dist/components/ui-form-field.js +1 -0
- package/dist/components/ui-icon-button.d.ts +11 -0
- package/dist/components/ui-icon-button.js +1 -0
- package/dist/components/ui-input.d.ts +11 -0
- package/dist/components/ui-input.js +1 -0
- package/dist/components/ui-menu-item.d.ts +11 -0
- package/dist/components/ui-menu-item.js +1 -0
- package/dist/components/ui-menu.d.ts +11 -0
- package/dist/components/ui-menu.js +1 -0
- package/dist/components/ui-popover.d.ts +11 -0
- package/dist/components/ui-popover.js +1 -0
- package/dist/components/ui-radio-group.d.ts +11 -0
- package/dist/components/ui-radio-group.js +1 -0
- package/dist/components/ui-radio.d.ts +11 -0
- package/dist/components/ui-radio.js +1 -0
- package/dist/components/ui-search-result-row.d.ts +11 -0
- package/dist/components/ui-search-result-row.js +1 -0
- package/dist/components/ui-search-shell.d.ts +11 -0
- package/dist/components/ui-search-shell.js +1 -0
- package/dist/components/ui-select.d.ts +11 -0
- package/dist/components/ui-select.js +1 -0
- package/dist/components/ui-switch.d.ts +11 -0
- package/dist/components/ui-switch.js +1 -0
- package/dist/components/ui-tabs.d.ts +11 -0
- package/dist/components/ui-tabs.js +1 -0
- package/dist/components/ui-textarea.d.ts +11 -0
- package/dist/components/ui-textarea.js +1 -0
- package/dist/components/ui-toast-region.d.ts +11 -0
- package/dist/components/ui-toast-region.js +1 -0
- package/dist/components/ui-tooltip.d.ts +11 -0
- package/dist/components/ui-tooltip.js +1 -0
- package/dist/components/ui-top-bar.d.ts +11 -0
- package/dist/components/ui-top-bar.js +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/events-JwSoedEO.js +15 -0
- package/dist/esm/id-hgBUJRDa.js +7 -0
- package/dist/esm/index-CEeiinfk.js +1561 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/looma.js +21 -0
- package/dist/esm/manager-CR7f2MQC.js +89 -0
- package/dist/esm/ui-avatar-group.entry.js +49 -0
- package/dist/esm/ui-avatar.entry.js +48 -0
- package/dist/esm/ui-badge.entry.js +17 -0
- package/dist/esm/ui-button.entry.js +60 -0
- package/dist/esm/ui-checkbox.entry.js +89 -0
- package/dist/esm/ui-context-menu.entry.js +199 -0
- package/dist/esm/ui-dialog.entry.js +91 -0
- package/dist/esm/ui-disclosure.entry.js +107 -0
- package/dist/esm/ui-floating-action-button.entry.js +18 -0
- package/dist/esm/ui-form-field.entry.js +57 -0
- package/dist/esm/ui-icon-button.entry.js +19 -0
- package/dist/esm/ui-input.entry.js +99 -0
- package/dist/esm/ui-menu-item.entry.js +17 -0
- package/dist/esm/ui-menu.entry.js +94 -0
- package/dist/esm/ui-popover.entry.js +90 -0
- package/dist/esm/ui-radio-group.entry.js +132 -0
- package/dist/esm/ui-radio.entry.js +83 -0
- package/dist/esm/ui-search-result-row.entry.js +45 -0
- package/dist/esm/ui-search-shell.entry.js +37 -0
- package/dist/esm/ui-select.entry.js +98 -0
- package/dist/esm/ui-switch.entry.js +63 -0
- package/dist/esm/ui-tabs.entry.js +115 -0
- package/dist/esm/ui-textarea.entry.js +104 -0
- package/dist/esm/ui-toast-region.entry.js +65 -0
- package/dist/esm/ui-tooltip.entry.js +131 -0
- package/dist/esm/ui-top-bar.entry.js +41 -0
- package/dist/index.cjs +4062 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +129 -0
- package/dist/looma/index.esm.js +0 -0
- package/dist/looma/looma.esm.js +1 -0
- package/dist/looma/p-03f0594b.entry.js +1 -0
- package/dist/looma/p-15e619fd.entry.js +1 -0
- package/dist/looma/p-201243dc.entry.js +1 -0
- package/dist/looma/p-24d7aa5b.entry.js +1 -0
- package/dist/looma/p-341ba64a.entry.js +1 -0
- package/dist/looma/p-41d62a83.entry.js +1 -0
- package/dist/looma/p-4742e6b4.entry.js +1 -0
- package/dist/looma/p-4c54d489.entry.js +1 -0
- package/dist/looma/p-52c537fa.entry.js +1 -0
- package/dist/looma/p-5a645647.entry.js +1 -0
- package/dist/looma/p-610b2eca.entry.js +1 -0
- package/dist/looma/p-649dad92.entry.js +1 -0
- package/dist/looma/p-66a203a1.entry.js +1 -0
- package/dist/looma/p-754cfff3.entry.js +1 -0
- package/dist/looma/p-93ce1c62.entry.js +1 -0
- package/dist/looma/p-955fb814.entry.js +1 -0
- package/dist/looma/p-96de71ad.entry.js +1 -0
- package/dist/looma/p-CEeiinfk.js +2 -0
- package/dist/looma/p-CR7f2MQC.js +1 -0
- package/dist/looma/p-DQuL1Twl.js +1 -0
- package/dist/looma/p-JwSoedEO.js +1 -0
- package/dist/looma/p-ab4151d5.entry.js +1 -0
- package/dist/looma/p-c14233bc.entry.js +1 -0
- package/dist/looma/p-dc857ed4.entry.js +1 -0
- package/dist/looma/p-dfcb2cca.entry.js +1 -0
- package/dist/looma/p-dff144bd.entry.js +1 -0
- package/dist/looma/p-ebb74106.entry.js +1 -0
- package/dist/looma/p-ecb5739b.entry.js +1 -0
- package/dist/looma/p-ee31c7b4.entry.js +1 -0
- package/dist/looma/p-fa4659c4.entry.js +1 -0
- package/dist/looma/p-hgBUJRDa.js +1 -0
- package/dist/types/components/ui-avatar/ui-avatar.d.ts +11 -0
- package/dist/types/components/ui-avatar-group/ui-avatar-group.d.ts +12 -0
- package/dist/types/components/ui-badge/ui-badge.d.ts +5 -0
- package/dist/types/components/ui-button/ui-button.d.ts +13 -0
- package/dist/types/components/ui-checkbox/ui-checkbox.d.ts +19 -0
- package/dist/types/components/ui-context-menu/ui-context-menu.d.ts +37 -0
- package/dist/types/components/ui-dialog/ui-dialog.d.ts +19 -0
- package/dist/types/components/ui-disclosure/ui-disclosure.d.ts +20 -0
- package/dist/types/components/ui-floating-action-button/ui-floating-action-button.d.ts +6 -0
- package/dist/types/components/ui-form-field/ui-form-field.d.ts +10 -0
- package/dist/types/components/ui-icon-button/ui-icon-button.d.ts +7 -0
- package/dist/types/components/ui-input/ui-input.d.ts +19 -0
- package/dist/types/components/ui-menu/ui-menu.d.ts +14 -0
- package/dist/types/components/ui-menu-item/ui-menu-item.d.ts +5 -0
- package/dist/types/components/ui-popover/ui-popover.d.ts +16 -0
- package/dist/types/components/ui-radio/ui-radio.d.ts +17 -0
- package/dist/types/components/ui-radio-group/ui-radio-group.d.ts +21 -0
- package/dist/types/components/ui-search-result-row/ui-search-result-row.d.ts +15 -0
- package/dist/types/components/ui-search-shell/ui-search-shell.d.ts +9 -0
- package/dist/types/components/ui-select/ui-select.d.ts +19 -0
- package/dist/types/components/ui-switch/ui-switch.d.ts +15 -0
- package/dist/types/components/ui-tabs/ui-tabs.d.ts +17 -0
- package/dist/types/components/ui-textarea/ui-textarea.d.ts +20 -0
- package/dist/types/components/ui-toast-region/ui-toast-region.d.ts +12 -0
- package/dist/types/components/ui-tooltip/ui-tooltip.d.ts +24 -0
- package/dist/types/components/ui-top-bar/ui-top-bar.d.ts +12 -0
- package/dist/types/components.d.ts +1148 -0
- package/dist/types/overlay/manager.d.ts +14 -0
- package/dist/types/stencil-public-runtime.d.ts +1860 -0
- package/dist/types/utils/events.d.ts +4 -0
- package/dist/types/utils/id.d.ts +1 -0
- package/dist/types/utils/initials.d.ts +1 -0
- package/dist/ui-avatar-group.entry-BZGXBOSE.js +59 -0
- package/dist/ui-avatar.entry-S2O2W5SA.js +51 -0
- package/dist/ui-badge.entry-CVJDISCR.js +22 -0
- package/dist/ui-button.entry-LNJBEJFE.js +72 -0
- package/dist/ui-checkbox.entry-5RA2CB43.js +102 -0
- package/dist/ui-context-menu.entry-UUOCT75F.js +211 -0
- package/dist/ui-dialog.entry-OEPJTEES.js +106 -0
- package/dist/ui-disclosure.entry-LRRISGUD.js +120 -0
- package/dist/ui-floating-action-button.entry-7TSAZRXP.js +23 -0
- package/dist/ui-form-field.entry-73YOVICF.js +67 -0
- package/dist/ui-icon-button.entry-MNXGPG36.js +24 -0
- package/dist/ui-input.entry-UWRVAOSW.js +112 -0
- package/dist/ui-menu-item.entry-5AOJO5MP.js +22 -0
- package/dist/ui-menu.entry-YDS6UMB5.js +98 -0
- package/dist/ui-popover.entry-PGWDCQIX.js +104 -0
- package/dist/ui-radio-group.entry-RHP5GNWU.js +142 -0
- package/dist/ui-radio.entry-5WRWPSTK.js +96 -0
- package/dist/ui-search-result-row.entry-IKJB2SJJ.js +50 -0
- package/dist/ui-search-shell.entry-ZIWF4ZHH.js +41 -0
- package/dist/ui-select.entry-N5TIKHR7.js +111 -0
- package/dist/ui-switch.entry-WUSZTXIR.js +75 -0
- package/dist/ui-tabs.entry-UFAVAQIF.js +124 -0
- package/dist/ui-textarea.entry-BYT47RAQ.js +117 -0
- package/dist/ui-toast-region.entry-6UYR3ZU2.js +78 -0
- package/dist/ui-tooltip.entry-YS7UX4FS.js +145 -0
- package/dist/ui-top-bar.entry-V27H6NFO.js +49 -0
- package/editor/chunk-JKRA4D4W.js +435 -0
- package/editor/chunk-NOOV344H.js +783 -0
- package/editor/extensions/index.d.ts +78 -0
- package/editor/extensions/index.js +28 -0
- package/editor/index.d.ts +7 -0
- package/editor/index.js +29 -0
- package/editor/table-overlay-DTr3KC9e.d.ts +12 -0
- package/editor/ui.d.ts +48 -0
- package/editor/ui.js +1 -0
- package/editor.css +662 -0
- package/layout/index.cjs +207 -0
- package/layout/index.css +166 -0
- package/layout/index.d.cts +3 -0
- package/layout/index.d.ts +3 -0
- package/layout/index.js +182 -0
- package/layout.css +124 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +244 -0
- package/styles.css +899 -0
- package/theme-dark.css +59 -0
- package/theme-high-contrast.css +21 -0
- package/theme-light.css +30 -0
- package/tokens.css +148 -0
- package/vue/chunk-J4UBEIIL.js +83 -0
- package/vue/editor/index.d.ts +89 -0
- package/vue/editor/index.js +125 -0
- package/vue/index.d.ts +167 -0
- package/vue/index.js +113 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
// src/extensions/preset.ts
|
|
2
|
+
import Document from "@tiptap/extension-document";
|
|
3
|
+
import Paragraph from "@tiptap/extension-paragraph";
|
|
4
|
+
import Text from "@tiptap/extension-text";
|
|
5
|
+
import Bold from "@tiptap/extension-bold";
|
|
6
|
+
import Italic from "@tiptap/extension-italic";
|
|
7
|
+
import Strike from "@tiptap/extension-strike";
|
|
8
|
+
import Underline from "@tiptap/extension-underline";
|
|
9
|
+
import Heading from "@tiptap/extension-heading";
|
|
10
|
+
import BulletList from "@tiptap/extension-bullet-list";
|
|
11
|
+
import OrderedList from "@tiptap/extension-ordered-list";
|
|
12
|
+
import ListItem from "@tiptap/extension-list-item";
|
|
13
|
+
import TaskList from "@tiptap/extension-task-list";
|
|
14
|
+
import TaskItem from "@tiptap/extension-task-item";
|
|
15
|
+
import Blockquote from "@tiptap/extension-blockquote";
|
|
16
|
+
import HorizontalRule from "@tiptap/extension-horizontal-rule";
|
|
17
|
+
import HardBreak from "@tiptap/extension-hard-break";
|
|
18
|
+
import History from "@tiptap/extension-history";
|
|
19
|
+
import Dropcursor from "@tiptap/extension-dropcursor";
|
|
20
|
+
import Gapcursor from "@tiptap/extension-gapcursor";
|
|
21
|
+
import Link from "@tiptap/extension-link";
|
|
22
|
+
import Image from "@tiptap/extension-image";
|
|
23
|
+
import Highlight from "@tiptap/extension-highlight";
|
|
24
|
+
import Typography from "@tiptap/extension-typography";
|
|
25
|
+
import Placeholder from "@tiptap/extension-placeholder";
|
|
26
|
+
import Code from "@tiptap/extension-code";
|
|
27
|
+
import CodeBlock from "@tiptap/extension-code-block";
|
|
28
|
+
import TableRow from "@tiptap/extension-table-row";
|
|
29
|
+
|
|
30
|
+
// src/extensions/list-behavior.ts
|
|
31
|
+
import { Extension } from "@tiptap/core";
|
|
32
|
+
function isEmptyParagraphAtStart(editor) {
|
|
33
|
+
const { selection } = editor.state;
|
|
34
|
+
return selection.empty && selection.$from.parent.isTextblock && selection.$from.parent.content.size === 0 && selection.$from.parentOffset === 0;
|
|
35
|
+
}
|
|
36
|
+
var LoomaListBehavior = Extension.create({
|
|
37
|
+
name: "loomaListBehavior",
|
|
38
|
+
addKeyboardShortcuts() {
|
|
39
|
+
return {
|
|
40
|
+
Enter: () => {
|
|
41
|
+
if (this.editor.isActive("taskItem")) {
|
|
42
|
+
return this.editor.commands.splitListItem("taskItem");
|
|
43
|
+
}
|
|
44
|
+
if (this.editor.isActive("listItem")) {
|
|
45
|
+
return this.editor.commands.splitListItem("listItem");
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
},
|
|
49
|
+
Backspace: () => {
|
|
50
|
+
if (!isEmptyParagraphAtStart(this.editor)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (this.editor.isActive("taskItem")) {
|
|
54
|
+
return this.editor.commands.liftListItem("taskItem");
|
|
55
|
+
}
|
|
56
|
+
if (this.editor.isActive("listItem")) {
|
|
57
|
+
return this.editor.commands.liftListItem("listItem");
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// src/extensions/table-formatting.ts
|
|
66
|
+
import TableBase from "@tiptap/extension-table";
|
|
67
|
+
import TableCellBase from "@tiptap/extension-table-cell";
|
|
68
|
+
import TableHeaderBase from "@tiptap/extension-table-header";
|
|
69
|
+
var TABLE_CELL_BACKGROUND_PRESETS = {
|
|
70
|
+
none: null,
|
|
71
|
+
gray: "#f3f4f6",
|
|
72
|
+
yellow: "#fef3c7",
|
|
73
|
+
blue: "#dbeafe",
|
|
74
|
+
green: "#dcfce7",
|
|
75
|
+
red: "#fee2e2"
|
|
76
|
+
};
|
|
77
|
+
var LoomaTable = TableBase.configure({
|
|
78
|
+
resizable: true,
|
|
79
|
+
lastColumnResizable: false
|
|
80
|
+
});
|
|
81
|
+
function normalizeTableCellAlignment(value) {
|
|
82
|
+
if (value === "left" || value === "center" || value === "right") {
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
function normalizeTableCellBackground(value) {
|
|
88
|
+
if (typeof value !== "string") {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const normalized = value.trim();
|
|
92
|
+
return normalized.length > 0 ? normalized : null;
|
|
93
|
+
}
|
|
94
|
+
function renderTableCellStyle(attributes) {
|
|
95
|
+
const styleFragments = [];
|
|
96
|
+
const textAlign = normalizeTableCellAlignment(attributes.textAlign);
|
|
97
|
+
const backgroundColor = normalizeTableCellBackground(attributes.backgroundColor);
|
|
98
|
+
if (textAlign && textAlign !== "left") {
|
|
99
|
+
styleFragments.push(`text-align: ${textAlign}`);
|
|
100
|
+
}
|
|
101
|
+
if (backgroundColor) {
|
|
102
|
+
styleFragments.push(`background-color: ${backgroundColor}`);
|
|
103
|
+
}
|
|
104
|
+
return styleFragments.length > 0 ? `${styleFragments.join("; ")};` : null;
|
|
105
|
+
}
|
|
106
|
+
var tableAlignmentAttributes = {
|
|
107
|
+
textAlign: {
|
|
108
|
+
default: null,
|
|
109
|
+
parseHTML: (element) => normalizeTableCellAlignment(element.style.textAlign),
|
|
110
|
+
renderHTML: (attributes) => {
|
|
111
|
+
const style = renderTableCellStyle(attributes);
|
|
112
|
+
return style ? { style } : {};
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
backgroundColor: {
|
|
116
|
+
default: null,
|
|
117
|
+
parseHTML: (element) => normalizeTableCellBackground(element.style.backgroundColor),
|
|
118
|
+
renderHTML: (attributes) => {
|
|
119
|
+
const style = renderTableCellStyle(attributes);
|
|
120
|
+
return style ? { style } : {};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
var LoomaTableHeader = TableHeaderBase.extend({
|
|
125
|
+
addAttributes() {
|
|
126
|
+
return {
|
|
127
|
+
...this.parent?.(),
|
|
128
|
+
...tableAlignmentAttributes
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
var LoomaTableCell = TableCellBase.extend({
|
|
133
|
+
addAttributes() {
|
|
134
|
+
return {
|
|
135
|
+
...this.parent?.(),
|
|
136
|
+
...tableAlignmentAttributes
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
function getActiveTableCellAlignment(editor) {
|
|
141
|
+
const { $from } = editor.state.selection;
|
|
142
|
+
for (let depth = $from.depth; depth > 0; depth -= 1) {
|
|
143
|
+
const node = $from.node(depth);
|
|
144
|
+
if (node.type.name === "tableCell" || node.type.name === "tableHeader") {
|
|
145
|
+
return normalizeTableCellAlignment(node.attrs.textAlign) ?? "left";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return "left";
|
|
149
|
+
}
|
|
150
|
+
function getActiveTableCellBackground(editor) {
|
|
151
|
+
const { $from } = editor.state.selection;
|
|
152
|
+
for (let depth = $from.depth; depth > 0; depth -= 1) {
|
|
153
|
+
const node = $from.node(depth);
|
|
154
|
+
if (node.type.name === "tableCell" || node.type.name === "tableHeader") {
|
|
155
|
+
return normalizeTableCellBackground(node.attrs.backgroundColor);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
function setActiveTableCellAlignment(editor, alignment) {
|
|
161
|
+
const textAlign = alignment === "left" ? null : alignment;
|
|
162
|
+
if (editor.isActive("tableHeader")) {
|
|
163
|
+
return editor.chain().focus().updateAttributes("tableHeader", { textAlign }).run();
|
|
164
|
+
}
|
|
165
|
+
if (editor.isActive("tableCell")) {
|
|
166
|
+
return editor.chain().focus().updateAttributes("tableCell", { textAlign }).run();
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
function setActiveTableCellBackground(editor, backgroundColor) {
|
|
171
|
+
const normalizedBackgroundColor = normalizeTableCellBackground(backgroundColor);
|
|
172
|
+
if (editor.isActive("tableHeader")) {
|
|
173
|
+
return editor.chain().focus().updateAttributes("tableHeader", {
|
|
174
|
+
backgroundColor: normalizedBackgroundColor
|
|
175
|
+
}).run();
|
|
176
|
+
}
|
|
177
|
+
if (editor.isActive("tableCell")) {
|
|
178
|
+
return editor.chain().focus().updateAttributes("tableCell", {
|
|
179
|
+
backgroundColor: normalizedBackgroundColor
|
|
180
|
+
}).run();
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// src/extensions/preset.ts
|
|
186
|
+
function getDefaultEditorExtensions(options = {}) {
|
|
187
|
+
const {
|
|
188
|
+
placeholder = "Type \u201C/\u201D for commands, or start writing\u2026",
|
|
189
|
+
linkOpenOnClick = false,
|
|
190
|
+
imageInline = false
|
|
191
|
+
} = options;
|
|
192
|
+
return [
|
|
193
|
+
Document,
|
|
194
|
+
Paragraph,
|
|
195
|
+
Text,
|
|
196
|
+
Bold,
|
|
197
|
+
Italic,
|
|
198
|
+
Strike,
|
|
199
|
+
Underline,
|
|
200
|
+
Heading.configure({ levels: [1, 2, 3] }),
|
|
201
|
+
BulletList,
|
|
202
|
+
OrderedList,
|
|
203
|
+
ListItem,
|
|
204
|
+
TaskList,
|
|
205
|
+
TaskItem.configure({ nested: false }),
|
|
206
|
+
Blockquote,
|
|
207
|
+
HorizontalRule,
|
|
208
|
+
HardBreak,
|
|
209
|
+
History,
|
|
210
|
+
Dropcursor,
|
|
211
|
+
Gapcursor,
|
|
212
|
+
Link.configure({
|
|
213
|
+
openOnClick: linkOpenOnClick,
|
|
214
|
+
HTMLAttributes: { rel: "noopener noreferrer", target: "_blank" }
|
|
215
|
+
}),
|
|
216
|
+
Image.configure({ inline: imageInline }),
|
|
217
|
+
Highlight.configure({ multicolor: false }),
|
|
218
|
+
Code,
|
|
219
|
+
CodeBlock,
|
|
220
|
+
Typography,
|
|
221
|
+
Placeholder.configure({
|
|
222
|
+
placeholder: ({ node }) => node.type.name === "paragraph" ? placeholder : "",
|
|
223
|
+
emptyNodeClass: "is-editor-empty"
|
|
224
|
+
}),
|
|
225
|
+
LoomaTable,
|
|
226
|
+
TableRow,
|
|
227
|
+
LoomaTableHeader,
|
|
228
|
+
LoomaTableCell,
|
|
229
|
+
LoomaListBehavior
|
|
230
|
+
];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// src/extensions/table-commands.ts
|
|
234
|
+
import { TableMap } from "prosemirror-tables";
|
|
235
|
+
function arrayEquals(left, right) {
|
|
236
|
+
if (!left || left.length !== right.length) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return left.every((value, index) => value === right[index]);
|
|
240
|
+
}
|
|
241
|
+
function readRenderedColumnWidths(tableElement) {
|
|
242
|
+
const colElements = Array.from(tableElement.querySelectorAll("colgroup col"));
|
|
243
|
+
if (colElements.length > 0) {
|
|
244
|
+
return colElements.map((column) => Math.max(1, Math.round(column.getBoundingClientRect().width)));
|
|
245
|
+
}
|
|
246
|
+
const firstRow = tableElement.rows.item(0);
|
|
247
|
+
if (!firstRow) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
return Array.from(firstRow.cells).map((cell) => Math.max(1, Math.round(cell.getBoundingClientRect().width)));
|
|
251
|
+
}
|
|
252
|
+
function distributeWidthDelta(widths, availableWidth, minWidth) {
|
|
253
|
+
const normalized = [...widths];
|
|
254
|
+
let delta = availableWidth - normalized.reduce((sum, width) => sum + width, 0);
|
|
255
|
+
while (delta !== 0) {
|
|
256
|
+
const adjustableIndices = normalized.map((width, index) => ({ width, index })).filter(({ width }) => delta > 0 || width > minWidth).sort((left, right) => {
|
|
257
|
+
if (delta > 0) {
|
|
258
|
+
return left.width - right.width;
|
|
259
|
+
}
|
|
260
|
+
return right.width - left.width;
|
|
261
|
+
});
|
|
262
|
+
if (adjustableIndices.length === 0) {
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
for (const { index } of adjustableIndices) {
|
|
266
|
+
if (delta === 0) {
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
const currentWidth = normalized[index];
|
|
270
|
+
if (currentWidth === void 0) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (delta > 0) {
|
|
274
|
+
normalized[index] = currentWidth + 1;
|
|
275
|
+
delta -= 1;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (currentWidth <= minWidth) {
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
normalized[index] = currentWidth - 1;
|
|
282
|
+
delta += 1;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return normalized;
|
|
286
|
+
}
|
|
287
|
+
function normalizeColumnWidths(widths, availableWidth, minWidth) {
|
|
288
|
+
if (widths.length === 0 || availableWidth <= 0) {
|
|
289
|
+
return widths;
|
|
290
|
+
}
|
|
291
|
+
const totalWidth = widths.reduce((sum, width) => sum + width, 0);
|
|
292
|
+
if (totalWidth <= 0) {
|
|
293
|
+
return widths;
|
|
294
|
+
}
|
|
295
|
+
const scaled = widths.map(
|
|
296
|
+
(width) => Math.max(minWidth, Math.round(width / totalWidth * availableWidth))
|
|
297
|
+
);
|
|
298
|
+
return distributeWidthDelta(scaled, availableWidth, minWidth);
|
|
299
|
+
}
|
|
300
|
+
function getTextPositionInCell(tablePos, table, rowIndex, colIndex) {
|
|
301
|
+
let pos = tablePos + 1;
|
|
302
|
+
for (let r = 0; r < rowIndex; r++) {
|
|
303
|
+
pos += table.child(r).nodeSize;
|
|
304
|
+
}
|
|
305
|
+
const row = table.child(rowIndex);
|
|
306
|
+
for (let c = 0; c < colIndex; c++) {
|
|
307
|
+
pos += row.child(c).nodeSize;
|
|
308
|
+
}
|
|
309
|
+
return pos + 3;
|
|
310
|
+
}
|
|
311
|
+
function findTable(editor) {
|
|
312
|
+
const { $from } = editor.state.selection;
|
|
313
|
+
for (let d = $from.depth; d > 0; d--) {
|
|
314
|
+
const node = $from.node(d);
|
|
315
|
+
if (node.type.name === "table") {
|
|
316
|
+
return { pos: $from.before(d), node };
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
function insertTableAtRange(editor, range, options = {}) {
|
|
322
|
+
const rows = Math.min(10, Math.max(1, options.rows ?? 3));
|
|
323
|
+
const cols = Math.min(10, Math.max(1, options.cols ?? 3));
|
|
324
|
+
const withHeaderRow = options.withHeaderRow ?? true;
|
|
325
|
+
return editor.chain().focus().deleteRange(range).insertTable({ rows, cols, withHeaderRow }).run();
|
|
326
|
+
}
|
|
327
|
+
function normalizeActiveTableColumnWidths(editor, tableElement, minWidth = 25) {
|
|
328
|
+
const tableInfo = findTable(editor);
|
|
329
|
+
if (!tableInfo) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
const renderedColumnWidths = readRenderedColumnWidths(tableElement);
|
|
333
|
+
if (renderedColumnWidths.length === 0) {
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
const availableWidth = Math.max(1, Math.round(tableElement.getBoundingClientRect().width));
|
|
337
|
+
const normalizedColumnWidths = normalizeColumnWidths(
|
|
338
|
+
renderedColumnWidths,
|
|
339
|
+
availableWidth,
|
|
340
|
+
minWidth
|
|
341
|
+
);
|
|
342
|
+
const { pos: tablePos, node: table } = tableInfo;
|
|
343
|
+
const map = TableMap.get(table);
|
|
344
|
+
const tableStart = tablePos + 1;
|
|
345
|
+
let tr = editor.state.tr;
|
|
346
|
+
let changed = false;
|
|
347
|
+
for (let row = 0; row < map.height; row += 1) {
|
|
348
|
+
for (let col = 0; col < map.width; col += 1) {
|
|
349
|
+
const mapIndex = row * map.width + col;
|
|
350
|
+
const cellPos = map.map[mapIndex];
|
|
351
|
+
if (cellPos === void 0) {
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
if (col > 0 && map.map[mapIndex - 1] === cellPos || row > 0 && map.map[mapIndex - map.width] === cellPos) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const cellNode = table.nodeAt(cellPos);
|
|
358
|
+
if (!cellNode) {
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const startCol = map.colCount(cellPos);
|
|
362
|
+
const cellWidths = normalizedColumnWidths.slice(startCol, startCol + cellNode.attrs.colspan);
|
|
363
|
+
if (cellWidths.length !== cellNode.attrs.colspan || arrayEquals(cellNode.attrs.colwidth, cellWidths)) {
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
tr = tr.setNodeMarkup(tableStart + cellPos, null, {
|
|
367
|
+
...cellNode.attrs,
|
|
368
|
+
colwidth: cellWidths
|
|
369
|
+
});
|
|
370
|
+
changed = true;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (changed) {
|
|
374
|
+
editor.view.dispatch(tr);
|
|
375
|
+
}
|
|
376
|
+
return changed;
|
|
377
|
+
}
|
|
378
|
+
function handleTableOverlayAction(editor, detail) {
|
|
379
|
+
const tableInfo = findTable(editor);
|
|
380
|
+
if (!tableInfo) return false;
|
|
381
|
+
const { action, boundaryIndex } = detail;
|
|
382
|
+
const { pos: tablePos, node: table } = tableInfo;
|
|
383
|
+
const rows = table.childCount;
|
|
384
|
+
const cols = rows > 0 ? table.child(0).childCount : 0;
|
|
385
|
+
let cellPos;
|
|
386
|
+
let command;
|
|
387
|
+
switch (action) {
|
|
388
|
+
case "add-row-before": {
|
|
389
|
+
const rowIndex = Math.min(boundaryIndex, rows - 1);
|
|
390
|
+
if (rowIndex < 0) return false;
|
|
391
|
+
cellPos = getTextPositionInCell(tablePos, table, rowIndex, 0);
|
|
392
|
+
command = () => editor.chain().focus().setTextSelection(cellPos).addRowBefore().run();
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
case "add-row-after": {
|
|
396
|
+
const rowIndex = Math.min(boundaryIndex, rows - 1);
|
|
397
|
+
if (rowIndex < 0) return false;
|
|
398
|
+
cellPos = getTextPositionInCell(tablePos, table, rowIndex, 0);
|
|
399
|
+
command = () => editor.chain().focus().setTextSelection(cellPos).addRowAfter().run();
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
case "add-column-before": {
|
|
403
|
+
const colIndex = Math.min(boundaryIndex, cols - 1);
|
|
404
|
+
if (colIndex < 0) return false;
|
|
405
|
+
cellPos = getTextPositionInCell(tablePos, table, 0, colIndex);
|
|
406
|
+
command = () => editor.chain().focus().setTextSelection(cellPos).addColumnBefore().run();
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
case "add-column-after": {
|
|
410
|
+
const colIndex = Math.min(boundaryIndex, cols - 1);
|
|
411
|
+
if (colIndex < 0) return false;
|
|
412
|
+
cellPos = getTextPositionInCell(tablePos, table, 0, colIndex);
|
|
413
|
+
command = () => editor.chain().focus().setTextSelection(cellPos).addColumnAfter().run();
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
default:
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
return command();
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export {
|
|
423
|
+
TABLE_CELL_BACKGROUND_PRESETS,
|
|
424
|
+
LoomaTable,
|
|
425
|
+
LoomaTableHeader,
|
|
426
|
+
LoomaTableCell,
|
|
427
|
+
getActiveTableCellAlignment,
|
|
428
|
+
getActiveTableCellBackground,
|
|
429
|
+
setActiveTableCellAlignment,
|
|
430
|
+
setActiveTableCellBackground,
|
|
431
|
+
getDefaultEditorExtensions,
|
|
432
|
+
insertTableAtRange,
|
|
433
|
+
normalizeActiveTableColumnWidths,
|
|
434
|
+
handleTableOverlayAction
|
|
435
|
+
};
|