@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
@@ -1,102 +1,168 @@
1
- <script>import { Button, IconButton, Input, List, OneLine, TwoLine } from 'nunui';
2
- import { getContext } from 'svelte';
3
- import { slashVisible, slashItems, slashLocaltion, slashProps, slashDetail, slashSelection } from '../plugin/command/stores';
4
- import { fly, slide } from 'svelte/transition';
5
- import { quartOut } from 'svelte/easing';
6
- import i18n from '../i18n';
7
- const tiptap = getContext('editor');
8
- export let selectedIndex = 0;
9
- let height = 0, elements = [];
10
- let input = '', focus;
11
- $: if ($slashVisible) {
12
- input = '';
13
- }
14
- $: setTimeout(() => focus?.focus?.(), 100);
1
+ <script lang="ts">
2
+ import { Button, IconButton, Input, List, OneLine, TwoLine } from 'nunui';
3
+ import { getContext } from 'svelte';
4
+ import {
5
+ slashVisible,
6
+ slashItems,
7
+ slashLocaltion,
8
+ slashProps,
9
+ slashDetail,
10
+ slashSelection
11
+ } from '../plugin/command/stores';
12
+ import { fly, slide } from 'svelte/transition';
13
+ import { quartOut } from 'svelte/easing';
14
+ import i18n from '../i18n';
15
+
16
+ const editor = getContext<{ v: any }>('editor');
17
+ const tiptap = $derived(editor.v);
18
+ let { selectedIndex = 0 } = $props();
19
+
20
+ let height = $state(0),
21
+ elements = $state([]);
22
+ let input = $state(''),
23
+ focus: any = $state(null);
24
+
25
+ $effect(() => {
26
+ if ($slashVisible) input = '';
27
+ });
28
+ $effect(() => {
29
+ focus;
30
+ setTimeout(() => focus?.focus?.(), 100);
31
+ });
15
32
  </script>
16
33
 
17
34
  <svelte:window bind:innerHeight={height} />
18
35
 
19
36
  {#if $slashVisible}
20
- <div class="scrim" on:click={() => $slashVisible = false} />
21
- <main style="left: {$slashLocaltion.x}px; top: {$slashLocaltion.y + $slashLocaltion.height + 384 > height
37
+ <div class="scrim" onclick={() => ($slashVisible = false)} />
38
+ <main
39
+ style="left: {$slashLocaltion.x}px; top: {$slashLocaltion.y + $slashLocaltion.height + 384 >
40
+ height
22
41
  ? $slashLocaltion.y - $slashLocaltion.height - 384
23
- : $slashLocaltion.y + $slashLocaltion.height}px;" transition:fly={{y: 10, duration: 200, easing: quartOut}}>
42
+ : $slashLocaltion.y + $slashLocaltion.height}px;"
43
+ transition:fly={{ y: 10, duration: 200, easing: quartOut }}
44
+ >
24
45
  {#if $slashDetail === 'emoji'}
25
46
  <div class="list">
26
47
  <List>
27
- {#each $slashItems as { title, command }, i(title)}
28
- <div transition:slide={{duration: 400, easing: quartOut}}>
29
- <OneLine on:click={() => {
30
- command?.($slashProps);
31
- setTimeout(() => $tiptap.commands.focus());
32
- }} bind:this={elements[i]} {title} active={selectedIndex === i} />
48
+ {#each $slashItems as { title, command }, i (title)}
49
+ <div transition:slide={{ duration: 400, easing: quartOut }}>
50
+ <OneLine
51
+ onclick={() => {
52
+ command?.($slashProps);
53
+ setTimeout(() => tiptap.commands.focus());
54
+ }}
55
+ bind:this={elements[i]}
56
+ {title}
57
+ active={selectedIndex === i}
58
+ />
33
59
  </div>
34
60
  {/each}
35
61
  {#if !$slashItems.length}
36
- <div class="section"
37
- transition:slide={{duration: 400, easing: quartOut}}>{i18n('noResult')}</div>
62
+ <div class="section" transition:slide={{ duration: 400, easing: quartOut }}>
63
+ {i18n('noResult')}
64
+ </div>
38
65
  {/if}
39
66
  </List>
40
67
  </div>
41
68
  {:else if $slashDetail?.type === 'code'}
42
69
  <div class="detail">
43
70
  <header>
44
- <IconButton icon="arrow_back" on:click={() => $slashDetail = null} />
71
+ <IconButton icon="arrow_back" onclick={() => ($slashDetail = null)} />
45
72
  <div class="title">{i18n('insertCode')}</div>
46
73
  </header>
47
74
  <div>
48
- <Button small on:click={() => {$slashSelection?.();$slashDetail.handler(undefined);}}>{i18n('auto')}</Button>
75
+ <Button
76
+ small
77
+ onclick={() => {
78
+ $slashSelection?.();
79
+ $slashDetail.handler(undefined);
80
+ }}>{i18n('auto')}</Button
81
+ >
49
82
  {#each ['cpp', 'python', 'java'] as lang}
50
- <Button small outlined on:click={() => {$slashSelection?.();$slashDetail.handler(lang);}}>{lang}</Button>
83
+ <Button
84
+ small
85
+ outlined
86
+ onclick={() => {
87
+ $slashSelection?.();
88
+ $slashDetail.handler(lang);
89
+ }}>{lang}</Button
90
+ >
51
91
  {/each}
52
92
  </div>
53
93
  </div>
54
94
  {:else if $slashDetail}
55
95
  <div class="detail">
56
96
  <header>
57
- <IconButton icon="arrow_back" on:click={() => $slashDetail = null} />
97
+ <IconButton icon="arrow_back" onclick={() => ($slashDetail = null)} />
58
98
  <div class="title">{$slashDetail.title}</div>
59
99
  </header>
60
- <Input placeholder={$slashDetail.placeholder} fullWidth bind:value={input} bind:input={focus}
61
- on:submit={() => {
62
- $slashSelection?.();
63
- $slashDetail.handler(input)
64
- }} />
100
+ <Input
101
+ placeholder={$slashDetail.placeholder}
102
+ fullWidth
103
+ bind:value={input}
104
+ bind:input={focus}
105
+ onsubmit={() => {
106
+ $slashSelection?.();
107
+ $slashDetail.handler(input);
108
+ }}
109
+ />
65
110
  <footer>
66
- <Button tabindex="0" transparent small on:click={() => {
67
- input = ''
68
- $slashDetail = null
69
- }}>{i18n('cancel')}
111
+ <Button
112
+ tabindex="0"
113
+ transparent
114
+ small
115
+ onclick={() => {
116
+ input = '';
117
+ $slashDetail = null;
118
+ }}
119
+ >{i18n('cancel')}
70
120
  </Button>
71
- <Button tabindex="0" transparent small
72
- on:click={() => {
73
- $slashSelection?.();
74
- $slashDetail.handler(input);
75
- }}>{i18n('insert')}
121
+ <Button
122
+ tabindex="0"
123
+ transparent
124
+ small
125
+ onclick={() => {
126
+ $slashSelection?.();
127
+ $slashDetail.handler(input);
128
+ }}
129
+ >{i18n('insert')}
76
130
  </Button>
77
131
  </footer>
78
132
  </div>
79
133
  {:else}
80
134
  <div class="list">
81
135
  <List>
82
- {#each $slashItems as { section, list }, j(section)}
83
- {@const lastCount = $slashItems.slice(0, j).reduce((acc, cur) => acc + cur.list.length, 0)}
84
- <div class="section" transition:slide={{duration: 400, easing: quartOut}}>{section}</div>
85
- <div transition:slide={{duration: 400, easing: quartOut}}>
86
- {#each list || [] as { title, subtitle, icon, command, section }, i(title)}
87
- <div transition:slide={{duration: 400, easing: quartOut}}>
88
- <TwoLine on:mouseenter={() => (selectedIndex = i + lastCount)} on:click={() => {
89
- command?.($slashProps);
90
- setTimeout(() => $tiptap.commands.focus());
91
- }} bind:this={elements[i + lastCount]} {icon} {title} subtitle={subtitle || ''}
92
- active={selectedIndex === i + lastCount} />
136
+ {#each $slashItems as { section, list }, j (section)}
137
+ {@const lastCount = $slashItems
138
+ .slice(0, j)
139
+ .reduce((acc, cur) => acc + cur.list.length, 0)}
140
+ <div class="section" transition:slide={{ duration: 400, easing: quartOut }}>
141
+ {section}
142
+ </div>
143
+ <div transition:slide={{ duration: 400, easing: quartOut }}>
144
+ {#each list || [] as { title, subtitle, icon, command, section }, i (title)}
145
+ <div transition:slide={{ duration: 400, easing: quartOut }}>
146
+ <TwoLine
147
+ onmouseenter={() => (selectedIndex = i + lastCount)}
148
+ onclick={() => {
149
+ command?.($slashProps);
150
+ setTimeout(() => tiptap.commands.focus());
151
+ }}
152
+ bind:this={elements[i + lastCount]}
153
+ {icon}
154
+ {title}
155
+ subtitle={subtitle || ''}
156
+ active={selectedIndex === i + lastCount}
157
+ />
93
158
  </div>
94
159
  {/each}
95
160
  </div>
96
161
  {/each}
97
162
  {#if !$slashItems.length}
98
- <div class="section"
99
- transition:slide={{duration: 400, easing: quartOut}}>{i18n('noResult')}</div>
163
+ <div class="section" transition:slide={{ duration: 400, easing: quartOut }}>
164
+ {i18n('noResult')}
165
+ </div>
100
166
  {/if}
101
167
  </List>
102
168
  </div>
@@ -136,12 +202,12 @@ main {
136
202
  .list {
137
203
  color: var(--primary-dark7);
138
204
  }
139
- .list :global(.title) {
205
+ .list :global .title {
140
206
  font-size: 0.7em !important;
141
207
  font-weight: 300 !important;
142
208
  margin-bottom: 4px;
143
209
  }
144
- .list :global(.subtitle) {
210
+ .list :global .subtitle {
145
211
  font-size: 0.8em !important;
146
212
  font-weight: 300 !important;
147
213
  color: var(--primary-dark1);
@@ -170,4 +236,4 @@ footer {
170
236
  margin-top: 0.6em;
171
237
  display: flex;
172
238
  justify-content: flex-end;
173
- }</style>
239
+ }</style>
@@ -1,16 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- selectedIndex?: number | undefined;
5
- };
6
- events: {
7
- [evt: string]: CustomEvent<any>;
8
- };
9
- slots: {};
10
- };
11
- export type CommandProps = typeof __propDef.props;
12
- export type CommandEvents = typeof __propDef.events;
13
- export type CommandSlots = typeof __propDef.slots;
14
- export default class Command extends SvelteComponentTyped<CommandProps, CommandEvents, CommandSlots> {
15
- }
16
- export {};
1
+ declare const Command: import("svelte").Component<{
2
+ selectedIndex?: number;
3
+ }, {}, "">;
4
+ export default Command;
@@ -1,45 +1,71 @@
1
- <script>import { FloatingMenu } from "svelte-tiptap";
2
- import { getContext } from "svelte";
3
- import { IconButton, List, OneLine, Tooltip } from "nunui";
4
- import ToolbarButton from "./ToolbarButton.svelte";
5
- import i18n from "../i18n";
6
- const tiptap = getContext('editor');
1
+ <script lang="ts">
2
+ import { FloatingMenu } from 'svelte-tiptap';
3
+ import { getContext } from 'svelte';
4
+ import { IconButton, List, OneLine, Paper } from 'nunui';
5
+ import ToolbarButton from './ToolbarButton.svelte';
6
+ import i18n from '../i18n';
7
+
8
+ const editor = getContext<{ v: any }>('editor');
9
+ const tiptap = $derived(editor.v);
7
10
  </script>
8
11
 
9
- {#if $tiptap}
10
- <FloatingMenu editor={$tiptap} tippyOptions={{animation:'fade', duration: [200, 50]}}>
11
- <main on:mousedown={() => setTimeout(() => $tiptap.commands.focus())}>
12
- <span>
13
- {i18n('newLineInfo')}
14
- </span>
15
- <Tooltip bottom left xstack width="160px">
16
- <IconButton size="1.2em" icon="text_fields" slot="target"/>
17
- <div style="margin: -6px">
18
- <List>
19
- <OneLine icon="counter_1" title="{i18n('title')} 1"
20
- on:click={() => $tiptap.commands.setHeading({level: 1})}/>
21
- <OneLine icon="counter_2" title="{i18n('title')} 2"
22
- on:click={() => $tiptap.commands.setHeading({level: 2})}/>
23
- <OneLine icon="counter_3" title="{i18n('title')} 3"
24
- on:click={() => $tiptap.commands.setHeading({level: 3})}/>
25
- <OneLine icon="segment" title={i18n('paragraph')}
26
- on:click={() => $tiptap.commands.setParagraph()}/>
27
- </List>
28
- </div>
29
- </Tooltip>
30
- <ToolbarButton icon="format_bold" prop="bold"/>
31
- <ToolbarButton icon="format_italic" prop="italic"/>
32
- <ToolbarButton icon="format_strikethrough" prop="strike"/>
33
- <ToolbarButton icon="format_underlined" prop="underline"/>
34
- <ToolbarButton icon="functions" handler={() => {
35
- const end = $tiptap.state.selection.$to.pos;
36
- $tiptap.chain().focus().insertContent({
37
- type: 'math_inline',
38
- }).insertContent(' ').run();
39
- }}/>
40
- <ToolbarButton icon="code" prop="code"/>
41
- </main>
42
- </FloatingMenu>
12
+ {#if tiptap}
13
+ <FloatingMenu editor={tiptap} tippyOptions={{ animation: 'fade', duration: [200, 50] }}>
14
+ <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
15
+ <main onmousedown={() => setTimeout(() => tiptap.commands.focus())}>
16
+ <span>
17
+ {i18n('newLineInfo')}
18
+ </span>
19
+ <Paper bl hover width="160px">
20
+ {#snippet target()}
21
+ <IconButton size="1.2em" icon="text_fields" />
22
+ {/snippet}
23
+ <div style="margin: -6px">
24
+ <List>
25
+ <OneLine
26
+ icon="counter_1"
27
+ title="{i18n('title')} 1"
28
+ onclick={() => tiptap.commands.setHeading({ level: 1 })}
29
+ />
30
+ <OneLine
31
+ icon="counter_2"
32
+ title="{i18n('title')} 2"
33
+ onclick={() => tiptap.commands.setHeading({ level: 2 })}
34
+ />
35
+ <OneLine
36
+ icon="counter_3"
37
+ title="{i18n('title')} 3"
38
+ onclick={() => tiptap.commands.setHeading({ level: 3 })}
39
+ />
40
+ <OneLine
41
+ icon="segment"
42
+ title={i18n('paragraph')}
43
+ onclick={() => tiptap.commands.setParagraph()}
44
+ />
45
+ </List>
46
+ </div>
47
+ </Paper>
48
+ <ToolbarButton icon="format_bold" prop="bold" />
49
+ <ToolbarButton icon="format_italic" prop="italic" />
50
+ <ToolbarButton icon="format_strikethrough" prop="strike" />
51
+ <ToolbarButton icon="format_underlined" prop="underline" />
52
+ <ToolbarButton
53
+ icon="functions"
54
+ handler={() => {
55
+ const end = tiptap.state.selection.$to.pos;
56
+ tiptap
57
+ .chain()
58
+ .focus()
59
+ .insertContent({
60
+ type: 'math_inline'
61
+ })
62
+ .insertContent(' ')
63
+ .run();
64
+ }}
65
+ />
66
+ <ToolbarButton icon="code" prop="code" />
67
+ </main>
68
+ </FloatingMenu>
43
69
  {/if}
44
70
 
45
71
  <style>span {
@@ -54,4 +80,4 @@ main {
54
80
  }
55
81
  main > :global(*) {
56
82
  margin-right: 4px;
57
- }</style>
83
+ }</style>
@@ -1,14 +1,2 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: Record<string, never>;
4
- events: {
5
- [evt: string]: CustomEvent<any>;
6
- };
7
- slots: {};
8
- };
9
- export type FloatingProps = typeof __propDef.props;
10
- export type FloatingEvents = typeof __propDef.events;
11
- export type FloatingSlots = typeof __propDef.slots;
12
- export default class Floating extends SvelteComponentTyped<FloatingProps, FloatingEvents, FloatingSlots> {
13
- }
14
- export {};
1
+ declare const Floating: import("svelte").Component<Record<string, never>, {}, "">;
2
+ export default Floating;