@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
|
@@ -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
|
});
|
|
@@ -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) =>
|
|
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];
|
package/dist/plugin/youtube.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
2
|
export interface VideoPlayerOptions {
|
|
3
3
|
HTMLAttributes: Record<string, any>;
|
|
4
4
|
}
|
|
5
|
-
declare module
|
|
5
|
+
declare module '@tiptap/core' {
|
|
6
6
|
interface Commands<ReturnType> {
|
|
7
7
|
videoPlayer: {
|
|
8
8
|
insertVideoPlayer: (options: {
|
package/dist/plugin/youtube.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from
|
|
2
|
-
import { Plugin, PluginKey } from
|
|
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:
|
|
11
|
-
content:
|
|
12
|
-
marks:
|
|
13
|
-
group:
|
|
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:
|
|
22
|
-
}
|
|
21
|
+
default: 'youtube'
|
|
22
|
+
}
|
|
23
23
|
};
|
|
24
24
|
},
|
|
25
25
|
parseHTML() {
|
|
26
26
|
return [
|
|
27
27
|
{
|
|
28
|
-
tag:
|
|
29
|
-
}
|
|
28
|
+
tag: 'lite-youtube'
|
|
29
|
+
}
|
|
30
30
|
];
|
|
31
31
|
},
|
|
32
32
|
renderHTML({ HTMLAttributes }) {
|
|
33
33
|
return [
|
|
34
|
-
|
|
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()
|
|
46
|
+
return chain()
|
|
47
|
+
.insertContentAt(pos.before(), [
|
|
48
|
+
{
|
|
47
49
|
type: this.name,
|
|
48
|
-
attrs: { videoid, provider:
|
|
49
|
-
}
|
|
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(
|
|
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 =
|
|
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
|
|
94
|
+
this.editor
|
|
95
|
+
.chain()
|
|
96
|
+
.insertContentAt(pos.before(), [
|
|
97
|
+
{
|
|
91
98
|
type: this.name,
|
|
92
|
-
attrs: { videoid, provider:
|
|
93
|
-
}
|
|
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>
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
38
|
-
<BubbleMenu
|
|
39
|
-
|
|
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
|
-
<
|
|
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"
|
|
94
|
+
<Input placeholder="url" bind:value={href} autofocus />
|
|
53
95
|
<div>
|
|
54
|
-
<Button
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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={() =>
|
|
114
|
+
<ToolbarButton icon="cell_merge" handler={() => tiptap.commands.mergeCells()} />
|
|
67
115
|
{:else}
|
|
68
|
-
<ToolbarButton icon="splitscreen_left" handler={() =>
|
|
116
|
+
<ToolbarButton icon="splitscreen_left" handler={() => tiptap.commands.splitCell()} />
|
|
69
117
|
{/if}
|
|
70
|
-
<ToolbarButton
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<ToolbarButton
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<ToolbarButton
|
|
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
|
-
<
|
|
82
|
-
|
|
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
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<OneLine
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
</
|
|
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(
|
|
179
|
+
<ToolbarButton icon="functions" handler={() => setMath(tiptap)} />
|
|
110
180
|
{/if}
|
|
111
|
-
<
|
|
112
|
-
|
|
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
|
-
<
|
|
115
|
-
<Button small outlined
|
|
186
|
+
<div class="colors">
|
|
187
|
+
<Button small outlined onclick={() => tiptap.chain().focus().unsetColor().run()}>
|
|
116
188
|
{i18n('default')}
|
|
117
189
|
</Button>
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
|
129
|
-
|
|
130
|
-
|
|
211
|
+
<Button
|
|
212
|
+
small
|
|
213
|
+
outlined
|
|
214
|
+
onclick={() => tiptap.chain().focus().setColor(color).run()}
|
|
215
|
+
>
|
|
131
216
|
<span
|
|
132
|
-
|
|
217
|
+
style:background={color}
|
|
218
|
+
class="pal"
|
|
219
|
+
></span>
|
|
133
220
|
</Button>
|
|
134
221
|
{/each}
|
|
135
|
-
</
|
|
222
|
+
</div>
|
|
136
223
|
</div>
|
|
137
|
-
</
|
|
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
|
-
<
|
|
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
|
-
}
|
|
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
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|