@zipify/wysiwyg 1.0.0-dev.77 → 1.0.0-dev.78
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/wysiwyg.mjs
CHANGED
|
@@ -14394,6 +14394,9 @@ function importIcon(name) {
|
|
|
14394
14394
|
function isWysiwygContent(content) {
|
|
14395
14395
|
return typeof content === "object" && content.__wswg__;
|
|
14396
14396
|
}
|
|
14397
|
+
function unmarkWysiwygContent({ __wswg__, ...content }) {
|
|
14398
|
+
return content;
|
|
14399
|
+
}
|
|
14397
14400
|
function markWysiwygContent(content) {
|
|
14398
14401
|
return { ...content, __wswg__: true };
|
|
14399
14402
|
}
|
|
@@ -22784,16 +22787,17 @@ const Toolbar = /* @__PURE__ */ function() {
|
|
|
22784
22787
|
function useEditor({ content, onChange, extensions: extensions2, isReadonlyRef }) {
|
|
22785
22788
|
const editor = reactive(new Editor({
|
|
22786
22789
|
content: ContentNormalizer.normalize(content.value),
|
|
22787
|
-
onUpdate: () => onChange(editor.getJSON()),
|
|
22790
|
+
onUpdate: () => onChange(markWysiwygContent(editor.getJSON())),
|
|
22788
22791
|
extensions: extensions2,
|
|
22789
22792
|
injectCSS: false
|
|
22790
22793
|
}));
|
|
22791
22794
|
onUnmounted(() => editor.destroy());
|
|
22792
22795
|
watch(content, (value) => {
|
|
22793
|
-
const
|
|
22796
|
+
const content2 = unmarkWysiwygContent(value);
|
|
22797
|
+
const isChanged = JSON.stringify(editor.getJSON()) !== JSON.stringify(content2);
|
|
22794
22798
|
if (isChanged) {
|
|
22795
|
-
const
|
|
22796
|
-
editor.commands.setContent(
|
|
22799
|
+
const content3 = ContentNormalizer.normalize(value);
|
|
22800
|
+
editor.commands.setContent(content3, false);
|
|
22797
22801
|
}
|
|
22798
22802
|
});
|
|
22799
22803
|
watch(isReadonlyRef, (isReadonly) => editor.setEditable(!isReadonly), { immediate: true });
|
|
@@ -25961,7 +25965,7 @@ const __vue2_script = {
|
|
|
25961
25965
|
});
|
|
25962
25966
|
const updateToolbar = () => toolbar.update();
|
|
25963
25967
|
function onChange(content) {
|
|
25964
|
-
emit("input",
|
|
25968
|
+
emit("input", content);
|
|
25965
25969
|
updateToolbar();
|
|
25966
25970
|
}
|
|
25967
25971
|
const pageBlocks = toRef(props, "pageBlocks");
|
package/lib/Wysiwyg.vue
CHANGED
|
@@ -21,7 +21,6 @@ import { ContextWindow, FavoriteColors, Storage } from './services';
|
|
|
21
21
|
import { Devices } from './enums';
|
|
22
22
|
import { outClick } from './directives';
|
|
23
23
|
import { Font } from './models';
|
|
24
|
-
import { markWysiwygContent } from './utils';
|
|
25
24
|
|
|
26
25
|
const MIN_FONT_SIZE = 5;
|
|
27
26
|
const MAX_FONT_SIZE = 112;
|
|
@@ -151,7 +150,7 @@ export default {
|
|
|
151
150
|
const updateToolbar = () => toolbar.update();
|
|
152
151
|
|
|
153
152
|
function onChange(content) {
|
|
154
|
-
emit('input',
|
|
153
|
+
emit('input', content);
|
|
155
154
|
updateToolbar();
|
|
156
155
|
}
|
|
157
156
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/vue-2';
|
|
2
2
|
import { onUnmounted, watch, reactive } from 'vue';
|
|
3
3
|
import { ContentNormalizer } from '../services';
|
|
4
|
+
import { markWysiwygContent, unmarkWysiwygContent } from '../utils';
|
|
4
5
|
|
|
5
6
|
export function useEditor({ content, onChange, extensions, isReadonlyRef }) {
|
|
6
7
|
const editor = reactive(new Editor({
|
|
7
8
|
content: ContentNormalizer.normalize(content.value),
|
|
8
|
-
onUpdate: () => onChange(editor.getJSON()),
|
|
9
|
+
onUpdate: () => onChange(markWysiwygContent(editor.getJSON())),
|
|
9
10
|
extensions,
|
|
10
11
|
injectCSS: false
|
|
11
12
|
}));
|
|
@@ -13,7 +14,8 @@ export function useEditor({ content, onChange, extensions, isReadonlyRef }) {
|
|
|
13
14
|
onUnmounted(() => editor.destroy());
|
|
14
15
|
|
|
15
16
|
watch(content, (value) => {
|
|
16
|
-
const
|
|
17
|
+
const content = unmarkWysiwygContent(value);
|
|
18
|
+
const isChanged = JSON.stringify(editor.getJSON()) !== JSON.stringify(content);
|
|
17
19
|
|
|
18
20
|
if (isChanged) {
|
|
19
21
|
const content = ContentNormalizer.normalize(value);
|
package/lib/utils/index.js
CHANGED
|
@@ -7,4 +7,4 @@ export { convertLineHeight } from './convertLineHeight';
|
|
|
7
7
|
export { convertFontSize } from './convertFontSize';
|
|
8
8
|
export { convertAlignment } from './convertAlignment';
|
|
9
9
|
export { importIcon } from './importIcon';
|
|
10
|
-
export { isWysiwygContent, markWysiwygContent } from './isWysiwygContent';
|
|
10
|
+
export { isWysiwygContent, markWysiwygContent, unmarkWysiwygContent } from './isWysiwygContent';
|
|
@@ -2,6 +2,11 @@ export function isWysiwygContent(content) {
|
|
|
2
2
|
return typeof content === 'object' && content.__wswg__;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
|
6
|
+
export function unmarkWysiwygContent({ __wswg__, ...content }) {
|
|
7
|
+
return content;
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
export function markWysiwygContent(content) {
|
|
6
11
|
return { ...content, __wswg__: true };
|
|
7
12
|
}
|