@peteai/presentation-editor 0.0.6 → 0.0.8
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 +38 -38
- package/dist/components/editor/active-layers-buttons.svelte +56 -0
- package/dist/components/editor/active-layers.svelte +237 -0
- package/dist/components/editor/active-layers.svelte.d.ts +8 -0
- package/dist/components/{presentation-editor/cognition-slides.d.ts → editor/cognition-pages.d.ts} +1 -1
- package/dist/components/{presentation-editor/cognition-slides.js → editor/cognition-pages.js} +1 -1
- package/dist/components/{presentation-editor → editor}/cursor-tooltip.svelte +6 -2
- package/dist/components/editor/cursor-tooltip.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/dragged.svelte +7 -3
- package/dist/components/editor/dragged.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor/presentation-editor.svelte → editor/editor.svelte} +64 -61
- package/dist/components/editor/editor.svelte.d.ts +4 -0
- package/dist/components/editor/editor.svelte.js +1169 -0
- package/dist/components/editor/header.svelte +62 -0
- package/dist/components/editor/header.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/hotkeys.svelte +48 -16
- package/dist/components/editor/index.d.ts +3 -0
- package/dist/components/editor/index.js +3 -0
- package/dist/components/{presentation-editor → editor}/layers/active-background-border.svelte +2 -2
- package/dist/components/{presentation-editor → editor}/layers/active-layer-border.svelte +5 -8
- package/dist/components/editor/layers/buttons/border-button/border-button-colors.svelte +59 -0
- package/dist/components/editor/layers/buttons/border-button/border-button-colors.svelte.d.ts +9 -0
- package/dist/components/{presentation-editor → editor}/layers/buttons/border-button/border-button.svelte +47 -65
- package/dist/components/{presentation-editor → editor}/layers/buttons/corner-radius-button/corner-radius-button.svelte +24 -28
- package/dist/components/{presentation-editor → editor}/layers/buttons/flip-button/flip-button.svelte +11 -12
- package/dist/components/{presentation-editor → editor}/layers/buttons/opacity-button/opacity-button.svelte +33 -44
- package/dist/components/{presentation-editor → editor}/layers/controls/corner-scale-control/corner-scale-control.svelte +27 -32
- package/dist/components/editor/layers/controls/group-resize-control/group-resize-control.svelte +418 -0
- package/dist/components/{presentation-editor → editor}/layers/controls/rotate-control/rotate-control.svelte +33 -34
- package/dist/components/editor/layers/controls/rotate-control/rotate-control.svelte.d.ts +6 -0
- package/dist/components/{presentation-editor → editor}/layers/controls/side-resize-control/side-resize-control.svelte +22 -26
- package/dist/components/{presentation-editor → editor}/layers/controls/side-scale-control/side-scale-control.svelte +13 -15
- package/dist/components/{presentation-editor → editor}/layers/controls/side-scale-control/side-scale-control.svelte.d.ts +2 -2
- package/dist/components/editor/layers/index.d.ts +10 -0
- package/dist/components/{presentation-editor → editor}/layers/index.js +8 -5
- package/dist/components/{presentation-editor → editor}/layers/layer-button.svelte +14 -8
- package/dist/components/{presentation-editor → editor}/layers/layer-thumb-wrapper.svelte +5 -6
- package/dist/components/{presentation-editor → editor}/layers/layer-wrapper.svelte +46 -57
- package/dist/components/editor/layers/types/background/background-content-image.svelte +36 -0
- package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer-buttons.svelte +6 -6
- package/dist/components/editor/layers/types/background/background-layer-content.svelte +21 -0
- package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer-content.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer.svelte +7 -9
- package/dist/components/editor/layers/types/group/group-child-wrapper.svelte +44 -0
- package/dist/components/editor/layers/types/group/group-child-wrapper.svelte.d.ts +9 -0
- package/dist/components/editor/layers/types/group/group-layer-content.svelte +45 -0
- package/dist/components/editor/layers/types/group/group-layer-content.svelte.d.ts +9 -0
- package/dist/components/editor/layers/types/group/group-layer.svelte +33 -0
- package/dist/components/editor/layers/types/group/group-layer.svelte.d.ts +8 -0
- package/dist/components/editor/layers/types/group/index.d.ts +3 -0
- package/dist/components/editor/layers/types/group/index.js +3 -0
- package/dist/components/editor/layers/types/image/controls/image-rotate-control/image-rotate-control.svelte +120 -0
- package/dist/components/editor/layers/types/image/controls/image-rotate-control/image-rotate-control.svelte.d.ts +8 -0
- package/dist/components/editor/layers/types/image/controls/image-rotate-control/index.d.ts +2 -0
- package/dist/components/editor/layers/types/image/controls/image-rotate-control/index.js +4 -0
- package/dist/components/editor/layers/types/image/controls/image-scale-control/image-scale-control.svelte +154 -0
- package/dist/components/editor/layers/types/image/controls/image-scale-control/image-scale-control.svelte.d.ts +91 -0
- package/dist/components/editor/layers/types/image/controls/image-scale-control/index.d.ts +2 -0
- package/dist/components/editor/layers/types/image/controls/image-scale-control/index.js +4 -0
- package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer-active.svelte +10 -13
- package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer-content.svelte +15 -12
- package/dist/components/editor/layers/types/image/image-layer-crop.svelte +182 -0
- package/dist/components/editor/layers/types/image/image-layer-crop.svelte.d.ts +10 -0
- package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer.svelte +24 -14
- package/dist/components/editor/layers/types/image/index.d.ts +4 -0
- package/dist/components/editor/layers/types/image/index.js +4 -0
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/alignment-button/alignment-button.svelte +13 -14
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/alignment-button/alignment-button.svelte.d.ts +2 -2
- package/dist/components/editor/layers/types/text/buttons/bold-button/bold-button.svelte +65 -0
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/bold-button/bold-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/case-button/case-button.svelte +24 -30
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/case-button/case-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/color-button/color-button.svelte +4 -4
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/color-button/color-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-family-button/font-family-button.svelte +4 -4
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-family-button/font-family-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-size-button/font-size-button.svelte +33 -40
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-size-button/font-size-button.svelte.d.ts +2 -2
- package/dist/components/editor/layers/types/text/buttons/italic-button/italic-button.svelte +65 -0
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/italic-button/italic-button.svelte.d.ts +2 -2
- package/dist/components/editor/layers/types/text/buttons/list-button/list-button.svelte +113 -0
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/list-button/list-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/strikethrough-button/strikethrough-button.svelte +10 -11
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/strikethrough-button/strikethrough-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/underline-button/underline-button.svelte +10 -11
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/underline-button/underline-button.svelte.d.ts +2 -2
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/utils.d.ts +2 -0
- package/dist/components/editor/layers/types/text/editor/utils.js +166 -0
- package/dist/components/editor/layers/types/text/extensions/list/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/list/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/list/list.d.ts +67 -0
- package/dist/components/editor/layers/types/text/extensions/list/list.js +237 -0
- package/dist/components/editor/layers/types/text/extensions/list-item/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/list-item/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/list-item/list-item.d.ts +13 -0
- package/dist/components/editor/layers/types/text/extensions/list-item/list-item.js +262 -0
- package/dist/components/editor/layers/types/text/extensions/list-item-paragraph/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/list-item-paragraph/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/list-item-paragraph/list-item-paragraph.d.ts +14 -0
- package/dist/components/editor/layers/types/text/extensions/list-item-paragraph/list-item-paragraph.js +27 -0
- package/dist/components/editor/layers/types/text/extensions/paragraph/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/paragraph/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/paragraph/paragraph.d.ts +6 -0
- package/dist/components/editor/layers/types/text/extensions/paragraph/paragraph.js +28 -0
- package/dist/components/editor/layers/types/text/extensions/preserve-formatting-on-clear/index.d.ts +3 -0
- package/dist/components/editor/layers/types/text/extensions/preserve-formatting-on-clear/index.js +3 -0
- package/dist/components/editor/layers/types/text/extensions/preserve-formatting-on-clear/preserve-formatting-on-clear.d.ts +2 -0
- package/dist/components/editor/layers/types/text/extensions/preserve-formatting-on-clear/preserve-formatting-on-clear.js +74 -0
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/text-transform/text-transform.js +1 -4
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions.js +13 -23
- package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/html-content.svelte +0 -9
- package/dist/components/editor/layers/types/text/index.d.ts +5 -0
- package/dist/components/editor/layers/types/text/index.js +5 -0
- package/dist/components/{presentation-editor/layers/types/html/html-layer-content.svelte → editor/layers/types/text/text-layer-content.svelte} +2 -2
- package/dist/components/editor/layers/types/text/text-layer-content.svelte.d.ts +9 -0
- package/dist/components/editor/layers/types/text/text-layer-edit.svelte +114 -0
- package/dist/components/editor/layers/types/text/text-layer-edit.svelte.d.ts +9 -0
- package/dist/components/editor/layers/types/text/text-layer.svelte +125 -0
- package/dist/components/editor/layers/types/text/text-layer.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/layers/utils.d.ts +32 -24
- package/dist/components/{presentation-editor → editor}/layers/utils.js +152 -102
- package/dist/components/{presentation-editor → editor}/menu/background-menu-content.svelte +24 -24
- package/dist/components/{presentation-editor → editor}/menu/background-menu-content.svelte.d.ts +4 -4
- package/dist/components/{presentation-editor → editor}/menu/layer-menu-content.svelte +62 -38
- package/dist/components/{presentation-editor/menu/slide-menu-content.svelte → editor/menu/page-menu-content.svelte} +19 -19
- package/dist/components/editor/menu/page-menu-content.svelte.d.ts +9 -0
- package/dist/components/{presentation-editor/slide-editor.svelte → editor/page-editor.svelte} +30 -25
- package/dist/components/editor/page-editor.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor/slide-inner.svelte → editor/page-inner.svelte} +5 -5
- package/dist/components/{presentation-editor/sidebar/sidebar.svelte.d.ts → editor/page-inner.svelte.d.ts} +3 -3
- package/dist/components/editor/page.svelte +69 -0
- package/dist/components/editor/page.svelte.d.ts +4 -0
- package/dist/components/editor/pages-navigation/page-preview.svelte +36 -0
- package/dist/components/editor/pages-navigation/page-preview.svelte.d.ts +8 -0
- package/dist/components/{presentation-editor/slides-navigation/slide-preview.svelte → editor/pages-navigation/pages-navigation-item.svelte} +21 -41
- package/dist/components/editor/pages-navigation/pages-navigation-item.svelte.d.ts +11 -0
- package/dist/components/{presentation-editor/slides-navigation/slides-navigation.svelte → editor/pages-navigation/pages-navigation.svelte} +26 -21
- package/dist/components/editor/pages-navigation/pages-navigation.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar-color.svelte +1 -1
- package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar-gradient-picker.svelte +2 -2
- package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar.svelte +92 -89
- package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/font-sidebar-button.svelte +3 -3
- package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/font-sidebar.svelte +34 -39
- package/dist/components/editor/sidebar/image-crop-sidebar.svelte +112 -0
- package/dist/components/editor/sidebar/image-crop-sidebar.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor/sidebar/position-slidebar.svelte → editor/sidebar/position-sidebar.svelte} +26 -20
- package/dist/components/editor/sidebar/position-sidebar.svelte.d.ts +3 -0
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar-text-tab-button.svelte +5 -5
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar-text-tab.svelte +5 -5
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar-uploads-tab.svelte +4 -4
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar-wrapper.svelte +6 -4
- package/dist/components/{presentation-editor → editor}/sidebar/sidebar.svelte +17 -10
- package/dist/components/editor/sidebar/sidebar.svelte.d.ts +7 -0
- package/dist/components/{presentation-editor → editor}/sidebar/uploads-image.svelte +3 -3
- package/dist/components/editor/types.d.ts +283 -0
- package/dist/components/{presentation-editor → editor}/utils.d.ts +14 -6
- package/dist/components/{presentation-editor → editor}/utils.js +98 -63
- package/dist/components/ui/color-picker/color-picker.svelte +2 -2
- package/dist/components/ui/context-menu/context-menu-checkbox-item.svelte +2 -2
- package/dist/components/ui/context-menu/context-menu-radio-item.svelte +1 -1
- package/dist/components/ui/context-menu/context-menu-sub-trigger.svelte +1 -1
- package/dist/components/ui/dialog/dialog-content.svelte +3 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +3 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +2 -2
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +1 -1
- package/dist/components/ui/dropdown-menu/index.d.ts +1 -0
- package/dist/components/ui/slider/slider.svelte +28 -20
- package/dist/index.d.ts +12 -6
- package/dist/index.js +5 -3
- package/package.json +42 -38
- package/dist/components/presentation-editor/active-layers-buttons.svelte +0 -53
- package/dist/components/presentation-editor/active-layers.svelte +0 -181
- package/dist/components/presentation-editor/active-layers.svelte.d.ts +0 -3
- package/dist/components/presentation-editor/cursor-tooltip.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/dragged.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/header.svelte +0 -54
- package/dist/components/presentation-editor/header.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/index.d.ts +0 -2
- package/dist/components/presentation-editor/index.js +0 -2
- package/dist/components/presentation-editor/layers/controls/group-resize-control/group-resize-control.svelte +0 -337
- package/dist/components/presentation-editor/layers/controls/rotate-control/rotate-control.svelte.d.ts +0 -3
- package/dist/components/presentation-editor/layers/index.d.ts +0 -9
- package/dist/components/presentation-editor/layers/types/background/background-content-image.svelte +0 -41
- package/dist/components/presentation-editor/layers/types/background/background-layer-content.svelte +0 -19
- package/dist/components/presentation-editor/layers/types/html/buttons/bold-button/bold-button.svelte +0 -71
- package/dist/components/presentation-editor/layers/types/html/buttons/italic-button/italic-button.svelte +0 -71
- package/dist/components/presentation-editor/layers/types/html/buttons/list-button/list-button.svelte +0 -90
- package/dist/components/presentation-editor/layers/types/html/editor/utils.js +0 -88
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/index.d.ts +0 -3
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/index.js +0 -3
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/unstyled-list.d.ts +0 -47
- package/dist/components/presentation-editor/layers/types/html/extensions/unstyled-list/unstyled-list.js +0 -74
- package/dist/components/presentation-editor/layers/types/html/html-layer-content.svelte.d.ts +0 -9
- package/dist/components/presentation-editor/layers/types/html/html-layer-edit.svelte +0 -103
- package/dist/components/presentation-editor/layers/types/html/html-layer-edit.svelte.d.ts +0 -8
- package/dist/components/presentation-editor/layers/types/html/html-layer.svelte +0 -105
- package/dist/components/presentation-editor/layers/types/html/html-layer.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/layers/types/html/index.d.ts +0 -5
- package/dist/components/presentation-editor/layers/types/html/index.js +0 -5
- package/dist/components/presentation-editor/layers/types/image/index.d.ts +0 -3
- package/dist/components/presentation-editor/layers/types/image/index.js +0 -3
- package/dist/components/presentation-editor/menu/slide-menu-content.svelte.d.ts +0 -9
- package/dist/components/presentation-editor/presentation-editor.svelte.d.ts +0 -4
- package/dist/components/presentation-editor/presentation-editor.svelte.js +0 -813
- package/dist/components/presentation-editor/sidebar/position-slidebar.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/slide-editor.svelte.d.ts +0 -7
- package/dist/components/presentation-editor/slide-inner.svelte.d.ts +0 -18
- package/dist/components/presentation-editor/slides-navigation/slide-preview.svelte.d.ts +0 -11
- package/dist/components/presentation-editor/slides-navigation/slides-navigation.svelte.d.ts +0 -3
- package/dist/components/presentation-editor/types.d.ts +0 -158
- /package/dist/components/{presentation-editor → editor}/active-layers-buttons.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator-gradient-def.svelte +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator-gradient-def.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator-gradient.svelte +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator-gradient.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator.svelte +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/color-indicator.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/color-indicator/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/fonts.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/fonts.js +0 -0
- /package/dist/components/{presentation-editor → editor}/hotkeys.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/active-background-border.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/active-layer-border.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/border-button/border-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/border-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/border-button/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/corner-radius-button/corner-radius-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/corner-radius-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/corner-radius-button/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/flip-button/flip-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/flip-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/flip-button/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/opacity-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/opacity-button/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/buttons/opacity-button/opacity-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/corner-scale-control/corner-scale-control.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/corner-scale-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/corner-scale-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/group-resize-control/group-resize-control.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/group-resize-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/group-resize-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/rotate-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/rotate-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-resize-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-resize-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-resize-control/side-resize-control.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-scale-control/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/controls/side-scale-control/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/layer-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/layer-thumb-wrapper.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/layer-wrapper.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/background-content-image.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer-buttons.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/background-layer.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/background/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer-active.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer-content.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/layers/types/image/image-layer.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/alignment-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/alignment-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/bold-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/bold-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/case-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/case-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/color-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/color-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-family-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-family-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-size-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/font-size-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/italic-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/italic-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/list-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/list-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/strikethrough-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/strikethrough-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/underline-button/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/buttons/underline-button/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/Editor.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/Editor.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/createEditor.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/createEditor.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/editor-content.svelte +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/editor-content.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/types.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor/types.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/editor.css +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-family/font-family.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-family/font-family.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-family/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-family/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-size/font-size.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-size/font-size.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-size/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/font-size/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/line-height/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/line-height/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/line-height/line-height.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/line-height/line-height.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/selection/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/selection/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/selection/selection.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/selection/selection.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/text-transform/index.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/text-transform/index.js +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions/text-transform/text-transform.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/extensions.d.ts +0 -0
- /package/dist/components/{presentation-editor/layers/types/html → editor/layers/types/text}/html-content.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/menu/layer-menu-content.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar-color.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar-gradient-picker.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/color-sidebar.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/color-sidebar/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/font-sidebar-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/font-sidebar.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/index.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/font-sidebar/index.js +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/sidebar-text-tab-button.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/sidebar-text-tab.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/sidebar-uploads-tab.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/sidebar-wrapper.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/sidebar/uploads-image.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/snapping-guides.svelte +0 -0
- /package/dist/components/{presentation-editor → editor}/snapping-guides.svelte.d.ts +0 -0
- /package/dist/components/{presentation-editor → editor}/types.js +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import StrikethroughIcon from 'lucide
|
|
2
|
+
import StrikethroughIcon from '@lucide/svelte/icons/strikethrough';
|
|
3
3
|
import { Toggle } from '../../../../../../ui/toggle/index.js';
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
4
|
+
import type { TextLayer } from '../../../../../types.js';
|
|
5
|
+
import { getEditorContext } from '../../../../../editor.svelte.js';
|
|
6
6
|
import { createEditorNotReactive } from '../../editor/utils.js';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
|
-
layers:
|
|
9
|
+
layers: TextLayer[];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
let { layers = $bindable() }: Props = $props();
|
|
13
13
|
|
|
14
|
-
const editor =
|
|
14
|
+
const editor = getEditorContext();
|
|
15
15
|
|
|
16
16
|
const { htmlEditor } = editor;
|
|
17
17
|
|
|
@@ -36,9 +36,8 @@
|
|
|
36
36
|
$htmlEditor.chain().focus().unsetStrike().run();
|
|
37
37
|
}
|
|
38
38
|
} else {
|
|
39
|
-
editor.historyPush(
|
|
40
|
-
|
|
41
|
-
actions: layers.map((layer) => {
|
|
39
|
+
editor.historyPush(
|
|
40
|
+
layers.map((layer) => {
|
|
42
41
|
let chain = editorNotReactive.chain().setContent(layer.html).selectAll();
|
|
43
42
|
if (value) {
|
|
44
43
|
chain = chain.setStrike();
|
|
@@ -48,14 +47,14 @@
|
|
|
48
47
|
chain.run();
|
|
49
48
|
|
|
50
49
|
return {
|
|
51
|
-
type: '
|
|
52
|
-
|
|
50
|
+
type: 'layerUpdate',
|
|
51
|
+
pageId: editor.activePage.id,
|
|
53
52
|
layer: { id: layer.id, type: layer.type },
|
|
54
53
|
undo: { html: layer.html },
|
|
55
54
|
redo: { html: editorNotReactive.getJSON() },
|
|
56
55
|
};
|
|
57
56
|
}),
|
|
58
|
-
|
|
57
|
+
);
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
60
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TextLayer } from '../../../../../types.js';
|
|
2
2
|
interface Props {
|
|
3
|
-
layers:
|
|
3
|
+
layers: TextLayer[];
|
|
4
4
|
}
|
|
5
5
|
declare const StrikethroughButton: import("svelte").Component<Props, {}, "layers">;
|
|
6
6
|
type StrikethroughButton = ReturnType<typeof StrikethroughButton>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import UnderlineIcon from 'lucide
|
|
2
|
+
import UnderlineIcon from '@lucide/svelte/icons/underline';
|
|
3
3
|
import { Toggle } from '../../../../../../ui/toggle/index.js';
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
4
|
+
import type { TextLayer } from '../../../../../types.js';
|
|
5
|
+
import { getEditorContext } from '../../../../../editor.svelte.js';
|
|
6
6
|
import { createEditorNotReactive } from '../../editor/utils.js';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
|
-
layers:
|
|
9
|
+
layers: TextLayer[];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
let { layers = $bindable() }: Props = $props();
|
|
13
13
|
|
|
14
|
-
const editor =
|
|
14
|
+
const editor = getEditorContext();
|
|
15
15
|
|
|
16
16
|
const { htmlEditor } = editor;
|
|
17
17
|
|
|
@@ -36,9 +36,8 @@
|
|
|
36
36
|
$htmlEditor.chain().focus().unsetUnderline().run();
|
|
37
37
|
}
|
|
38
38
|
} else {
|
|
39
|
-
editor.historyPush(
|
|
40
|
-
|
|
41
|
-
actions: layers.map((layer) => {
|
|
39
|
+
editor.historyPush(
|
|
40
|
+
layers.map((layer) => {
|
|
42
41
|
let chain = editorNotReactive.chain().setContent(layer.html).selectAll();
|
|
43
42
|
if (value) {
|
|
44
43
|
chain = chain.setUnderline();
|
|
@@ -48,14 +47,14 @@
|
|
|
48
47
|
chain.run();
|
|
49
48
|
|
|
50
49
|
return {
|
|
51
|
-
type: '
|
|
52
|
-
|
|
50
|
+
type: 'layerUpdate',
|
|
51
|
+
pageId: editor.activePage.id,
|
|
53
52
|
layer: { id: layer.id, type: layer.type },
|
|
54
53
|
undo: { html: layer.html },
|
|
55
54
|
redo: { html: editorNotReactive.getJSON() },
|
|
56
55
|
};
|
|
57
56
|
}),
|
|
58
|
-
|
|
57
|
+
);
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
60
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TextLayer } from '../../../../../types.js';
|
|
2
2
|
interface Props {
|
|
3
|
-
layers:
|
|
3
|
+
layers: TextLayer[];
|
|
4
4
|
}
|
|
5
5
|
declare const UnderlineButton: import("svelte").Component<Props, {}, "layers">;
|
|
6
6
|
type UnderlineButton = ReturnType<typeof UnderlineButton>;
|
|
@@ -2,6 +2,8 @@ import { type JSONContent } from '@tiptap/core';
|
|
|
2
2
|
import { Editor } from './Editor.js';
|
|
3
3
|
export declare const DEFAULT_COLOR = "#000000";
|
|
4
4
|
export declare const createEditorNotReactive: (content?: JSONContent) => Editor;
|
|
5
|
+
export declare const extractSelectionListStyleTypes: (editor: Editor, set?: Set<string>) => string[];
|
|
6
|
+
export declare const extractNodeListStyleTypes: (content: JSONContent, set?: Set<string>) => string[];
|
|
5
7
|
export declare const extractSelectionFonts: (editor: Editor) => string[];
|
|
6
8
|
export declare const extractNodeFonts: (content: JSONContent, set?: Set<string>) => string[];
|
|
7
9
|
export declare const extractSelectionFontSizes: (editor: Editor) => number[];
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {} from '@tiptap/core';
|
|
2
|
+
import { Editor } from './Editor.js';
|
|
3
|
+
import { extensions } from '../extensions.js';
|
|
4
|
+
export const DEFAULT_COLOR = '#000000';
|
|
5
|
+
export const createEditorNotReactive = (content) => {
|
|
6
|
+
return new Editor({
|
|
7
|
+
extensions,
|
|
8
|
+
injectCSS: false,
|
|
9
|
+
content,
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export const extractSelectionListStyleTypes = (editor, set = new Set()) => {
|
|
13
|
+
const { state } = editor.view;
|
|
14
|
+
const { from, to } = state.selection;
|
|
15
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
16
|
+
if (node.type.name === 'list') {
|
|
17
|
+
if (node.attrs.listStyleType) {
|
|
18
|
+
node.forEach((item, itemOffset) => {
|
|
19
|
+
item.forEach((child, childOffset) => {
|
|
20
|
+
if (child.isTextblock) {
|
|
21
|
+
const start = pos + itemOffset + childOffset;
|
|
22
|
+
const end = start + child.nodeSize;
|
|
23
|
+
if (start <= to && end >= from) {
|
|
24
|
+
set.add(node.attrs.listStyleType);
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return Array.from(set);
|
|
34
|
+
};
|
|
35
|
+
export const extractNodeListStyleTypes = (content, set = new Set()) => {
|
|
36
|
+
if (content.type === 'list') {
|
|
37
|
+
if (content.attrs?.listStyleType) {
|
|
38
|
+
set.add(content.attrs.listStyleType);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
content.content?.forEach((content) => extractNodeListStyleTypes(content, set));
|
|
42
|
+
return Array.from(set);
|
|
43
|
+
};
|
|
44
|
+
export const extractSelectionFonts = (editor) => {
|
|
45
|
+
const { state } = editor.view;
|
|
46
|
+
const { from, to } = state.selection;
|
|
47
|
+
const set = new Set();
|
|
48
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
49
|
+
if (node.attrs.fontFamily) {
|
|
50
|
+
if (node.isTextblock) {
|
|
51
|
+
set.add(node.attrs.fontFamily);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
node.forEach((child, offset) => {
|
|
56
|
+
if (child.isTextblock) {
|
|
57
|
+
const start = pos + offset;
|
|
58
|
+
const end = start + child.nodeSize;
|
|
59
|
+
if (start <= to && end >= from) {
|
|
60
|
+
set.add(node.attrs.fontFamily);
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return Array.from(set);
|
|
69
|
+
};
|
|
70
|
+
export const extractNodeFonts = (content, set = new Set()) => {
|
|
71
|
+
if (content.type !== 'text') {
|
|
72
|
+
if (content.attrs?.fontFamily) {
|
|
73
|
+
set.add(content.attrs.fontFamily);
|
|
74
|
+
}
|
|
75
|
+
content.content?.forEach((content) => extractNodeFonts(content, set));
|
|
76
|
+
}
|
|
77
|
+
return Array.from(set);
|
|
78
|
+
};
|
|
79
|
+
export const extractSelectionFontSizes = (editor) => {
|
|
80
|
+
const { state } = editor.view;
|
|
81
|
+
const { from, to } = state.selection;
|
|
82
|
+
const set = new Set();
|
|
83
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
84
|
+
if (node.attrs.fontSize) {
|
|
85
|
+
if (node.isTextblock) {
|
|
86
|
+
set.add(node.attrs.fontSize);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
node.forEach((child, offset) => {
|
|
91
|
+
if (child.isTextblock) {
|
|
92
|
+
const start = pos + offset;
|
|
93
|
+
const end = start + child.nodeSize;
|
|
94
|
+
if (start <= to && end >= from) {
|
|
95
|
+
set.add(node.attrs.fontSize);
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return Array.from(set);
|
|
104
|
+
};
|
|
105
|
+
export const extractNodeFontSizes = (content, set = new Set()) => {
|
|
106
|
+
if (content.type !== 'text') {
|
|
107
|
+
if (content.attrs?.fontSize) {
|
|
108
|
+
set.add(content.attrs.fontSize);
|
|
109
|
+
}
|
|
110
|
+
content.content?.forEach((content) => extractNodeFontSizes(content, set));
|
|
111
|
+
}
|
|
112
|
+
return Array.from(set);
|
|
113
|
+
};
|
|
114
|
+
export const extractSelectionColors = (editor) => {
|
|
115
|
+
const selection = editor.view.state.selection;
|
|
116
|
+
const set = new Set();
|
|
117
|
+
editor.view.state.doc.nodesBetween(selection.from, selection.to, (node) => {
|
|
118
|
+
if (node.isText && node.text?.trim().length) {
|
|
119
|
+
const color = node.marks?.find((mark) => mark.type.name === 'textStyle')?.attrs?.color;
|
|
120
|
+
set.add(color || DEFAULT_COLOR);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return Array.from(set);
|
|
124
|
+
};
|
|
125
|
+
export const extractNodeColors = (content, set = new Set()) => {
|
|
126
|
+
if (content.type === 'text') {
|
|
127
|
+
const color = content.marks?.find((mark) => mark.type === 'textStyle')?.attrs?.color;
|
|
128
|
+
set.add(color || DEFAULT_COLOR);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (content.attrs?.color) {
|
|
132
|
+
set.add(content.attrs.color);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
content.content?.forEach((content) => extractNodeColors(content, set));
|
|
136
|
+
return Array.from(set);
|
|
137
|
+
};
|
|
138
|
+
export const extractUppercase = (editor) => {
|
|
139
|
+
const { state } = editor.view;
|
|
140
|
+
const { from, to } = state.selection;
|
|
141
|
+
let uppercase = null;
|
|
142
|
+
const checkUppercase = (node) => {
|
|
143
|
+
uppercase = uppercase !== false && node.attrs.textTransform === 'uppercase';
|
|
144
|
+
};
|
|
145
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
146
|
+
if (node.type.spec.attrs?.['textTransform'] !== undefined) {
|
|
147
|
+
if (node.isTextblock) {
|
|
148
|
+
checkUppercase(node);
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
node.forEach((child, offset) => {
|
|
153
|
+
if (child.isTextblock) {
|
|
154
|
+
const start = pos + offset;
|
|
155
|
+
const end = start + child.nodeSize;
|
|
156
|
+
if (start <= to && end >= from) {
|
|
157
|
+
checkUppercase(node);
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return !!uppercase;
|
|
166
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Node, type InputRuleFinder, type ExtendedRegExpMatchArray, InputRule } from '@tiptap/core';
|
|
2
|
+
import type { Node as ProseMirrorNode, NodeType } from '@tiptap/pm/model';
|
|
3
|
+
export interface ListOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The node name for the list items
|
|
6
|
+
* @default 'listItem'
|
|
7
|
+
* @example 'paragraph'
|
|
8
|
+
*/
|
|
9
|
+
itemTypeName: string;
|
|
10
|
+
/**
|
|
11
|
+
* HTML attributes to add to the list element
|
|
12
|
+
* @default {}
|
|
13
|
+
* @example { class: 'foo' }
|
|
14
|
+
*/
|
|
15
|
+
HTMLAttributes: Record<string, any>;
|
|
16
|
+
/**
|
|
17
|
+
* A list of list style types.
|
|
18
|
+
* @default ['disc', 'decimal', 'lower-alpha', 'lower-roman', 'upper-alpha', 'upper-roman']
|
|
19
|
+
* @example ['disc', 'decimal']
|
|
20
|
+
*/
|
|
21
|
+
styleTypes: string[];
|
|
22
|
+
}
|
|
23
|
+
declare module '@tiptap/core' {
|
|
24
|
+
interface Commands<ReturnType> {
|
|
25
|
+
list: {
|
|
26
|
+
/**
|
|
27
|
+
* Toggle a list
|
|
28
|
+
*/
|
|
29
|
+
toggleListStyleType: (listStyleType?: string) => ReturnType;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Matches a list to a dash or asterisk.
|
|
35
|
+
*/
|
|
36
|
+
export declare const bulletListInputRegex: RegExp;
|
|
37
|
+
/**
|
|
38
|
+
* Matches an ordered list to a 1. on input (or any number followed by a dot).
|
|
39
|
+
*/
|
|
40
|
+
export declare const orderedListInputRegex: RegExp;
|
|
41
|
+
/**
|
|
42
|
+
* Build an input rule for automatically wrapping a textblock when a
|
|
43
|
+
* given string is typed. When using a regular expresion you’ll
|
|
44
|
+
* probably want the regexp to start with `^`, so that the pattern can
|
|
45
|
+
* only occur at the start of a textblock.
|
|
46
|
+
*
|
|
47
|
+
* `type` is the type of node to wrap in.
|
|
48
|
+
*
|
|
49
|
+
* By default, if there’s a node with the same type above the newly
|
|
50
|
+
* wrapped node, the rule will try to join those
|
|
51
|
+
* two nodes. You can pass a join predicate, which takes a regular
|
|
52
|
+
* expression match and the node before the wrapped node, and can
|
|
53
|
+
* return a boolean to indicate whether a join should happen.
|
|
54
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
55
|
+
*/
|
|
56
|
+
export declare function wrappingInputRule(config: {
|
|
57
|
+
find: InputRuleFinder;
|
|
58
|
+
type: NodeType;
|
|
59
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
60
|
+
joinPredicate?: (match: ExtendedRegExpMatchArray, node: ProseMirrorNode) => boolean;
|
|
61
|
+
}): InputRule;
|
|
62
|
+
/**
|
|
63
|
+
* This extension allows you to create lists.
|
|
64
|
+
* This requires the ListItem extension
|
|
65
|
+
* @see https://tiptap.dev/api/nodes/list-item.
|
|
66
|
+
*/
|
|
67
|
+
export declare const List: Node<ListOptions, any>;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { mergeAttributes, Node, InputRule, callOrReturn, getNodeType, } from '@tiptap/core';
|
|
2
|
+
import { TextSelection } from '@tiptap/pm/state';
|
|
3
|
+
import { canJoin } from '@tiptap/pm/transform';
|
|
4
|
+
/**
|
|
5
|
+
* Matches a list to a dash or asterisk.
|
|
6
|
+
*/
|
|
7
|
+
export const bulletListInputRegex = /^\s*([-+*])\s$/;
|
|
8
|
+
/**
|
|
9
|
+
* Matches an ordered list to a 1. on input (or any number followed by a dot).
|
|
10
|
+
*/
|
|
11
|
+
export const orderedListInputRegex = /^(\d+)\.\s$/;
|
|
12
|
+
/**
|
|
13
|
+
* Build an input rule for automatically wrapping a textblock when a
|
|
14
|
+
* given string is typed. When using a regular expresion you’ll
|
|
15
|
+
* probably want the regexp to start with `^`, so that the pattern can
|
|
16
|
+
* only occur at the start of a textblock.
|
|
17
|
+
*
|
|
18
|
+
* `type` is the type of node to wrap in.
|
|
19
|
+
*
|
|
20
|
+
* By default, if there’s a node with the same type above the newly
|
|
21
|
+
* wrapped node, the rule will try to join those
|
|
22
|
+
* two nodes. You can pass a join predicate, which takes a regular
|
|
23
|
+
* expression match and the node before the wrapped node, and can
|
|
24
|
+
* return a boolean to indicate whether a join should happen.
|
|
25
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
26
|
+
*/
|
|
27
|
+
export function wrappingInputRule(config) {
|
|
28
|
+
return new InputRule({
|
|
29
|
+
find: config.find,
|
|
30
|
+
handler: ({ state, range, match, chain }) => {
|
|
31
|
+
const attributes = callOrReturn(config.getAttributes, undefined, match) || {};
|
|
32
|
+
const tr = state.tr.delete(range.from, range.to);
|
|
33
|
+
const $start = tr.doc.resolve(range.from);
|
|
34
|
+
const paragraph = $start.node();
|
|
35
|
+
if (paragraph.type.name !== 'paragraph')
|
|
36
|
+
return null;
|
|
37
|
+
const blockRange = $start.blockRange();
|
|
38
|
+
if (!blockRange)
|
|
39
|
+
return null;
|
|
40
|
+
const { schema } = state;
|
|
41
|
+
const listItemType = schema.nodes.listItem;
|
|
42
|
+
const listItemParagraphType = schema.nodes.listItemParagraph;
|
|
43
|
+
if (!listItemType || !listItemParagraphType)
|
|
44
|
+
return null;
|
|
45
|
+
// Create the wrapper list node
|
|
46
|
+
const list = config.type.create(attributes, [
|
|
47
|
+
listItemType.createChecked(paragraph.attrs, listItemParagraphType.create(null, paragraph.content)),
|
|
48
|
+
]);
|
|
49
|
+
// Replace the current block with the new list
|
|
50
|
+
tr.replaceRangeWith($start.pos, tr.mapping.map($start.pos + paragraph.nodeSize), list);
|
|
51
|
+
// Put cursor inside the new paragraph
|
|
52
|
+
const $pos = state.tr.doc.resolve(range.from + 2); // inside listItemParagraph
|
|
53
|
+
tr.setSelection(TextSelection.near($pos));
|
|
54
|
+
tr.scrollIntoView();
|
|
55
|
+
const before = tr.doc.resolve(range.from - 1).nodeBefore;
|
|
56
|
+
if (before &&
|
|
57
|
+
before.type === config.type &&
|
|
58
|
+
canJoin(tr.doc, range.from - 1) &&
|
|
59
|
+
(!config.joinPredicate || config.joinPredicate(match, before))) {
|
|
60
|
+
tr.join(range.from - 1);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* This extension allows you to create lists.
|
|
67
|
+
* This requires the ListItem extension
|
|
68
|
+
* @see https://tiptap.dev/api/nodes/list-item.
|
|
69
|
+
*/
|
|
70
|
+
export const List = Node.create({
|
|
71
|
+
name: 'list',
|
|
72
|
+
addOptions() {
|
|
73
|
+
return {
|
|
74
|
+
itemTypeName: 'listItem',
|
|
75
|
+
HTMLAttributes: {},
|
|
76
|
+
styleTypes: [
|
|
77
|
+
'disc',
|
|
78
|
+
'circle',
|
|
79
|
+
'square',
|
|
80
|
+
'decimal',
|
|
81
|
+
'lower-alpha',
|
|
82
|
+
'upper-alpha',
|
|
83
|
+
'upper-roman',
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
group: 'block list',
|
|
88
|
+
content() {
|
|
89
|
+
return `${this.options.itemTypeName}+`;
|
|
90
|
+
},
|
|
91
|
+
parseHTML() {
|
|
92
|
+
return [{ tag: 'ul' }];
|
|
93
|
+
},
|
|
94
|
+
renderHTML({ HTMLAttributes }) {
|
|
95
|
+
return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
96
|
+
},
|
|
97
|
+
addAttributes() {
|
|
98
|
+
return {
|
|
99
|
+
listStyleType: {
|
|
100
|
+
default: 'disc',
|
|
101
|
+
parseHTML: (element) => {
|
|
102
|
+
return element.style.getPropertyValue('list-style-type');
|
|
103
|
+
},
|
|
104
|
+
renderHTML: (attributes) => {
|
|
105
|
+
return { style: `list-style-type: ${attributes.listStyleType}` };
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
addCommands() {
|
|
111
|
+
return {
|
|
112
|
+
toggleListStyleType: (listStyleType) => ({ tr, state, dispatch }) => {
|
|
113
|
+
if (listStyleType && !this.options.styleTypes.includes(listStyleType))
|
|
114
|
+
return false;
|
|
115
|
+
const listType = getNodeType('list', state.schema);
|
|
116
|
+
const listItemType = getNodeType('listItem', state.schema);
|
|
117
|
+
const listItemParagraphType = getNodeType('listItemParagraph', state.schema);
|
|
118
|
+
const paragraphType = getNodeType('paragraph', state.schema);
|
|
119
|
+
const { from, to } = state.selection;
|
|
120
|
+
if (!dispatch)
|
|
121
|
+
return true;
|
|
122
|
+
if (!listStyleType) {
|
|
123
|
+
const blocksToConvert = [];
|
|
124
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
125
|
+
if (node.type === listType) {
|
|
126
|
+
const block = {
|
|
127
|
+
nodes: [],
|
|
128
|
+
pos,
|
|
129
|
+
nodesSize: node.nodeSize,
|
|
130
|
+
};
|
|
131
|
+
state.doc.nodesBetween(pos, pos + node.nodeSize, (node, pos) => {
|
|
132
|
+
if (node.type === listItemType) {
|
|
133
|
+
block.nodes.push(node);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
if (block.nodes.length > 0) {
|
|
137
|
+
blocksToConvert.push(block);
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
blocksToConvert.reverse().forEach(({ nodes, pos, nodesSize }) => {
|
|
143
|
+
const paragraphs = [];
|
|
144
|
+
nodes.forEach((item) => {
|
|
145
|
+
item.forEach((child) => {
|
|
146
|
+
if (child.isTextblock) {
|
|
147
|
+
// Create paragraph with item attributes
|
|
148
|
+
paragraphs.push(paragraphType.create(item.attrs, child.content));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
tr.replaceWith(pos, pos + nodesSize, paragraphs);
|
|
153
|
+
});
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
const blocksToConvert = [];
|
|
157
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
158
|
+
if (node.type === listType) {
|
|
159
|
+
// convert if the any child textblock node overlaps with selection
|
|
160
|
+
let shouldConvert = false;
|
|
161
|
+
node.forEach((item, itemOffset) => {
|
|
162
|
+
item.forEach((child, childOffset) => {
|
|
163
|
+
if (child.isTextblock) {
|
|
164
|
+
const start = pos + itemOffset + childOffset;
|
|
165
|
+
const end = start + child.nodeSize;
|
|
166
|
+
if (!shouldConvert && start < to && end > from) {
|
|
167
|
+
shouldConvert = true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
if (shouldConvert) {
|
|
173
|
+
tr.setNodeMarkup(pos, null, { ...node.attrs, listStyleType });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else if (node.type === paragraphType) {
|
|
177
|
+
const block = blocksToConvert.find((block) => block.pos + block.nodesSize === pos);
|
|
178
|
+
if (block) {
|
|
179
|
+
block.nodes.push(node);
|
|
180
|
+
block.nodesSize += node.nodeSize;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
blocksToConvert.push({
|
|
184
|
+
nodes: [node],
|
|
185
|
+
pos,
|
|
186
|
+
nodesSize: node.nodeSize,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
// Convert collected paragraphs to lists
|
|
193
|
+
blocksToConvert.reverse().forEach(({ nodes, pos, nodesSize }) => {
|
|
194
|
+
const listItems = nodes.map((node) => {
|
|
195
|
+
// Create list item with paragraph attributes and content
|
|
196
|
+
const paragraphContent = listItemParagraphType.create(null, node.content);
|
|
197
|
+
return listItemType.create(node.attrs, [paragraphContent]);
|
|
198
|
+
});
|
|
199
|
+
const list = listType.create({ listStyleType }, listItems);
|
|
200
|
+
tr.replaceWith(pos, pos + nodesSize, list);
|
|
201
|
+
const listDepth = tr.doc.resolve(pos + 1).depth;
|
|
202
|
+
const before = tr.doc.resolve(Math.max(0, pos - 1)).before(listDepth);
|
|
203
|
+
if (before !== undefined) {
|
|
204
|
+
const nodeBefore = tr.doc.nodeAt(before);
|
|
205
|
+
const canJoinBackwards = list.type === nodeBefore?.type && canJoin(tr.doc, pos);
|
|
206
|
+
if (canJoinBackwards) {
|
|
207
|
+
tr.join(pos);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const after = tr.doc.resolve(pos + 1).after(listDepth);
|
|
211
|
+
if (after !== undefined) {
|
|
212
|
+
const nodeAfter = tr.doc.nodeAt(after);
|
|
213
|
+
const canJoinForwards = list.type === nodeAfter?.type && canJoin(tr.doc, after);
|
|
214
|
+
if (canJoinForwards) {
|
|
215
|
+
tr.join(after);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
return true;
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
addInputRules() {
|
|
224
|
+
return [
|
|
225
|
+
{ regex: bulletListInputRegex, attributes: { listStyleType: 'disc' } },
|
|
226
|
+
{ regex: orderedListInputRegex, attributes: { listStyleType: 'decimal' } },
|
|
227
|
+
]
|
|
228
|
+
.filter((rule) => this.options.styleTypes.includes(rule.attributes.listStyleType))
|
|
229
|
+
.map(({ regex, attributes }) => {
|
|
230
|
+
return wrappingInputRule({
|
|
231
|
+
find: regex,
|
|
232
|
+
type: this.type,
|
|
233
|
+
getAttributes: () => attributes,
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node as TiptapNode } from '@tiptap/core';
|
|
2
|
+
export interface ListItemOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The HTML attributes for a list item node.
|
|
5
|
+
* @default {}
|
|
6
|
+
* @example { class: 'foo' }
|
|
7
|
+
*/
|
|
8
|
+
HTMLAttributes: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* This extension allows you to create list items.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ListItem: TiptapNode<ListItemOptions, any>;
|