@zipify/wysiwyg 1.0.0-dev.89 → 1.0.0-dev.91
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 +59 -58
- 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/package.json +1 -1
package/dist/wysiwyg.css
CHANGED
|
@@ -521,19 +521,19 @@
|
|
|
521
521
|
line-height: var(--zw-line-height-xxs);
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
-
.zw-style-preset-control[data-v-
|
|
524
|
+
.zw-style-preset-control[data-v-2893d64e] {
|
|
525
525
|
display: flex;
|
|
526
526
|
align-items: center;
|
|
527
527
|
}
|
|
528
|
-
.zw-style-preset-control__dropdown[data-v-
|
|
528
|
+
.zw-style-preset-control__dropdown[data-v-2893d64e] {
|
|
529
529
|
width: 96px;
|
|
530
530
|
}
|
|
531
|
-
.zw-style-preset-control__reset[data-v-
|
|
531
|
+
.zw-style-preset-control__reset[data-v-2893d64e] {
|
|
532
532
|
color: rgb(var(--zw-color-n70));
|
|
533
533
|
}
|
|
534
|
-
.zw-style-preset-control__reset[data-v-
|
|
535
|
-
.zw-style-preset-control__reset[data-v-
|
|
536
|
-
.zw-style-preset-control__reset[data-v-
|
|
534
|
+
.zw-style-preset-control__reset[data-v-2893d64e]:not(:disabled):hover,
|
|
535
|
+
.zw-style-preset-control__reset[data-v-2893d64e]:not(:disabled):focus,
|
|
536
|
+
.zw-style-preset-control__reset[data-v-2893d64e]:not(:disabled):focus-within {
|
|
537
537
|
color: rgb(var(--zw-color-white));
|
|
538
538
|
}
|
|
539
539
|
|
|
@@ -572,17 +572,17 @@
|
|
|
572
572
|
margin-left: var(--zw-offset-sm);
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
.zpa-list-control[data-v-
|
|
575
|
+
.zpa-list-control[data-v-2eeb2252] {
|
|
576
576
|
display: flex;
|
|
577
577
|
}
|
|
578
|
-
.zpa-list-control[data-v-
|
|
578
|
+
.zpa-list-control[data-v-2eeb2252]:hover {
|
|
579
579
|
color: rgb(var(--zw-color-white));
|
|
580
580
|
background-color: rgb(var(--zw-color-n5));
|
|
581
581
|
}
|
|
582
|
-
.zw-list-control__activator[data-v-
|
|
582
|
+
.zw-list-control__activator[data-v-2eeb2252] {
|
|
583
583
|
padding: 0 var(--zw-offset-xs);
|
|
584
584
|
}
|
|
585
|
-
.zw-list-control__option[data-v-
|
|
585
|
+
.zw-list-control__option[data-v-2eeb2252] {
|
|
586
586
|
padding: 0 var(--zw-offset-xs);
|
|
587
587
|
display: flex;
|
|
588
588
|
}
|
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;
|
|
@@ -20683,11 +20683,11 @@ const __vue2_script$p = {
|
|
|
20683
20683
|
const preset = editor.commands.getPreset();
|
|
20684
20684
|
const customization = editor.commands.getPresetCustomization();
|
|
20685
20685
|
const isCustomized = computed(() => {
|
|
20686
|
-
const { attributes, marks } = customization
|
|
20686
|
+
const { attributes, marks } = unref(customization);
|
|
20687
20687
|
return !!attributes.length || !!marks.length;
|
|
20688
20688
|
});
|
|
20689
20689
|
const options = computed(() => {
|
|
20690
|
-
return presets.
|
|
20690
|
+
return unref(presets).map((preset2) => ({
|
|
20691
20691
|
id: preset2.id,
|
|
20692
20692
|
title: preset2.name
|
|
20693
20693
|
}));
|
|
@@ -20712,7 +20712,7 @@ var __component__$p = /* @__PURE__ */ normalizeComponent(
|
|
|
20712
20712
|
staticRenderFns$p,
|
|
20713
20713
|
false,
|
|
20714
20714
|
__vue2_injectStyles$p,
|
|
20715
|
-
"
|
|
20715
|
+
"2893d64e",
|
|
20716
20716
|
null,
|
|
20717
20717
|
null
|
|
20718
20718
|
);
|
|
@@ -20876,7 +20876,7 @@ const __vue2_script$n = {
|
|
|
20876
20876
|
setup() {
|
|
20877
20877
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
20878
20878
|
const font = editor.commands.getFont();
|
|
20879
|
-
const options = computed(() => font.
|
|
20879
|
+
const options = computed(() => unref(font).weights.map((style2) => ({ id: style2 })));
|
|
20880
20880
|
const currentValue = editor.commands.getFontWeight();
|
|
20881
20881
|
const apply2 = (value) => editor.chain().focus().applyFontWeight(value).run();
|
|
20882
20882
|
return {
|
|
@@ -21249,7 +21249,7 @@ const __vue2_script$i = {
|
|
|
21249
21249
|
},
|
|
21250
21250
|
setup() {
|
|
21251
21251
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
21252
|
-
const currentValue =
|
|
21252
|
+
const currentValue = editor.commands.isUnderline();
|
|
21253
21253
|
const apply2 = () => editor.chain().focus().toggleUnderline().run();
|
|
21254
21254
|
return {
|
|
21255
21255
|
currentValue,
|
|
@@ -21901,10 +21901,10 @@ const __vue2_script$b = {
|
|
|
21901
21901
|
setup() {
|
|
21902
21902
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
21903
21903
|
const selectionValue = editor.commands.getListType();
|
|
21904
|
-
const isList2 = computed(() => !!selectionValue
|
|
21905
|
-
const currentValue = computed(() => selectionValue
|
|
21904
|
+
const isList2 = computed(() => !!unref(selectionValue));
|
|
21905
|
+
const currentValue = computed(() => unref(selectionValue) || "none");
|
|
21906
21906
|
const recentListType = ref(ListTypes.DISC);
|
|
21907
|
-
const isCurrentListSelected = computed(() => selectionValue
|
|
21907
|
+
const isCurrentListSelected = computed(() => unref(selectionValue) === recentListType.value);
|
|
21908
21908
|
const currentIcon = computed(() => `list-${recentListType.value}`);
|
|
21909
21909
|
const apply2 = (type) => {
|
|
21910
21910
|
recentListType.value = type;
|
|
@@ -21928,7 +21928,7 @@ var __component__$b = /* @__PURE__ */ normalizeComponent(
|
|
|
21928
21928
|
staticRenderFns$b,
|
|
21929
21929
|
false,
|
|
21930
21930
|
__vue2_injectStyles$b,
|
|
21931
|
-
"
|
|
21931
|
+
"2eeb2252",
|
|
21932
21932
|
null,
|
|
21933
21933
|
null
|
|
21934
21934
|
);
|
|
@@ -22876,7 +22876,7 @@ const FontFamily = Mark.create({
|
|
|
22876
22876
|
applyFontFamily: createCommand(({ commands: commands2 }, value) => {
|
|
22877
22877
|
commands2.setMark(this.name, { value });
|
|
22878
22878
|
const font = commands2.findFontByName(value);
|
|
22879
|
-
let fontWeight = commands2.getFontWeight()
|
|
22879
|
+
let fontWeight = unref(commands2.getFontWeight());
|
|
22880
22880
|
if (!font.isWeightSupported(fontWeight)) {
|
|
22881
22881
|
fontWeight = font.findClosestWeight(fontWeight);
|
|
22882
22882
|
commands2.applyFontWeight(fontWeight);
|
|
@@ -22887,7 +22887,7 @@ const FontFamily = Mark.create({
|
|
|
22887
22887
|
}),
|
|
22888
22888
|
getFont: createCommand(({ commands: commands2 }) => {
|
|
22889
22889
|
const fontFamily = commands2.getFontFamily();
|
|
22890
|
-
return computed(() => commands2.findFontByName(fontFamily
|
|
22890
|
+
return computed(() => commands2.findFontByName(unref(fontFamily)));
|
|
22891
22891
|
}),
|
|
22892
22892
|
findFontByName: createCommand((_, name) => {
|
|
22893
22893
|
return this.options.fonts.find((font) => font.name === name);
|
|
@@ -22896,12 +22896,12 @@ const FontFamily = Mark.create({
|
|
|
22896
22896
|
const defaultValue = commands2.getDefaultFontFamily();
|
|
22897
22897
|
return computed(() => {
|
|
22898
22898
|
var _a, _b;
|
|
22899
|
-
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : defaultValue
|
|
22899
|
+
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : unref(defaultValue);
|
|
22900
22900
|
});
|
|
22901
22901
|
}),
|
|
22902
22902
|
getDefaultFontFamily: createCommand(({ commands: commands2 }) => {
|
|
22903
22903
|
const preset = commands2.getPreset();
|
|
22904
|
-
return computed(() => preset.
|
|
22904
|
+
return computed(() => unref(preset).common.font_family);
|
|
22905
22905
|
})
|
|
22906
22906
|
};
|
|
22907
22907
|
},
|
|
@@ -23018,7 +23018,7 @@ const StylePreset = Extension.create({
|
|
|
23018
23018
|
isRequired: false,
|
|
23019
23019
|
default: { id: this.options.defaultId },
|
|
23020
23020
|
parseHTML: (element) => {
|
|
23021
|
-
const presets = this.options.presets
|
|
23021
|
+
const presets = unref(this.options.presets);
|
|
23022
23022
|
if (element.parentElement.tagName === "LI")
|
|
23023
23023
|
return null;
|
|
23024
23024
|
for (const { id: id2, node, fallbackClass } of presets) {
|
|
@@ -23054,11 +23054,11 @@ const StylePreset = Extension.create({
|
|
|
23054
23054
|
getPreset: createCommand(({ commands: commands2 }) => {
|
|
23055
23055
|
const selection = commands2.getBlockAttributes("preset", { id: this.options.defaultId });
|
|
23056
23056
|
const presets = commands2.getPresetList();
|
|
23057
|
-
return computed(() => findPresetById(presets
|
|
23057
|
+
return computed(() => findPresetById(unref(presets), unref(selection).id));
|
|
23058
23058
|
}),
|
|
23059
23059
|
applyPreset: createCommand(({ commands: commands2, chain }, presetId) => {
|
|
23060
23060
|
var _a, _b;
|
|
23061
|
-
const presets = commands2.getPresetList()
|
|
23061
|
+
const presets = unref(commands2.getPresetList());
|
|
23062
23062
|
const preset = findPresetById(presets, presetId);
|
|
23063
23063
|
const nodeType = (_b = (_a = preset.node) == null ? void 0 : _a.type) != null ? _b : NodeTypes.PARAGRAPH;
|
|
23064
23064
|
const attrs = {
|
|
@@ -23068,7 +23068,7 @@ const StylePreset = Extension.create({
|
|
|
23068
23068
|
attrs.level = preset.node.level;
|
|
23069
23069
|
}
|
|
23070
23070
|
for (const textAttribute of TextSettings.attributes) {
|
|
23071
|
-
attrs[textAttribute] = commands2.getBlockAttributes(textAttribute)
|
|
23071
|
+
attrs[textAttribute] = unref(commands2.getBlockAttributes(textAttribute));
|
|
23072
23072
|
}
|
|
23073
23073
|
chain().removeList().setNode(nodeType, attrs).run();
|
|
23074
23074
|
}),
|
|
@@ -23144,14 +23144,14 @@ const FontWeight = Mark.create({
|
|
|
23144
23144
|
return {
|
|
23145
23145
|
applyFontWeight: createCommand(({ commands: commands2 }, value) => {
|
|
23146
23146
|
commands2.setMark(this.name, { value });
|
|
23147
|
-
const font = commands2.getFont()
|
|
23147
|
+
const font = unref(commands2.getFont());
|
|
23148
23148
|
if (!font.isItalicSupported(value)) {
|
|
23149
23149
|
commands2.removeItalic();
|
|
23150
23150
|
}
|
|
23151
23151
|
}),
|
|
23152
23152
|
toggleBold: createCommand(({ commands: commands2 }) => {
|
|
23153
|
-
const currentWeight = commands2.getFontWeight()
|
|
23154
|
-
const currentFont = commands2.getFont()
|
|
23153
|
+
const currentWeight = unref(commands2.getFontWeight());
|
|
23154
|
+
const currentFont = unref(commands2.getFont());
|
|
23155
23155
|
const isBold = Number(currentWeight) >= 600;
|
|
23156
23156
|
const wantedWeight = isBold ? "400" : "700";
|
|
23157
23157
|
const nextWeight = currentFont.findClosestWeight(wantedWeight);
|
|
@@ -23159,19 +23159,20 @@ const FontWeight = Mark.create({
|
|
|
23159
23159
|
}),
|
|
23160
23160
|
getFontWeight: createCommand(({ editor, commands: commands2 }) => {
|
|
23161
23161
|
const defaultValue = commands2.getDefaultFontWeight();
|
|
23162
|
-
const
|
|
23162
|
+
const fontRef = commands2.getFont();
|
|
23163
23163
|
return computed(() => {
|
|
23164
23164
|
var _a, _b;
|
|
23165
|
-
const weight = (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : defaultValue
|
|
23166
|
-
|
|
23165
|
+
const weight = (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : unref(defaultValue);
|
|
23166
|
+
const font = unref(fontRef);
|
|
23167
|
+
if (font.isWeightSupported(weight)) {
|
|
23167
23168
|
return weight;
|
|
23168
23169
|
}
|
|
23169
|
-
return font.
|
|
23170
|
+
return font.findClosestWeight(weight);
|
|
23170
23171
|
});
|
|
23171
23172
|
}),
|
|
23172
23173
|
getDefaultFontWeight: createCommand(({ commands: commands2 }) => {
|
|
23173
23174
|
const preset = commands2.getPreset();
|
|
23174
|
-
return computed(() => preset.
|
|
23175
|
+
return computed(() => unref(preset).common.font_weight);
|
|
23175
23176
|
})
|
|
23176
23177
|
};
|
|
23177
23178
|
},
|
|
@@ -23226,25 +23227,25 @@ const FontSize = Mark.create({
|
|
|
23226
23227
|
const defaultValue = commands2.getDefaultFontSize();
|
|
23227
23228
|
return computed(() => {
|
|
23228
23229
|
var _a, _b;
|
|
23229
|
-
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a[device
|
|
23230
|
+
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a[unref(device)]) != null ? _b : unref(defaultValue);
|
|
23230
23231
|
});
|
|
23231
23232
|
}),
|
|
23232
23233
|
getDefaultFontSize: createCommand(({ commands: commands2 }) => {
|
|
23233
23234
|
const device = commands2.getDevice();
|
|
23234
23235
|
const preset = commands2.getPreset();
|
|
23235
|
-
return computed(() => preset
|
|
23236
|
+
return computed(() => unref(preset)[unref(device)].font_size.replace("px", ""));
|
|
23236
23237
|
}),
|
|
23237
23238
|
applyFontSize: createCommand(({ commands: commands2 }, value) => {
|
|
23238
|
-
const device = commands2.getDevice()
|
|
23239
|
+
const device = unref(commands2.getDevice());
|
|
23239
23240
|
commands2.setMark(this.name, { [device]: value });
|
|
23240
23241
|
}),
|
|
23241
23242
|
increaseFontSize: createCommand(({ commands: commands2 }) => {
|
|
23242
|
-
const size2 = Number(commands2.getFontSize()
|
|
23243
|
+
const size2 = Number(unref(commands2.getFontSize()));
|
|
23243
23244
|
const nextSize = Math.min(size2 + 1, this.options.maxSize);
|
|
23244
23245
|
commands2.applyFontSize(String(nextSize));
|
|
23245
23246
|
}),
|
|
23246
23247
|
decreaseFontSize: createCommand(({ commands: commands2 }) => {
|
|
23247
|
-
const size2 = Number(commands2.getFontSize()
|
|
23248
|
+
const size2 = Number(unref(commands2.getFontSize()));
|
|
23248
23249
|
const nextSize = Math.max(size2 - 1, this.options.minSize);
|
|
23249
23250
|
commands2.applyFontSize(String(nextSize));
|
|
23250
23251
|
})
|
|
@@ -23258,7 +23259,7 @@ const FontSize = Mark.create({
|
|
|
23258
23259
|
const parseSize = (value) => {
|
|
23259
23260
|
if (!value)
|
|
23260
23261
|
return null;
|
|
23261
|
-
const wrapperEl = this.options.wrapperRef
|
|
23262
|
+
const wrapperEl = unref(this.options.wrapperRef);
|
|
23262
23263
|
const converted = convertFontSize(value, wrapperEl);
|
|
23263
23264
|
return String(converted);
|
|
23264
23265
|
};
|
|
@@ -23300,12 +23301,12 @@ const FontColor = Mark.create({
|
|
|
23300
23301
|
const defaultValue = commands2.getDefaultFontColor();
|
|
23301
23302
|
return computed(() => {
|
|
23302
23303
|
var _a, _b;
|
|
23303
|
-
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : defaultValue
|
|
23304
|
+
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : unref(defaultValue);
|
|
23304
23305
|
});
|
|
23305
23306
|
}),
|
|
23306
23307
|
getDefaultFontColor: createCommand(({ commands: commands2 }) => {
|
|
23307
23308
|
const preset = commands2.getPreset();
|
|
23308
|
-
return computed(() => preset.
|
|
23309
|
+
return computed(() => unref(preset).common.color);
|
|
23309
23310
|
}),
|
|
23310
23311
|
applyFontColor: createCommand(({ commands: commands2 }, value) => {
|
|
23311
23312
|
commands2.setMark(this.name, { value });
|
|
@@ -23383,25 +23384,25 @@ const FontStyle = Mark.create({
|
|
|
23383
23384
|
const defaultValue = commands2.getDefaultFontStyle();
|
|
23384
23385
|
return computed(() => {
|
|
23385
23386
|
var _a, _b;
|
|
23386
|
-
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.italic) != null ? _b : defaultValue.
|
|
23387
|
+
return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.italic) != null ? _b : unref(defaultValue).italic;
|
|
23387
23388
|
});
|
|
23388
23389
|
}),
|
|
23389
23390
|
isItalicAvailable: createCommand(({ commands: commands2 }) => {
|
|
23390
23391
|
const font = commands2.getFont();
|
|
23391
23392
|
const fontWeight = commands2.getFontWeight();
|
|
23392
|
-
return computed(() => font.
|
|
23393
|
+
return computed(() => unref(font).isItalicSupported(unref(fontWeight)));
|
|
23393
23394
|
}),
|
|
23394
23395
|
getDefaultFontStyle: createCommand(({ commands: commands2 }) => {
|
|
23395
23396
|
const preset = commands2.getPreset();
|
|
23396
23397
|
return computed(() => ({
|
|
23397
|
-
italic: preset.
|
|
23398
|
+
italic: unref(preset).common.font_style === "italic"
|
|
23398
23399
|
}));
|
|
23399
23400
|
}),
|
|
23400
23401
|
toggleItalic: createCommand(({ commands: commands2 }) => {
|
|
23401
|
-
const isItalicAvailable = this.editor.commands.isItalicAvailable();
|
|
23402
|
-
if (!isItalicAvailable
|
|
23402
|
+
const isItalicAvailable = unref(this.editor.commands.isItalicAvailable());
|
|
23403
|
+
if (!isItalicAvailable)
|
|
23403
23404
|
return;
|
|
23404
|
-
commands2.isItalic()
|
|
23405
|
+
unref(commands2.isItalic()) ? commands2.removeItalic() : commands2.applyItalic();
|
|
23405
23406
|
}),
|
|
23406
23407
|
applyItalic: createCommand(({ commands: commands2 }) => {
|
|
23407
23408
|
commands2.setMark(this.name, { italic: true });
|
|
@@ -23447,11 +23448,11 @@ const TextDecoration = Mark.create({
|
|
|
23447
23448
|
return {
|
|
23448
23449
|
isUnderline: createCommand(({ commands: commands2, editor }) => {
|
|
23449
23450
|
const decoration = commands2.getTextDecoration();
|
|
23450
|
-
return computed(() => editor.isActive("link") || decoration.
|
|
23451
|
+
return computed(() => editor.isActive("link") || unref(decoration).underline);
|
|
23451
23452
|
}),
|
|
23452
23453
|
isStrikeThrough: createCommand(({ commands: commands2 }) => {
|
|
23453
23454
|
const decoration = commands2.getTextDecoration();
|
|
23454
|
-
return computed(() => decoration.
|
|
23455
|
+
return computed(() => unref(decoration).strike_through);
|
|
23455
23456
|
}),
|
|
23456
23457
|
getTextDecoration: createCommand(({ editor, commands: commands2 }) => {
|
|
23457
23458
|
const defaultValue = commands2.getDefaultTextDecoration();
|
|
@@ -23459,15 +23460,15 @@ const TextDecoration = Mark.create({
|
|
|
23459
23460
|
var _a, _b, _c;
|
|
23460
23461
|
const attrs = (_a = editor.getAttributes(this.name)) != null ? _a : {};
|
|
23461
23462
|
return {
|
|
23462
|
-
underline: (_b = attrs.underline) != null ? _b : defaultValue.
|
|
23463
|
-
strike_through: (_c = attrs.strike_through) != null ? _c : defaultValue.
|
|
23463
|
+
underline: (_b = attrs.underline) != null ? _b : unref(defaultValue).underline,
|
|
23464
|
+
strike_through: (_c = attrs.strike_through) != null ? _c : unref(defaultValue).strike_through
|
|
23464
23465
|
};
|
|
23465
23466
|
});
|
|
23466
23467
|
}),
|
|
23467
23468
|
getDefaultTextDecoration: createCommand(({ commands: commands2 }) => {
|
|
23468
23469
|
const preset = commands2.getPreset();
|
|
23469
23470
|
return computed(() => {
|
|
23470
|
-
const decoration = preset.
|
|
23471
|
+
const decoration = unref(preset).common.text_decoration;
|
|
23471
23472
|
return {
|
|
23472
23473
|
underline: decoration.includes("underline"),
|
|
23473
23474
|
strike_through: decoration.includes("line-through")
|
|
@@ -23483,7 +23484,7 @@ const TextDecoration = Mark.create({
|
|
|
23483
23484
|
commands2.toggleTextDecoration("strike_through");
|
|
23484
23485
|
}),
|
|
23485
23486
|
toggleTextDecoration: createCommand(({ commands: commands2 }, name) => {
|
|
23486
|
-
const isEnabled = commands2.getTextDecoration()
|
|
23487
|
+
const isEnabled = unref(commands2.getTextDecoration())[name];
|
|
23487
23488
|
isEnabled ? commands2.removeTextDecoration(name) : commands2.applyTextDecoration(name);
|
|
23488
23489
|
}),
|
|
23489
23490
|
applyTextDecoration: createCommand(({ commands: commands2 }, name) => {
|
|
@@ -23491,7 +23492,7 @@ const TextDecoration = Mark.create({
|
|
|
23491
23492
|
}),
|
|
23492
23493
|
removeTextDecoration: createCommand(({ commands: commands2 }, name) => {
|
|
23493
23494
|
const mark = {
|
|
23494
|
-
...commands2.getTextDecoration()
|
|
23495
|
+
...unref(commands2.getTextDecoration()),
|
|
23495
23496
|
[name]: false
|
|
23496
23497
|
};
|
|
23497
23498
|
const isRemoveMark = !mark.underline && !mark.strike_through;
|
|
@@ -23621,7 +23622,7 @@ const Alignment = Extension.create({
|
|
|
23621
23622
|
addCommands() {
|
|
23622
23623
|
return {
|
|
23623
23624
|
applyAlignment: createCommand(({ commands: commands2 }, value) => {
|
|
23624
|
-
const device = commands2.getDevice()
|
|
23625
|
+
const device = unref(commands2.getDevice());
|
|
23625
23626
|
commands2.setBlockAttributes(this.name, { [device]: value }, DEFAULTS$1);
|
|
23626
23627
|
}),
|
|
23627
23628
|
getAlignment: createCommand(({ commands: commands2 }) => {
|
|
@@ -23630,13 +23631,13 @@ const Alignment = Extension.create({
|
|
|
23630
23631
|
const defaultValue = commands2.getDefaultAlignment();
|
|
23631
23632
|
return computed(() => {
|
|
23632
23633
|
var _a, _b;
|
|
23633
|
-
return (_b = (_a = attribute
|
|
23634
|
+
return (_b = (_a = unref(attribute)) == null ? void 0 : _a[unref(device)]) != null ? _b : unref(defaultValue);
|
|
23634
23635
|
});
|
|
23635
23636
|
}),
|
|
23636
23637
|
getDefaultAlignment: createCommand(({ commands: commands2 }) => {
|
|
23637
23638
|
const device = commands2.getDevice();
|
|
23638
23639
|
const preset = commands2.getPreset();
|
|
23639
|
-
return computed(() => preset
|
|
23640
|
+
return computed(() => unref(preset)[unref(device)].alignment);
|
|
23640
23641
|
})
|
|
23641
23642
|
};
|
|
23642
23643
|
},
|
|
@@ -23671,7 +23672,7 @@ const LineHeight = Extension.create({
|
|
|
23671
23672
|
const value = element.style.lineHeight;
|
|
23672
23673
|
if (!value)
|
|
23673
23674
|
return null;
|
|
23674
|
-
const wrapperEl = this.options.wrapperRef
|
|
23675
|
+
const wrapperEl = unref(this.options.wrapperRef);
|
|
23675
23676
|
const converted = convertLineHeight(value, element, wrapperEl);
|
|
23676
23677
|
return { desktop: converted, tablet: converted, mobile: converted };
|
|
23677
23678
|
},
|
|
@@ -23697,16 +23698,16 @@ const LineHeight = Extension.create({
|
|
|
23697
23698
|
const defaultValue = commands2.getDefaultLineHeight();
|
|
23698
23699
|
return computed(() => {
|
|
23699
23700
|
var _a, _b;
|
|
23700
|
-
return (_b = (_a = attribute
|
|
23701
|
+
return (_b = (_a = unref(attribute)) == null ? void 0 : _a[unref(device)]) != null ? _b : unref(defaultValue);
|
|
23701
23702
|
});
|
|
23702
23703
|
}),
|
|
23703
23704
|
getDefaultLineHeight: createCommand(({ commands: commands2 }) => {
|
|
23704
23705
|
const device = commands2.getDevice();
|
|
23705
23706
|
const preset = commands2.getPreset();
|
|
23706
|
-
return computed(() => preset
|
|
23707
|
+
return computed(() => unref(preset)[unref(device)].line_height);
|
|
23707
23708
|
}),
|
|
23708
23709
|
applyLineHeight: createCommand(({ commands: commands2 }, value) => {
|
|
23709
|
-
const device = commands2.getDevice()
|
|
23710
|
+
const device = unref(commands2.getDevice());
|
|
23710
23711
|
commands2.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
|
|
23711
23712
|
})
|
|
23712
23713
|
};
|
|
@@ -23803,11 +23804,11 @@ const List = Node$1.create({
|
|
|
23803
23804
|
const attribute = commands2.getBlockAttributes("bullet", { type: null });
|
|
23804
23805
|
return computed(() => {
|
|
23805
23806
|
var _a;
|
|
23806
|
-
return (_a = attribute.
|
|
23807
|
+
return (_a = unref(attribute).type) != null ? _a : null;
|
|
23807
23808
|
});
|
|
23808
23809
|
}),
|
|
23809
23810
|
applyList: createCommand(({ commands: commands2, chain }, type) => {
|
|
23810
|
-
const currentType = commands2.getListType()
|
|
23811
|
+
const currentType = unref(commands2.getListType());
|
|
23811
23812
|
if (currentType === type) {
|
|
23812
23813
|
commands2.applyDefaultPreset();
|
|
23813
23814
|
return;
|
|
@@ -24840,7 +24841,7 @@ const Link = Link$1.extend({
|
|
|
24840
24841
|
if (!href.startsWith("#"))
|
|
24841
24842
|
return LinkDestinations.URL;
|
|
24842
24843
|
const id2 = href.replace("#", "");
|
|
24843
|
-
const blocks = this.options.pageBlocks
|
|
24844
|
+
const blocks = unref(this.options.pageBlocks);
|
|
24844
24845
|
const block = blocks.find((block2) => block2.id === parseInt(id2));
|
|
24845
24846
|
return block ? LinkDestinations.BLOCK : LinkDestinations.URL;
|
|
24846
24847
|
}
|
|
@@ -25583,7 +25584,7 @@ const NodeProcessor = Extension.create({
|
|
|
25583
25584
|
return {
|
|
25584
25585
|
setBlockAttributes: createCommand(({ commands: commands2 }, name, attrs, defaults2 = {}) => {
|
|
25585
25586
|
var _a;
|
|
25586
|
-
const current = (_a = commands2.getBlockAttributes(name)
|
|
25587
|
+
const current = (_a = unref(commands2.getBlockAttributes(name))) != null ? _a : {};
|
|
25587
25588
|
for (const type of NodeTypes.blocks) {
|
|
25588
25589
|
commands2.updateAttributes(type, {
|
|
25589
25590
|
[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) {
|