goodteditor-ui 1.0.18 → 1.0.19
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/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { Button, Select, InputUnits, ColorPicker, ToolbarPopover, InputAuto, InputBrowse } from './renders';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @typedef {import('./WysiwygEditor').NodeType} NodeType
|
|
5
|
+
* @typedef {import('./WysiwygEditor').MarkType} MarkType
|
|
6
|
+
* @typedef {import('./WysiwygEditor').CommandType} CommandType
|
|
7
|
+
* @typedef {import('./WysiwygEditor').ToolType} ToolType
|
|
8
|
+
* @typedef {import('./WysiwygEditor').Render} Render
|
|
9
|
+
* @typedef {import('./WysiwygEditor').CommandDef} Command
|
|
10
|
+
* @typedef {import('./WysiwygEditor').ToolDef} Tool
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @type NodeType
|
|
5
15
|
*/
|
|
6
16
|
export const NodeType = Object.freeze({
|
|
7
17
|
BLOCKQUOTE: 'blockquote',
|
|
@@ -22,7 +32,7 @@ export const NodeType = Object.freeze({
|
|
|
22
32
|
});
|
|
23
33
|
|
|
24
34
|
/**
|
|
25
|
-
* @type
|
|
35
|
+
* @type MarkType
|
|
26
36
|
*/
|
|
27
37
|
export const MarkType = Object.freeze({
|
|
28
38
|
BOLD: 'bold',
|
|
@@ -35,7 +45,7 @@ export const MarkType = Object.freeze({
|
|
|
35
45
|
});
|
|
36
46
|
|
|
37
47
|
/**
|
|
38
|
-
* @type
|
|
48
|
+
* @type CommandType
|
|
39
49
|
*/
|
|
40
50
|
export const CommandType = Object.freeze({
|
|
41
51
|
/* paragraph style */
|
|
@@ -53,7 +63,7 @@ export const CommandType = Object.freeze({
|
|
|
53
63
|
});
|
|
54
64
|
|
|
55
65
|
/**
|
|
56
|
-
* @type
|
|
66
|
+
* @type ToolType
|
|
57
67
|
*/
|
|
58
68
|
export const ToolType = Object.freeze({
|
|
59
69
|
/* typography */
|
|
@@ -110,6 +120,10 @@ export const ToolType = Object.freeze({
|
|
|
110
120
|
INSERT_LINK: 'insertLink'
|
|
111
121
|
});
|
|
112
122
|
|
|
123
|
+
/**
|
|
124
|
+
* @param {Command} command
|
|
125
|
+
* @return Command
|
|
126
|
+
*/
|
|
113
127
|
export const createCommand = ({
|
|
114
128
|
name,
|
|
115
129
|
title = 'Unknown command',
|
|
@@ -125,7 +139,7 @@ export const createCommand = ({
|
|
|
125
139
|
});
|
|
126
140
|
|
|
127
141
|
/**
|
|
128
|
-
* @type
|
|
142
|
+
* @type Render
|
|
129
143
|
*/
|
|
130
144
|
export const Render = Object.freeze({
|
|
131
145
|
BUTTON: Button,
|
|
@@ -137,6 +151,10 @@ export const Render = Object.freeze({
|
|
|
137
151
|
INPUT_BROWSE: InputBrowse
|
|
138
152
|
});
|
|
139
153
|
|
|
154
|
+
/**
|
|
155
|
+
* @param {Tool} tool
|
|
156
|
+
* @return Tool
|
|
157
|
+
*/
|
|
140
158
|
export const createBaseTool = ({
|
|
141
159
|
name,
|
|
142
160
|
render = Render.BUTTON,
|
|
@@ -155,36 +173,64 @@ export const createBaseTool = ({
|
|
|
155
173
|
isEnabled
|
|
156
174
|
});
|
|
157
175
|
|
|
176
|
+
/**
|
|
177
|
+
* @param {Tool} toolOptions
|
|
178
|
+
* @return Tool
|
|
179
|
+
*/
|
|
158
180
|
export const createButtonTool = (toolOptions) => createBaseTool(toolOptions);
|
|
159
181
|
|
|
182
|
+
/**
|
|
183
|
+
* @param {Tool} tool
|
|
184
|
+
* @return Tool
|
|
185
|
+
*/
|
|
160
186
|
export const createSelectTool = ({ getValue = () => null, options = [], ...toolOptions }) => ({
|
|
161
187
|
...createBaseTool({ render: Render.SELECT, ...toolOptions }),
|
|
162
188
|
getValue,
|
|
163
189
|
options
|
|
164
190
|
});
|
|
165
191
|
|
|
192
|
+
/**
|
|
193
|
+
* @param {Tool} tool
|
|
194
|
+
* @return Tool
|
|
195
|
+
*/
|
|
166
196
|
export const createColorPickerTool = ({ getValue = () => null, ...toolOptions }) => ({
|
|
167
197
|
...createBaseTool({ render: Render.COLOR_PICKER, ...toolOptions }),
|
|
168
198
|
getValue
|
|
169
199
|
});
|
|
170
200
|
|
|
201
|
+
/**
|
|
202
|
+
* @param {Tool} tool
|
|
203
|
+
* @return Tool
|
|
204
|
+
*/
|
|
171
205
|
export const createInputUnitsTool = ({ getValue = () => null, units = [], ...toolOptions }) => ({
|
|
172
206
|
...createBaseTool({ render: Render.INPUT_UNITS, ...toolOptions }),
|
|
173
207
|
getValue,
|
|
174
208
|
units
|
|
175
209
|
});
|
|
176
210
|
|
|
211
|
+
/**
|
|
212
|
+
* @param {Tool} tool
|
|
213
|
+
* @return Tool
|
|
214
|
+
*/
|
|
177
215
|
export const createToolbarPopoverTool = ({ options = [], ...toolOptions }) => ({
|
|
178
216
|
...createBaseTool({ render: Render.TOOLBAR_POPOVER, ...toolOptions }),
|
|
179
217
|
options
|
|
180
218
|
});
|
|
181
219
|
|
|
220
|
+
/**
|
|
221
|
+
* @param {Tool} tool
|
|
222
|
+
* @return Tool
|
|
223
|
+
*/
|
|
182
224
|
export const createInputAutoTool = ({ getValue = () => null, options = [], ...toolOptions }) => ({
|
|
183
225
|
...createBaseTool({ render: Render.INPUT_AUTO, ...toolOptions }),
|
|
184
226
|
getValue,
|
|
185
227
|
options
|
|
186
228
|
});
|
|
187
229
|
|
|
230
|
+
/**
|
|
231
|
+
* @param {Tool} tool
|
|
232
|
+
* @return Tool
|
|
233
|
+
*/
|
|
188
234
|
export const createInputBrowseTool = ({ getValue = () => null, ...toolOptions }) => ({
|
|
189
235
|
...createBaseTool({ render: Render.INPUT_BROWSE, ...toolOptions }),
|
|
190
236
|
getValue
|
|
@@ -5,6 +5,7 @@ export { Dropcursor } from '@tiptap/extension-dropcursor';
|
|
|
5
5
|
export { Gapcursor } from '@tiptap/extension-gapcursor';
|
|
6
6
|
export { Color } from '@tiptap/extension-color';
|
|
7
7
|
export { FontFamily } from '@tiptap/extension-font-family';
|
|
8
|
+
export { HardBreak } from '@tiptap/extension-hard-break';
|
|
8
9
|
|
|
9
10
|
export { Table } from './table';
|
|
10
11
|
export { TableRow } from './table-row';
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
<grid class="editor" v-bind="$options.static.GridProps">
|
|
3
3
|
<template #editor-toolbar="{ style }">
|
|
4
4
|
<div :style="style" class="editor-toolbar">
|
|
5
|
+
<!--
|
|
6
|
+
@slot Toolbar slot
|
|
7
|
+
@binding {Tool[][]} toolGroups 2d matrix of using tools split into groups
|
|
8
|
+
@binding {Function} resolveGroupTitle resolve group title function(index:number)
|
|
9
|
+
@binding {Function} buildToolBinds build tool binds function(tool:Tool)
|
|
10
|
+
-->
|
|
5
11
|
<slot
|
|
6
12
|
v-if="editor != null"
|
|
7
13
|
name="toolbar"
|
|
@@ -13,6 +19,11 @@
|
|
|
13
19
|
class="col col-vmid col-auto">
|
|
14
20
|
<div class="d-flex flex-col flex-v-center">
|
|
15
21
|
<div class="group-header">
|
|
22
|
+
<!--
|
|
23
|
+
@slot Group header slot
|
|
24
|
+
@binding {number} groupIndex index of the tools group
|
|
25
|
+
@binding {Function} resolveGroupTitle resolve group title function(index:number)
|
|
26
|
+
-->
|
|
16
27
|
<slot name="group-header" v-bind="{ groupIndex, resolveGroupTitle }">
|
|
17
28
|
<div class="text-small text-center">{{ resolveGroupTitle(groupIndex) }}</div>
|
|
18
29
|
</slot>
|
|
@@ -22,6 +33,10 @@
|
|
|
22
33
|
v-for="tool of toolsGroup"
|
|
23
34
|
:key="tool.name"
|
|
24
35
|
class="tool d-inline-block">
|
|
36
|
+
<!--
|
|
37
|
+
@slot Tool slot
|
|
38
|
+
@binding {Tool} tool tool's already bound to editor context
|
|
39
|
+
-->
|
|
25
40
|
<slot name="tool" v-bind="buildToolBinds(tool)">
|
|
26
41
|
<component :is="tool.render" :tool="buildToolBinds(tool)" />
|
|
27
42
|
</slot>
|
|
@@ -89,6 +104,7 @@ export default {
|
|
|
89
104
|
},
|
|
90
105
|
/**
|
|
91
106
|
* @public
|
|
107
|
+
* func allows to receive image url from the environment
|
|
92
108
|
*/
|
|
93
109
|
getImageUrl: {
|
|
94
110
|
type: Function,
|
|
@@ -170,9 +186,17 @@ export default {
|
|
|
170
186
|
},
|
|
171
187
|
methods: {
|
|
172
188
|
onInput() {
|
|
189
|
+
/**
|
|
190
|
+
* Input event
|
|
191
|
+
* @property {string} value
|
|
192
|
+
*/
|
|
173
193
|
this.$emit('input', this.content);
|
|
174
194
|
},
|
|
175
195
|
onChange() {
|
|
196
|
+
/**
|
|
197
|
+
* change event
|
|
198
|
+
* @property {string} value
|
|
199
|
+
*/
|
|
176
200
|
this.$emit('change', this.content);
|
|
177
201
|
},
|
|
178
202
|
/**
|