@blokkli/editor 1.0.1 → 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 +31 -1
- package/dist/runtime/adapter/drupal/graphqlMiddleware.js +9 -1
- package/dist/runtime/adapter/index.d.ts +4 -0
- package/dist/runtime/components/Blocks/FromLibrary/index.vue +2 -3
- package/dist/runtime/components/Edit/Dialog/index.vue +14 -1
- package/dist/runtime/components/Edit/DragInteractions/index.vue +6 -7
- package/dist/runtime/components/Edit/EditProvider.vue +1 -0
- package/dist/runtime/components/Edit/Features/Edit/index.vue +63 -14
- package/dist/runtime/components/Edit/Features/Exit/index.vue +2 -1
- package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +206 -0
- package/dist/runtime/components/Edit/Features/Library/index.vue +25 -2
- 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/Publish/index.vue +4 -1
- package/dist/runtime/components/Edit/Features/Translations/index.vue +43 -1
- package/dist/runtime/css/output.css +1 -1
- package/dist/runtime/helpers/broadcastProvider.d.ts +10 -2
- package/dist/runtime/helpers/composables/onBroadcastEvent.d.ts +2 -0
- package/dist/runtime/helpers/composables/onBroadcastEvent.js +10 -0
- package/dist/runtime/helpers/index.js +2 -2
- package/dist/runtime/helpers/runtimeHelpers/index.d.ts +5 -0
- package/dist/runtime/helpers/runtimeHelpers/index.js +4 -6
- package/dist/runtime/types/index.d.ts +12 -2
- package/package.json +1 -1
|
@@ -72,8 +72,10 @@
|
|
|
72
72
|
<PluginItemAction
|
|
73
73
|
v-if="editMode === 'translating'"
|
|
74
74
|
id="translate"
|
|
75
|
+
:disabled="!canTranslateBlock"
|
|
75
76
|
:title="$t('translationsItemAction', 'Translate')"
|
|
76
77
|
icon="translate"
|
|
78
|
+
:weight="-100"
|
|
77
79
|
@click="onTranslate"
|
|
78
80
|
/>
|
|
79
81
|
</template>
|
|
@@ -98,6 +100,8 @@ import type {
|
|
|
98
100
|
Language,
|
|
99
101
|
} from '#blokkli/types'
|
|
100
102
|
import Banner from './Banner/index.vue'
|
|
103
|
+
import { getDefinition } from '#blokkli/definitions'
|
|
104
|
+
import onBlokkliEvent from '#blokkli/helpers/composables/onBlokkliEvent'
|
|
101
105
|
|
|
102
106
|
const { adapter } = defineBlokkliFeature({
|
|
103
107
|
id: 'translations',
|
|
@@ -107,7 +111,7 @@ const { adapter } = defineBlokkliFeature({
|
|
|
107
111
|
description: 'Adds support for block translations.',
|
|
108
112
|
})
|
|
109
113
|
|
|
110
|
-
const { eventBus, state, context, $t, ui } = useBlokkli()
|
|
114
|
+
const { eventBus, state, context, $t, ui, selection, types } = useBlokkli()
|
|
111
115
|
const { translation, editMode } = state
|
|
112
116
|
|
|
113
117
|
const isOpen = ref(false)
|
|
@@ -152,6 +156,38 @@ const items = computed<TranslationStateItem[]>(() => {
|
|
|
152
156
|
.filter(falsy)
|
|
153
157
|
})
|
|
154
158
|
|
|
159
|
+
const canTranslateBlock = computed(() => {
|
|
160
|
+
if (selection.blocks.value.length !== 1) {
|
|
161
|
+
return false
|
|
162
|
+
}
|
|
163
|
+
const block = selection.blocks.value[0]
|
|
164
|
+
|
|
165
|
+
if (block.libraryItemUuid) {
|
|
166
|
+
return false
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const definition = getDefinition(
|
|
170
|
+
block.itemBundle,
|
|
171
|
+
block.hostFieldListType,
|
|
172
|
+
block.parentBlockBundle,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
if (definition?.editor?.disableEdit) {
|
|
176
|
+
return false
|
|
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
|
+
}
|
|
187
|
+
|
|
188
|
+
return true
|
|
189
|
+
})
|
|
190
|
+
|
|
155
191
|
function onClick(item: TranslationStateItem, event: Event) {
|
|
156
192
|
if (item.translation?.exists) {
|
|
157
193
|
return adapter.changeLanguage(item.translation)
|
|
@@ -170,6 +206,12 @@ function onTranslate(items: DraggableExistingBlock[]) {
|
|
|
170
206
|
})
|
|
171
207
|
}
|
|
172
208
|
|
|
209
|
+
onBlokkliEvent('item:doubleClick', function (block) {
|
|
210
|
+
if (editMode.value === 'translating' && canTranslateBlock.value) {
|
|
211
|
+
onTranslate([block])
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
|
|
173
215
|
onMounted(() => {
|
|
174
216
|
// Make sure the user is not trying to edit a translation that does not exist.
|
|
175
217
|
const translationExists = !!translation.value.translations?.find(
|