@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.
- package/dist/i18n/en-us/index.js +1 -1
- package/dist/i18n/index.js +2 -3
- package/dist/i18n/ko-kr/index.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/plugin/command/emoji.d.ts +2 -2
- package/dist/plugin/command/emoji.js +7 -3
- package/dist/plugin/command/stores.d.ts +0 -1
- package/dist/plugin/command/suggest.d.ts +2 -2
- package/dist/plugin/command/suggest.js +85 -26
- package/dist/plugin/embed.js +15 -9
- package/dist/plugin/iframe.js +19 -10
- package/dist/plugin/image/dragdrop.js +10 -12
- package/dist/plugin/image/index.d.ts +1 -1
- package/dist/plugin/image/index.js +12 -8
- package/dist/plugin/indent.js +16 -14
- package/dist/plugin/orderedlist/index.js +55 -23
- package/dist/plugin/orderedlist/korean.scss +12 -13
- package/dist/plugin/orderedlist/toggleList.js +7 -7
- package/dist/plugin/table/deleteTable.d.ts +1 -1
- package/dist/plugin/table/deleteTable.js +2 -2
- package/dist/plugin/table/index.js +10 -6
- package/dist/plugin/table/style/cell.scss +14 -13
- package/dist/plugin/table/style/grip.scss +61 -59
- package/dist/plugin/table/style/resize.scss +21 -23
- package/dist/plugin/table/style/table.scss +72 -69
- package/dist/plugin/table/tableCell/index.js +6 -6
- package/dist/plugin/table/tableHeader/index.js +6 -6
- package/dist/plugin/table/tableRow/index.js +1 -1
- package/dist/plugin/table/util.d.ts +2 -2
- package/dist/plugin/table/util.js +9 -9
- package/dist/plugin/youtube.d.ts +2 -2
- package/dist/plugin/youtube.js +35 -26
- package/dist/tiptap/Bubble.svelte +199 -95
- package/dist/tiptap/Bubble.svelte.d.ts +7 -21
- package/dist/tiptap/Command.svelte +125 -59
- package/dist/tiptap/Command.svelte.d.ts +4 -16
- package/dist/tiptap/Floating.svelte +67 -41
- package/dist/tiptap/Floating.svelte.d.ts +2 -14
- package/dist/tiptap/TipTap.svelte +210 -132
- package/dist/tiptap/TipTap.svelte.d.ts +18 -34
- package/dist/tiptap/ToolbarButton.svelte +33 -21
- package/dist/tiptap/ToolbarButton.svelte.d.ts +10 -25
- package/dist/tiptap/index.d.ts +1 -1
- package/dist/tiptap/index.js +2 -2
- package/dist/tiptap/setMath.js +5 -2
- package/dist/tiptap/tiptap.d.ts +2 -2
- package/dist/tiptap/tiptap.js +87 -76
- package/package.json +109 -102
|
@@ -1,102 +1,168 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
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"
|
|
21
|
-
<main
|
|
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;"
|
|
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
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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"
|
|
71
|
+
<IconButton icon="arrow_back" onclick={() => ($slashDetail = null)} />
|
|
45
72
|
<div class="title">{i18n('insertCode')}</div>
|
|
46
73
|
</header>
|
|
47
74
|
<div>
|
|
48
|
-
<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
|
|
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"
|
|
97
|
+
<IconButton icon="arrow_back" onclick={() => ($slashDetail = null)} />
|
|
58
98
|
<div class="title">{$slashDetail.title}</div>
|
|
59
99
|
</header>
|
|
60
|
-
<Input
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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 {
|
|
2
|
-
|
|
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;
|