@seorii/tiptap 0.2.22 → 0.3.0-next.10

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.
Files changed (49) hide show
  1. package/dist/i18n/en-us/index.js +1 -1
  2. package/dist/i18n/index.js +2 -3
  3. package/dist/i18n/ko-kr/index.js +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +3 -3
  6. package/dist/plugin/command/emoji.d.ts +2 -2
  7. package/dist/plugin/command/emoji.js +7 -3
  8. package/dist/plugin/command/stores.d.ts +0 -1
  9. package/dist/plugin/command/suggest.d.ts +2 -2
  10. package/dist/plugin/command/suggest.js +85 -26
  11. package/dist/plugin/embed.js +15 -9
  12. package/dist/plugin/iframe.js +19 -10
  13. package/dist/plugin/image/dragdrop.js +10 -12
  14. package/dist/plugin/image/index.d.ts +1 -1
  15. package/dist/plugin/image/index.js +12 -8
  16. package/dist/plugin/indent.js +16 -14
  17. package/dist/plugin/orderedlist/index.js +55 -23
  18. package/dist/plugin/orderedlist/korean.scss +12 -13
  19. package/dist/plugin/orderedlist/toggleList.js +7 -7
  20. package/dist/plugin/table/deleteTable.d.ts +1 -1
  21. package/dist/plugin/table/deleteTable.js +2 -2
  22. package/dist/plugin/table/index.js +10 -6
  23. package/dist/plugin/table/style/cell.scss +14 -13
  24. package/dist/plugin/table/style/grip.scss +61 -59
  25. package/dist/plugin/table/style/resize.scss +21 -23
  26. package/dist/plugin/table/style/table.scss +72 -69
  27. package/dist/plugin/table/tableCell/index.js +6 -6
  28. package/dist/plugin/table/tableHeader/index.js +6 -6
  29. package/dist/plugin/table/tableRow/index.js +1 -1
  30. package/dist/plugin/table/util.d.ts +2 -2
  31. package/dist/plugin/table/util.js +9 -9
  32. package/dist/plugin/youtube.d.ts +2 -2
  33. package/dist/plugin/youtube.js +35 -26
  34. package/dist/tiptap/Bubble.svelte +199 -95
  35. package/dist/tiptap/Bubble.svelte.d.ts +7 -21
  36. package/dist/tiptap/Command.svelte +125 -59
  37. package/dist/tiptap/Command.svelte.d.ts +4 -16
  38. package/dist/tiptap/Floating.svelte +67 -41
  39. package/dist/tiptap/Floating.svelte.d.ts +2 -14
  40. package/dist/tiptap/TipTap.svelte +210 -132
  41. package/dist/tiptap/TipTap.svelte.d.ts +18 -34
  42. package/dist/tiptap/ToolbarButton.svelte +33 -21
  43. package/dist/tiptap/ToolbarButton.svelte.d.ts +10 -25
  44. package/dist/tiptap/index.d.ts +1 -1
  45. package/dist/tiptap/index.js +2 -2
  46. package/dist/tiptap/setMath.js +5 -2
  47. package/dist/tiptap/tiptap.d.ts +2 -2
  48. package/dist/tiptap/tiptap.js +87 -76
  49. package/package.json +109 -102
@@ -12,9 +12,9 @@ export default BuiltInTableHeader.extend({
12
12
  parseHTML: (element) => {
13
13
  const colwidth = element.getAttribute('colwidth');
14
14
  return colwidth ? colwidth.split(',').map((item) => parseInt(item, 10)) : null;
15
- },
15
+ }
16
16
  },
17
- style: { default: null },
17
+ style: { default: null }
18
18
  };
19
19
  },
20
20
  addProseMirrorPlugins() {
@@ -51,9 +51,9 @@ export default BuiltInTableHeader.extend({
51
51
  });
52
52
  }
53
53
  return DecorationSet.create(doc, decorations);
54
- },
55
- },
56
- }),
54
+ }
55
+ }
56
+ })
57
57
  ];
58
- },
58
+ }
59
59
  });
@@ -1,4 +1,4 @@
1
1
  import { TableRow as BuiltInTableRow } from '@tiptap/extension-table-row';
2
2
  export default BuiltInTableRow.extend({
3
- allowGapCursor: false,
3
+ allowGapCursor: false
4
4
  });
@@ -6,9 +6,9 @@ export declare const findTable: (selection: Selection) => {
6
6
  pos: number;
7
7
  start: number;
8
8
  depth: number;
9
- node: Node;
9
+ node: import("prosemirror-model").Node;
10
10
  } | undefined;
11
- export declare const isCellSelection: (selection: any) => boolean;
11
+ export declare const isCellSelection: (selection: any) => selection is CellSelection;
12
12
  export declare const isTableAnySelected: (selection: any) => false | number[];
13
13
  export declare const isColumnSelected: (columnIndex: number) => (selection: any) => boolean;
14
14
  export declare const isRowSelected: (rowIndex: number) => (selection: any) => boolean;
@@ -31,7 +31,7 @@ export const isColumnSelected = (columnIndex) => (selection) => {
31
31
  left: columnIndex,
32
32
  right: columnIndex + 1,
33
33
  top: 0,
34
- bottom: map.height,
34
+ bottom: map.height
35
35
  })(selection);
36
36
  }
37
37
  return false;
@@ -43,7 +43,7 @@ export const isRowSelected = (rowIndex) => (selection) => {
43
43
  left: 0,
44
44
  right: map.width,
45
45
  top: rowIndex,
46
- bottom: rowIndex + 1,
46
+ bottom: rowIndex + 1
47
47
  })(selection);
48
48
  }
49
49
  return false;
@@ -55,7 +55,7 @@ export const isTableSelected = (selection) => {
55
55
  left: 0,
56
56
  right: map.width,
57
57
  top: 0,
58
- bottom: map.height,
58
+ bottom: map.height
59
59
  })(selection);
60
60
  }
61
61
  return false;
@@ -71,7 +71,7 @@ export const getCellsInColumn = (columnIndex) => (selection) => {
71
71
  left: index,
72
72
  right: index + 1,
73
73
  top: 0,
74
- bottom: map.height,
74
+ bottom: map.height
75
75
  });
76
76
  return acc.concat(cells.map((nodePos) => {
77
77
  const node = table.node.nodeAt(nodePos);
@@ -94,7 +94,7 @@ export const getCellsInRow = (rowIndex) => (selection) => {
94
94
  left: 0,
95
95
  right: map.width,
96
96
  top: index,
97
- bottom: index + 1,
97
+ bottom: index + 1
98
98
  });
99
99
  return acc.concat(cells.map((nodePos) => {
100
100
  const node = table.node.nodeAt(nodePos);
@@ -114,7 +114,7 @@ export const getCellsInTable = (selection) => {
114
114
  left: 0,
115
115
  right: map.width,
116
116
  top: 0,
117
- bottom: map.height,
117
+ bottom: map.height
118
118
  });
119
119
  return cells.map((nodePos) => {
120
120
  const node = table.node.nodeAt(nodePos);
@@ -131,7 +131,7 @@ export const findParentNodeClosestToPos = ($pos, predicate) => {
131
131
  pos: i > 0 ? $pos.before(i) : 0,
132
132
  start: $pos.start(i),
133
133
  depth: i,
134
- node,
134
+ node
135
135
  };
136
136
  }
137
137
  }
@@ -155,7 +155,7 @@ const select = (type) => (index) => (tr) => {
155
155
  left,
156
156
  top,
157
157
  right: isRowSelection ? right : left + 1,
158
- bottom: isRowSelection ? top + 1 : bottom,
158
+ bottom: isRowSelection ? top + 1 : bottom
159
159
  });
160
160
  const cellsInLastRow = bottom - top === 1
161
161
  ? cellsInFirstRow
@@ -163,7 +163,7 @@ const select = (type) => (index) => (tr) => {
163
163
  left: isRowSelection ? left : right - 1,
164
164
  top: isRowSelection ? bottom - 1 : top,
165
165
  right,
166
- bottom,
166
+ bottom
167
167
  });
168
168
  const head = table.start + cellsInFirstRow[0];
169
169
  const anchor = table.start + cellsInLastRow[cellsInLastRow.length - 1];
@@ -1,8 +1,8 @@
1
- import { Node } from "@tiptap/core";
1
+ import { Node } from '@tiptap/core';
2
2
  export interface VideoPlayerOptions {
3
3
  HTMLAttributes: Record<string, any>;
4
4
  }
5
- declare module "@tiptap/core" {
5
+ declare module '@tiptap/core' {
6
6
  interface Commands<ReturnType> {
7
7
  videoPlayer: {
8
8
  insertVideoPlayer: (options: {
@@ -1,5 +1,5 @@
1
- import { Node, mergeAttributes } from "@tiptap/core";
2
- import { Plugin, PluginKey } from "prosemirror-state";
1
+ import { Node, mergeAttributes } from '@tiptap/core';
2
+ import { Plugin, PluginKey } from 'prosemirror-state';
3
3
  const youtubeRegExp = /^(?:(?:https?:)?\/\/)?(?:www\.)?(?:m\.)?(?:youtu(?:be)?\.com\/(?:v\/|embed\/|watch(?:\/|\?v=))|youtu\.be\/)((?:\w|-){11})(?:\S+)?$/;
4
4
  const youtubeExtractId = (url) => {
5
5
  const match = youtubeRegExp.exec(url.trim());
@@ -7,32 +7,32 @@ const youtubeExtractId = (url) => {
7
7
  };
8
8
  const videoPlayerStaticAttributes = { nocookie: true };
9
9
  export default Node.create({
10
- name: "lite-youtube",
11
- content: "",
12
- marks: "",
13
- group: "block",
10
+ name: 'lite-youtube',
11
+ content: '',
12
+ marks: '',
13
+ group: 'block',
14
14
  draggable: true,
15
15
  addAttributes() {
16
16
  return {
17
17
  videoid: {
18
- default: null,
18
+ default: null
19
19
  },
20
20
  provider: {
21
- default: "youtube",
22
- },
21
+ default: 'youtube'
22
+ }
23
23
  };
24
24
  },
25
25
  parseHTML() {
26
26
  return [
27
27
  {
28
- tag: "lite-youtube",
29
- },
28
+ tag: 'lite-youtube'
29
+ }
30
30
  ];
31
31
  },
32
32
  renderHTML({ HTMLAttributes }) {
33
33
  return [
34
- "lite-youtube",
35
- mergeAttributes(videoPlayerStaticAttributes, this.options.HTMLAttributes, HTMLAttributes),
34
+ 'lite-youtube',
35
+ mergeAttributes(videoPlayerStaticAttributes, this.options.HTMLAttributes, HTMLAttributes)
36
36
  ];
37
37
  },
38
38
  addCommands() {
@@ -43,19 +43,23 @@ export default Node.create({
43
43
  if (videoid) {
44
44
  const { selection } = editor.state;
45
45
  const pos = selection.$head;
46
- return chain().insertContentAt(pos.before(), [{
46
+ return chain()
47
+ .insertContentAt(pos.before(), [
48
+ {
47
49
  type: this.name,
48
- attrs: { videoid, provider: "youtube" },
49
- }]).run();
50
+ attrs: { videoid, provider: 'youtube' }
51
+ }
52
+ ])
53
+ .run();
50
54
  }
51
55
  return false;
52
- },
56
+ }
53
57
  };
54
58
  },
55
59
  addProseMirrorPlugins() {
56
60
  return [
57
61
  new Plugin({
58
- key: new PluginKey("handlePasteVideoURL"),
62
+ key: new PluginKey('handlePasteVideoURL'),
59
63
  props: {
60
64
  handlePaste: (view, _event, slice) => {
61
65
  if (slice.content.childCount !== 1)
@@ -69,7 +73,7 @@ export default Node.create({
69
73
  const node = pos.node();
70
74
  if (node.content.size > 0)
71
75
  return false;
72
- let textContent = "", href = "";
76
+ let textContent = '', href = '';
73
77
  slice.content.forEach((node) => {
74
78
  textContent += node.textContent;
75
79
  });
@@ -87,14 +91,19 @@ export default Node.create({
87
91
  }
88
92
  if (!videoid)
89
93
  return false;
90
- this.editor.chain().insertContentAt(pos.before(), [{
94
+ this.editor
95
+ .chain()
96
+ .insertContentAt(pos.before(), [
97
+ {
91
98
  type: this.name,
92
- attrs: { videoid, provider: "youtube" },
93
- }]).run();
99
+ attrs: { videoid, provider: 'youtube' }
100
+ }
101
+ ])
102
+ .run();
94
103
  return true;
95
- },
96
- },
97
- }),
104
+ }
105
+ }
106
+ })
98
107
  ];
99
- },
108
+ }
100
109
  });
@@ -1,45 +1,87 @@
1
- <script>import { BubbleMenu } from 'svelte-tiptap';
2
- import { getContext, tick } from 'svelte';
3
- import 'tippy.js/animations/shift-away-subtle.css';
4
- import ToolbarButton from './ToolbarButton.svelte';
5
- import { isTableAnySelected } from '../plugin/table/util';
6
- import deleteTable from '../plugin/table/deleteTable';
7
- import setMath from './setMath';
8
- import { Button, Icon, IconButton, Input, List, OneLine, Tooltip } from 'nunui';
9
- import i18n from '../i18n';
10
- import ColorPicker from 'svelte-awesome-color-picker';
11
- import { isTextSelection } from '@tiptap/core';
12
- export let colors = [], editable, override;
13
- const tiptap = getContext('editor');
14
- let link = false, href = '', sel = '', _sel = '';
15
- $: selection = $tiptap?.state?.selection;
16
- $: table = isTableAnySelected(selection);
17
- $: sel = selection?.from + '-' + selection?.to;
18
- $: if ($tiptap && sel !== _sel) {
19
- _sel = sel;
20
- link = false;
21
- href = $tiptap.getAttributes('link').href;
22
- }
23
- $: if ($tiptap && link) {
24
- if (href)
25
- $tiptap.chain().setLink({ href }).run();
26
- else if ($tiptap.getAttributes('link').href)
27
- $tiptap.chain().unsetLink().run();
28
- }
29
- const shouldShow = ({ view, state, from, to }) => {
30
- const { doc, selection } = state;
31
- const { empty } = selection;
32
- const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
33
- return !(empty || isEmptyTextBlock);
34
- };
1
+ <script lang="ts">
2
+ import { BubbleMenu } from 'svelte-tiptap';
3
+ import { flushSync, getContext, tick, untrack } from 'svelte';
4
+ import 'tippy.js/animations/shift-away-subtle.css';
5
+ import ToolbarButton from './ToolbarButton.svelte';
6
+ import { isTableAnySelected } from '../plugin/table/util';
7
+ import deleteTable from '../plugin/table/deleteTable';
8
+ import setMath from './setMath';
9
+ import { Button, Icon, IconButton, Input, List, OneLine, Paper, Render } from 'nunui';
10
+ import i18n from '../i18n';
11
+ import ColorPicker from 'svelte-awesome-color-picker';
12
+ import { isTextSelection } from '@tiptap/core';
13
+
14
+ let { colors = [], editable, override, children } = $props();
15
+
16
+ const editor = getContext<{ v: any; c: number }>('editor');
17
+ const tiptap = $derived(editor.v);
18
+
19
+ let selection = $state(null);
20
+ let table = $state(false);
21
+ let sel = $state('');
22
+ let _sel = $state('');
23
+ let link = $state(false);
24
+ let href = $state('');
25
+
26
+ $effect(() => {
27
+ let _ = editor.c;
28
+ flushSync();
29
+ selection = tiptap?.state?.selection;
30
+ });
31
+
32
+ $effect(() => {
33
+ table = isTableAnySelected(selection);
34
+ });
35
+
36
+ $effect(() => {
37
+ sel = selection?.from + '-' + selection?.to;
38
+ });
39
+
40
+ $effect(() => {
41
+ if (tiptap && sel !== _sel) {
42
+ _sel = sel;
43
+ link = false;
44
+ href = tiptap.getAttributes('link').href || '';
45
+ }
46
+ });
47
+
48
+ $effect(() => {
49
+ const _href = href;
50
+ untrack(() => {
51
+ if (tiptap && link) {
52
+ if (href) {
53
+ tiptap.chain().setLink({ href: _href }).run();
54
+ } else if (tiptap.getAttributes('link').href) {
55
+ tiptap.chain().unsetLink().run();
56
+ }
57
+ }
58
+ })
59
+ });
60
+
61
+ const shouldShow = ({ view, state, from, to }) => {
62
+ const { doc, selection } = state;
63
+ const { empty } = selection;
64
+
65
+ const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
66
+
67
+ return !(empty || isEmptyTextBlock);
68
+ };
35
69
  </script>
36
70
 
37
- {#if $tiptap}
38
- <BubbleMenu editor={$tiptap} updateDelay={50} {shouldShow}
39
- tippyOptions={{moveTransition: 'transform 0.2s cubic-bezier(1,.5,0,.85)', animation:'shift-away-subtle', duration: [200, 50]}}>
71
+ {#if tiptap}
72
+ <BubbleMenu
73
+ editor={tiptap}
74
+ updateDelay={50}
75
+ {shouldShow}
76
+ tippyOptions={{
77
+ moveTransition: 'transform 0.2s cubic-bezier(1,.5,0,.85)',
78
+ animation: 'shift-away-subtle',
79
+ duration: [200, 50]
80
+ }}
81
+ >
40
82
  {#if override}
41
83
  <main>
42
- <slot name="override" />
84
+ <Render it={override} />
43
85
  </main>
44
86
  {:else}
45
87
  <main>
@@ -49,54 +91,82 @@ const shouldShow = ({ view, state, from, to }) => {
49
91
  <Icon icon="link" />
50
92
  {i18n('link')}
51
93
  </p>
52
- <Input placeholder="url" fullWidth bind:value={href} autofocus />
94
+ <Input placeholder="url" bind:value={href} autofocus />
53
95
  <div>
54
- <Button tabindex="0" transparent small on:click={() => {
55
- href = ''
56
- $tiptap.chain().focus().unsetLink().run()
57
- tick().then(() => link = false)
58
- }}>{i18n('delete')}
96
+ <Button
97
+ tabindex="0"
98
+ transparent
99
+ small
100
+ onclick={() => {
101
+ href = '';
102
+ tiptap.chain().focus().unsetLink().run();
103
+ tick().then(() => (link = false));
104
+ }}
105
+ >{i18n('delete')}
59
106
  </Button>
60
- <Button tabindex="0" transparent small
61
- on:click={() => link = false}>{i18n('close')}</Button>
107
+ <Button tabindex="0" transparent small onclick={() => (link = false)}
108
+ >{i18n('close')}</Button
109
+ >
62
110
  </div>
63
111
  </div>
64
112
  {:else if table}
65
113
  {#if table.length > 1}
66
- <ToolbarButton icon="cell_merge" handler={() => $tiptap.commands.mergeCells()} />
114
+ <ToolbarButton icon="cell_merge" handler={() => tiptap.commands.mergeCells()} />
67
115
  {:else}
68
- <ToolbarButton icon="splitscreen_left" handler={() => $tiptap.commands.splitCell()} />
116
+ <ToolbarButton icon="splitscreen_left" handler={() => tiptap.commands.splitCell()} />
69
117
  {/if}
70
- <ToolbarButton icon="keyboard_double_arrow_left"
71
- handler={() => $tiptap.chain().focus().addColumnBefore().run()} />
72
- <ToolbarButton icon="keyboard_double_arrow_right"
73
- handler={() => $tiptap.chain().focus().addColumnAfter().run()} />
74
- <ToolbarButton icon="keyboard_double_arrow_up"
75
- handler={() => $tiptap.chain().focus().addRowBefore().run()} />
76
- <ToolbarButton icon="keyboard_double_arrow_down"
77
- handler={() => $tiptap.chain().focus().addRowAfter().run()} />
78
- <ToolbarButton icon="close" handler={() => deleteTable({editor: $tiptap})} />
118
+ <ToolbarButton
119
+ icon="keyboard_double_arrow_left"
120
+ handler={() => tiptap.chain().focus().addColumnBefore().run()}
121
+ />
122
+ <ToolbarButton
123
+ icon="keyboard_double_arrow_right"
124
+ handler={() => tiptap.chain().focus().addColumnAfter().run()}
125
+ />
126
+ <ToolbarButton
127
+ icon="keyboard_double_arrow_up"
128
+ handler={() => tiptap.chain().focus().addRowBefore().run()}
129
+ />
130
+ <ToolbarButton
131
+ icon="keyboard_double_arrow_down"
132
+ handler={() => tiptap.chain().focus().addRowAfter().run()}
133
+ />
134
+ <ToolbarButton icon="close" handler={() => deleteTable({ editor: tiptap })} />
79
135
  {:else}
80
136
  {#if editable}
81
- <Tooltip bottom left xstack width="160px">
82
- <IconButton size="1.2em" icon="format_align_left" slot="target" />
137
+ <Paper hover bl>
138
+ {#snippet target()}
139
+ <IconButton size="1.2em" icon="format_align_left" />
140
+ {/snippet}
83
141
  <div style="margin: -6px;font-size: 0.6em">
84
142
  <List>
85
- <OneLine icon="format_align_left" title={i18n('alignLeft')}
86
- on:click={() => $tiptap.chain().focus().setTextAlign('left').run()}
87
- active={$tiptap.isActive({ textAlign: 'left' })} />
88
- <OneLine icon="format_align_center" title={i18n('alignCenter')}
89
- on:click={() => $tiptap.chain().focus().setTextAlign('center').run()}
90
- active={$tiptap.isActive({ textAlign: 'center' })} />
91
- <OneLine icon="format_align_right" title={i18n('alignRight')}
92
- on:click={() => $tiptap.chain().focus().setTextAlign('right').run()}
93
- active={$tiptap.isActive({ textAlign: 'right' })} />
94
- <OneLine icon="format_align_justify" title={i18n('alignJustify')}
95
- on:click={() => $tiptap.chain().focus().setTextAlign('justify').run()}
96
- active={$tiptap.isActive({ textAlign: 'justify' })} />
143
+ <OneLine
144
+ icon="format_align_left"
145
+ title={i18n('alignLeft')}
146
+ onclick={() => tiptap.chain().focus().setTextAlign('left').run()}
147
+ active={tiptap.isActive({ textAlign: 'left' })}
148
+ />
149
+ <OneLine
150
+ icon="format_align_center"
151
+ title={i18n('alignCenter')}
152
+ onclick={() => tiptap.chain().focus().setTextAlign('center').run()}
153
+ active={tiptap.isActive({ textAlign: 'center' })}
154
+ />
155
+ <OneLine
156
+ icon="format_align_right"
157
+ title={i18n('alignRight')}
158
+ onclick={() => tiptap.chain().focus().setTextAlign('right').run()}
159
+ active={tiptap.isActive({ textAlign: 'right' })}
160
+ />
161
+ <OneLine
162
+ icon="format_align_justify"
163
+ title={i18n('alignJustify')}
164
+ onclick={() => tiptap.chain().focus().setTextAlign('justify').run()}
165
+ active={tiptap.isActive({ textAlign: 'justify' })}
166
+ />
97
167
  </List>
98
168
  </div>
99
- </Tooltip>
169
+ </Paper>
100
170
  {/if}
101
171
  <ToolbarButton icon="format_bold" prop="bold" />
102
172
  <ToolbarButton icon="format_italic" prop="italic" />
@@ -106,41 +176,58 @@ const shouldShow = ({ view, state, from, to }) => {
106
176
  <ToolbarButton icon="subscript" prop="subscript" />
107
177
  <ToolbarButton icon="border_color" prop="highlight" />
108
178
  {#if editable}
109
- <ToolbarButton icon="functions" handler={() => setMath($tiptap)} />
179
+ <ToolbarButton icon="functions" handler={() => setMath(tiptap)} />
110
180
  {/if}
111
- <Tooltip bottom left xstack>
112
- <IconButton size="1.2em" icon="palette" slot="target" />
181
+ <Paper bl block>
182
+ {#snippet target()}
183
+ <IconButton size="1.2em" icon="palette" />
184
+ {/snippet}
113
185
  <div style="font-size: 0.6em">
114
- <List>
115
- <Button small outlined on:click={() => $tiptap.chain().focus().unsetColor().run()}>
186
+ <div class="colors">
187
+ <Button small outlined onclick={() => tiptap.chain().focus().unsetColor().run()}>
116
188
  {i18n('default')}
117
189
  </Button>
118
- <Tooltip bottom left xstack stacked="2">
119
- <Button small outlined on:click={() => $tiptap.chain().focus().unsetColor().run()}
120
- slot="target">
121
- <Icon colorize />
122
- </Button>
123
- <ColorPicker isDialog={false} on:input={(event) => {
124
- $tiptap.chain().focus().setColor(event.detail.hex).run()
125
- }} />
126
- </Tooltip>
190
+ <Paper bl remap block>
191
+ {#snippet target()}
192
+ <Button
193
+ small
194
+ full
195
+ outlined
196
+ onclick={() => tiptap.chain().focus().unsetColor().run()}
197
+ >
198
+ <Icon colorize />
199
+ </Button>
200
+ {/snippet}
201
+ <div onclick={(event) => event.stopPropagation()} onmousedown={(event) => event.stopPropagation()}>
202
+ <ColorPicker
203
+ isDialog={false}
204
+ onInput={(event) => {
205
+ tiptap.chain().focus().setColor(event.hex).run();
206
+ }}
207
+ />
208
+ </div>
209
+ </Paper>
127
210
  {#each colors as color}
128
- <Button small outlined
129
- on:click={() => $tiptap.chain().focus().setColor(color).run()}
130
- style="margin-right:4px">
211
+ <Button
212
+ small
213
+ outlined
214
+ onclick={() => tiptap.chain().focus().setColor(color).run()}
215
+ >
131
216
  <span
132
- style="width: 20px; height: 16px; background: {color}; border-radius: 4px;display: inline-block;margin-bottom: -2px"></span>
217
+ style:background={color}
218
+ class="pal"
219
+ ></span>
133
220
  </Button>
134
221
  {/each}
135
- </List>
222
+ </div>
136
223
  </div>
137
- </Tooltip>
224
+ </Paper>
138
225
  {#if editable}
139
226
  <ToolbarButton icon="code" prop="code" />
140
- <ToolbarButton icon="link" prop="link" handler={() => link = true} />
227
+ <ToolbarButton icon="link" prop="link" handler={() => (link = true)} />
141
228
  {/if}
142
229
  {/if}
143
- <slot />
230
+ <Render it={children} />
144
231
  </main>
145
232
  {/if}
146
233
  </BubbleMenu>
@@ -179,4 +266,21 @@ main > :global(*):last-child {
179
266
  margin-top: 0.6em;
180
267
  display: flex;
181
268
  justify-content: flex-end;
182
- }</style>
269
+ }
270
+
271
+ .colors {
272
+ display: grid;
273
+ grid-template-columns: 1fr 1fr 1fr;
274
+ gap: 4px;
275
+ }
276
+ .colors > :global(:first-child) {
277
+ grid-column: 1/3;
278
+ }
279
+
280
+ .pal {
281
+ width: 20px;
282
+ height: 16px;
283
+ border-radius: 4px;
284
+ display: inline-block;
285
+ margin-bottom: -2px;
286
+ }</style>
@@ -1,22 +1,8 @@
1
- import { SvelteComponentTyped } from "svelte";
2
1
  import 'tippy.js/animations/shift-away-subtle.css';
3
- declare const __propDef: {
4
- props: {
5
- colors?: any[] | undefined;
6
- editable: any;
7
- override: any;
8
- };
9
- events: {
10
- [evt: string]: CustomEvent<any>;
11
- };
12
- slots: {
13
- override: {};
14
- default: {};
15
- };
16
- };
17
- export type BubbleProps = typeof __propDef.props;
18
- export type BubbleEvents = typeof __propDef.events;
19
- export type BubbleSlots = typeof __propDef.slots;
20
- export default class Bubble extends SvelteComponentTyped<BubbleProps, BubbleEvents, BubbleSlots> {
21
- }
22
- export {};
2
+ declare const Bubble: import("svelte").Component<{
3
+ colors?: unknown;
4
+ editable: unknown;
5
+ override: unknown;
6
+ children: unknown;
7
+ }, {}, "">;
8
+ export default Bubble;