@seorii/tiptap 0.2.13 → 0.2.15
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/ko-kr/index.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/plugin/command/suggest.d.ts +1 -0
- package/dist/plugin/command/suggest.js +21 -9
- package/dist/tiptap/Command.svelte +28 -46
- package/dist/tiptap/TipTap.svelte +9 -1
- package/dist/tiptap/TipTap.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/i18n/ko-kr/index.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -30,6 +30,10 @@ function fixRange(editor, range, split = '/') {
|
|
|
30
30
|
}
|
|
31
31
|
return range;
|
|
32
32
|
}
|
|
33
|
+
export function getDetail(editor, range, opt) {
|
|
34
|
+
slashSelection.set(() => editor.chain().focus().deleteRange(fixRange(editor, range)).run());
|
|
35
|
+
slashDetail.set(opt);
|
|
36
|
+
}
|
|
33
37
|
export const suggest = {
|
|
34
38
|
pluginKey: new PluginKey('slash-suggest'),
|
|
35
39
|
char: '/',
|
|
@@ -128,7 +132,10 @@ export const suggest = {
|
|
|
128
132
|
title: i18n('table'),
|
|
129
133
|
subtitle: i18n('tableInfo'),
|
|
130
134
|
command: ({ editor, range }) => {
|
|
131
|
-
editor.chain().focus().deleteRange(fixRange(editor, range)).insertTable({
|
|
135
|
+
editor.chain().focus().deleteRange(fixRange(editor, range)).insertTable({
|
|
136
|
+
rows: 2,
|
|
137
|
+
cols: 3
|
|
138
|
+
}).run();
|
|
132
139
|
}
|
|
133
140
|
},
|
|
134
141
|
{
|
|
@@ -143,19 +150,24 @@ export const suggest = {
|
|
|
143
150
|
icon: 'iframe',
|
|
144
151
|
title: i18n('iframe'),
|
|
145
152
|
subtitle: i18n('iframeInfo'),
|
|
146
|
-
command: ({ editor, range }) => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
command: ({ editor, range }) => getDetail(editor, range, {
|
|
154
|
+
title: 'iframe', placeholder: 'url', handler: (input) => {
|
|
155
|
+
editor.chain().focus().insertContent([{
|
|
156
|
+
type: 'iframe',
|
|
157
|
+
attrs: { src: input }
|
|
158
|
+
}, { type: 'paragraph' }]).run();
|
|
159
|
+
}
|
|
160
|
+
})
|
|
150
161
|
},
|
|
151
162
|
{
|
|
152
163
|
icon: 'youtube_activity',
|
|
153
164
|
title: i18n('youtube'),
|
|
154
165
|
subtitle: i18n('youtubeInfo'),
|
|
155
|
-
command: ({ editor, range }) => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
166
|
+
command: ({ editor, range }) => getDetail(editor, range, {
|
|
167
|
+
title: 'youtube', placeholder: 'url', handler: (input) => {
|
|
168
|
+
editor.chain().focus().insertVideoPlayer({ url: input }).insertContent('\n').run();
|
|
169
|
+
}
|
|
170
|
+
})
|
|
159
171
|
}
|
|
160
172
|
]
|
|
161
173
|
}
|
|
@@ -7,9 +7,9 @@ import i18n from "../i18n";
|
|
|
7
7
|
const tiptap = getContext('editor');
|
|
8
8
|
export let selectedIndex = 0;
|
|
9
9
|
let height = 0, elements = [];
|
|
10
|
-
let
|
|
10
|
+
let input = '', focus;
|
|
11
11
|
$: if ($slashVisible) {
|
|
12
|
-
|
|
12
|
+
input = '';
|
|
13
13
|
}
|
|
14
14
|
$: setTimeout(() => focus?.focus?.(), 100);
|
|
15
15
|
</script>
|
|
@@ -21,50 +21,7 @@ $: setTimeout(() => focus?.focus?.(), 100);
|
|
|
21
21
|
<main style="left: {$slashLocaltion.x}px; top: {$slashLocaltion.y + $slashLocaltion.height + 384 > height
|
|
22
22
|
? $slashLocaltion.y - $slashLocaltion.height - 384
|
|
23
23
|
: $slashLocaltion.y + $slashLocaltion.height}px;" transition:fly={{y: 10, duration: 200, easing: quartOut}}>
|
|
24
|
-
{#if $slashDetail === '
|
|
25
|
-
<div class="detail">
|
|
26
|
-
<header>
|
|
27
|
-
<IconButton icon="arrow_back" on:click={() => $slashDetail = ''}/>
|
|
28
|
-
<div class="title">iframe</div>
|
|
29
|
-
</header>
|
|
30
|
-
<Input placeholder="url" fullWidth bind:value={iframe} bind:input={focus}
|
|
31
|
-
on:submit={() => $tiptap.chain().focus().insertContent([{type: 'iframe', attrs: {src: iframe}}, {type: 'paragraph'}]).run()}/>
|
|
32
|
-
<footer>
|
|
33
|
-
<Button tabindex="0" transparent small on:click={() => {
|
|
34
|
-
iframe = ''
|
|
35
|
-
$slashDetail = ''
|
|
36
|
-
}}>{i18n('cancel')}
|
|
37
|
-
</Button>
|
|
38
|
-
<Button tabindex="0" transparent small
|
|
39
|
-
on:click={() => {
|
|
40
|
-
$slashSelection?.();
|
|
41
|
-
$tiptap.chain().focus().insertContent([{type: 'iframe', attrs: {src: iframe}}, {type: 'paragraph'}]).run();
|
|
42
|
-
}}>{i18n('insert')}
|
|
43
|
-
</Button>
|
|
44
|
-
</footer>
|
|
45
|
-
</div>
|
|
46
|
-
{:else if $slashDetail === 'youtube'}
|
|
47
|
-
<div class="detail">
|
|
48
|
-
<header>
|
|
49
|
-
<IconButton icon="arrow_back" on:click={() => $slashDetail = ''}/>
|
|
50
|
-
<div class="title">Youtube</div>
|
|
51
|
-
</header>
|
|
52
|
-
<Input placeholder="url" fullWidth bind:value={iframe} bind:input={focus}
|
|
53
|
-
on:submit={() => $tiptap.chain().focus().insertVideoPlayer({url: iframe}).insertContent('\n').run()}/>
|
|
54
|
-
<footer>
|
|
55
|
-
<Button tabindex="0" transparent small on:click={() => {
|
|
56
|
-
iframe = ''
|
|
57
|
-
$slashDetail = ''
|
|
58
|
-
}}>{i18n('cancel')}
|
|
59
|
-
</Button>
|
|
60
|
-
<Button tabindex="0" transparent small on:click={() => {
|
|
61
|
-
$slashSelection?.();
|
|
62
|
-
$tiptap.chain().focus().insertVideoPlayer({url: iframe}).insertContent('\n').run();
|
|
63
|
-
}}>{i18n('insert')}
|
|
64
|
-
</Button>
|
|
65
|
-
</footer>
|
|
66
|
-
</div>
|
|
67
|
-
{:else if $slashDetail === 'emoji'}
|
|
24
|
+
{#if $slashDetail === 'emoji'}
|
|
68
25
|
<div class="list">
|
|
69
26
|
<List>
|
|
70
27
|
{#each $slashItems as {title, command}, i(title)}
|
|
@@ -81,6 +38,31 @@ $: setTimeout(() => focus?.focus?.(), 100);
|
|
|
81
38
|
{/if}
|
|
82
39
|
</List>
|
|
83
40
|
</div>
|
|
41
|
+
{:else if $slashDetail}
|
|
42
|
+
<div class="detail">
|
|
43
|
+
<header>
|
|
44
|
+
<IconButton icon="arrow_back" on:click={() => $slashDetail = null}/>
|
|
45
|
+
<div class="title">{$slashDetail.title}</div>
|
|
46
|
+
</header>
|
|
47
|
+
<Input placeholder={$slashDetail.placeholder} fullWidth bind:value={input} bind:input={focus}
|
|
48
|
+
on:submit={() => {
|
|
49
|
+
$slashSelection?.();
|
|
50
|
+
$slashDetail.handler(input)
|
|
51
|
+
}}/>
|
|
52
|
+
<footer>
|
|
53
|
+
<Button tabindex="0" transparent small on:click={() => {
|
|
54
|
+
input = ''
|
|
55
|
+
$slashDetail = null
|
|
56
|
+
}}>{i18n('cancel')}
|
|
57
|
+
</Button>
|
|
58
|
+
<Button tabindex="0" transparent small
|
|
59
|
+
on:click={() => {
|
|
60
|
+
$slashSelection?.();
|
|
61
|
+
$slashDetail.handler(input);
|
|
62
|
+
}}>{i18n('insert')}
|
|
63
|
+
</Button>
|
|
64
|
+
</footer>
|
|
65
|
+
</div>
|
|
84
66
|
{:else}
|
|
85
67
|
<div class="list">
|
|
86
68
|
<List>
|
|
@@ -10,7 +10,7 @@ import { slashItems, slashProps, slashVisible } from "../plugin/command/stores";
|
|
|
10
10
|
import i18n from "../i18n";
|
|
11
11
|
import { fallbackUpload } from "../plugin/image/dragdrop";
|
|
12
12
|
const san = (body) => sanitizeHtml(body, {
|
|
13
|
-
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'math-inline', 'math-node', 'iframe', '
|
|
13
|
+
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'math-inline', 'math-node', 'iframe', 'lite-youtube', 'blockquote', 'embed', ...allowedTags]),
|
|
14
14
|
allowedStyles: '*', allowedAttributes: {
|
|
15
15
|
'*': ['style', 'class'],
|
|
16
16
|
a: ['href', 'name', 'target'],
|
|
@@ -26,6 +26,7 @@ const san = (body) => sanitizeHtml(body, {
|
|
|
26
26
|
export let body = '', editable = false, ref = null, options = {}, loaded = false;
|
|
27
27
|
export let imageUpload = fallbackUpload, style = '';
|
|
28
28
|
export let blocks = [], placeholder = i18n('placeholder');
|
|
29
|
+
export let allowedTags = [];
|
|
29
30
|
export let colors = [
|
|
30
31
|
'#ef5350', //red
|
|
31
32
|
'#ec407a', //pink
|
|
@@ -173,6 +174,10 @@ main .wrapper {
|
|
|
173
174
|
outline: 3px solid var(--primary);
|
|
174
175
|
}
|
|
175
176
|
|
|
177
|
+
.editable :global(lite-youtube.ProseMirror-selectednode) {
|
|
178
|
+
outline: 3px solid var(--primary);
|
|
179
|
+
}
|
|
180
|
+
|
|
176
181
|
div > :global(div) {
|
|
177
182
|
outline: none !important;
|
|
178
183
|
}
|
|
@@ -222,6 +227,9 @@ div > :global(div) :global(table) :global(th), div > :global(div) :global(table)
|
|
|
222
227
|
div > :global(div) :global(.math-render) {
|
|
223
228
|
cursor: initial;
|
|
224
229
|
}
|
|
230
|
+
div > :global(div) :global(lite-youtube) {
|
|
231
|
+
border-radius: 12px;
|
|
232
|
+
}
|
|
225
233
|
div > :global(div) :global(.iframe-wrapper) {
|
|
226
234
|
position: relative;
|
|
227
235
|
padding-bottom: 12px;
|