goodteditor-ui 1.0.62 → 1.0.63

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,6 +1,6 @@
1
1
  {
2
2
  "name": "goodteditor-ui",
3
- "version": "1.0.62",
3
+ "version": "1.0.63",
4
4
  "main": "index.js",
5
5
  "homepage": "https://goodt-ui.netlify.app/",
6
6
  "scripts": {
@@ -2,8 +2,7 @@ Simple example
2
2
  ```vue
3
3
  <template>
4
4
  <div class="pad-l5">
5
- <button class="btn" @click="toggled = !toggled">toggle</button>
6
- <ui-wysiwyg-editor v-model="model" :autofocus="false" :editorContent="editorContent"></ui-wysiwyg-editor>
5
+ <ui-wysiwyg-editor v-model="model" :autofocus="false" :editorContent="{ class: ['h-100', 'pad-3', 'scroll-y'] }"></ui-wysiwyg-editor>
7
6
  </div>
8
7
  </template>
9
8
  <script>
@@ -11,23 +10,10 @@ import UiWysiwygEditor from './WysiwygEditor.vue';
11
10
  export default {
12
11
  components: { UiWysiwygEditor },
13
12
  data: () => ({
14
- toggled: false,
15
13
  model: `<p>This WYSIWYG is based on
16
14
  <a target="_blank" rel="noopener noreferrer nofollow" href="https://tiptap.dev/" class="color-link">tiptap</a>
17
15
  editor framework.</p>`
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
- },
16
+ })
31
17
  };
32
18
  </script>
33
19
  ```
@@ -54,6 +54,7 @@ import { buildToolGroups, bindContext } from './utils';
54
54
  import { DefaultTools, WysiwygAutofocus, EMPTY_PTAG_REGEXP } from './constants';
55
55
 
56
56
  /**
57
+ * @typedef {import('@tiptap/core').EditorEvents} EditorEvents
57
58
  * @typedef {Omit<import('@tiptap/extension-bubble-menu').BubbleMenuOptions, 'element'>} BubbleMenuOptions
58
59
  * @typedef {import('vue').PropOptions.<Boolean|BubbleMenuOptions>} BubbleMenuOptionsProp
59
60
  * @typedef {import('./constants').ITool} ITool
@@ -202,8 +203,18 @@ export default {
202
203
  },
203
204
  onUpdate: () => {
204
205
  this.onInput();
206
+ // case when the editor lost focus bc the editor menu form element (e.g. input)
207
+ // intercepted it & the editor value was updated from that element later
208
+ if (!this.editor.isFocused) {
209
+ this.onChange();
210
+ }
205
211
  },
206
212
  onBlur: () => {
213
+ const isSame = this.content === this.value;
214
+
215
+ if (isSame) {
216
+ return;
217
+ }
207
218
  this.onChange();
208
219
  },
209
220
  onSelectionUpdate: onSelectionUpdateDebounced
@@ -231,7 +242,8 @@ export default {
231
242
  this.$emit('change', this.content);
232
243
  },
233
244
  /**
234
- * @param {Transaction} transaction
245
+ * @param {EditorEvents.selectionUpdate} selectionUpdateEvent
246
+ * @param {EditorEvents.selectionUpdate.transaction} selectionUpdateEvent.transaction
235
247
  */
236
248
  onSelectionUpdate({ transaction }) {
237
249
  this.caretPosition = transaction.curSelection.to;
@@ -11,11 +11,20 @@ import BubbleMenuToExtend from '@tiptap/extension-bubble-menu';
11
11
  */
12
12
  export const BubbleMenu = ({
13
13
  element = null,
14
- tippyOptions = { maxWidth: 'none', appendTo: () => document.body },
14
+ tippyOptions = {
15
+ maxWidth: 'none',
16
+ appendTo: () => document.body,
17
+ onClickOutside: (instance) => {
18
+ instance.hide();
19
+ },
20
+ },
15
21
  } = {}) => {
16
22
  const {
17
23
  maxWidth = 'none',
18
24
  appendTo = () => document.body,
25
+ onClickOutside = (instance) => {
26
+ instance.hide();
27
+ },
19
28
  ...restOptions
20
29
  } = tippyOptions;
21
30
 
@@ -24,6 +33,7 @@ export const BubbleMenu = ({
24
33
  tippyOptions: {
25
34
  maxWidth,
26
35
  appendTo,
36
+ onClickOutside,
27
37
  ...restOptions
28
38
  },
29
39
  });
@@ -23,6 +23,12 @@ import { useRender, RenderMixinTypes } from './mixins';
23
23
  export default {
24
24
  components: { ColorPicker, Popover },
25
25
  mixins: [useRender(), WithPopover],
26
+ props: {
27
+ appendToBody: {
28
+ type: Boolean,
29
+ default: false
30
+ }
31
+ },
26
32
  computed: {
27
33
  value() {
28
34
  return this.tool.getValue();
@@ -1,7 +1,13 @@
1
1
  <template>
2
2
  <div :title="title" class="autocomplete-tool">
3
3
  <input-autocomplete
4
- v-bind="{ value, options: tool.options, disabled: !isEnabled, size: 'small' }"
4
+ v-bind="{
5
+ value,
6
+ options: tool.options,
7
+ disabled: !isEnabled,
8
+ size: 'small',
9
+ appendToBody: false
10
+ }"
5
11
  @input="onInput" />
6
12
  </div>
7
13
  </template>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div :title="title" class="input-units-tool">
3
3
  <input-units
4
- v-bind="{ value, units, size: 'small', disabled: !isEnabled }"
4
+ v-bind="{ value, units, size: 'small', disabled: !isEnabled, appendToBody: false }"
5
5
  @change="onChange" />
6
6
  </div>
7
7
  </template>
@@ -1,7 +1,14 @@
1
1
  <template>
2
2
  <div :title="title" class="select-tool">
3
3
  <ui-select
4
- v-bind="{ value, options, valueObjects, disabled: !isEnabled, size: 'small' }"
4
+ v-bind="{
5
+ value,
6
+ options,
7
+ valueObjects,
8
+ disabled: !isEnabled,
9
+ size: 'small',
10
+ appendToBody: false
11
+ }"
5
12
  class="w-100"
6
13
  @change="onChange" />
7
14
  </div>
@@ -32,6 +32,12 @@ import { useRender, RenderMixinTypes } from './mixins';
32
32
  export default {
33
33
  components: { Popover, UiDatalist },
34
34
  mixins: [useRender(), WithPopover],
35
+ props: {
36
+ appendToBody: {
37
+ type: Boolean,
38
+ default: false
39
+ }
40
+ },
35
41
  methods: {
36
42
  ...RenderMixinTypes,
37
43
  onCommandExecuted() {