@mythrantic/svelte-rich-text 1.0.1 → 1.2.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/README.md +2 -0
- package/dist/components/AGENTS.md +1 -0
- package/dist/components/ValiantRichText/commands/index.d.ts +1 -0
- package/dist/components/ValiantRichText/commands/index.js +1 -0
- package/dist/components/ValiantRichText/commands/toolbar-commands.d.ts +3 -0
- package/dist/components/ValiantRichText/commands/toolbar-commands.js +501 -0
- package/dist/components/ValiantRichText/commands/types.d.ts +12 -0
- package/dist/components/ValiantRichText/commands/types.js +1 -0
- package/dist/components/ValiantRichText/components/BubbleMenu.svelte +67 -0
- package/dist/components/ValiantRichText/components/BubbleMenu.svelte.d.ts +29 -0
- package/dist/components/ValiantRichText/components/DragHandle.svelte +31 -0
- package/dist/components/{viewBlocks/viewImage.svelte.d.ts → ValiantRichText/components/DragHandle.svelte.d.ts} +6 -7
- package/dist/components/ValiantRichText/components/MediaPlaceHolder.svelte +30 -0
- package/dist/components/ValiantRichText/components/MediaPlaceHolder.svelte.d.ts +26 -0
- package/dist/components/ValiantRichText/editor.css +531 -0
- package/dist/components/ValiantRichText/editor.d.ts +4 -0
- package/dist/components/ValiantRichText/editor.js +123 -0
- package/dist/components/ValiantRichText/extensions/ColorHighlighter.d.ts +2 -0
- package/dist/components/ValiantRichText/extensions/ColorHighlighter.js +25 -0
- package/dist/components/ValiantRichText/extensions/FindAndReplace.d.ts +57 -0
- package/dist/components/ValiantRichText/extensions/FindAndReplace.js +234 -0
- package/dist/components/ValiantRichText/extensions/InlineMathReplacer.d.ts +1 -0
- package/dist/components/ValiantRichText/extensions/InlineMathReplacer.js +20 -0
- package/dist/components/ValiantRichText/extensions/audio/AudiExtended.d.ts +3 -0
- package/dist/components/ValiantRichText/extensions/audio/AudiExtended.js +29 -0
- package/dist/components/ValiantRichText/extensions/audio/AudioExtension.d.ts +23 -0
- package/dist/components/ValiantRichText/extensions/audio/AudioExtension.js +93 -0
- package/dist/components/ValiantRichText/extensions/audio/AudioPlaceholder.d.ts +22 -0
- package/dist/components/ValiantRichText/extensions/audio/AudioPlaceholder.js +36 -0
- package/dist/components/ValiantRichText/extensions/drag-handle/ClipboardSerializer.d.ts +3 -0
- package/dist/components/ValiantRichText/extensions/drag-handle/ClipboardSerializer.js +24 -0
- package/dist/components/ValiantRichText/extensions/drag-handle/index.d.ts +36 -0
- package/dist/components/ValiantRichText/extensions/drag-handle/index.js +293 -0
- package/dist/components/ValiantRichText/extensions/iframe/IFrame.d.ts +22 -0
- package/dist/components/ValiantRichText/extensions/iframe/IFrame.js +51 -0
- package/dist/components/ValiantRichText/extensions/iframe/IFrameExtended.d.ts +3 -0
- package/dist/components/ValiantRichText/extensions/iframe/IFrameExtended.js +29 -0
- package/dist/components/ValiantRichText/extensions/iframe/IFramePlaceholder.d.ts +16 -0
- package/dist/components/ValiantRichText/extensions/iframe/IFramePlaceholder.js +36 -0
- package/dist/components/ValiantRichText/extensions/image/ImageExtended.d.ts +4 -0
- package/dist/components/ValiantRichText/extensions/image/ImageExtended.js +33 -0
- package/dist/components/ValiantRichText/extensions/image/ImagePlaceholder.d.ts +22 -0
- package/dist/components/ValiantRichText/extensions/image/ImagePlaceholder.js +36 -0
- package/dist/components/ValiantRichText/extensions/slash-command/groups.d.ts +8 -0
- package/dist/components/ValiantRichText/extensions/slash-command/groups.js +48 -0
- package/dist/components/ValiantRichText/extensions/slash-command/slashcommand.d.ts +4 -0
- package/dist/components/ValiantRichText/extensions/slash-command/slashcommand.js +216 -0
- package/dist/components/ValiantRichText/extensions/table/index.d.ts +4 -0
- package/dist/components/ValiantRichText/extensions/table/index.js +4 -0
- package/dist/components/ValiantRichText/extensions/table/table-cell.d.ts +5 -0
- package/dist/components/ValiantRichText/extensions/table/table-cell.js +95 -0
- package/dist/components/ValiantRichText/extensions/table/table-header.d.ts +2 -0
- package/dist/components/ValiantRichText/extensions/table/table-header.js +71 -0
- package/dist/components/ValiantRichText/extensions/table/table-row.d.ts +2 -0
- package/dist/components/ValiantRichText/extensions/table/table-row.js +6 -0
- package/dist/components/ValiantRichText/extensions/table/table.d.ts +2 -0
- package/dist/components/ValiantRichText/extensions/table/table.js +7 -0
- package/dist/components/ValiantRichText/extensions/table/utils.d.ts +58 -0
- package/dist/components/ValiantRichText/extensions/table/utils.js +217 -0
- package/dist/components/ValiantRichText/extensions/video/VideoExtended.d.ts +3 -0
- package/dist/components/ValiantRichText/extensions/video/VideoExtended.js +29 -0
- package/dist/components/ValiantRichText/extensions/video/VideoExtension.d.ts +23 -0
- package/dist/components/ValiantRichText/extensions/video/VideoExtension.js +93 -0
- package/dist/components/ValiantRichText/extensions/video/VideoPlaceholder.d.ts +22 -0
- package/dist/components/ValiantRichText/extensions/video/VideoPlaceholder.js +36 -0
- package/dist/components/ValiantRichText/headless/components/AudioExtended.svelte +13 -0
- package/dist/components/ValiantRichText/headless/components/AudioExtended.svelte.d.ts +19 -0
- package/dist/components/ValiantRichText/headless/components/AudioPlaceHolder.svelte +61 -0
- package/dist/components/ValiantRichText/headless/components/AudioPlaceHolder.svelte.d.ts +19 -0
- package/dist/components/ValiantRichText/headless/components/CodeBlock.svelte +47 -0
- package/dist/components/ValiantRichText/headless/components/CodeBlock.svelte.d.ts +19 -0
- package/dist/components/ValiantRichText/headless/components/IFrameExtended.svelte +13 -0
- package/dist/components/ValiantRichText/headless/components/IFrameExtended.svelte.d.ts +19 -0
- package/dist/components/ValiantRichText/headless/components/IFramePlaceHolder.svelte +26 -0
- package/dist/components/{core/blockWrapper.svelte.d.ts → ValiantRichText/headless/components/IFramePlaceHolder.svelte.d.ts} +5 -7
- package/dist/components/ValiantRichText/headless/components/ImageExtended.svelte +13 -0
- package/dist/components/ValiantRichText/headless/components/ImageExtended.svelte.d.ts +19 -0
- package/dist/components/ValiantRichText/headless/components/ImagePlaceholder.svelte +61 -0
- package/dist/components/ValiantRichText/headless/components/ImagePlaceholder.svelte.d.ts +19 -0
- package/dist/components/ValiantRichText/headless/components/MediaExtended.svelte +243 -0
- package/dist/components/{editBlocks/img.svelte.d.ts → ValiantRichText/headless/components/MediaExtended.svelte.d.ts} +8 -11
- package/dist/components/ValiantRichText/headless/components/SlashCommandList.svelte +114 -0
- package/dist/components/{viewBlocks/viewHeader.svelte.d.ts → ValiantRichText/headless/components/SlashCommandList.svelte.d.ts} +5 -6
- package/dist/components/ValiantRichText/headless/components/ToolBarIcon.svelte +26 -0
- package/dist/components/{editBlocks/code.svelte.d.ts → ValiantRichText/headless/components/ToolBarIcon.svelte.d.ts} +8 -11
- package/dist/components/ValiantRichText/headless/components/VideoExtended.svelte +15 -0
- package/dist/components/ValiantRichText/headless/components/VideoExtended.svelte.d.ts +19 -0
- package/dist/components/ValiantRichText/headless/components/VideoPlaceholder.svelte +61 -0
- package/dist/components/ValiantRichText/headless/components/VideoPlaceholder.svelte.d.ts +19 -0
- package/dist/components/ValiantRichText/headless/components/toolbar/FontSize.svelte +33 -0
- package/dist/components/{viewBlocks/viewQuote.svelte.d.ts → ValiantRichText/headless/components/toolbar/FontSize.svelte.d.ts} +6 -6
- package/dist/components/ValiantRichText/headless/components/toolbar/QuickColors.svelte +52 -0
- package/dist/components/{editBlocks/space.svelte.d.ts → ValiantRichText/headless/components/toolbar/QuickColors.svelte.d.ts} +6 -9
- package/dist/components/ValiantRichText/headless/components/toolbar/SearchAndReplace.svelte +121 -0
- package/dist/components/{editBlocks/header.svelte.d.ts → ValiantRichText/headless/components/toolbar/SearchAndReplace.svelte.d.ts} +7 -10
- package/dist/components/ValiantRichText/headless/components/toolbar/ToolbarDropdown.svelte +177 -0
- package/dist/components/{extra/input.svelte.d.ts → ValiantRichText/headless/components/toolbar/ToolbarDropdown.svelte.d.ts} +12 -6
- package/dist/components/ValiantRichText/headless/editor.svelte +164 -0
- package/dist/components/ValiantRichText/headless/editor.svelte.d.ts +29 -0
- package/dist/components/ValiantRichText/headless/index.d.ts +3 -0
- package/dist/components/ValiantRichText/headless/index.js +3 -0
- package/dist/components/ValiantRichText/headless/menus/Link.svelte +44 -0
- package/dist/components/{viewBlocks/viewParagraph.svelte.d.ts → ValiantRichText/headless/menus/Link.svelte.d.ts} +6 -5
- package/dist/components/ValiantRichText/headless/menus/Menu.svelte +96 -0
- package/dist/components/{viewBlocks/viewSpace.svelte.d.ts → ValiantRichText/headless/menus/Menu.svelte.d.ts} +5 -6
- package/dist/components/ValiantRichText/headless/menus/TableCol.svelte +53 -0
- package/dist/components/{viewBlocks/viewList.svelte.d.ts → ValiantRichText/headless/menus/TableCol.svelte.d.ts} +6 -6
- package/dist/components/ValiantRichText/headless/menus/TableRow.svelte +53 -0
- package/dist/components/ValiantRichText/headless/menus/TableRow.svelte.d.ts +21 -0
- package/dist/components/ValiantRichText/headless/style.css +481 -0
- package/dist/components/ValiantRichText/headless/toolbar.svelte +163 -0
- package/dist/components/ValiantRichText/headless/toolbar.svelte.d.ts +19 -0
- package/dist/components/ValiantRichText/onedark.css +176 -0
- package/dist/components/ValiantRichText/svelte-renderer.d.ts +22 -0
- package/dist/components/ValiantRichText/svelte-renderer.js +55 -0
- package/dist/components/ValiantRichText/themes/default-dark.css +70 -0
- package/dist/components/ValiantRichText/themes/default-light.css +68 -0
- package/dist/components/ValiantRichText/themes/inherit.css +67 -0
- package/dist/components/ValiantRichText/themes/modern-dark.css +69 -0
- package/dist/components/ValiantRichText/themes/modern-light.css +67 -0
- package/dist/components/ValiantRichText/themes/professional-dark.css +69 -0
- package/dist/components/ValiantRichText/themes/professional-light.css +67 -0
- package/dist/components/ValiantRichText/types.d.ts +30 -0
- package/dist/components/ValiantRichText/utils.d.ts +28 -0
- package/dist/components/ValiantRichText/utils.js +110 -0
- package/dist/default_content.d.ts +400 -0
- package/dist/default_content.js +1103 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -10
- package/package.json +31 -4
- package/dist/components/core/blockWrapper.svelte +0 -93
- package/dist/components/core/editMode.svelte +0 -114
- package/dist/components/core/editMode.svelte.d.ts +0 -18
- package/dist/components/core/main.svelte +0 -195
- package/dist/components/core/main.svelte.d.ts +0 -67
- package/dist/components/core/toolBar.svelte +0 -144
- package/dist/components/core/toolBar.svelte.d.ts +0 -18
- package/dist/components/core/viewMode.svelte +0 -28
- package/dist/components/core/viewMode.svelte.d.ts +0 -26
- package/dist/components/editBlocks/code.svelte +0 -72
- package/dist/components/editBlocks/header.svelte +0 -68
- package/dist/components/editBlocks/img.svelte +0 -49
- package/dist/components/editBlocks/list.svelte +0 -107
- package/dist/components/editBlocks/list.svelte.d.ts +0 -25
- package/dist/components/editBlocks/paragraph.svelte +0 -24
- package/dist/components/editBlocks/paragraph.svelte.d.ts +0 -28
- package/dist/components/editBlocks/quote.svelte +0 -58
- package/dist/components/editBlocks/quote.svelte.d.ts +0 -25
- package/dist/components/editBlocks/space.svelte +0 -25
- package/dist/components/extra/dropDown.svelte +0 -121
- package/dist/components/extra/dropDown.svelte.d.ts +0 -25
- package/dist/components/extra/input.svelte +0 -64
- package/dist/components/extra/select.svelte +0 -51
- package/dist/components/extra/select.svelte.d.ts +0 -33
- package/dist/components/extra/textarea.svelte +0 -41
- package/dist/components/extra/textarea.svelte.d.ts +0 -23
- package/dist/components/extra/upload.svelte +0 -82
- package/dist/components/extra/upload.svelte.d.ts +0 -23
- package/dist/components/icons/closeIcon.svelte +0 -6
- package/dist/components/icons/closeIcon.svelte.d.ts +0 -26
- package/dist/components/icons/closeQuoteIcon.svelte +0 -9
- package/dist/components/icons/closeQuoteIcon.svelte.d.ts +0 -26
- package/dist/components/icons/codeIcon.svelte +0 -12
- package/dist/components/icons/codeIcon.svelte.d.ts +0 -26
- package/dist/components/icons/copyIcon.svelte +0 -12
- package/dist/components/icons/copyIcon.svelte.d.ts +0 -26
- package/dist/components/icons/deleteIcon.svelte +0 -12
- package/dist/components/icons/deleteIcon.svelte.d.ts +0 -26
- package/dist/components/icons/doneIcon.svelte +0 -17
- package/dist/components/icons/doneIcon.svelte.d.ts +0 -26
- package/dist/components/icons/downIcon.svelte +0 -12
- package/dist/components/icons/downIcon.svelte.d.ts +0 -26
- package/dist/components/icons/headerIcon.svelte +0 -12
- package/dist/components/icons/headerIcon.svelte.d.ts +0 -26
- package/dist/components/icons/imageIcon.svelte +0 -12
- package/dist/components/icons/imageIcon.svelte.d.ts +0 -26
- package/dist/components/icons/listIcon.svelte +0 -12
- package/dist/components/icons/listIcon.svelte.d.ts +0 -26
- package/dist/components/icons/menuIcon.svelte +0 -12
- package/dist/components/icons/menuIcon.svelte.d.ts +0 -26
- package/dist/components/icons/openQuoteIcon.svelte +0 -9
- package/dist/components/icons/openQuoteIcon.svelte.d.ts +0 -26
- package/dist/components/icons/paragraphIcon.svelte +0 -12
- package/dist/components/icons/paragraphIcon.svelte.d.ts +0 -26
- package/dist/components/icons/plusIcon.svelte +0 -3
- package/dist/components/icons/plusIcon.svelte.d.ts +0 -26
- package/dist/components/icons/spaceIcon.svelte +0 -9
- package/dist/components/icons/spaceIcon.svelte.d.ts +0 -26
- package/dist/components/icons/upIcon.svelte +0 -12
- package/dist/components/icons/upIcon.svelte.d.ts +0 -26
- package/dist/components/icons/uploadIcon.svelte +0 -9
- package/dist/components/icons/uploadIcon.svelte.d.ts +0 -26
- package/dist/components/viewBlocks/viewCode.svelte +0 -168
- package/dist/components/viewBlocks/viewCode.svelte.d.ts +0 -22
- package/dist/components/viewBlocks/viewHeader.svelte +0 -14
- package/dist/components/viewBlocks/viewImage.svelte +0 -38
- package/dist/components/viewBlocks/viewList.svelte +0 -70
- package/dist/components/viewBlocks/viewParagraph.svelte +0 -13
- package/dist/components/viewBlocks/viewQuote.svelte +0 -30
- package/dist/components/viewBlocks/viewSpace.svelte +0 -5
- package/dist/utils/consts.d.ts +0 -96
- package/dist/utils/functions.d.ts +0 -2
- package/dist/utils/functions.js +0 -9
- package/dist/utils/stores.d.ts +0 -6
- package/dist/utils/stores.js +0 -3
- package/dist/utils/stores.svelte.d.ts +0 -10
- package/dist/utils/stores.svelte.js +0 -8
- /package/dist/{utils/consts.js → components/ValiantRichText/types.js} +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://coder.valiantlynx.com/templates/docker/workspace?param.git_repo=git@github.com:mythrantic/svelte-rich-text.git)
|
|
2
|
+
|
|
1
3
|
# Valiant Rich Text Svelte Component
|
|
2
4
|
|
|
3
5
|

|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
the edra folder is for rich text editor mcp. it not part of the project currently. and more of a feature idea in progress.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ToolBarCommands } from './toolbar-commands.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ToolBarCommands } from './toolbar-commands.js';
|
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
import { isMac } from '../utils.js';
|
|
2
|
+
import Undo from '@lucide/svelte/icons/undo-2';
|
|
3
|
+
import Redo from '@lucide/svelte/icons/redo-2';
|
|
4
|
+
import Heading1 from '@lucide/svelte/icons/heading-1';
|
|
5
|
+
import Heading2 from '@lucide/svelte/icons/heading-2';
|
|
6
|
+
import Heading3 from '@lucide/svelte/icons/heading-3';
|
|
7
|
+
import Heading4 from '@lucide/svelte/icons/heading-4';
|
|
8
|
+
import Link from '@lucide/svelte/icons/link-2';
|
|
9
|
+
import Bold from '@lucide/svelte/icons/bold';
|
|
10
|
+
import Italic from '@lucide/svelte/icons/italic';
|
|
11
|
+
import Underline from '@lucide/svelte/icons/underline';
|
|
12
|
+
import StrikeThrough from '@lucide/svelte/icons/strikethrough';
|
|
13
|
+
import Quote from '@lucide/svelte/icons/quote';
|
|
14
|
+
import Code from '@lucide/svelte/icons/code';
|
|
15
|
+
import Superscript from '@lucide/svelte/icons/superscript';
|
|
16
|
+
import Subscript from '@lucide/svelte/icons/subscript';
|
|
17
|
+
import AlignLeft from '@lucide/svelte/icons/align-left';
|
|
18
|
+
import AlignCenter from '@lucide/svelte/icons/align-center';
|
|
19
|
+
import AlignRight from '@lucide/svelte/icons/align-right';
|
|
20
|
+
import AlighJustify from '@lucide/svelte/icons/align-justify';
|
|
21
|
+
import List from '@lucide/svelte/icons/list';
|
|
22
|
+
import ListOrdered from '@lucide/svelte/icons/list-ordered';
|
|
23
|
+
import ListChecks from '@lucide/svelte/icons/list-checks';
|
|
24
|
+
import Image from '@lucide/svelte/icons/image';
|
|
25
|
+
import Video from '@lucide/svelte/icons/video';
|
|
26
|
+
import Audio from '@lucide/svelte/icons/audio-lines';
|
|
27
|
+
import IFrame from '@lucide/svelte/icons/code-xml';
|
|
28
|
+
import Table from '@lucide/svelte/icons/table';
|
|
29
|
+
import Radical from '@lucide/svelte/icons/radical';
|
|
30
|
+
import SquareRadical from '@lucide/svelte/icons/square-radical';
|
|
31
|
+
import { isTextSelection } from '@tiptap/core';
|
|
32
|
+
import Pilcrow from '@lucide/svelte/icons/pilcrow';
|
|
33
|
+
const commands = {
|
|
34
|
+
'undo-redo': [
|
|
35
|
+
{
|
|
36
|
+
icon: Undo,
|
|
37
|
+
name: 'undo',
|
|
38
|
+
tooltip: 'Undo',
|
|
39
|
+
shortCut: `${isMac ? '⌘' : 'Ctrl+'}Z`,
|
|
40
|
+
onClick: (editor) => {
|
|
41
|
+
editor.chain().focus().undo().run();
|
|
42
|
+
},
|
|
43
|
+
clickable: (editor) => {
|
|
44
|
+
return editor.can().undo();
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
icon: Redo,
|
|
49
|
+
name: 'redo',
|
|
50
|
+
tooltip: 'Redo',
|
|
51
|
+
shortCut: `${isMac ? '⌘' : 'Ctrl+'}Y`,
|
|
52
|
+
onClick: (editor) => {
|
|
53
|
+
editor.chain().focus().redo().run();
|
|
54
|
+
},
|
|
55
|
+
clickable: (editor) => {
|
|
56
|
+
return editor.can().redo();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
headings: [
|
|
61
|
+
{
|
|
62
|
+
icon: Heading1,
|
|
63
|
+
name: 'h1',
|
|
64
|
+
tooltip: 'Heading 1',
|
|
65
|
+
shortCut: `${isMac ? '⌘⌥' : 'Ctrl+Alt+'}1`,
|
|
66
|
+
onClick: (editor) => {
|
|
67
|
+
editor.chain().focus().toggleHeading({ level: 1 }).run();
|
|
68
|
+
},
|
|
69
|
+
turnInto: (editor, pos) => {
|
|
70
|
+
editor.chain().setNodeSelection(pos).setHeading({ level: 1 }).run();
|
|
71
|
+
},
|
|
72
|
+
clickable: (editor) => {
|
|
73
|
+
return editor.can().toggleHeading({ level: 1 });
|
|
74
|
+
},
|
|
75
|
+
isActive: (editor) => {
|
|
76
|
+
return editor.isActive('heading', { level: 1 });
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
icon: Heading2,
|
|
81
|
+
name: 'h2',
|
|
82
|
+
tooltip: 'Heading 2',
|
|
83
|
+
shortCut: `${isMac ? '⌘⌥' : 'Ctrl+Alt+'}2`,
|
|
84
|
+
onClick: (editor) => {
|
|
85
|
+
editor.chain().focus().toggleHeading({ level: 2 }).run();
|
|
86
|
+
},
|
|
87
|
+
turnInto: (editor, pos) => {
|
|
88
|
+
editor.chain().setNodeSelection(pos).setHeading({ level: 2 }).run();
|
|
89
|
+
},
|
|
90
|
+
clickable: (editor) => {
|
|
91
|
+
return editor.can().toggleHeading({ level: 2 });
|
|
92
|
+
},
|
|
93
|
+
isActive: (editor) => {
|
|
94
|
+
return editor.isActive('heading', { level: 2 });
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
icon: Heading3,
|
|
99
|
+
name: 'h3',
|
|
100
|
+
tooltip: 'Heading 3',
|
|
101
|
+
shortCut: `${isMac ? '⌘⌥' : 'Ctrl+Alt+'}3`,
|
|
102
|
+
onClick: (editor) => {
|
|
103
|
+
editor.chain().focus().toggleHeading({ level: 3 }).run();
|
|
104
|
+
},
|
|
105
|
+
turnInto: (editor, pos) => {
|
|
106
|
+
editor.chain().setNodeSelection(pos).setHeading({ level: 3 }).run();
|
|
107
|
+
},
|
|
108
|
+
clickable: (editor) => {
|
|
109
|
+
return editor.can().toggleHeading({ level: 3 });
|
|
110
|
+
},
|
|
111
|
+
isActive: (editor) => {
|
|
112
|
+
return editor.isActive('heading', { level: 3 });
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
icon: Heading4,
|
|
117
|
+
name: 'h4',
|
|
118
|
+
tooltip: 'Heading 4',
|
|
119
|
+
shortCut: `${isMac ? '⌘⌥' : 'Ctrl+Alt+'}4`,
|
|
120
|
+
onClick: (editor) => {
|
|
121
|
+
editor.chain().focus().toggleHeading({ level: 4 }).run();
|
|
122
|
+
},
|
|
123
|
+
turnInto: (editor, pos) => {
|
|
124
|
+
editor.chain().setNodeSelection(pos).setHeading({ level: 4 }).run();
|
|
125
|
+
},
|
|
126
|
+
clickable: (editor) => {
|
|
127
|
+
return editor.can().toggleHeading({ level: 4 });
|
|
128
|
+
},
|
|
129
|
+
isActive: (editor) => {
|
|
130
|
+
return editor.isActive('heading', { level: 4 });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
'text-formatting': [
|
|
135
|
+
{
|
|
136
|
+
icon: Link,
|
|
137
|
+
name: 'link',
|
|
138
|
+
tooltip: 'Link',
|
|
139
|
+
onClick: (editor) => {
|
|
140
|
+
if (editor.isActive('link')) {
|
|
141
|
+
editor.chain().focus().unsetLink().run();
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
const url = window.prompt('Enter the URL of the link:');
|
|
145
|
+
if (url) {
|
|
146
|
+
editor.chain().focus().toggleLink({ href: url }).run();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
isActive: (editor) => {
|
|
151
|
+
return editor.isActive('link');
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
icon: Pilcrow,
|
|
156
|
+
name: 'paragraph',
|
|
157
|
+
tooltip: 'Paragraph',
|
|
158
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}0`,
|
|
159
|
+
onClick: (editor) => {
|
|
160
|
+
editor.chain().focus().setParagraph().run();
|
|
161
|
+
},
|
|
162
|
+
turnInto: (editor, pos) => {
|
|
163
|
+
editor.chain().setNodeSelection(pos).setParagraph().run();
|
|
164
|
+
},
|
|
165
|
+
clickable: (editor) => {
|
|
166
|
+
return editor.can().setParagraph();
|
|
167
|
+
},
|
|
168
|
+
isActive: (editor) => {
|
|
169
|
+
return editor.isActive('paragraph');
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
icon: Bold,
|
|
174
|
+
name: 'bold',
|
|
175
|
+
tooltip: 'Bold',
|
|
176
|
+
shortCut: `${isMac ? '⌘' : 'Ctrl+'}B`,
|
|
177
|
+
onClick: (editor) => {
|
|
178
|
+
editor.chain().focus().toggleBold().run();
|
|
179
|
+
},
|
|
180
|
+
turnInto: (editor, pos) => {
|
|
181
|
+
editor.chain().setNodeSelection(pos).setMark('bold').run();
|
|
182
|
+
},
|
|
183
|
+
clickable: (editor) => {
|
|
184
|
+
return editor.can().toggleBold();
|
|
185
|
+
},
|
|
186
|
+
isActive: (editor) => {
|
|
187
|
+
return editor.isActive('bold');
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
icon: Italic,
|
|
192
|
+
name: 'italic',
|
|
193
|
+
tooltip: 'Italic',
|
|
194
|
+
shortCut: `${isMac ? '⌘' : 'Ctrl+'}I`,
|
|
195
|
+
onClick: (editor) => {
|
|
196
|
+
editor.chain().focus().toggleItalic().run();
|
|
197
|
+
},
|
|
198
|
+
turnInto: (editor, pos) => {
|
|
199
|
+
editor.chain().setNodeSelection(pos).setMark('italic').run();
|
|
200
|
+
},
|
|
201
|
+
clickable: (editor) => {
|
|
202
|
+
return editor.can().toggleItalic();
|
|
203
|
+
},
|
|
204
|
+
isActive: (editor) => {
|
|
205
|
+
return editor.isActive('italic');
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
icon: Underline,
|
|
210
|
+
name: 'underline',
|
|
211
|
+
tooltip: 'Underline',
|
|
212
|
+
shortCut: `${isMac ? '⌘' : 'Ctrl+'}U`,
|
|
213
|
+
onClick: (editor) => {
|
|
214
|
+
editor.chain().focus().toggleUnderline().run();
|
|
215
|
+
},
|
|
216
|
+
turnInto: (editor, pos) => {
|
|
217
|
+
editor.chain().setNodeSelection(pos).setMark('underline').run();
|
|
218
|
+
},
|
|
219
|
+
clickable: (editor) => {
|
|
220
|
+
return editor.can().toggleUnderline();
|
|
221
|
+
},
|
|
222
|
+
isActive: (editor) => {
|
|
223
|
+
return editor.isActive('underline');
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
icon: StrikeThrough,
|
|
228
|
+
name: 'strikethrough',
|
|
229
|
+
tooltip: 'Strikethrough',
|
|
230
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}S`,
|
|
231
|
+
onClick: (editor) => {
|
|
232
|
+
editor.chain().focus().toggleStrike().run();
|
|
233
|
+
},
|
|
234
|
+
turnInto: (editor, pos) => {
|
|
235
|
+
editor.chain().setNodeSelection(pos).setMark('strike').run();
|
|
236
|
+
},
|
|
237
|
+
clickable: (editor) => {
|
|
238
|
+
return editor.can().toggleStrike();
|
|
239
|
+
},
|
|
240
|
+
isActive: (editor) => {
|
|
241
|
+
return editor.isActive('strike');
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
icon: Quote,
|
|
246
|
+
name: 'blockQuote',
|
|
247
|
+
tooltip: 'BlockQuote',
|
|
248
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}B`,
|
|
249
|
+
onClick: (editor) => {
|
|
250
|
+
editor.chain().focus().toggleBlockquote().run();
|
|
251
|
+
},
|
|
252
|
+
turnInto: (editor, pos) => {
|
|
253
|
+
editor.chain().setNodeSelection(pos).toggleBlockquote().run();
|
|
254
|
+
},
|
|
255
|
+
clickable: (editor) => {
|
|
256
|
+
return editor.can().toggleBlockquote();
|
|
257
|
+
},
|
|
258
|
+
isActive: (editor) => {
|
|
259
|
+
return editor.isActive('blockquote');
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
icon: Code,
|
|
264
|
+
name: 'code',
|
|
265
|
+
tooltip: 'Inline Code',
|
|
266
|
+
shortCut: `${isMac ? '⌘' : 'Ctrl+'}E`,
|
|
267
|
+
onClick: (editor) => {
|
|
268
|
+
editor.chain().focus().toggleCode().run();
|
|
269
|
+
},
|
|
270
|
+
turnInto: (editor, pos) => {
|
|
271
|
+
editor.chain().setNodeSelection(pos).toggleCodeBlock().run();
|
|
272
|
+
},
|
|
273
|
+
clickable: (editor) => {
|
|
274
|
+
return editor.can().toggleCode();
|
|
275
|
+
},
|
|
276
|
+
isActive: (editor) => {
|
|
277
|
+
return editor.isActive('code');
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
icon: Superscript,
|
|
282
|
+
name: 'superscript',
|
|
283
|
+
tooltip: 'Superscript',
|
|
284
|
+
shortCut: `${isMac ? '⌘' : 'Ctrl+'}.`,
|
|
285
|
+
onClick: (editor) => {
|
|
286
|
+
editor.chain().focus().toggleSuperscript().run();
|
|
287
|
+
},
|
|
288
|
+
clickable: (editor) => {
|
|
289
|
+
return editor.can().toggleSuperscript();
|
|
290
|
+
},
|
|
291
|
+
isActive: (editor) => {
|
|
292
|
+
return editor.isActive('superscript');
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
icon: Subscript,
|
|
297
|
+
name: 'subscript',
|
|
298
|
+
tooltip: 'Subscript',
|
|
299
|
+
shortCut: `${isMac ? '⌘' : 'Ctrl+'},`,
|
|
300
|
+
onClick: (editor) => {
|
|
301
|
+
editor.chain().focus().toggleSubscript().run();
|
|
302
|
+
},
|
|
303
|
+
clickable: (editor) => {
|
|
304
|
+
return editor.can().toggleSubscript();
|
|
305
|
+
},
|
|
306
|
+
isActive: (editor) => {
|
|
307
|
+
return editor.isActive('subscript');
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
],
|
|
311
|
+
alignment: [
|
|
312
|
+
{
|
|
313
|
+
icon: AlignLeft,
|
|
314
|
+
name: 'align-left',
|
|
315
|
+
tooltip: 'Align Left',
|
|
316
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}L`,
|
|
317
|
+
onClick: (editor) => {
|
|
318
|
+
editor.chain().focus().toggleTextAlign('left').run();
|
|
319
|
+
},
|
|
320
|
+
clickable: (editor) => {
|
|
321
|
+
return editor.can().toggleTextAlign('left');
|
|
322
|
+
},
|
|
323
|
+
isActive: (editor) => editor.isActive({ textAlign: 'left' })
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
icon: AlignCenter,
|
|
327
|
+
name: 'align-center',
|
|
328
|
+
tooltip: 'Align Center',
|
|
329
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}E`,
|
|
330
|
+
onClick: (editor) => {
|
|
331
|
+
editor.chain().focus().toggleTextAlign('center').run();
|
|
332
|
+
},
|
|
333
|
+
clickable: (editor) => {
|
|
334
|
+
return editor.can().toggleTextAlign('center');
|
|
335
|
+
},
|
|
336
|
+
isActive: (editor) => editor.isActive({ textAlign: 'center' })
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
icon: AlignRight,
|
|
340
|
+
name: 'align-right',
|
|
341
|
+
tooltip: 'Align Right',
|
|
342
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}R`,
|
|
343
|
+
onClick: (editor) => {
|
|
344
|
+
editor.chain().focus().toggleTextAlign('right').run();
|
|
345
|
+
},
|
|
346
|
+
clickable: (editor) => {
|
|
347
|
+
return editor.can().toggleTextAlign('right');
|
|
348
|
+
},
|
|
349
|
+
isActive: (editor) => editor.isActive({ textAlign: 'right' })
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
icon: AlighJustify,
|
|
353
|
+
name: 'align-justify',
|
|
354
|
+
tooltip: 'Align Justify',
|
|
355
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}J`,
|
|
356
|
+
onClick: (editor) => {
|
|
357
|
+
editor.chain().focus().toggleTextAlign('justify').run();
|
|
358
|
+
},
|
|
359
|
+
clickable: (editor) => {
|
|
360
|
+
return editor.can().toggleTextAlign('justify');
|
|
361
|
+
},
|
|
362
|
+
isActive: (editor) => editor.isActive({ textAlign: 'justify' })
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
lists: [
|
|
366
|
+
{
|
|
367
|
+
icon: List,
|
|
368
|
+
name: 'bulletList',
|
|
369
|
+
tooltip: 'Bullet List',
|
|
370
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}8`,
|
|
371
|
+
onClick: (editor) => {
|
|
372
|
+
editor.chain().focus().toggleBulletList().run();
|
|
373
|
+
},
|
|
374
|
+
turnInto: (editor, pos) => {
|
|
375
|
+
editor.chain().setNodeSelection(pos).toggleBulletList().run();
|
|
376
|
+
},
|
|
377
|
+
isActive: (editor) => editor.isActive('bulletList')
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
icon: ListOrdered,
|
|
381
|
+
name: 'orderedList',
|
|
382
|
+
tooltip: 'Ordered List',
|
|
383
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}7`,
|
|
384
|
+
onClick: (editor) => {
|
|
385
|
+
editor.chain().focus().toggleOrderedList().run();
|
|
386
|
+
},
|
|
387
|
+
turnInto: (editor, pos) => {
|
|
388
|
+
editor.chain().setNodeSelection(pos).toggleOrderedList().run();
|
|
389
|
+
},
|
|
390
|
+
clickable: (editor) => {
|
|
391
|
+
return editor.can().toggleOrderedList();
|
|
392
|
+
},
|
|
393
|
+
isActive: (editor) => {
|
|
394
|
+
return editor.isActive('orderedList');
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
icon: ListChecks,
|
|
399
|
+
name: 'taskList',
|
|
400
|
+
tooltip: 'Task List',
|
|
401
|
+
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}9`,
|
|
402
|
+
onClick: (editor) => {
|
|
403
|
+
editor.chain().focus().toggleTaskList().run();
|
|
404
|
+
},
|
|
405
|
+
turnInto: (editor, pos) => {
|
|
406
|
+
editor.chain().setNodeSelection(pos).toggleTaskList().run();
|
|
407
|
+
},
|
|
408
|
+
clickable: (editor) => {
|
|
409
|
+
return editor.can().toggleTaskList();
|
|
410
|
+
},
|
|
411
|
+
isActive: (editor) => {
|
|
412
|
+
return editor.isActive('taskList');
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
],
|
|
416
|
+
media: [
|
|
417
|
+
{
|
|
418
|
+
icon: Image,
|
|
419
|
+
name: 'image-placeholder',
|
|
420
|
+
tooltip: 'Image Placeholder',
|
|
421
|
+
onClick: (editor) => {
|
|
422
|
+
editor.chain().focus().insertImagePlaceholder().run();
|
|
423
|
+
},
|
|
424
|
+
isActive: (editor) => editor.isActive('image-placeholder')
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
icon: Video,
|
|
428
|
+
name: 'video-placeholder',
|
|
429
|
+
tooltip: 'Video Placeholder',
|
|
430
|
+
onClick: (editor) => {
|
|
431
|
+
editor.chain().focus().insertVideoPlaceholder().run();
|
|
432
|
+
},
|
|
433
|
+
isActive: (editor) => editor.isActive('video-placeholder')
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
icon: Audio,
|
|
437
|
+
name: 'audio-placeholder',
|
|
438
|
+
tooltip: 'Audio Placeholder',
|
|
439
|
+
onClick: (editor) => {
|
|
440
|
+
editor.chain().focus().insertAudioPlaceholder().run();
|
|
441
|
+
},
|
|
442
|
+
isActive: (editor) => editor.isActive('audio-placeholder')
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
icon: IFrame,
|
|
446
|
+
name: 'iframe-placeholder',
|
|
447
|
+
tooltip: 'IFrame Placeholder',
|
|
448
|
+
onClick: (editor) => {
|
|
449
|
+
editor.chain().focus().insertIFramePlaceholder().run();
|
|
450
|
+
},
|
|
451
|
+
isActive: (editor) => editor.isActive('iframe-placeholder')
|
|
452
|
+
}
|
|
453
|
+
],
|
|
454
|
+
table: [
|
|
455
|
+
{
|
|
456
|
+
icon: Table,
|
|
457
|
+
name: 'table',
|
|
458
|
+
tooltip: 'Table',
|
|
459
|
+
onClick: (editor) => {
|
|
460
|
+
if (editor.isActive('table')) {
|
|
461
|
+
const del = confirm('Do you really want to delete this table??');
|
|
462
|
+
if (del) {
|
|
463
|
+
editor.chain().focus().deleteTable().run();
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
editor.chain().focus().insertTable({ cols: 3, rows: 3, withHeaderRow: false }).run();
|
|
468
|
+
},
|
|
469
|
+
isActive: (editor) => editor.isActive('table')
|
|
470
|
+
}
|
|
471
|
+
],
|
|
472
|
+
math: [
|
|
473
|
+
{
|
|
474
|
+
icon: Radical,
|
|
475
|
+
name: 'mathematics',
|
|
476
|
+
tooltip: 'Inline Expression',
|
|
477
|
+
onClick: (editor) => {
|
|
478
|
+
let latex = 'a^2 + b^2 = c^2';
|
|
479
|
+
const chain = editor.chain().focus();
|
|
480
|
+
if (isTextSelection(editor.view.state.selection)) {
|
|
481
|
+
const { from, to } = editor.view.state.selection;
|
|
482
|
+
latex = editor.view.state.doc.textBetween(from, to);
|
|
483
|
+
chain.deleteRange({ from, to });
|
|
484
|
+
}
|
|
485
|
+
chain.insertInlineMath({ latex }).run();
|
|
486
|
+
},
|
|
487
|
+
isActive: (editor) => editor.isActive('inlineMath')
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
icon: SquareRadical,
|
|
491
|
+
name: 'mathematics',
|
|
492
|
+
tooltip: 'Block Expression',
|
|
493
|
+
onClick: (editor) => {
|
|
494
|
+
const latex = 'a^2 + b^2 = c^2';
|
|
495
|
+
editor.chain().focus().insertBlockMath({ latex }).run();
|
|
496
|
+
},
|
|
497
|
+
isActive: (editor) => editor.isActive('blockMath')
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
};
|
|
501
|
+
export default commands;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
import { Icon } from '@lucide/svelte';
|
|
3
|
+
export interface EdraToolBarCommands {
|
|
4
|
+
name: string;
|
|
5
|
+
icon: typeof Icon;
|
|
6
|
+
tooltip?: string;
|
|
7
|
+
shortCut?: string;
|
|
8
|
+
onClick?: (editor: Editor) => void;
|
|
9
|
+
turnInto?: (editor: Editor, pos: number) => void;
|
|
10
|
+
isActive?: (editor: Editor) => boolean;
|
|
11
|
+
clickable?: (editor: Editor) => boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Icon } from '@lucide/svelte';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, type Snippet } from 'svelte';
|
|
3
|
+
import { BubbleMenuPlugin, type BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu';
|
|
4
|
+
import type { Editor } from '@tiptap/core';
|
|
5
|
+
|
|
6
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
7
|
+
|
|
8
|
+
interface Props
|
|
9
|
+
extends Optional<Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'>, 'editor'> {
|
|
10
|
+
editor?: Editor;
|
|
11
|
+
children?: Snippet<[]>;
|
|
12
|
+
class?: string;
|
|
13
|
+
style?: string;
|
|
14
|
+
pluginKey?: string;
|
|
15
|
+
updateDelay?: number;
|
|
16
|
+
resizeDelay?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
editor,
|
|
21
|
+
shouldShow = null,
|
|
22
|
+
class: className = '',
|
|
23
|
+
style = '',
|
|
24
|
+
children,
|
|
25
|
+
updateDelay,
|
|
26
|
+
resizeDelay,
|
|
27
|
+
pluginKey = 'bubbleMenu',
|
|
28
|
+
options,
|
|
29
|
+
...restProps
|
|
30
|
+
}: Props = $props();
|
|
31
|
+
|
|
32
|
+
let element = $state<HTMLElement>();
|
|
33
|
+
|
|
34
|
+
onMount(() => {
|
|
35
|
+
if (!element) return;
|
|
36
|
+
|
|
37
|
+
element.style.position = 'absolute';
|
|
38
|
+
element.style.visibility = 'hidden';
|
|
39
|
+
|
|
40
|
+
if (!editor || editor.isDestroyed) {
|
|
41
|
+
console.warn('BubbleMenu component does not have editor prop or editor is destroyed.');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const plugin = BubbleMenuPlugin({
|
|
46
|
+
pluginKey,
|
|
47
|
+
editor,
|
|
48
|
+
element,
|
|
49
|
+
shouldShow,
|
|
50
|
+
updateDelay,
|
|
51
|
+
resizeDelay,
|
|
52
|
+
options
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
editor.registerPlugin(plugin);
|
|
56
|
+
|
|
57
|
+
return () => {
|
|
58
|
+
if (editor && !editor.isDestroyed) {
|
|
59
|
+
editor.unregisterPlugin(pluginKey);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<div bind:this={element} class={`bubble-menu-wrapper ${className}`} {style} {...restProps}>
|
|
66
|
+
{@render children?.()}
|
|
67
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import { type BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu';
|
|
3
|
+
import type { Editor } from '@tiptap/core';
|
|
4
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
5
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
+
$$bindings?: Bindings;
|
|
7
|
+
} & Exports;
|
|
8
|
+
(internal: unknown, props: Props & {
|
|
9
|
+
$$events?: Events;
|
|
10
|
+
$$slots?: Slots;
|
|
11
|
+
}): Exports & {
|
|
12
|
+
$set?: any;
|
|
13
|
+
$on?: any;
|
|
14
|
+
};
|
|
15
|
+
z_$$bindings?: Bindings;
|
|
16
|
+
}
|
|
17
|
+
declare const BubbleMenu: $$__sveltets_2_IsomorphicComponent<Pick<Partial<Omit<Pick<Partial<BubbleMenuPluginProps>, "pluginKey"> & Omit<BubbleMenuPluginProps, "pluginKey">, "element">>, "editor"> & Omit<Omit<Pick<Partial<BubbleMenuPluginProps>, "pluginKey"> & Omit<BubbleMenuPluginProps, "pluginKey">, "element">, "editor"> & {
|
|
18
|
+
editor?: Editor;
|
|
19
|
+
children?: Snippet<[]>;
|
|
20
|
+
class?: string;
|
|
21
|
+
style?: string;
|
|
22
|
+
pluginKey?: string;
|
|
23
|
+
updateDelay?: number;
|
|
24
|
+
resizeDelay?: number;
|
|
25
|
+
}, {
|
|
26
|
+
[evt: string]: CustomEvent<any>;
|
|
27
|
+
}, {}, {}, "">;
|
|
28
|
+
type BubbleMenu = InstanceType<typeof BubbleMenu>;
|
|
29
|
+
export default BubbleMenu;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Editor } from '@tiptap/core';
|
|
3
|
+
import { onMount } from 'svelte';
|
|
4
|
+
import GripVertical from '@lucide/svelte/icons/grip-vertical';
|
|
5
|
+
import { DragHandlePlugin } from '../extensions/drag-handle/index.js';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
editor: Editor;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { editor }: Props = $props();
|
|
12
|
+
|
|
13
|
+
const pluginKey = 'globalDragHandle';
|
|
14
|
+
|
|
15
|
+
onMount(() => {
|
|
16
|
+
const plugin = DragHandlePlugin({
|
|
17
|
+
pluginKey: pluginKey,
|
|
18
|
+
dragHandleWidth: 20,
|
|
19
|
+
scrollTreshold: 100,
|
|
20
|
+
dragHandleSelector: '.drag-handle',
|
|
21
|
+
excludedTags: ['pre', 'code', 'table p'],
|
|
22
|
+
customNodes: []
|
|
23
|
+
});
|
|
24
|
+
editor.registerPlugin(plugin);
|
|
25
|
+
return () => editor.unregisterPlugin(pluginKey);
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div class="drag-handle">
|
|
30
|
+
<GripVertical />
|
|
31
|
+
</div>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
1
2
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
3
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
4
|
$$bindings?: Bindings;
|
|
@@ -11,12 +12,10 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
11
12
|
};
|
|
12
13
|
z_$$bindings?: Bindings;
|
|
13
14
|
}
|
|
14
|
-
declare const
|
|
15
|
-
|
|
16
|
-
caption: string;
|
|
17
|
-
name: string;
|
|
15
|
+
declare const DragHandle: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
editor: Editor;
|
|
18
17
|
}, {
|
|
19
18
|
[evt: string]: CustomEvent<any>;
|
|
20
|
-
}, {}, {},
|
|
21
|
-
type
|
|
22
|
-
export default
|
|
19
|
+
}, {}, {}, "">;
|
|
20
|
+
type DragHandle = InstanceType<typeof DragHandle>;
|
|
21
|
+
export default DragHandle;
|