@seorii/tiptap 0.3.0-next.9 → 0.3.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/dist/i18n/index.d.ts +106 -6
- package/dist/i18n/index.js +56 -11
- package/dist/plugin/command/emoji.d.ts +3 -17
- package/dist/plugin/command/emoji.js +51 -24
- package/dist/plugin/command/stores.svelte.d.ts +52 -0
- package/dist/plugin/command/stores.svelte.js +69 -0
- package/dist/plugin/command/suggest.d.ts +6 -19
- package/dist/plugin/command/suggest.js +133 -51
- package/dist/plugin/embed.d.ts +2 -2
- package/dist/plugin/embed.js +5 -1
- package/dist/plugin/image/dragdrop.d.ts +2 -0
- package/dist/plugin/image/dragdrop.js +66 -2
- package/dist/plugin/image/index.js +3 -2
- package/dist/plugin/indent.js +0 -1
- package/dist/plugin/orderedlist/index.d.ts +1 -1
- package/dist/plugin/orderedlist/index.js +1 -1
- package/dist/plugin/orderedlist/{korean.scss → korean.css} +2 -2
- package/dist/plugin/table/index.d.ts +1 -1
- package/dist/plugin/table/index.js +19 -11
- package/dist/plugin/table/style/{cell.scss → cell.css} +6 -5
- package/dist/plugin/table/style/{grip.scss → grip.css} +14 -19
- package/dist/plugin/table/style/resize.css +28 -0
- package/dist/plugin/table/style/{table.scss → table.css} +15 -17
- package/dist/plugin/table/style.css +4 -0
- package/dist/plugin/table/tableCell/index.js +2 -4
- package/dist/plugin/table/tableHeader/index.js +1 -2
- package/dist/tiptap/Bubble.svelte +104 -70
- package/dist/tiptap/Bubble.svelte.d.ts +8 -6
- package/dist/tiptap/Command.svelte +160 -158
- package/dist/tiptap/Command.svelte.d.ts +2 -3
- package/dist/tiptap/Floating.svelte +51 -24
- package/dist/tiptap/Floating.svelte.d.ts +1 -0
- package/dist/tiptap/TipTap.svelte +210 -133
- package/dist/tiptap/TipTap.svelte.d.ts +7 -3
- package/dist/tiptap/ToolbarButton.svelte +30 -10
- package/dist/tiptap/ToolbarButton.svelte.d.ts +10 -6
- package/dist/tiptap/setMath.d.ts +2 -1
- package/dist/tiptap/setMath.js +74 -12
- package/dist/tiptap/tiptap.d.ts +9 -1
- package/dist/tiptap/tiptap.js +170 -16
- package/package.json +63 -57
- package/dist/plugin/command/stores.d.ts +0 -13
- package/dist/plugin/command/stores.js +0 -7
- package/dist/plugin/table/style/resize.scss +0 -26
- package/dist/plugin/table/style.scss +0 -4
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
$grip-margin: 3px;
|
|
2
|
-
|
|
3
1
|
.ProseMirror table {
|
|
4
|
-
.grip-column {
|
|
2
|
+
& .grip-column {
|
|
5
3
|
position: absolute;
|
|
6
4
|
top: -0.7em;
|
|
7
5
|
left: 0;
|
|
8
6
|
z-index: 10;
|
|
9
7
|
display: block;
|
|
10
|
-
width: calc(100% -
|
|
8
|
+
width: calc(100% - 6px);
|
|
11
9
|
height: 0.4em;
|
|
12
|
-
margin: 0
|
|
10
|
+
margin: 0 3px 3px 3px;
|
|
13
11
|
background: var(--primary-light3);
|
|
14
12
|
opacity: 0;
|
|
15
13
|
border-radius: 10px;
|
|
16
|
-
|
|
17
14
|
transition: all 0.1s ease-in-out;
|
|
18
15
|
|
|
19
16
|
&:hover,
|
|
@@ -22,19 +19,18 @@ $grip-margin: 3px;
|
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
.grip-row {
|
|
22
|
+
& .grip-row {
|
|
26
23
|
position: absolute;
|
|
27
24
|
top: 0;
|
|
28
25
|
left: -0.7em;
|
|
29
26
|
z-index: 10;
|
|
30
27
|
display: block;
|
|
31
28
|
width: 0.4em;
|
|
32
|
-
height: calc(100% -
|
|
33
|
-
margin:
|
|
29
|
+
height: calc(100% - 6px);
|
|
30
|
+
margin: 3px 3px 3px 0;
|
|
34
31
|
background: var(--primary-light3);
|
|
35
32
|
opacity: 0;
|
|
36
33
|
border-radius: 10px;
|
|
37
|
-
|
|
38
34
|
transition: all 0.1s ease-in-out;
|
|
39
35
|
|
|
40
36
|
&:hover,
|
|
@@ -43,7 +39,7 @@ $grip-margin: 3px;
|
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
.grip-table {
|
|
42
|
+
& .grip-table {
|
|
47
43
|
position: absolute;
|
|
48
44
|
top: -0.8em;
|
|
49
45
|
left: -0.8em;
|
|
@@ -54,7 +50,6 @@ $grip-margin: 3px;
|
|
|
54
50
|
background: var(--primary-light3);
|
|
55
51
|
border-radius: 50%;
|
|
56
52
|
opacity: 0;
|
|
57
|
-
|
|
58
53
|
transition: all 0.1s ease-in-out;
|
|
59
54
|
|
|
60
55
|
&:hover,
|
|
@@ -62,13 +57,13 @@ $grip-margin: 3px;
|
|
|
62
57
|
background: var(--primary-light6);
|
|
63
58
|
}
|
|
64
59
|
}
|
|
60
|
+
}
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
62
|
+
.editable .ProseMirror table {
|
|
63
|
+
& .grip-column,
|
|
64
|
+
& .grip-row,
|
|
65
|
+
& .grip-table {
|
|
66
|
+
opacity: 1;
|
|
67
|
+
cursor: pointer;
|
|
73
68
|
}
|
|
74
69
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.ProseMirror {
|
|
2
|
+
& table .column-resize-handle {
|
|
3
|
+
position: absolute;
|
|
4
|
+
top: 0;
|
|
5
|
+
right: -2px;
|
|
6
|
+
bottom: -2px;
|
|
7
|
+
width: 4px;
|
|
8
|
+
pointer-events: none;
|
|
9
|
+
background-color: var(--primary-light6);
|
|
10
|
+
opacity: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&.resize-cursor {
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.editable .ProseMirror {
|
|
19
|
+
& table .column-resize-handle {
|
|
20
|
+
opacity: 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.resize-cursor {
|
|
24
|
+
pointer-events: initial;
|
|
25
|
+
cursor: ew-resize;
|
|
26
|
+
cursor: col-resize; /* stylelint-disable declaration-block-no-duplicate-properties */
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.ProseMirror {
|
|
2
|
-
.tableWrapper {
|
|
2
|
+
& .tableWrapper {
|
|
3
3
|
position: relative;
|
|
4
4
|
margin-top: 0.75em;
|
|
5
5
|
scrollbar-width: thin;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
transition: all 0.1s ease-in-out;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.scrollable {
|
|
10
|
+
& .scrollable {
|
|
11
11
|
padding-left: 1em;
|
|
12
12
|
margin-left: -1em;
|
|
13
13
|
overflow: auto hidden;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
transition: border 250ms ease-in-out 0s;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.scrollable-shadow {
|
|
19
|
+
& .scrollable-shadow {
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
22
|
bottom: 0;
|
|
@@ -52,17 +52,17 @@
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
table {
|
|
55
|
+
& table {
|
|
56
56
|
margin-top: 1em;
|
|
57
57
|
border-radius: 4px;
|
|
58
58
|
border-collapse: collapse;
|
|
59
59
|
box-sizing: border-box;
|
|
60
60
|
width: 100% !important;
|
|
61
61
|
|
|
62
|
-
h1,
|
|
63
|
-
h2,
|
|
64
|
-
h3,
|
|
65
|
-
p {
|
|
62
|
+
& h1,
|
|
63
|
+
& h2,
|
|
64
|
+
& h3,
|
|
65
|
+
& p {
|
|
66
66
|
margin: 0;
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -72,15 +72,13 @@
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
.editable {
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
75
|
+
.editable .ProseMirror {
|
|
76
|
+
& .tableWrapper {
|
|
77
|
+
padding: 10px;
|
|
78
|
+
}
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
80
|
+
& .selectedCell {
|
|
81
|
+
border-style: double;
|
|
82
|
+
background: var(--primary-light3);
|
|
85
83
|
}
|
|
86
84
|
}
|
|
@@ -18,14 +18,12 @@ export default BuiltInTableCell.extend({
|
|
|
18
18
|
};
|
|
19
19
|
},
|
|
20
20
|
addProseMirrorPlugins() {
|
|
21
|
-
const { isEditable } = this.editor;
|
|
22
21
|
return [
|
|
23
22
|
new Plugin({
|
|
24
23
|
props: {
|
|
25
24
|
decorations: (state) => {
|
|
26
|
-
if (!isEditable)
|
|
27
|
-
|
|
28
|
-
}
|
|
25
|
+
if (!this.editor.isEditable)
|
|
26
|
+
return DecorationSet.empty;
|
|
29
27
|
const { doc, selection } = state;
|
|
30
28
|
const decorations = [];
|
|
31
29
|
const cells = getCellsInColumn(0)(selection);
|
|
@@ -18,12 +18,11 @@ export default BuiltInTableHeader.extend({
|
|
|
18
18
|
};
|
|
19
19
|
},
|
|
20
20
|
addProseMirrorPlugins() {
|
|
21
|
-
const { isEditable } = this.editor;
|
|
22
21
|
return [
|
|
23
22
|
new Plugin({
|
|
24
23
|
props: {
|
|
25
24
|
decorations: (state) => {
|
|
26
|
-
if (!isEditable)
|
|
25
|
+
if (!this.editor.isEditable)
|
|
27
26
|
return DecorationSet.empty;
|
|
28
27
|
const { doc, selection } = state;
|
|
29
28
|
const decorations = [];
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { BubbleMenu } from 'svelte-tiptap';
|
|
3
|
-
import { getContext, tick } from 'svelte';
|
|
3
|
+
import { flushSync, getContext, tick, untrack } from 'svelte';
|
|
4
4
|
import 'tippy.js/animations/shift-away-subtle.css';
|
|
5
5
|
import ToolbarButton from './ToolbarButton.svelte';
|
|
6
6
|
import { isTableAnySelected } from '../plugin/table/util';
|
|
7
7
|
import deleteTable from '../plugin/table/deleteTable';
|
|
8
8
|
import setMath from './setMath';
|
|
9
9
|
import { Button, Icon, IconButton, Input, List, OneLine, Paper, Render } from 'nunui';
|
|
10
|
-
import
|
|
10
|
+
import defaultI18n, { I18N_CONTEXT, type I18nTranslate } from '../i18n';
|
|
11
11
|
import ColorPicker from 'svelte-awesome-color-picker';
|
|
12
12
|
import { isTextSelection } from '@tiptap/core';
|
|
13
|
+
import type { EditorState, Selection } from '@tiptap/pm/state';
|
|
14
|
+
import type { EditorView } from '@tiptap/pm/view';
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
type Props = {
|
|
17
|
+
colors?: string[];
|
|
18
|
+
editable?: boolean;
|
|
19
|
+
override?: any;
|
|
20
|
+
children?: any;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let { colors = [], editable, override, children }: Props = $props();
|
|
15
24
|
|
|
16
25
|
const editor = getContext<{ v: any; c: number }>('editor');
|
|
26
|
+
const i18nFromContext = getContext<I18nTranslate | undefined>(I18N_CONTEXT);
|
|
27
|
+
const i18n: I18nTranslate = (...args) =>
|
|
28
|
+
i18nFromContext ? i18nFromContext(...args) : defaultI18n(...args);
|
|
17
29
|
const tiptap = $derived(editor.v);
|
|
18
30
|
|
|
19
|
-
let selection = $state(null);
|
|
20
|
-
let table = $state(false);
|
|
31
|
+
let selection = $state<Selection | null>(null);
|
|
32
|
+
let table = $state<number[] | false>(false);
|
|
21
33
|
let sel = $state('');
|
|
22
34
|
let _sel = $state('');
|
|
23
35
|
let link = $state(false);
|
|
@@ -25,6 +37,7 @@
|
|
|
25
37
|
|
|
26
38
|
$effect(() => {
|
|
27
39
|
let _ = editor.c;
|
|
40
|
+
flushSync();
|
|
28
41
|
selection = tiptap?.state?.selection;
|
|
29
42
|
});
|
|
30
43
|
|
|
@@ -45,16 +58,30 @@
|
|
|
45
58
|
});
|
|
46
59
|
|
|
47
60
|
$effect(() => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
const _href = href;
|
|
62
|
+
untrack(() => {
|
|
63
|
+
if (tiptap && link) {
|
|
64
|
+
if (href) {
|
|
65
|
+
tiptap.chain().setLink({ href: _href }).run();
|
|
66
|
+
} else if (tiptap.getAttributes('link').href) {
|
|
67
|
+
tiptap.chain().unsetLink().run();
|
|
68
|
+
}
|
|
53
69
|
}
|
|
54
|
-
}
|
|
70
|
+
});
|
|
55
71
|
});
|
|
56
72
|
|
|
57
|
-
const shouldShow = ({
|
|
73
|
+
const shouldShow = ({
|
|
74
|
+
state,
|
|
75
|
+
from,
|
|
76
|
+
to
|
|
77
|
+
}: {
|
|
78
|
+
view: EditorView;
|
|
79
|
+
state: EditorState;
|
|
80
|
+
from: number;
|
|
81
|
+
to: number;
|
|
82
|
+
}) => {
|
|
83
|
+
if (!tiptap?.isEditable) return false;
|
|
84
|
+
|
|
58
85
|
const { doc, selection } = state;
|
|
59
86
|
const { empty } = selection;
|
|
60
87
|
|
|
@@ -87,10 +114,10 @@
|
|
|
87
114
|
<Icon icon="link" />
|
|
88
115
|
{i18n('link')}
|
|
89
116
|
</p>
|
|
90
|
-
<Input placeholder="url"
|
|
117
|
+
<Input placeholder="url" bind:value={href} autofocus />
|
|
91
118
|
<div>
|
|
92
119
|
<Button
|
|
93
|
-
tabindex=
|
|
120
|
+
tabindex={0}
|
|
94
121
|
transparent
|
|
95
122
|
small
|
|
96
123
|
onclick={() => {
|
|
@@ -100,7 +127,7 @@
|
|
|
100
127
|
}}
|
|
101
128
|
>{i18n('delete')}
|
|
102
129
|
</Button>
|
|
103
|
-
<Button tabindex=
|
|
130
|
+
<Button tabindex={0} transparent small onclick={() => (link = false)}
|
|
104
131
|
>{i18n('close')}</Button
|
|
105
132
|
>
|
|
106
133
|
</div>
|
|
@@ -172,7 +199,7 @@
|
|
|
172
199
|
<ToolbarButton icon="subscript" prop="subscript" />
|
|
173
200
|
<ToolbarButton icon="border_color" prop="highlight" />
|
|
174
201
|
{#if editable}
|
|
175
|
-
<ToolbarButton icon="functions" handler={() => setMath(tiptap)} />
|
|
202
|
+
<ToolbarButton icon="functions" prop="math_inline" handler={() => setMath(tiptap)} />
|
|
176
203
|
{/if}
|
|
177
204
|
<Paper bl block>
|
|
178
205
|
{#snippet target()}
|
|
@@ -191,10 +218,13 @@
|
|
|
191
218
|
outlined
|
|
192
219
|
onclick={() => tiptap.chain().focus().unsetColor().run()}
|
|
193
220
|
>
|
|
194
|
-
<Icon
|
|
221
|
+
<Icon icon="palette" />
|
|
195
222
|
</Button>
|
|
196
223
|
{/snippet}
|
|
197
|
-
<div
|
|
224
|
+
<div
|
|
225
|
+
onclick={(event) => event.stopPropagation()}
|
|
226
|
+
onmousedown={(event) => event.stopPropagation()}
|
|
227
|
+
>
|
|
198
228
|
<ColorPicker
|
|
199
229
|
isDialog={false}
|
|
200
230
|
onInput={(event) => {
|
|
@@ -209,10 +239,7 @@
|
|
|
209
239
|
outlined
|
|
210
240
|
onclick={() => tiptap.chain().focus().setColor(color).run()}
|
|
211
241
|
>
|
|
212
|
-
<span
|
|
213
|
-
style:background={color}
|
|
214
|
-
class="pal"
|
|
215
|
-
></span>
|
|
242
|
+
<span style:background={color} class="pal"></span>
|
|
216
243
|
</Button>
|
|
217
244
|
{/each}
|
|
218
245
|
</div>
|
|
@@ -229,54 +256,61 @@
|
|
|
229
256
|
</BubbleMenu>
|
|
230
257
|
{/if}
|
|
231
258
|
|
|
232
|
-
<style>
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
259
|
+
<style>
|
|
260
|
+
main {
|
|
261
|
+
box-shadow: var(--shadow);
|
|
262
|
+
background: var(--surface, #fff);
|
|
263
|
+
color: var(--on-surface, #000);
|
|
264
|
+
padding: 8px;
|
|
265
|
+
border-radius: 4px;
|
|
266
|
+
display: flex;
|
|
267
|
+
align-items: center;
|
|
268
|
+
justify-content: center;
|
|
269
|
+
font-size: 1.2em;
|
|
270
|
+
& > :global(*) {
|
|
271
|
+
margin: 0 2px;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
& > :global(*:first-child) {
|
|
275
|
+
margin-left: 0;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
& > :global(*:last-child) {
|
|
279
|
+
margin-right: 0;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.link {
|
|
284
|
+
display: flex;
|
|
285
|
+
flex-direction: column;
|
|
286
|
+
font-size: 0.7em;
|
|
287
|
+
|
|
288
|
+
& p {
|
|
289
|
+
margin: 0 0 0.6em 0;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
& div {
|
|
293
|
+
margin-top: 0.6em;
|
|
294
|
+
display: flex;
|
|
295
|
+
justify-content: flex-end;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
252
298
|
|
|
253
|
-
.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
.link p {
|
|
259
|
-
margin: 0 0 0.6em 0;
|
|
260
|
-
}
|
|
261
|
-
.link div {
|
|
262
|
-
margin-top: 0.6em;
|
|
263
|
-
display: flex;
|
|
264
|
-
justify-content: flex-end;
|
|
265
|
-
}
|
|
299
|
+
.colors {
|
|
300
|
+
display: grid;
|
|
301
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
302
|
+
gap: 4px;
|
|
266
303
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
.colors > :global(:first-child) {
|
|
273
|
-
grid-column: 1/3;
|
|
274
|
-
}
|
|
304
|
+
& > :global(:first-child) {
|
|
305
|
+
grid-column: 1/3;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
275
308
|
|
|
276
|
-
.pal {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
309
|
+
.pal {
|
|
310
|
+
width: 20px;
|
|
311
|
+
height: 16px;
|
|
312
|
+
border-radius: 4px;
|
|
313
|
+
display: inline-block;
|
|
314
|
+
margin-bottom: -2px;
|
|
315
|
+
}
|
|
316
|
+
</style>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import 'tippy.js/animations/shift-away-subtle.css';
|
|
2
|
-
|
|
3
|
-
colors?:
|
|
4
|
-
editable
|
|
5
|
-
override
|
|
6
|
-
children
|
|
7
|
-
}
|
|
2
|
+
type Props = {
|
|
3
|
+
colors?: string[];
|
|
4
|
+
editable?: boolean;
|
|
5
|
+
override?: any;
|
|
6
|
+
children?: any;
|
|
7
|
+
};
|
|
8
|
+
declare const Bubble: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type Bubble = ReturnType<typeof Bubble>;
|
|
8
10
|
export default Bubble;
|