goodteditor-ui 1.0.60 → 1.0.62
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 +1 -1
- package/src/components/ui/WysiwygEditor/WysiwygEditor.md +16 -2
- package/src/components/ui/WysiwygEditor/WysiwygEditor.vue +13 -2
- package/src/components/ui/WysiwygEditor/constants.d.ts +2 -0
- package/src/components/ui/WysiwygEditor/constants.js +2 -0
- package/src/components/ui/WysiwygEditor/extensions/bubble-menu.js +17 -5
package/package.json
CHANGED
|
@@ -2,7 +2,8 @@ Simple example
|
|
|
2
2
|
```vue
|
|
3
3
|
<template>
|
|
4
4
|
<div class="pad-l5">
|
|
5
|
-
<
|
|
5
|
+
<button class="btn" @click="toggled = !toggled">toggle</button>
|
|
6
|
+
<ui-wysiwyg-editor v-model="model" :autofocus="false" :editorContent="editorContent"></ui-wysiwyg-editor>
|
|
6
7
|
</div>
|
|
7
8
|
</template>
|
|
8
9
|
<script>
|
|
@@ -10,10 +11,23 @@ import UiWysiwygEditor from './WysiwygEditor.vue';
|
|
|
10
11
|
export default {
|
|
11
12
|
components: { UiWysiwygEditor },
|
|
12
13
|
data: () => ({
|
|
14
|
+
toggled: false,
|
|
13
15
|
model: `<p>This WYSIWYG is based on
|
|
14
16
|
<a target="_blank" rel="noopener noreferrer nofollow" href="https://tiptap.dev/" class="color-link">tiptap</a>
|
|
15
17
|
editor framework.</p>`
|
|
16
|
-
})
|
|
18
|
+
}),
|
|
19
|
+
computed: {
|
|
20
|
+
editorContent() {
|
|
21
|
+
if (!this.toggled) {
|
|
22
|
+
return {
|
|
23
|
+
class: ['h-100', 'pad-3', 'scroll-y']
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
class: ['h-100', 'pad-3', 'scroll-y', 'color-red']
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
17
31
|
};
|
|
18
32
|
</script>
|
|
19
33
|
```
|
|
@@ -51,7 +51,7 @@ import { Editor, EditorContent } from '@tiptap/vue-2';
|
|
|
51
51
|
import { debounce } from '../utils/Helpers';
|
|
52
52
|
import { resolveExtensions } from './extensions';
|
|
53
53
|
import { buildToolGroups, bindContext } from './utils';
|
|
54
|
-
import { DefaultTools, WysiwygAutofocus } from './constants';
|
|
54
|
+
import { DefaultTools, WysiwygAutofocus, EMPTY_PTAG_REGEXP } from './constants';
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* @typedef {Omit<import('@tiptap/extension-bubble-menu').BubbleMenuOptions, 'element'>} BubbleMenuOptions
|
|
@@ -131,7 +131,8 @@ export default {
|
|
|
131
131
|
* @return {string}
|
|
132
132
|
*/
|
|
133
133
|
content() {
|
|
134
|
-
|
|
134
|
+
const html = this.editor?.getHTML() ?? '';
|
|
135
|
+
return EMPTY_PTAG_REGEXP.test(html) ? '' : html;
|
|
135
136
|
},
|
|
136
137
|
/**
|
|
137
138
|
* @return {{title: string, group: ITool[]}[]}
|
|
@@ -165,6 +166,16 @@ export default {
|
|
|
165
166
|
|
|
166
167
|
this.editor.commands.setContent(value, false);
|
|
167
168
|
},
|
|
169
|
+
editorContent() {
|
|
170
|
+
this.editor.setOptions({
|
|
171
|
+
editorProps: {
|
|
172
|
+
attributes: {
|
|
173
|
+
class: this.editorClass,
|
|
174
|
+
style: this.editorContent?.style ?? ''
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
}
|
|
168
179
|
},
|
|
169
180
|
created() {
|
|
170
181
|
this.onSelectionUpdateDebounced = debounce(this.onSelectionUpdate, 300);
|
|
@@ -11,8 +11,20 @@ import BubbleMenuToExtend from '@tiptap/extension-bubble-menu';
|
|
|
11
11
|
*/
|
|
12
12
|
export const BubbleMenu = ({
|
|
13
13
|
element = null,
|
|
14
|
-
tippyOptions = { maxWidth: 'none',
|
|
15
|
-
} = {}) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
tippyOptions = { maxWidth: 'none', appendTo: () => document.body },
|
|
15
|
+
} = {}) => {
|
|
16
|
+
const {
|
|
17
|
+
maxWidth = 'none',
|
|
18
|
+
appendTo = () => document.body,
|
|
19
|
+
...restOptions
|
|
20
|
+
} = tippyOptions;
|
|
21
|
+
|
|
22
|
+
return BubbleMenuToExtend.configure({
|
|
23
|
+
element,
|
|
24
|
+
tippyOptions: {
|
|
25
|
+
maxWidth,
|
|
26
|
+
appendTo,
|
|
27
|
+
...restOptions
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
};
|