@zipify/wysiwyg 1.2.1-2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/wysiwyg.mjs CHANGED
@@ -22926,8 +22926,7 @@ function useToolbar({ wrapperRef, offsets, isActiveRef, placementRef }) {
22926
22926
  const FontFamily = Mark.create({
22927
22927
  name: TextSettings.FONT_FAMILY,
22928
22928
  addOptions: () => ({
22929
- fonts: [],
22930
- defaultFont: ""
22929
+ fonts: []
22931
22930
  }),
22932
22931
  addAttributes: () => ({
22933
22932
  value: { required: true }
@@ -22970,7 +22969,7 @@ const FontFamily = Mark.create({
22970
22969
  const getAttrs = (input) => {
22971
22970
  const parsed = input.replace(/"/g, "");
22972
22971
  const isExists = this.options.fonts.some((font) => font.name === parsed);
22973
- const value = isExists ? parsed : this.options.defaultFont;
22972
+ const value = isExists ? parsed : unref(this.options.defaultPreset).common.font_family;
22974
22973
  return { value };
22975
22974
  };
22976
22975
  return [
@@ -25855,8 +25854,11 @@ const Margin = Extension.create({
25855
25854
  });
25856
25855
  function buildExtensions(options) {
25857
25856
  const getPresetById = (id2) => options.presetsRef.value.find((preset) => preset.id === id2);
25858
- const defaultPreset = getPresetById(options.defaultPresetId);
25859
- const linkPreset = getPresetById(options.linkPresetId);
25857
+ const presetsMap = reactive({ default: null, link: null });
25858
+ watch(options.presetsRef, () => {
25859
+ presetsMap.default = getPresetById(options.defaultPresetId);
25860
+ presetsMap.link = getPresetById(options.linkPresetId);
25861
+ }, { immediate: true });
25860
25862
  return buildCoreExtensions().concat([
25861
25863
  StylePreset.configure({
25862
25864
  presets: options.presetsRef,
@@ -25877,7 +25879,7 @@ function buildExtensions(options) {
25877
25879
  }),
25878
25880
  FontFamily.configure({
25879
25881
  fonts: options.fonts,
25880
- defaultFont: defaultPreset.common.font_family
25882
+ defaultPreset: toRef(presetsMap, "default")
25881
25883
  }),
25882
25884
  FontWeight,
25883
25885
  FontColor,
@@ -25891,7 +25893,7 @@ function buildExtensions(options) {
25891
25893
  wrapperRef: options.wrapperRef
25892
25894
  }),
25893
25895
  Link.configure({
25894
- preset: linkPreset,
25896
+ preset: toRef(presetsMap, "link"),
25895
25897
  basePresetClass: options.basePresetClass,
25896
25898
  pageBlocks: options.pageBlocksRef
25897
25899
  }),
@@ -7,8 +7,7 @@ export const FontFamily = Mark.create({
7
7
  name: TextSettings.FONT_FAMILY,
8
8
 
9
9
  addOptions: () => ({
10
- fonts: [],
11
- defaultFont: ''
10
+ fonts: []
12
11
  }),
13
12
 
14
13
  addAttributes: () => ({
@@ -61,7 +60,7 @@ export const FontFamily = Mark.create({
61
60
  const getAttrs = (input) => {
62
61
  const parsed = input.replace(/"/g, '');
63
62
  const isExists = this.options.fonts.some((font) => font.name === parsed);
64
- const value = isExists ? parsed : this.options.defaultFont;
63
+ const value = isExists ? parsed : unref(this.options.defaultPreset).common.font_family;
65
64
 
66
65
  return { value };
67
66
  };
@@ -36,7 +36,9 @@ function createEditor({ content }) {
36
36
  new Font({ name: 'Roboto', styles: ['400', '400i'] }),
37
37
  new Font({ name: 'Josefin Slab', styles: ['400', '400i'] })
38
38
  ],
39
- defaultFont: 'Lato'
39
+ defaultPreset: ref({
40
+ common: { font_family: 'Lato' }
41
+ })
40
42
  }),
41
43
  FontWeight,
42
44
  FontStyle
@@ -1,3 +1,4 @@
1
+ import { reactive, toRef, watch } from 'vue';
1
2
  import { FontFamily } from './FontFamily';
2
3
  import { StylePreset } from './StylePreset';
3
4
  import { FontWeight } from './FontWeight';
@@ -18,8 +19,12 @@ import { Margin } from './Margin';
18
19
 
19
20
  export function buildExtensions(options) {
20
21
  const getPresetById = (id) => options.presetsRef.value.find((preset) => preset.id === id);
21
- const defaultPreset = getPresetById(options.defaultPresetId);
22
- const linkPreset = getPresetById(options.linkPresetId);
22
+ const presetsMap = reactive({ default: null, link: null });
23
+
24
+ watch(options.presetsRef, () => {
25
+ presetsMap.default = getPresetById(options.defaultPresetId);
26
+ presetsMap.link = getPresetById(options.linkPresetId);
27
+ }, { immediate: true });
23
28
 
24
29
  return buildCoreExtensions(options).concat([
25
30
  StylePreset.configure({
@@ -42,7 +47,7 @@ export function buildExtensions(options) {
42
47
  }),
43
48
  FontFamily.configure({
44
49
  fonts: options.fonts,
45
- defaultFont: defaultPreset.common.font_family
50
+ defaultPreset: toRef(presetsMap, 'default')
46
51
  }),
47
52
  FontWeight,
48
53
  FontColor,
@@ -56,7 +61,7 @@ export function buildExtensions(options) {
56
61
  wrapperRef: options.wrapperRef
57
62
  }),
58
63
  Link.configure({
59
- preset: linkPreset,
64
+ preset: toRef(presetsMap, 'link'),
60
65
  basePresetClass: options.basePresetClass,
61
66
  pageBlocks: options.pageBlocksRef
62
67
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "1.2.1-2",
3
+ "version": "1.2.1",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "bin": {