@zipify/wysiwyg 1.0.0-dev.90 → 1.0.0-dev.93
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.css +10 -10
- package/dist/wysiwyg.mjs +63 -60
- package/lib/components/toolbar/controls/FontWeightControl.vue +2 -2
- package/lib/components/toolbar/controls/ListControl.vue +4 -4
- package/lib/components/toolbar/controls/StylePresetControl.vue +3 -3
- package/lib/components/toolbar/controls/UnderlineControl.vue +2 -2
- package/lib/extensions/Alignment.js +4 -4
- package/lib/extensions/FontColor.js +3 -3
- package/lib/extensions/FontFamily.js +5 -5
- package/lib/extensions/FontSize.js +7 -7
- package/lib/extensions/FontStyle.js +7 -7
- package/lib/extensions/FontWeight.js +10 -9
- package/lib/extensions/LineHeight.js +5 -5
- package/lib/extensions/Link.js +3 -1
- package/lib/extensions/StylePreset.js +5 -5
- package/lib/extensions/TextDecoration.js +8 -8
- package/lib/extensions/core/NodeProcessor.js +2 -2
- package/lib/extensions/list/List.js +3 -3
- package/lib/services/ContentNormalizer.js +5 -2
- package/lib/services/__tests__/ContentNormalizer.test.js +7 -0
- package/package.json +1 -1
package/dist/wysiwyg.css
CHANGED
|
@@ -525,19 +525,19 @@
|
|
|
525
525
|
line-height: var(--zw-line-height-xxs);
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
-
.zw-style-preset-control[data-v-
|
|
528
|
+
.zw-style-preset-control[data-v-2893d64e] {
|
|
529
529
|
display: flex;
|
|
530
530
|
align-items: center;
|
|
531
531
|
}
|
|
532
|
-
.zw-style-preset-control__dropdown[data-v-
|
|
532
|
+
.zw-style-preset-control__dropdown[data-v-2893d64e] {
|
|
533
533
|
width: 96px;
|
|
534
534
|
}
|
|
535
|
-
.zw-style-preset-control__reset[data-v-
|
|
535
|
+
.zw-style-preset-control__reset[data-v-2893d64e] {
|
|
536
536
|
color: rgb(var(--zw-color-n70));
|
|
537
537
|
}
|
|
538
|
-
.zw-style-preset-control__reset[data-v-
|
|
539
|
-
.zw-style-preset-control__reset[data-v-
|
|
540
|
-
.zw-style-preset-control__reset[data-v-
|
|
538
|
+
.zw-style-preset-control__reset[data-v-2893d64e]:not(:disabled):hover,
|
|
539
|
+
.zw-style-preset-control__reset[data-v-2893d64e]:not(:disabled):focus,
|
|
540
|
+
.zw-style-preset-control__reset[data-v-2893d64e]:not(:disabled):focus-within {
|
|
541
541
|
color: rgb(var(--zw-color-white));
|
|
542
542
|
}
|
|
543
543
|
|
|
@@ -576,17 +576,17 @@
|
|
|
576
576
|
margin-left: var(--zw-offset-sm);
|
|
577
577
|
}
|
|
578
578
|
|
|
579
|
-
.zpa-list-control[data-v-
|
|
579
|
+
.zpa-list-control[data-v-2eeb2252] {
|
|
580
580
|
display: flex;
|
|
581
581
|
}
|
|
582
|
-
.zpa-list-control[data-v-
|
|
582
|
+
.zpa-list-control[data-v-2eeb2252]:hover {
|
|
583
583
|
color: rgb(var(--zw-color-white));
|
|
584
584
|
background-color: rgb(var(--zw-color-n5));
|
|
585
585
|
}
|
|
586
|
-
.zw-list-control__activator[data-v-
|
|
586
|
+
.zw-list-control__activator[data-v-2eeb2252] {
|
|
587
587
|
padding: 0 var(--zw-offset-xs);
|
|
588
588
|
}
|
|
589
|
-
.zw-list-control__option[data-v-
|
|
589
|
+
.zw-list-control__option[data-v-2eeb2252] {
|
|
590
590
|
padding: 0 var(--zw-offset-xs);
|
|
591
591
|
display: flex;
|
|
592
592
|
}
|
package/dist/wysiwyg.mjs
CHANGED
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import { computed, ref, watch, inject, onUnmounted, nextTick, provide, onMounted, toRef, reactive } from "vue";
|
|
7
|
+
import { computed, ref, watch, inject, onUnmounted, nextTick, provide, onMounted, toRef, unref, reactive } from "vue";
|
|
8
8
|
import { ColorModel, ZipifyColorPicker } from "@zipify/colorpicker";
|
|
9
9
|
function OrderedMap(content) {
|
|
10
10
|
this.content = content;
|
|
@@ -19588,7 +19588,9 @@ const _ContentNormalizer = class {
|
|
|
19588
19588
|
return;
|
|
19589
19589
|
const fragment = new DocumentFragment();
|
|
19590
19590
|
const children = Array.from(parentElement.childNodes);
|
|
19591
|
-
|
|
19591
|
+
const parentTemplate = parentElement.cloneNode(true);
|
|
19592
|
+
parentTemplate.innerHTML = "";
|
|
19593
|
+
let capturingParagraph = parentTemplate.cloneNode();
|
|
19592
19594
|
const append2 = (node) => {
|
|
19593
19595
|
this._assignElementProperties(node, parentElement, _ContentNormalizer.BLOCK_STYLES);
|
|
19594
19596
|
fragment.append(node);
|
|
@@ -19596,7 +19598,7 @@ const _ContentNormalizer = class {
|
|
|
19596
19598
|
for (const child of children) {
|
|
19597
19599
|
if (child.tagName === "BR") {
|
|
19598
19600
|
append2(capturingParagraph);
|
|
19599
|
-
capturingParagraph =
|
|
19601
|
+
capturingParagraph = parentTemplate.cloneNode();
|
|
19600
19602
|
continue;
|
|
19601
19603
|
}
|
|
19602
19604
|
capturingParagraph.append(child);
|
|
@@ -20683,11 +20685,11 @@ const __vue2_script$p = {
|
|
|
20683
20685
|
const preset = editor.commands.getPreset();
|
|
20684
20686
|
const customization = editor.commands.getPresetCustomization();
|
|
20685
20687
|
const isCustomized = computed(() => {
|
|
20686
|
-
const { attributes, marks } = customization
|
|
20688
|
+
const { attributes, marks } = unref(customization);
|
|
20687
20689
|
return !!attributes.length || !!marks.length;
|
|
20688
20690
|
});
|
|
20689
20691
|
const options = computed(() => {
|
|
20690
|
-
return presets.
|
|
20692
|
+
return unref(presets).map((preset2) => ({
|
|
20691
20693
|
id: preset2.id,
|
|
20692
20694
|
title: preset2.name
|
|
20693
20695
|
}));
|
|
@@ -20712,7 +20714,7 @@ var __component__$p = /* @__PURE__ */ normalizeComponent(
|
|
|
20712
20714
|
staticRenderFns$p,
|
|
20713
20715
|
false,
|
|
20714
20716
|
__vue2_injectStyles$p,
|
|
20715
|
-
"
|
|
20717
|
+
"2893d64e",
|
|
20716
20718
|
null,
|
|
20717
20719
|
null
|
|
20718
20720
|
);
|
|
@@ -20876,7 +20878,7 @@ const __vue2_script$n = {
|
|
|
20876
20878
|
setup() {
|
|
20877
20879
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
20878
20880
|
const font = editor.commands.getFont();
|
|
20879
|
-
const options = computed(() => font.
|
|
20881
|
+
const options = computed(() => unref(font).weights.map((style2) => ({ id: style2 })));
|
|
20880
20882
|
const currentValue = editor.commands.getFontWeight();
|
|
20881
20883
|
const apply2 = (value) => editor.chain().focus().applyFontWeight(value).run();
|
|
20882
20884
|
return {
|
|
@@ -21249,7 +21251,7 @@ const __vue2_script$i = {
|
|
|
21249
21251
|
},
|
|
21250
21252
|
setup() {
|
|
21251
21253
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
21252
|
-
const currentValue =
|
|
21254
|
+
const currentValue = editor.commands.isUnderline();
|
|
21253
21255
|
const apply2 = () => editor.chain().focus().toggleUnderline().run();
|
|
21254
21256
|
return {
|
|
21255
21257
|
currentValue,
|
|
@@ -21901,10 +21903,10 @@ const __vue2_script$b = {
|
|
|
21901
21903
|
setup() {
|
|
21902
21904
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
21903
21905
|
const selectionValue = editor.commands.getListType();
|
|
21904
|
-
const isList2 = computed(() => !!selectionValue
|
|
21905
|
-
const currentValue = computed(() => selectionValue
|
|
21906
|
+
const isList2 = computed(() => !!unref(selectionValue));
|
|
21907
|
+
const currentValue = computed(() => unref(selectionValue) || "none");
|
|
21906
21908
|
const recentListType = ref(ListTypes.DISC);
|
|
21907
|
-
const isCurrentListSelected = computed(() => selectionValue
|
|
21909
|
+
const isCurrentListSelected = computed(() => unref(selectionValue) === recentListType.value);
|
|
21908
21910
|
const currentIcon = computed(() => `list-${recentListType.value}`);
|
|
21909
21911
|
const apply2 = (type) => {
|
|
21910
21912
|
recentListType.value = type;
|
|
@@ -21928,7 +21930,7 @@ var __component__$b = /* @__PURE__ */ normalizeComponent(
|
|
|
21928
21930
|
staticRenderFns$b,
|
|
21929
21931
|
false,
|
|
21930
21932
|
__vue2_injectStyles$b,
|
|
21931
|
-
"
|
|
21933
|
+
"2eeb2252",
|
|
21932
21934
|
null,
|
|
21933
21935
|
null
|
|
21934
21936
|
);
|
|
@@ -22876,7 +22878,7 @@ const FontFamily = Mark.create({
|
|
|
22876
22878
|
applyFontFamily: createCommand(({ commands: commands2 }, value) => {
|
|
22877
22879
|
commands2.setMark(this.name, { value });
|
|
22878
22880
|
const font = commands2.findFontByName(value);
|
|
22879
|
-
let fontWeight = commands2.getFontWeight()
|
|
22881
|
+
let fontWeight = unref(commands2.getFontWeight());
|
|
22880
22882
|
if (!font.isWeightSupported(fontWeight)) {
|
|
22881
22883
|
fontWeight = font.findClosestWeight(fontWeight);
|
|
22882
22884
|
commands2.applyFontWeight(fontWeight);
|
|
@@ -22887,7 +22889,7 @@ const FontFamily = Mark.create({
|
|
|
22887
22889
|
}),
|
|
22888
22890
|
getFont: createCommand(({ commands: commands2 }) => {
|
|
22889
22891
|
const fontFamily = commands2.getFontFamily();
|
|
22890
|
-
return computed(() => commands2.findFontByName(fontFamily
|
|
22892
|
+
return computed(() => commands2.findFontByName(unref(fontFamily)));
|
|
22891
22893
|
}),
|
|
22892
22894
|
findFontByName: createCommand((_, name) => {
|
|
22893
22895
|
return this.options.fonts.find((font) => font.name === name);
|
|
@@ -22896,12 +22898,12 @@ const FontFamily = Mark.create({
|
|
|
22896
22898
|
const defaultValue = commands2.getDefaultFontFamily();
|
|
22897
22899
|
return computed(() => {
|
|
22898
22900
|
var _a, _b;
|
|
22899
|
-
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : defaultValue
|
|
22901
|
+
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : unref(defaultValue);
|
|
22900
22902
|
});
|
|
22901
22903
|
}),
|
|
22902
22904
|
getDefaultFontFamily: createCommand(({ commands: commands2 }) => {
|
|
22903
22905
|
const preset = commands2.getPreset();
|
|
22904
|
-
return computed(() => preset.
|
|
22906
|
+
return computed(() => unref(preset).common.font_family);
|
|
22905
22907
|
})
|
|
22906
22908
|
};
|
|
22907
22909
|
},
|
|
@@ -23018,7 +23020,7 @@ const StylePreset = Extension.create({
|
|
|
23018
23020
|
isRequired: false,
|
|
23019
23021
|
default: { id: this.options.defaultId },
|
|
23020
23022
|
parseHTML: (element) => {
|
|
23021
|
-
const presets = this.options.presets
|
|
23023
|
+
const presets = unref(this.options.presets);
|
|
23022
23024
|
if (element.parentElement.tagName === "LI")
|
|
23023
23025
|
return null;
|
|
23024
23026
|
for (const { id: id2, node, fallbackClass } of presets) {
|
|
@@ -23054,11 +23056,11 @@ const StylePreset = Extension.create({
|
|
|
23054
23056
|
getPreset: createCommand(({ commands: commands2 }) => {
|
|
23055
23057
|
const selection = commands2.getBlockAttributes("preset", { id: this.options.defaultId });
|
|
23056
23058
|
const presets = commands2.getPresetList();
|
|
23057
|
-
return computed(() => findPresetById(presets
|
|
23059
|
+
return computed(() => findPresetById(unref(presets), unref(selection).id));
|
|
23058
23060
|
}),
|
|
23059
23061
|
applyPreset: createCommand(({ commands: commands2, chain }, presetId) => {
|
|
23060
23062
|
var _a, _b;
|
|
23061
|
-
const presets = commands2.getPresetList()
|
|
23063
|
+
const presets = unref(commands2.getPresetList());
|
|
23062
23064
|
const preset = findPresetById(presets, presetId);
|
|
23063
23065
|
const nodeType = (_b = (_a = preset.node) == null ? void 0 : _a.type) != null ? _b : NodeTypes.PARAGRAPH;
|
|
23064
23066
|
const attrs = {
|
|
@@ -23068,7 +23070,7 @@ const StylePreset = Extension.create({
|
|
|
23068
23070
|
attrs.level = preset.node.level;
|
|
23069
23071
|
}
|
|
23070
23072
|
for (const textAttribute of TextSettings.attributes) {
|
|
23071
|
-
attrs[textAttribute] = commands2.getBlockAttributes(textAttribute)
|
|
23073
|
+
attrs[textAttribute] = unref(commands2.getBlockAttributes(textAttribute));
|
|
23072
23074
|
}
|
|
23073
23075
|
chain().removeList().setNode(nodeType, attrs).run();
|
|
23074
23076
|
}),
|
|
@@ -23144,14 +23146,14 @@ const FontWeight = Mark.create({
|
|
|
23144
23146
|
return {
|
|
23145
23147
|
applyFontWeight: createCommand(({ commands: commands2 }, value) => {
|
|
23146
23148
|
commands2.setMark(this.name, { value });
|
|
23147
|
-
const font = commands2.getFont()
|
|
23149
|
+
const font = unref(commands2.getFont());
|
|
23148
23150
|
if (!font.isItalicSupported(value)) {
|
|
23149
23151
|
commands2.removeItalic();
|
|
23150
23152
|
}
|
|
23151
23153
|
}),
|
|
23152
23154
|
toggleBold: createCommand(({ commands: commands2 }) => {
|
|
23153
|
-
const currentWeight = commands2.getFontWeight()
|
|
23154
|
-
const currentFont = commands2.getFont()
|
|
23155
|
+
const currentWeight = unref(commands2.getFontWeight());
|
|
23156
|
+
const currentFont = unref(commands2.getFont());
|
|
23155
23157
|
const isBold = Number(currentWeight) >= 600;
|
|
23156
23158
|
const wantedWeight = isBold ? "400" : "700";
|
|
23157
23159
|
const nextWeight = currentFont.findClosestWeight(wantedWeight);
|
|
@@ -23159,19 +23161,20 @@ const FontWeight = Mark.create({
|
|
|
23159
23161
|
}),
|
|
23160
23162
|
getFontWeight: createCommand(({ editor, commands: commands2 }) => {
|
|
23161
23163
|
const defaultValue = commands2.getDefaultFontWeight();
|
|
23162
|
-
const
|
|
23164
|
+
const fontRef = commands2.getFont();
|
|
23163
23165
|
return computed(() => {
|
|
23164
23166
|
var _a, _b;
|
|
23165
|
-
const weight = (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : defaultValue
|
|
23166
|
-
|
|
23167
|
+
const weight = (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : unref(defaultValue);
|
|
23168
|
+
const font = unref(fontRef);
|
|
23169
|
+
if (font.isWeightSupported(weight)) {
|
|
23167
23170
|
return weight;
|
|
23168
23171
|
}
|
|
23169
|
-
return font.
|
|
23172
|
+
return font.findClosestWeight(weight);
|
|
23170
23173
|
});
|
|
23171
23174
|
}),
|
|
23172
23175
|
getDefaultFontWeight: createCommand(({ commands: commands2 }) => {
|
|
23173
23176
|
const preset = commands2.getPreset();
|
|
23174
|
-
return computed(() => preset.
|
|
23177
|
+
return computed(() => unref(preset).common.font_weight);
|
|
23175
23178
|
})
|
|
23176
23179
|
};
|
|
23177
23180
|
},
|
|
@@ -23226,25 +23229,25 @@ const FontSize = Mark.create({
|
|
|
23226
23229
|
const defaultValue = commands2.getDefaultFontSize();
|
|
23227
23230
|
return computed(() => {
|
|
23228
23231
|
var _a, _b;
|
|
23229
|
-
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a[device
|
|
23232
|
+
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a[unref(device)]) != null ? _b : unref(defaultValue);
|
|
23230
23233
|
});
|
|
23231
23234
|
}),
|
|
23232
23235
|
getDefaultFontSize: createCommand(({ commands: commands2 }) => {
|
|
23233
23236
|
const device = commands2.getDevice();
|
|
23234
23237
|
const preset = commands2.getPreset();
|
|
23235
|
-
return computed(() => preset
|
|
23238
|
+
return computed(() => unref(preset)[unref(device)].font_size.replace("px", ""));
|
|
23236
23239
|
}),
|
|
23237
23240
|
applyFontSize: createCommand(({ commands: commands2 }, value) => {
|
|
23238
|
-
const device = commands2.getDevice()
|
|
23241
|
+
const device = unref(commands2.getDevice());
|
|
23239
23242
|
commands2.setMark(this.name, { [device]: value });
|
|
23240
23243
|
}),
|
|
23241
23244
|
increaseFontSize: createCommand(({ commands: commands2 }) => {
|
|
23242
|
-
const size2 = Number(commands2.getFontSize()
|
|
23245
|
+
const size2 = Number(unref(commands2.getFontSize()));
|
|
23243
23246
|
const nextSize = Math.min(size2 + 1, this.options.maxSize);
|
|
23244
23247
|
commands2.applyFontSize(String(nextSize));
|
|
23245
23248
|
}),
|
|
23246
23249
|
decreaseFontSize: createCommand(({ commands: commands2 }) => {
|
|
23247
|
-
const size2 = Number(commands2.getFontSize()
|
|
23250
|
+
const size2 = Number(unref(commands2.getFontSize()));
|
|
23248
23251
|
const nextSize = Math.max(size2 - 1, this.options.minSize);
|
|
23249
23252
|
commands2.applyFontSize(String(nextSize));
|
|
23250
23253
|
})
|
|
@@ -23258,7 +23261,7 @@ const FontSize = Mark.create({
|
|
|
23258
23261
|
const parseSize = (value) => {
|
|
23259
23262
|
if (!value)
|
|
23260
23263
|
return null;
|
|
23261
|
-
const wrapperEl = this.options.wrapperRef
|
|
23264
|
+
const wrapperEl = unref(this.options.wrapperRef);
|
|
23262
23265
|
const converted = convertFontSize(value, wrapperEl);
|
|
23263
23266
|
return String(converted);
|
|
23264
23267
|
};
|
|
@@ -23300,12 +23303,12 @@ const FontColor = Mark.create({
|
|
|
23300
23303
|
const defaultValue = commands2.getDefaultFontColor();
|
|
23301
23304
|
return computed(() => {
|
|
23302
23305
|
var _a, _b;
|
|
23303
|
-
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : defaultValue
|
|
23306
|
+
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : unref(defaultValue);
|
|
23304
23307
|
});
|
|
23305
23308
|
}),
|
|
23306
23309
|
getDefaultFontColor: createCommand(({ commands: commands2 }) => {
|
|
23307
23310
|
const preset = commands2.getPreset();
|
|
23308
|
-
return computed(() => preset.
|
|
23311
|
+
return computed(() => unref(preset).common.color);
|
|
23309
23312
|
}),
|
|
23310
23313
|
applyFontColor: createCommand(({ commands: commands2 }, value) => {
|
|
23311
23314
|
commands2.setMark(this.name, { value });
|
|
@@ -23383,25 +23386,25 @@ const FontStyle = Mark.create({
|
|
|
23383
23386
|
const defaultValue = commands2.getDefaultFontStyle();
|
|
23384
23387
|
return computed(() => {
|
|
23385
23388
|
var _a, _b;
|
|
23386
|
-
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.italic) != null ? _b : defaultValue.
|
|
23389
|
+
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.italic) != null ? _b : unref(defaultValue).italic;
|
|
23387
23390
|
});
|
|
23388
23391
|
}),
|
|
23389
23392
|
isItalicAvailable: createCommand(({ commands: commands2 }) => {
|
|
23390
23393
|
const font = commands2.getFont();
|
|
23391
23394
|
const fontWeight = commands2.getFontWeight();
|
|
23392
|
-
return computed(() => font.
|
|
23395
|
+
return computed(() => unref(font).isItalicSupported(unref(fontWeight)));
|
|
23393
23396
|
}),
|
|
23394
23397
|
getDefaultFontStyle: createCommand(({ commands: commands2 }) => {
|
|
23395
23398
|
const preset = commands2.getPreset();
|
|
23396
23399
|
return computed(() => ({
|
|
23397
|
-
italic: preset.
|
|
23400
|
+
italic: unref(preset).common.font_style === "italic"
|
|
23398
23401
|
}));
|
|
23399
23402
|
}),
|
|
23400
23403
|
toggleItalic: createCommand(({ commands: commands2 }) => {
|
|
23401
|
-
const isItalicAvailable = this.editor.commands.isItalicAvailable();
|
|
23402
|
-
if (!isItalicAvailable
|
|
23404
|
+
const isItalicAvailable = unref(this.editor.commands.isItalicAvailable());
|
|
23405
|
+
if (!isItalicAvailable)
|
|
23403
23406
|
return;
|
|
23404
|
-
commands2.isItalic()
|
|
23407
|
+
unref(commands2.isItalic()) ? commands2.removeItalic() : commands2.applyItalic();
|
|
23405
23408
|
}),
|
|
23406
23409
|
applyItalic: createCommand(({ commands: commands2 }) => {
|
|
23407
23410
|
commands2.setMark(this.name, { italic: true });
|
|
@@ -23447,11 +23450,11 @@ const TextDecoration = Mark.create({
|
|
|
23447
23450
|
return {
|
|
23448
23451
|
isUnderline: createCommand(({ commands: commands2, editor }) => {
|
|
23449
23452
|
const decoration = commands2.getTextDecoration();
|
|
23450
|
-
return computed(() => editor.isActive("link") || decoration.
|
|
23453
|
+
return computed(() => editor.isActive("link") || unref(decoration).underline);
|
|
23451
23454
|
}),
|
|
23452
23455
|
isStrikeThrough: createCommand(({ commands: commands2 }) => {
|
|
23453
23456
|
const decoration = commands2.getTextDecoration();
|
|
23454
|
-
return computed(() => decoration.
|
|
23457
|
+
return computed(() => unref(decoration).strike_through);
|
|
23455
23458
|
}),
|
|
23456
23459
|
getTextDecoration: createCommand(({ editor, commands: commands2 }) => {
|
|
23457
23460
|
const defaultValue = commands2.getDefaultTextDecoration();
|
|
@@ -23459,15 +23462,15 @@ const TextDecoration = Mark.create({
|
|
|
23459
23462
|
var _a, _b, _c;
|
|
23460
23463
|
const attrs = (_a = editor.getAttributes(this.name)) != null ? _a : {};
|
|
23461
23464
|
return {
|
|
23462
|
-
underline: (_b = attrs.underline) != null ? _b : defaultValue.
|
|
23463
|
-
strike_through: (_c = attrs.strike_through) != null ? _c : defaultValue.
|
|
23465
|
+
underline: (_b = attrs.underline) != null ? _b : unref(defaultValue).underline,
|
|
23466
|
+
strike_through: (_c = attrs.strike_through) != null ? _c : unref(defaultValue).strike_through
|
|
23464
23467
|
};
|
|
23465
23468
|
});
|
|
23466
23469
|
}),
|
|
23467
23470
|
getDefaultTextDecoration: createCommand(({ commands: commands2 }) => {
|
|
23468
23471
|
const preset = commands2.getPreset();
|
|
23469
23472
|
return computed(() => {
|
|
23470
|
-
const decoration = preset.
|
|
23473
|
+
const decoration = unref(preset).common.text_decoration;
|
|
23471
23474
|
return {
|
|
23472
23475
|
underline: decoration.includes("underline"),
|
|
23473
23476
|
strike_through: decoration.includes("line-through")
|
|
@@ -23483,7 +23486,7 @@ const TextDecoration = Mark.create({
|
|
|
23483
23486
|
commands2.toggleTextDecoration("strike_through");
|
|
23484
23487
|
}),
|
|
23485
23488
|
toggleTextDecoration: createCommand(({ commands: commands2 }, name) => {
|
|
23486
|
-
const isEnabled = commands2.getTextDecoration()
|
|
23489
|
+
const isEnabled = unref(commands2.getTextDecoration())[name];
|
|
23487
23490
|
isEnabled ? commands2.removeTextDecoration(name) : commands2.applyTextDecoration(name);
|
|
23488
23491
|
}),
|
|
23489
23492
|
applyTextDecoration: createCommand(({ commands: commands2 }, name) => {
|
|
@@ -23491,7 +23494,7 @@ const TextDecoration = Mark.create({
|
|
|
23491
23494
|
}),
|
|
23492
23495
|
removeTextDecoration: createCommand(({ commands: commands2 }, name) => {
|
|
23493
23496
|
const mark = {
|
|
23494
|
-
...commands2.getTextDecoration()
|
|
23497
|
+
...unref(commands2.getTextDecoration()),
|
|
23495
23498
|
[name]: false
|
|
23496
23499
|
};
|
|
23497
23500
|
const isRemoveMark = !mark.underline && !mark.strike_through;
|
|
@@ -23621,7 +23624,7 @@ const Alignment = Extension.create({
|
|
|
23621
23624
|
addCommands() {
|
|
23622
23625
|
return {
|
|
23623
23626
|
applyAlignment: createCommand(({ commands: commands2 }, value) => {
|
|
23624
|
-
const device = commands2.getDevice()
|
|
23627
|
+
const device = unref(commands2.getDevice());
|
|
23625
23628
|
commands2.setBlockAttributes(this.name, { [device]: value }, DEFAULTS$1);
|
|
23626
23629
|
}),
|
|
23627
23630
|
getAlignment: createCommand(({ commands: commands2 }) => {
|
|
@@ -23630,13 +23633,13 @@ const Alignment = Extension.create({
|
|
|
23630
23633
|
const defaultValue = commands2.getDefaultAlignment();
|
|
23631
23634
|
return computed(() => {
|
|
23632
23635
|
var _a, _b;
|
|
23633
|
-
return (_b = (_a = attribute
|
|
23636
|
+
return (_b = (_a = unref(attribute)) == null ? void 0 : _a[unref(device)]) != null ? _b : unref(defaultValue);
|
|
23634
23637
|
});
|
|
23635
23638
|
}),
|
|
23636
23639
|
getDefaultAlignment: createCommand(({ commands: commands2 }) => {
|
|
23637
23640
|
const device = commands2.getDevice();
|
|
23638
23641
|
const preset = commands2.getPreset();
|
|
23639
|
-
return computed(() => preset
|
|
23642
|
+
return computed(() => unref(preset)[unref(device)].alignment);
|
|
23640
23643
|
})
|
|
23641
23644
|
};
|
|
23642
23645
|
},
|
|
@@ -23671,7 +23674,7 @@ const LineHeight = Extension.create({
|
|
|
23671
23674
|
const value = element.style.lineHeight;
|
|
23672
23675
|
if (!value)
|
|
23673
23676
|
return null;
|
|
23674
|
-
const wrapperEl = this.options.wrapperRef
|
|
23677
|
+
const wrapperEl = unref(this.options.wrapperRef);
|
|
23675
23678
|
const converted = convertLineHeight(value, element, wrapperEl);
|
|
23676
23679
|
return { desktop: converted, tablet: converted, mobile: converted };
|
|
23677
23680
|
},
|
|
@@ -23697,16 +23700,16 @@ const LineHeight = Extension.create({
|
|
|
23697
23700
|
const defaultValue = commands2.getDefaultLineHeight();
|
|
23698
23701
|
return computed(() => {
|
|
23699
23702
|
var _a, _b;
|
|
23700
|
-
return (_b = (_a = attribute
|
|
23703
|
+
return (_b = (_a = unref(attribute)) == null ? void 0 : _a[unref(device)]) != null ? _b : unref(defaultValue);
|
|
23701
23704
|
});
|
|
23702
23705
|
}),
|
|
23703
23706
|
getDefaultLineHeight: createCommand(({ commands: commands2 }) => {
|
|
23704
23707
|
const device = commands2.getDevice();
|
|
23705
23708
|
const preset = commands2.getPreset();
|
|
23706
|
-
return computed(() => preset
|
|
23709
|
+
return computed(() => unref(preset)[unref(device)].line_height);
|
|
23707
23710
|
}),
|
|
23708
23711
|
applyLineHeight: createCommand(({ commands: commands2 }, value) => {
|
|
23709
|
-
const device = commands2.getDevice()
|
|
23712
|
+
const device = unref(commands2.getDevice());
|
|
23710
23713
|
commands2.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
|
|
23711
23714
|
})
|
|
23712
23715
|
};
|
|
@@ -23803,11 +23806,11 @@ const List = Node$1.create({
|
|
|
23803
23806
|
const attribute = commands2.getBlockAttributes("bullet", { type: null });
|
|
23804
23807
|
return computed(() => {
|
|
23805
23808
|
var _a;
|
|
23806
|
-
return (_a = attribute.
|
|
23809
|
+
return (_a = unref(attribute).type) != null ? _a : null;
|
|
23807
23810
|
});
|
|
23808
23811
|
}),
|
|
23809
23812
|
applyList: createCommand(({ commands: commands2, chain }, type) => {
|
|
23810
|
-
const currentType = commands2.getListType()
|
|
23813
|
+
const currentType = unref(commands2.getListType());
|
|
23811
23814
|
if (currentType === type) {
|
|
23812
23815
|
commands2.applyDefaultPreset();
|
|
23813
23816
|
return;
|
|
@@ -24840,7 +24843,7 @@ const Link = Link$1.extend({
|
|
|
24840
24843
|
if (!href.startsWith("#"))
|
|
24841
24844
|
return LinkDestinations.URL;
|
|
24842
24845
|
const id2 = href.replace("#", "");
|
|
24843
|
-
const blocks = this.options.pageBlocks
|
|
24846
|
+
const blocks = unref(this.options.pageBlocks);
|
|
24844
24847
|
const block = blocks.find((block2) => block2.id === parseInt(id2));
|
|
24845
24848
|
return block ? LinkDestinations.BLOCK : LinkDestinations.URL;
|
|
24846
24849
|
}
|
|
@@ -25583,7 +25586,7 @@ const NodeProcessor = Extension.create({
|
|
|
25583
25586
|
return {
|
|
25584
25587
|
setBlockAttributes: createCommand(({ commands: commands2 }, name, attrs, defaults2 = {}) => {
|
|
25585
25588
|
var _a;
|
|
25586
|
-
const current = (_a = commands2.getBlockAttributes(name)
|
|
25589
|
+
const current = (_a = unref(commands2.getBlockAttributes(name))) != null ? _a : {};
|
|
25587
25590
|
for (const type of NodeTypes.blocks) {
|
|
25588
25591
|
commands2.updateAttributes(type, {
|
|
25589
25592
|
[name]: { ...defaults2, ...current, ...attrs }
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script>
|
|
11
|
-
import { computed, inject } from 'vue';
|
|
11
|
+
import { computed, inject, unref } from 'vue';
|
|
12
12
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
13
13
|
import { Dropdown } from '../../base';
|
|
14
14
|
import { tooltip } from '../../../directives';
|
|
@@ -28,7 +28,7 @@ export default {
|
|
|
28
28
|
const editor = inject(InjectionTokens.EDITOR);
|
|
29
29
|
const font = editor.commands.getFont();
|
|
30
30
|
|
|
31
|
-
const options = computed(() => font.
|
|
31
|
+
const options = computed(() => unref(font).weights.map((style) => ({ id: style })));
|
|
32
32
|
const currentValue = editor.commands.getFontWeight();
|
|
33
33
|
|
|
34
34
|
const apply = (value) => editor.chain().focus().applyFontWeight(value).run();
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
</template>
|
|
46
46
|
|
|
47
47
|
<script>
|
|
48
|
-
import { computed, inject, ref } from 'vue';
|
|
48
|
+
import { computed, inject, ref, unref } from 'vue';
|
|
49
49
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
50
50
|
import { Dropdown, DropdownOption, Button, Icon } from '../../base';
|
|
51
51
|
import { ListTypes } from '../../../enums';
|
|
@@ -73,10 +73,10 @@ export default {
|
|
|
73
73
|
setup() {
|
|
74
74
|
const editor = inject(InjectionTokens.EDITOR);
|
|
75
75
|
const selectionValue = editor.commands.getListType();
|
|
76
|
-
const isList = computed(() => !!selectionValue
|
|
77
|
-
const currentValue = computed(() => selectionValue
|
|
76
|
+
const isList = computed(() => !!unref(selectionValue));
|
|
77
|
+
const currentValue = computed(() => unref(selectionValue) || 'none');
|
|
78
78
|
const recentListType = ref(ListTypes.DISC);
|
|
79
|
-
const isCurrentListSelected = computed(() => selectionValue
|
|
79
|
+
const isCurrentListSelected = computed(() => unref(selectionValue) === recentListType.value);
|
|
80
80
|
|
|
81
81
|
const currentIcon = computed(() => `list-${recentListType.value}`);
|
|
82
82
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script>
|
|
24
|
-
import { computed, inject } from 'vue';
|
|
24
|
+
import { computed, inject, unref } from 'vue';
|
|
25
25
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
26
26
|
import { Dropdown, Button, Icon } from '../../base';
|
|
27
27
|
import { tooltip } from '../../../directives';
|
|
@@ -50,13 +50,13 @@ export default {
|
|
|
50
50
|
const customization = editor.commands.getPresetCustomization();
|
|
51
51
|
|
|
52
52
|
const isCustomized = computed(() => {
|
|
53
|
-
const { attributes, marks } = customization
|
|
53
|
+
const { attributes, marks } = unref(customization);
|
|
54
54
|
|
|
55
55
|
return !!attributes.length || !!marks.length;
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
const options = computed(() => {
|
|
59
|
-
return presets.
|
|
59
|
+
return unref(presets).map((preset) => ({
|
|
60
60
|
id: preset.id,
|
|
61
61
|
title: preset.name
|
|
62
62
|
}));
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<script>
|
|
14
|
-
import { inject
|
|
14
|
+
import { inject } from 'vue';
|
|
15
15
|
import { Button, Icon } from '../../base';
|
|
16
16
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
17
17
|
import { tooltip } from '../../../directives';
|
|
@@ -31,7 +31,7 @@ export default {
|
|
|
31
31
|
setup() {
|
|
32
32
|
const editor = inject(InjectionTokens.EDITOR);
|
|
33
33
|
|
|
34
|
-
const currentValue =
|
|
34
|
+
const currentValue = editor.commands.isUnderline();
|
|
35
35
|
const apply = () => editor.chain().focus().toggleUnderline().run();
|
|
36
36
|
|
|
37
37
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { convertAlignment, createCommand, createKeyboardShortcut, renderInlineSetting } from '../utils';
|
|
4
4
|
import { Alignments, NodeTypes, TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -56,7 +56,7 @@ export const Alignment = Extension.create({
|
|
|
56
56
|
addCommands() {
|
|
57
57
|
return {
|
|
58
58
|
applyAlignment: createCommand(({ commands }, value) => {
|
|
59
|
-
const device = commands.getDevice()
|
|
59
|
+
const device = unref(commands.getDevice());
|
|
60
60
|
|
|
61
61
|
commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
|
|
62
62
|
}),
|
|
@@ -66,14 +66,14 @@ export const Alignment = Extension.create({
|
|
|
66
66
|
const device = commands.getDevice();
|
|
67
67
|
const defaultValue = commands.getDefaultAlignment();
|
|
68
68
|
|
|
69
|
-
return computed(() => attribute
|
|
69
|
+
return computed(() => unref(attribute)?.[unref(device)] ?? unref(defaultValue));
|
|
70
70
|
}),
|
|
71
71
|
|
|
72
72
|
getDefaultAlignment: createCommand(({ commands }) => {
|
|
73
73
|
const device = commands.getDevice();
|
|
74
74
|
const preset = commands.getPreset();
|
|
75
75
|
|
|
76
|
-
return computed(() => preset
|
|
76
|
+
return computed(() => unref(preset)[unref(device)].alignment);
|
|
77
77
|
})
|
|
78
78
|
};
|
|
79
79
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { convertColor, createCommand, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -15,13 +15,13 @@ export const FontColor = Mark.create({
|
|
|
15
15
|
getFontColor: createCommand(({ commands, editor }) => {
|
|
16
16
|
const defaultValue = commands.getDefaultFontColor();
|
|
17
17
|
|
|
18
|
-
return computed(() => editor.getAttributes(this.name)?.value ?? defaultValue
|
|
18
|
+
return computed(() => editor.getAttributes(this.name)?.value ?? unref(defaultValue));
|
|
19
19
|
}),
|
|
20
20
|
|
|
21
21
|
getDefaultFontColor: createCommand(({ commands }) => {
|
|
22
22
|
const preset = commands.getPreset();
|
|
23
23
|
|
|
24
|
-
return computed(() => preset.
|
|
24
|
+
return computed(() => unref(preset).common.color);
|
|
25
25
|
}),
|
|
26
26
|
|
|
27
27
|
applyFontColor: createCommand(({ commands }, value) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -21,7 +21,7 @@ export const FontFamily = Mark.create({
|
|
|
21
21
|
commands.setMark(this.name, { value });
|
|
22
22
|
|
|
23
23
|
const font = commands.findFontByName(value);
|
|
24
|
-
let fontWeight = commands.getFontWeight()
|
|
24
|
+
let fontWeight = unref(commands.getFontWeight());
|
|
25
25
|
|
|
26
26
|
if (!font.isWeightSupported(fontWeight)) {
|
|
27
27
|
fontWeight = font.findClosestWeight(fontWeight);
|
|
@@ -36,7 +36,7 @@ export const FontFamily = Mark.create({
|
|
|
36
36
|
getFont: createCommand(({ commands }) => {
|
|
37
37
|
const fontFamily = commands.getFontFamily();
|
|
38
38
|
|
|
39
|
-
return computed(() => commands.findFontByName(fontFamily
|
|
39
|
+
return computed(() => commands.findFontByName(unref(fontFamily)));
|
|
40
40
|
}),
|
|
41
41
|
|
|
42
42
|
findFontByName: createCommand((_, name) => {
|
|
@@ -46,13 +46,13 @@ export const FontFamily = Mark.create({
|
|
|
46
46
|
getFontFamily: createCommand(({ editor, commands }) => {
|
|
47
47
|
const defaultValue = commands.getDefaultFontFamily();
|
|
48
48
|
|
|
49
|
-
return computed(() => editor.getAttributes(this.name)?.value ?? defaultValue
|
|
49
|
+
return computed(() => editor.getAttributes(this.name)?.value ?? unref(defaultValue));
|
|
50
50
|
}),
|
|
51
51
|
|
|
52
52
|
getDefaultFontFamily: createCommand(({ commands }) => {
|
|
53
53
|
const preset = commands.getPreset();
|
|
54
54
|
|
|
55
|
-
return computed(() => preset.
|
|
55
|
+
return computed(() => unref(preset).common.font_family);
|
|
56
56
|
})
|
|
57
57
|
};
|
|
58
58
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { convertFontSize, createCommand, createKeyboardShortcut, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -25,31 +25,31 @@ export const FontSize = Mark.create({
|
|
|
25
25
|
const device = commands.getDevice();
|
|
26
26
|
const defaultValue = commands.getDefaultFontSize();
|
|
27
27
|
|
|
28
|
-
return computed(() => editor.getAttributes(this.name)?.[device
|
|
28
|
+
return computed(() => editor.getAttributes(this.name)?.[unref(device)] ?? unref(defaultValue));
|
|
29
29
|
}),
|
|
30
30
|
|
|
31
31
|
getDefaultFontSize: createCommand(({ commands }) => {
|
|
32
32
|
const device = commands.getDevice();
|
|
33
33
|
const preset = commands.getPreset();
|
|
34
34
|
|
|
35
|
-
return computed(() => preset
|
|
35
|
+
return computed(() => unref(preset)[unref(device)].font_size.replace('px', ''));
|
|
36
36
|
}),
|
|
37
37
|
|
|
38
38
|
applyFontSize: createCommand(({ commands }, value) => {
|
|
39
|
-
const device = commands.getDevice()
|
|
39
|
+
const device = unref(commands.getDevice());
|
|
40
40
|
|
|
41
41
|
commands.setMark(this.name, { [device]: value });
|
|
42
42
|
}),
|
|
43
43
|
|
|
44
44
|
increaseFontSize: createCommand(({ commands }) => {
|
|
45
|
-
const size = Number(commands.getFontSize()
|
|
45
|
+
const size = Number(unref(commands.getFontSize()));
|
|
46
46
|
const nextSize = Math.min(size + 1, this.options.maxSize);
|
|
47
47
|
|
|
48
48
|
commands.applyFontSize(String(nextSize));
|
|
49
49
|
}),
|
|
50
50
|
|
|
51
51
|
decreaseFontSize: createCommand(({ commands }) => {
|
|
52
|
-
const size = Number(commands.getFontSize()
|
|
52
|
+
const size = Number(unref(commands.getFontSize()));
|
|
53
53
|
const nextSize = Math.max(size - 1, this.options.minSize);
|
|
54
54
|
|
|
55
55
|
commands.applyFontSize(String(nextSize));
|
|
@@ -66,7 +66,7 @@ export const FontSize = Mark.create({
|
|
|
66
66
|
const parseSize = (value) => {
|
|
67
67
|
if (!value) return null;
|
|
68
68
|
|
|
69
|
-
const wrapperEl = this.options.wrapperRef
|
|
69
|
+
const wrapperEl = unref(this.options.wrapperRef);
|
|
70
70
|
const converted = convertFontSize(value, wrapperEl);
|
|
71
71
|
|
|
72
72
|
return String(converted);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -15,30 +15,30 @@ export const FontStyle = Mark.create({
|
|
|
15
15
|
isItalic: createCommand(({ editor, commands }) => {
|
|
16
16
|
const defaultValue = commands.getDefaultFontStyle();
|
|
17
17
|
|
|
18
|
-
return computed(() => editor.getAttributes(this.name)?.italic ?? defaultValue.
|
|
18
|
+
return computed(() => editor.getAttributes(this.name)?.italic ?? unref(defaultValue).italic);
|
|
19
19
|
}),
|
|
20
20
|
|
|
21
21
|
isItalicAvailable: createCommand(({ commands }) => {
|
|
22
22
|
const font = commands.getFont();
|
|
23
23
|
const fontWeight = commands.getFontWeight();
|
|
24
24
|
|
|
25
|
-
return computed(() => font.
|
|
25
|
+
return computed(() => unref(font).isItalicSupported(unref(fontWeight)));
|
|
26
26
|
}),
|
|
27
27
|
|
|
28
28
|
getDefaultFontStyle: createCommand(({ commands }) => {
|
|
29
29
|
const preset = commands.getPreset();
|
|
30
30
|
|
|
31
31
|
return computed(() => ({
|
|
32
|
-
italic: preset.
|
|
32
|
+
italic: unref(preset).common.font_style === 'italic'
|
|
33
33
|
}));
|
|
34
34
|
}),
|
|
35
35
|
|
|
36
36
|
toggleItalic: createCommand(({ commands }) => {
|
|
37
|
-
const isItalicAvailable = this.editor.commands.isItalicAvailable();
|
|
37
|
+
const isItalicAvailable = unref(this.editor.commands.isItalicAvailable());
|
|
38
38
|
|
|
39
|
-
if (!isItalicAvailable
|
|
39
|
+
if (!isItalicAvailable) return;
|
|
40
40
|
|
|
41
|
-
commands.isItalic()
|
|
41
|
+
unref(commands.isItalic()) ? commands.removeItalic() : commands.applyItalic();
|
|
42
42
|
}),
|
|
43
43
|
|
|
44
44
|
applyItalic: createCommand(({ commands }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@ export const FontWeight = Mark.create({
|
|
|
14
14
|
return {
|
|
15
15
|
applyFontWeight: createCommand(({ commands }, value) => {
|
|
16
16
|
commands.setMark(this.name, { value });
|
|
17
|
-
const font = commands.getFont()
|
|
17
|
+
const font = unref(commands.getFont());
|
|
18
18
|
|
|
19
19
|
if (!font.isItalicSupported(value)) {
|
|
20
20
|
commands.removeItalic();
|
|
@@ -22,8 +22,8 @@ export const FontWeight = Mark.create({
|
|
|
22
22
|
}),
|
|
23
23
|
|
|
24
24
|
toggleBold: createCommand(({ commands }) => {
|
|
25
|
-
const currentWeight = commands.getFontWeight()
|
|
26
|
-
const currentFont = commands.getFont()
|
|
25
|
+
const currentWeight = unref(commands.getFontWeight());
|
|
26
|
+
const currentFont = unref(commands.getFont());
|
|
27
27
|
const isBold = Number(currentWeight) >= 600;
|
|
28
28
|
const wantedWeight = isBold ? '400' : '700';
|
|
29
29
|
const nextWeight = currentFont.findClosestWeight(wantedWeight);
|
|
@@ -33,23 +33,24 @@ export const FontWeight = Mark.create({
|
|
|
33
33
|
|
|
34
34
|
getFontWeight: createCommand(({ editor, commands }) => {
|
|
35
35
|
const defaultValue = commands.getDefaultFontWeight();
|
|
36
|
-
const
|
|
36
|
+
const fontRef = commands.getFont();
|
|
37
37
|
|
|
38
38
|
return computed(() => {
|
|
39
|
-
const weight = editor.getAttributes(this.name)?.value ?? defaultValue
|
|
39
|
+
const weight = editor.getAttributes(this.name)?.value ?? unref(defaultValue);
|
|
40
|
+
const font = unref(fontRef);
|
|
40
41
|
|
|
41
|
-
if (font.
|
|
42
|
+
if (font.isWeightSupported(weight)) {
|
|
42
43
|
return weight;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
return font.
|
|
46
|
+
return font.findClosestWeight(weight);
|
|
46
47
|
});
|
|
47
48
|
}),
|
|
48
49
|
|
|
49
50
|
getDefaultFontWeight: createCommand(({ commands }) => {
|
|
50
51
|
const preset = commands.getPreset();
|
|
51
52
|
|
|
52
|
-
return computed(() => preset.
|
|
53
|
+
return computed(() => unref(preset).common.font_weight);
|
|
53
54
|
})
|
|
54
55
|
};
|
|
55
56
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand, renderInlineSetting, convertLineHeight } from '../utils';
|
|
4
4
|
import { NodeTypes, TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -33,7 +33,7 @@ export const LineHeight = Extension.create({
|
|
|
33
33
|
|
|
34
34
|
if (!value) return null;
|
|
35
35
|
|
|
36
|
-
const wrapperEl = this.options.wrapperRef
|
|
36
|
+
const wrapperEl = unref(this.options.wrapperRef);
|
|
37
37
|
const converted = convertLineHeight(value, element, wrapperEl);
|
|
38
38
|
|
|
39
39
|
return { desktop: converted, tablet: converted, mobile: converted };
|
|
@@ -61,18 +61,18 @@ export const LineHeight = Extension.create({
|
|
|
61
61
|
const device = commands.getDevice();
|
|
62
62
|
const defaultValue = commands.getDefaultLineHeight();
|
|
63
63
|
|
|
64
|
-
return computed(() => attribute
|
|
64
|
+
return computed(() => unref(attribute)?.[unref(device)] ?? unref(defaultValue));
|
|
65
65
|
}),
|
|
66
66
|
|
|
67
67
|
getDefaultLineHeight: createCommand(({ commands }) => {
|
|
68
68
|
const device = commands.getDevice();
|
|
69
69
|
const preset = commands.getPreset();
|
|
70
70
|
|
|
71
|
-
return computed(() => preset
|
|
71
|
+
return computed(() => unref(preset)[unref(device)].line_height);
|
|
72
72
|
}),
|
|
73
73
|
|
|
74
74
|
applyLineHeight: createCommand(({ commands }, value) => {
|
|
75
|
-
const device = commands.getDevice()
|
|
75
|
+
const device = unref(commands.getDevice());
|
|
76
76
|
|
|
77
77
|
commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
|
|
78
78
|
})
|
package/lib/extensions/Link.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Base from '@tiptap/extension-link';
|
|
2
|
+
import { unref } from 'vue';
|
|
2
3
|
import { createCommand } from '../utils';
|
|
3
4
|
import { LinkDestinations, LinkTargets } from '../enums';
|
|
4
5
|
|
|
@@ -32,13 +33,14 @@ export const Link = Base.extend({
|
|
|
32
33
|
|
|
33
34
|
destination: {
|
|
34
35
|
default: LinkDestinations.URL,
|
|
36
|
+
|
|
35
37
|
parseHTML: (element) => {
|
|
36
38
|
const href = element.getAttribute('href');
|
|
37
39
|
|
|
38
40
|
if (!href.startsWith('#')) return LinkDestinations.URL;
|
|
39
41
|
|
|
40
42
|
const id = href.replace('#', '');
|
|
41
|
-
const blocks = this.options.pageBlocks
|
|
43
|
+
const blocks = unref(this.options.pageBlocks);
|
|
42
44
|
const block = blocks.find((block) => block.id === parseInt(id));
|
|
43
45
|
|
|
44
46
|
return block ? LinkDestinations.BLOCK : LinkDestinations.URL;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-2';
|
|
2
|
-
import { computed, toRef } from 'vue';
|
|
2
|
+
import { computed, toRef, unref } from 'vue';
|
|
3
3
|
import { Heading } from '@tiptap/extension-heading';
|
|
4
4
|
import { createCommand } from '../utils';
|
|
5
5
|
import { Devices, NodeTypes, TextSettings } from '../enums';
|
|
@@ -35,7 +35,7 @@ export const StylePreset = Extension.create({
|
|
|
35
35
|
default: { id: this.options.defaultId },
|
|
36
36
|
|
|
37
37
|
parseHTML: (element) => {
|
|
38
|
-
const presets = this.options.presets
|
|
38
|
+
const presets = unref(this.options.presets);
|
|
39
39
|
|
|
40
40
|
if (element.parentElement.tagName === 'LI') return null;
|
|
41
41
|
|
|
@@ -79,11 +79,11 @@ export const StylePreset = Extension.create({
|
|
|
79
79
|
const selection = commands.getBlockAttributes('preset', { id: this.options.defaultId });
|
|
80
80
|
const presets = commands.getPresetList();
|
|
81
81
|
|
|
82
|
-
return computed(() => findPresetById(presets
|
|
82
|
+
return computed(() => findPresetById(unref(presets), unref(selection).id));
|
|
83
83
|
}),
|
|
84
84
|
|
|
85
85
|
applyPreset: createCommand(({ commands, chain }, presetId) => {
|
|
86
|
-
const presets = commands.getPresetList()
|
|
86
|
+
const presets = unref(commands.getPresetList());
|
|
87
87
|
const preset = findPresetById(presets, presetId);
|
|
88
88
|
const nodeType = preset.node?.type ?? NodeTypes.PARAGRAPH;
|
|
89
89
|
|
|
@@ -96,7 +96,7 @@ export const StylePreset = Extension.create({
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
for (const textAttribute of TextSettings.attributes) {
|
|
99
|
-
attrs[textAttribute] = commands.getBlockAttributes(textAttribute)
|
|
99
|
+
attrs[textAttribute] = unref(commands.getBlockAttributes(textAttribute));
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
chain().removeList().setNode(nodeType, attrs).run();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -16,13 +16,13 @@ export const TextDecoration = Mark.create({
|
|
|
16
16
|
isUnderline: createCommand(({ commands, editor }) => {
|
|
17
17
|
const decoration = commands.getTextDecoration();
|
|
18
18
|
|
|
19
|
-
return computed(() => editor.isActive('link') || decoration.
|
|
19
|
+
return computed(() => editor.isActive('link') || unref(decoration).underline);
|
|
20
20
|
}),
|
|
21
21
|
|
|
22
22
|
isStrikeThrough: createCommand(({ commands }) => {
|
|
23
23
|
const decoration = commands.getTextDecoration();
|
|
24
24
|
|
|
25
|
-
return computed(() => decoration.
|
|
25
|
+
return computed(() => unref(decoration).strike_through);
|
|
26
26
|
}),
|
|
27
27
|
|
|
28
28
|
getTextDecoration: createCommand(({ editor, commands }) => {
|
|
@@ -32,8 +32,8 @@ export const TextDecoration = Mark.create({
|
|
|
32
32
|
const attrs = editor.getAttributes(this.name) ?? {};
|
|
33
33
|
|
|
34
34
|
return {
|
|
35
|
-
underline: attrs.underline ?? defaultValue.
|
|
36
|
-
strike_through: attrs.strike_through ?? defaultValue.
|
|
35
|
+
underline: attrs.underline ?? unref(defaultValue).underline,
|
|
36
|
+
strike_through: attrs.strike_through ?? unref(defaultValue).strike_through
|
|
37
37
|
};
|
|
38
38
|
});
|
|
39
39
|
}),
|
|
@@ -42,7 +42,7 @@ export const TextDecoration = Mark.create({
|
|
|
42
42
|
const preset = commands.getPreset();
|
|
43
43
|
|
|
44
44
|
return computed(() => {
|
|
45
|
-
const decoration = preset.
|
|
45
|
+
const decoration = unref(preset).common.text_decoration;
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
48
|
underline: decoration.includes('underline'),
|
|
@@ -62,7 +62,7 @@ export const TextDecoration = Mark.create({
|
|
|
62
62
|
}),
|
|
63
63
|
|
|
64
64
|
toggleTextDecoration: createCommand(({ commands }, name) => {
|
|
65
|
-
const isEnabled = commands.getTextDecoration()
|
|
65
|
+
const isEnabled = unref(commands.getTextDecoration())[name];
|
|
66
66
|
|
|
67
67
|
isEnabled ? commands.removeTextDecoration(name) : commands.applyTextDecoration(name);
|
|
68
68
|
}),
|
|
@@ -73,7 +73,7 @@ export const TextDecoration = Mark.create({
|
|
|
73
73
|
|
|
74
74
|
removeTextDecoration: createCommand(({ commands }, name) => {
|
|
75
75
|
const mark = {
|
|
76
|
-
...commands.getTextDecoration()
|
|
76
|
+
...unref(commands.getTextDecoration()),
|
|
77
77
|
[name]: false
|
|
78
78
|
};
|
|
79
79
|
const isRemoveMark = !mark.underline && !mark.strike_through;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand } from '../../utils';
|
|
4
4
|
import { NodeTypes } from '../../enums';
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ export const NodeProcessor = Extension.create({
|
|
|
9
9
|
addCommands() {
|
|
10
10
|
return {
|
|
11
11
|
setBlockAttributes: createCommand(({ commands }, name, attrs, defaults = {}) => {
|
|
12
|
-
const current = commands.getBlockAttributes(name)
|
|
12
|
+
const current = unref(commands.getBlockAttributes(name)) ?? {};
|
|
13
13
|
|
|
14
14
|
for (const type of NodeTypes.blocks) {
|
|
15
15
|
commands.updateAttributes(type, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, wrappingInputRule } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand } from '../../utils';
|
|
4
4
|
import { ListTypes, NodeTypes } from '../../enums';
|
|
5
5
|
import { ListItem } from './ListItem';
|
|
@@ -70,11 +70,11 @@ export const List = Node.create({
|
|
|
70
70
|
getListType: createCommand(({ commands }) => {
|
|
71
71
|
const attribute = commands.getBlockAttributes('bullet', { type: null });
|
|
72
72
|
|
|
73
|
-
return computed(() => attribute.
|
|
73
|
+
return computed(() => unref(attribute).type ?? null);
|
|
74
74
|
}),
|
|
75
75
|
|
|
76
76
|
applyList: createCommand(({ commands, chain }, type) => {
|
|
77
|
-
const currentType = commands.getListType()
|
|
77
|
+
const currentType = unref(commands.getListType());
|
|
78
78
|
|
|
79
79
|
// Remove List
|
|
80
80
|
if (currentType === type) {
|
|
@@ -206,7 +206,10 @@ export class ContentNormalizer {
|
|
|
206
206
|
|
|
207
207
|
const fragment = new DocumentFragment();
|
|
208
208
|
const children = Array.from(parentElement.childNodes);
|
|
209
|
-
|
|
209
|
+
const parentTemplate = parentElement.cloneNode(true);
|
|
210
|
+
|
|
211
|
+
parentTemplate.innerHTML = '';
|
|
212
|
+
let capturingParagraph = parentTemplate.cloneNode();
|
|
210
213
|
|
|
211
214
|
const append = (node) => {
|
|
212
215
|
this._assignElementProperties(node, parentElement, ContentNormalizer.BLOCK_STYLES);
|
|
@@ -216,7 +219,7 @@ export class ContentNormalizer {
|
|
|
216
219
|
for (const child of children) {
|
|
217
220
|
if (child.tagName === 'BR') {
|
|
218
221
|
append(capturingParagraph);
|
|
219
|
-
capturingParagraph =
|
|
222
|
+
capturingParagraph = parentTemplate.cloneNode();
|
|
220
223
|
continue;
|
|
221
224
|
}
|
|
222
225
|
|
|
@@ -154,4 +154,11 @@ describe('normalize text content', () => {
|
|
|
154
154
|
|
|
155
155
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
156
156
|
});
|
|
157
|
+
|
|
158
|
+
test('should duplicate parent tag on normalize br', () => {
|
|
159
|
+
const input = '<h1><br></h1>';
|
|
160
|
+
const output = '<h1><br></h1>';
|
|
161
|
+
|
|
162
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
163
|
+
});
|
|
157
164
|
});
|