tiptapify 0.2.0 → 0.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tiptapify",
3
3
  "types": "./index.d.ts",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "description": "Tiptap3 editor with Vuetify3 menu implementation",
6
6
  "exports": {
7
7
  ".": {
@@ -94,14 +94,28 @@ function hexToRgb(hex: string): Color {
94
94
  function hoverColor(color: string) {
95
95
  colorSelected.value = false
96
96
 
97
- const interactiveStyles = editor.value.interactiveStyles
98
-
99
- if (props.fontColor && interactiveStyles) {
100
- editor.value.chain().focus().setColor(color).run()
97
+ if (props.fontColor) {
98
+ editor.value
99
+ .chain()
100
+ .focus()
101
+ .setColor(color)
102
+ .command(({ tr }) => {
103
+ tr.setMeta('addToHistory', false)
104
+ return true
105
+ })
106
+ .run()
101
107
  }
102
108
 
103
- if (props.backgroundColor && interactiveStyles) {
104
- editor.value.chain().focus().setHighlight({ color: color }).run()
109
+ if (props.backgroundColor) {
110
+ editor.value
111
+ .chain()
112
+ .focus()
113
+ .setHighlight({ color })
114
+ .command(({ tr }) => {
115
+ tr.setMeta('addToHistory', false)
116
+ return true
117
+ })
118
+ .run()
105
119
  }
106
120
  }
107
121
 
@@ -115,20 +129,52 @@ function resetColor() {
115
129
  }
116
130
 
117
131
  if (props.fontColor) {
118
- editor.value.chain().focus().setColor(initialColor.value).run()
132
+ editor.value
133
+ .chain()
134
+ .focus()
135
+ .setColor(initialColor.value)
136
+ .command(({ tr }) => {
137
+ tr.setMeta('addToHistory', false)
138
+ return true
139
+ })
140
+ .run()
119
141
  }
120
142
 
121
143
  if (props.backgroundColor) {
122
144
  if (initialColor.value) {
123
- editor.value.chain().focus().setHighlight({ color: initialColor.value }).run()
145
+ editor.value
146
+ .chain()
147
+ .focus()
148
+ .setHighlight({ color: initialColor.value })
149
+ .command(({ tr }) => {
150
+ tr.setMeta('addToHistory', false)
151
+ return true
152
+ })
153
+ .run()
124
154
  } else {
125
- editor.value.chain().focus().unsetHighlight().run()
155
+ editor.value
156
+ .chain()
157
+ .focus()
158
+ .unsetHighlight()
159
+ .command(({ tr }) => {
160
+ tr.setMeta('addToHistory', false)
161
+ return true
162
+ })
163
+ .run()
126
164
  }
127
165
  }
128
166
  }
129
167
 
130
- function setColor() {
168
+ function setColor(color: string) {
131
169
  colorSelected.value = true
170
+
171
+ if (props.fontColor) {
172
+ editor.value.chain().focus().setColor(color).run()
173
+ }
174
+
175
+ if (props.backgroundColor) {
176
+ editor.value.chain().focus().setHighlight({ color }).run()
177
+ }
132
178
  }
133
179
 
134
180
  function unsetColor() {
@@ -155,7 +201,7 @@ function isColorActive(color: string): boolean {
155
201
  :class="isColorActive(colorCode) ? 'tiptapify-style-color-item-active' : ''"
156
202
  @mouseenter="hoverColor(colorCode)"
157
203
  @mouseleave="resetColor()"
158
- @click="setColor"
204
+ @click="setColor(colorCode)"
159
205
  >
160
206
  <div
161
207
  class="tiptapify-style-color-picker"
@@ -188,7 +234,7 @@ function isColorActive(color: string): boolean {
188
234
  </VCardItem>
189
235
 
190
236
  <VCardActions>
191
- <VBtn variant="flat" color="primary" @click="setColor">
237
+ <VBtn variant="flat" color="primary" @click="setColor(customColor)">
192
238
  OK
193
239
  </VBtn>
194
240
  <VBtn variant="flat" color="grey-400" @click="colorPicker = !colorPicker; customColor = initialColor; resetColor()">
@@ -33,10 +33,8 @@ const selectedColor = computed(() => editor.value.getAttributes('textStyle').col
33
33
  <template>
34
34
  <VBtn
35
35
  :id="`tiptapify-color-button-${editor.instanceId}`"
36
- :disabled="!editor.can().chain().focus().toggleHighlight().run()"
37
36
  :variant="variantBtn"
38
37
  size="32"
39
- @click="editor.chain().focus().redo().run()"
40
38
  >
41
39
  <VTooltip activator="parent">
42
40
  {{ t('style.color.text') }}
@@ -45,7 +43,6 @@ const selectedColor = computed(() => editor.value.getAttributes('textStyle').col
45
43
  <BtnIcon :icon="`mdiSvg:${mdi.mdiFormatColorText}`" />
46
44
  <VIcon
47
45
  :icon="`mdiSvg:${mdi.mdiColorHelper}`"
48
- :disabled="!editor.can().chain().focus().toggleHighlight().run()"
49
46
  :color="activeColor"
50
47
  size="small"
51
48
  style="position: absolute; filter: drop-shadow(rgba(0, 0, 0, .75) 1px 1px 2px)"
@@ -36,7 +36,6 @@ const selectedColor = computed(() => editor.value.getAttributes('highlight').col
36
36
  :disabled="!editor.can().chain().focus().toggleHighlight().run()"
37
37
  :variant="variantBtn"
38
38
  size="32"
39
- @click="editor.chain().focus().redo().run()"
40
39
  >
41
40
  <VTooltip activator="parent">
42
41
  {{ t('style.color.highlight') }}