@blokkli/editor 1.0.2 → 1.0.3
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/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Edit/DragInteractions/index.vue +5 -3
- package/dist/runtime/components/Edit/Features/Edit/index.vue +3 -0
- package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +1 -1
- package/dist/runtime/components/Edit/Features/Options/Form/Item.vue +2 -4
- package/dist/runtime/components/Edit/Features/Translations/index.vue +18 -1
- package/dist/runtime/css/output.css +1 -1
- package/dist/runtime/helpers/runtimeHelpers/index.d.ts +5 -0
- package/dist/runtime/helpers/runtimeHelpers/index.js +4 -6
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { createUnplugin } from 'unplugin';
|
|
|
6
6
|
import MagicString from 'magic-string';
|
|
7
7
|
import { walk } from 'estree-walker-ts';
|
|
8
8
|
|
|
9
|
-
const version = "1.0.
|
|
9
|
+
const version = "1.0.3";
|
|
10
10
|
|
|
11
11
|
function sortObjectKeys(obj) {
|
|
12
12
|
const sortedKeys = Object.keys(obj).sort();
|
|
@@ -158,15 +158,17 @@ function onPointerDown(e: PointerEvent) {
|
|
|
158
158
|
e.stopImmediatePropagation()
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
if (e.pointerType === 'touch') {
|
|
162
|
+
return onTouchStart(e)
|
|
163
|
+
}
|
|
164
|
+
|
|
161
165
|
// If we are already dragging, return.
|
|
162
166
|
// This might be the case if a dragging:start event was manually triggered,
|
|
163
167
|
// e.g. when selecting a draggable item using the keyboard.
|
|
164
168
|
if (selection.isDragging.value) {
|
|
165
169
|
return
|
|
166
170
|
}
|
|
167
|
-
|
|
168
|
-
return onTouchStart(e)
|
|
169
|
-
}
|
|
171
|
+
|
|
170
172
|
pointerDownTimestamp = Date.now()
|
|
171
173
|
const coords = { x: e.clientX, y: e.clientY }
|
|
172
174
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<PluginItemAction
|
|
3
|
+
v-if="isEditing"
|
|
3
4
|
id="edit"
|
|
4
5
|
:title="$t('edit', 'Edit')"
|
|
5
6
|
:disabled="!canEdit"
|
|
@@ -36,6 +37,8 @@ const block = computed(() => {
|
|
|
36
37
|
return selection.blocks.value[0]
|
|
37
38
|
})
|
|
38
39
|
|
|
40
|
+
const isEditing = computed(() => state.editMode.value === 'editing')
|
|
41
|
+
|
|
39
42
|
const canEdit = computed(() => {
|
|
40
43
|
// Editing is only possible when a single block is selected.
|
|
41
44
|
if (!block.value) {
|
|
@@ -44,7 +44,7 @@ const onSelect = (uuids: string[]) => {
|
|
|
44
44
|
let startTimeout: any = null
|
|
45
45
|
|
|
46
46
|
onBlokkliEvent('mouse:down', (e) => {
|
|
47
|
-
if (!enabled.value || e.type !== 'mouse') {
|
|
47
|
+
if (!enabled.value || e.type !== 'mouse' || selection.isDragging.value) {
|
|
48
48
|
return
|
|
49
49
|
}
|
|
50
50
|
if (keyboard.isPressingSpace.value || keyboard.isPressingControl.value) {
|
|
@@ -69,6 +69,7 @@ import OptionColor from './Color/index.vue'
|
|
|
69
69
|
import OptionRange from './Range/index.vue'
|
|
70
70
|
import OptionNumber from './Number/index.vue'
|
|
71
71
|
import type { BlockOptionDefinition } from '#blokkli/types/blokkOptions'
|
|
72
|
+
import { mapCheckboxTrue } from '#blokkli/helpers/runtimeHelpers'
|
|
72
73
|
|
|
73
74
|
const { state } = useBlokkli()
|
|
74
75
|
|
|
@@ -99,10 +100,7 @@ const validateValue = (
|
|
|
99
100
|
return v
|
|
100
101
|
}
|
|
101
102
|
} else if (props.option.type === 'checkbox') {
|
|
102
|
-
|
|
103
|
-
return v ? '1' : '0'
|
|
104
|
-
}
|
|
105
|
-
return v === '1' ? '1' : '0'
|
|
103
|
+
return mapCheckboxTrue(v)
|
|
106
104
|
} else if (props.option.type === 'checkboxes') {
|
|
107
105
|
const options = Object.keys(props.option.options || {})
|
|
108
106
|
const items = Array.isArray(v)
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
:disabled="!canTranslateBlock"
|
|
76
76
|
:title="$t('translationsItemAction', 'Translate')"
|
|
77
77
|
icon="translate"
|
|
78
|
+
:weight="-100"
|
|
78
79
|
@click="onTranslate"
|
|
79
80
|
/>
|
|
80
81
|
</template>
|
|
@@ -100,6 +101,7 @@ import type {
|
|
|
100
101
|
} from '#blokkli/types'
|
|
101
102
|
import Banner from './Banner/index.vue'
|
|
102
103
|
import { getDefinition } from '#blokkli/definitions'
|
|
104
|
+
import onBlokkliEvent from '#blokkli/helpers/composables/onBlokkliEvent'
|
|
103
105
|
|
|
104
106
|
const { adapter } = defineBlokkliFeature({
|
|
105
107
|
id: 'translations',
|
|
@@ -109,7 +111,7 @@ const { adapter } = defineBlokkliFeature({
|
|
|
109
111
|
description: 'Adds support for block translations.',
|
|
110
112
|
})
|
|
111
113
|
|
|
112
|
-
const { eventBus, state, context, $t, ui, selection } = useBlokkli()
|
|
114
|
+
const { eventBus, state, context, $t, ui, selection, types } = useBlokkli()
|
|
113
115
|
const { translation, editMode } = state
|
|
114
116
|
|
|
115
117
|
const isOpen = ref(false)
|
|
@@ -173,6 +175,15 @@ const canTranslateBlock = computed(() => {
|
|
|
173
175
|
if (definition?.editor?.disableEdit) {
|
|
174
176
|
return false
|
|
175
177
|
}
|
|
178
|
+
const type = types.getBlockBundleDefinition(block.itemBundle)
|
|
179
|
+
|
|
180
|
+
if (!type) {
|
|
181
|
+
return false
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (!type.isTranslatable) {
|
|
185
|
+
return false
|
|
186
|
+
}
|
|
176
187
|
|
|
177
188
|
return true
|
|
178
189
|
})
|
|
@@ -195,6 +206,12 @@ function onTranslate(items: DraggableExistingBlock[]) {
|
|
|
195
206
|
})
|
|
196
207
|
}
|
|
197
208
|
|
|
209
|
+
onBlokkliEvent('item:doubleClick', function (block) {
|
|
210
|
+
if (editMode.value === 'translating' && canTranslateBlock.value) {
|
|
211
|
+
onTranslate([block])
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
|
|
198
215
|
onMounted(() => {
|
|
199
216
|
// Make sure the user is not trying to edit a translation that does not exist.
|
|
200
217
|
const translationExists = !!translation.value.translations?.find(
|