@blokkli/editor 2.0.0-alpha.20 → 2.0.0-alpha.22
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/BlokkliProvider.vue +9 -6
- package/dist/runtime/components/Edit/EditProvider.vue +44 -21
- package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/collectTextElements.js +3 -0
- package/dist/runtime/helpers/domProvider.js +1 -1
- package/dist/runtime/plugins/blokkliDirectives.js +23 -10
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
:data-provider-uuid="entityUuid"
|
|
5
5
|
:data-provider-entity-type="entityType"
|
|
6
6
|
:data-provider-entity-bundle="entityBundle"
|
|
7
|
-
:data-blokkli-provider-active="isInEditor
|
|
7
|
+
:data-blokkli-provider-active="isInEditor ? 'true' : 'false'"
|
|
8
8
|
>
|
|
9
9
|
<BlokkliErrorBoundary v-if="isInEditor">
|
|
10
10
|
<PreviewProvider
|
|
@@ -143,12 +143,15 @@ const blokkliProviderEntityContext = computed(
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
const entityContext = computed(() => {
|
|
147
|
+
return {
|
|
148
|
+
uuid: props.entityUuid,
|
|
149
|
+
type: props.entityType,
|
|
150
|
+
bundle: props.entityBundle
|
|
151
|
+
};
|
|
151
152
|
});
|
|
153
|
+
provide(INJECT_PROVIDER_CONTEXT, blokkliProviderEntityContext);
|
|
154
|
+
provide(INJECT_ENTITY_CONTEXT, entityContext.value);
|
|
152
155
|
onMounted(() => {
|
|
153
156
|
shouldRender.value = true;
|
|
154
157
|
});
|
|
@@ -56,7 +56,8 @@ import {
|
|
|
56
56
|
useRoute,
|
|
57
57
|
useRuntimeConfig,
|
|
58
58
|
nextTick,
|
|
59
|
-
inject
|
|
59
|
+
inject,
|
|
60
|
+
onUnmounted
|
|
60
61
|
} from "#imports";
|
|
61
62
|
import Toolbar from "./Toolbar/index.vue";
|
|
62
63
|
import Actions from "./Actions/index.vue";
|
|
@@ -101,6 +102,7 @@ import {
|
|
|
101
102
|
INJECT_EDIT_CONTEXT,
|
|
102
103
|
INJECT_EDIT_FIELD_LIST_COMPONENT,
|
|
103
104
|
INJECT_EDIT_LOGGER,
|
|
105
|
+
INJECT_ENTITY_CONTEXT,
|
|
104
106
|
INJECT_GLOBAL_PROXY_MODE,
|
|
105
107
|
INJECT_IS_EDITING,
|
|
106
108
|
INJECT_PROVIDER_KEY
|
|
@@ -118,6 +120,13 @@ const props = defineProps({
|
|
|
118
120
|
providerEl: { type: null, required: true }
|
|
119
121
|
});
|
|
120
122
|
defineSlots();
|
|
123
|
+
const entityContext = computed(() => {
|
|
124
|
+
return {
|
|
125
|
+
uuid: props.entityUuid,
|
|
126
|
+
type: props.entityType,
|
|
127
|
+
bundle: props.entityBundle
|
|
128
|
+
};
|
|
129
|
+
});
|
|
121
130
|
const context = computed(() => {
|
|
122
131
|
return {
|
|
123
132
|
entityType: props.entityType,
|
|
@@ -198,24 +207,9 @@ addElementClasses(
|
|
|
198
207
|
shouldIsolate
|
|
199
208
|
);
|
|
200
209
|
const baseLogger = debug.createLogger("EditProvider");
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
document.documentElement.addEventListener("touchstart", onTouchStart);
|
|
205
|
-
baseLogger.log("EditProvider mounted");
|
|
206
|
-
dom.init();
|
|
207
|
-
directive.init();
|
|
208
|
-
await nextTick();
|
|
209
|
-
isInitializing.value = false;
|
|
210
|
-
broadcast.emit("editorLoaded", { uuid: props.entityUuid });
|
|
211
|
-
});
|
|
212
|
-
onBeforeUnmount(() => {
|
|
213
|
-
window.removeEventListener("contextmenu", onContextMenu);
|
|
214
|
-
isInitializing.value = true;
|
|
215
|
-
toolbarLoaded.value = false;
|
|
216
|
-
document.documentElement.removeEventListener("touchmove", onTouchMove);
|
|
217
|
-
document.documentElement.removeEventListener("touchstart", onTouchStart);
|
|
218
|
-
});
|
|
210
|
+
function setElementSymbolProperty(el, symbol, value) {
|
|
211
|
+
el[symbol] = value;
|
|
212
|
+
}
|
|
219
213
|
provide(INJECT_EDIT_LOGGER, baseLogger);
|
|
220
214
|
provide(INJECT_EDIT_FIELD_LIST_COMPONENT, DraggableList);
|
|
221
215
|
provide(INJECT_IS_EDITING, true);
|
|
@@ -226,7 +220,7 @@ provide(INJECT_EDIT_CONTEXT, {
|
|
|
226
220
|
definitions,
|
|
227
221
|
useBlockRegistration
|
|
228
222
|
});
|
|
229
|
-
|
|
223
|
+
const app = {
|
|
230
224
|
$t,
|
|
231
225
|
adapter,
|
|
232
226
|
animation,
|
|
@@ -254,7 +248,8 @@ provide(INJECT_APP, {
|
|
|
254
248
|
types,
|
|
255
249
|
ui,
|
|
256
250
|
fields
|
|
257
|
-
}
|
|
251
|
+
};
|
|
252
|
+
provide(INJECT_APP, app);
|
|
258
253
|
function textWithHighlight(title, text) {
|
|
259
254
|
return `<strong>${title}</strong> ${text}`;
|
|
260
255
|
}
|
|
@@ -323,4 +318,32 @@ if (import.meta.hot) {
|
|
|
323
318
|
});
|
|
324
319
|
import.meta.hot.on("vite:afterUpdate", onAfterUpdate);
|
|
325
320
|
}
|
|
321
|
+
onMounted(async () => {
|
|
322
|
+
setElementSymbolProperty(props.providerEl, INJECT_APP, app);
|
|
323
|
+
setElementSymbolProperty(
|
|
324
|
+
props.providerEl,
|
|
325
|
+
INJECT_ENTITY_CONTEXT,
|
|
326
|
+
entityContext.value
|
|
327
|
+
);
|
|
328
|
+
window.addEventListener("contextmenu", onContextMenu);
|
|
329
|
+
document.documentElement.addEventListener("touchmove", onTouchMove);
|
|
330
|
+
document.documentElement.addEventListener("touchstart", onTouchStart);
|
|
331
|
+
baseLogger.log("EditProvider mounted");
|
|
332
|
+
dom.init();
|
|
333
|
+
directive.init();
|
|
334
|
+
await nextTick();
|
|
335
|
+
isInitializing.value = false;
|
|
336
|
+
broadcast.emit("editorLoaded", { uuid: props.entityUuid });
|
|
337
|
+
});
|
|
338
|
+
onBeforeUnmount(() => {
|
|
339
|
+
window.removeEventListener("contextmenu", onContextMenu);
|
|
340
|
+
isInitializing.value = true;
|
|
341
|
+
toolbarLoaded.value = false;
|
|
342
|
+
document.documentElement.removeEventListener("touchmove", onTouchMove);
|
|
343
|
+
document.documentElement.removeEventListener("touchstart", onTouchStart);
|
|
344
|
+
});
|
|
345
|
+
onUnmounted(() => {
|
|
346
|
+
setElementSymbolProperty(props.providerEl, INJECT_APP);
|
|
347
|
+
setElementSymbolProperty(props.providerEl, INJECT_ENTITY_CONTEXT);
|
|
348
|
+
});
|
|
326
349
|
</script>
|
package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/collectTextElements.js
CHANGED
|
@@ -64,6 +64,9 @@ const traverse = (element, results) => {
|
|
|
64
64
|
if (element.tagName === "SCRIPT" || element.tagName === "STYLE") {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
+
if (element.classList.contains("bk-skip-analyze")) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
67
70
|
if (isBlockElement(element)) {
|
|
68
71
|
if (!containsBlockElements(element)) {
|
|
69
72
|
const text = getCleanText(element);
|
|
@@ -387,7 +387,7 @@ export default function(ui, debug, definitions, state, element) {
|
|
|
387
387
|
logger.log("registerBlock: " + uuid);
|
|
388
388
|
blockUuidCurrentKey[uuid] = key;
|
|
389
389
|
doInitTimeout();
|
|
390
|
-
if (!el) {
|
|
390
|
+
if (!(el instanceof HTMLElement)) {
|
|
391
391
|
logger.log("registerBlock call unregisterBlock because no element", uuid);
|
|
392
392
|
unregisterBlock(key, uuid);
|
|
393
393
|
return;
|
|
@@ -4,14 +4,27 @@ import {
|
|
|
4
4
|
INJECT_IS_IN_REUSABLE
|
|
5
5
|
} from "#blokkli/helpers/symbols";
|
|
6
6
|
import { defineNuxtPlugin } from "#imports";
|
|
7
|
-
function
|
|
8
|
-
|
|
7
|
+
function getInjectionFromProviderElement(symbol, el) {
|
|
8
|
+
if (!el) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const providerEl = el.closest("[data-blokkli-provider-active]");
|
|
12
|
+
if (!(providerEl instanceof HTMLElement)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
return providerEl[symbol];
|
|
16
|
+
}
|
|
17
|
+
function getInjection(vnode, symbol, el) {
|
|
18
|
+
return (
|
|
19
|
+
// @ts-expect-error Private API.
|
|
20
|
+
vnode.ctx?.provides?.[symbol] ?? getInjectionFromProviderElement(symbol, el)
|
|
21
|
+
);
|
|
9
22
|
}
|
|
10
|
-
function getBlokkliApp(vnode) {
|
|
11
|
-
return getInjection(vnode, INJECT_APP);
|
|
23
|
+
function getBlokkliApp(vnode, el) {
|
|
24
|
+
return getInjection(vnode, INJECT_APP, el);
|
|
12
25
|
}
|
|
13
|
-
function getEntityContext(vnode) {
|
|
14
|
-
return getInjection(vnode, INJECT_ENTITY_CONTEXT);
|
|
26
|
+
function getEntityContext(vnode, el) {
|
|
27
|
+
return getInjection(vnode, INJECT_ENTITY_CONTEXT, el);
|
|
15
28
|
}
|
|
16
29
|
function isInReusable(vnode) {
|
|
17
30
|
return !!getInjection(vnode, INJECT_IS_IN_REUSABLE);
|
|
@@ -53,11 +66,11 @@ function createDirective(type) {
|
|
|
53
66
|
if (isInReusable(vnode)) {
|
|
54
67
|
return;
|
|
55
68
|
}
|
|
56
|
-
const app = getBlokkliApp(vnode);
|
|
69
|
+
const app = getBlokkliApp(vnode, el);
|
|
57
70
|
if (!app) {
|
|
58
71
|
return;
|
|
59
72
|
}
|
|
60
|
-
const entity = getEntityContext(vnode);
|
|
73
|
+
const entity = getEntityContext(vnode, el);
|
|
61
74
|
if (!entity) {
|
|
62
75
|
return;
|
|
63
76
|
}
|
|
@@ -71,11 +84,11 @@ function createDirective(type) {
|
|
|
71
84
|
if (!isEditing()) {
|
|
72
85
|
return;
|
|
73
86
|
}
|
|
74
|
-
const app = getBlokkliApp(vnode);
|
|
87
|
+
const app = getBlokkliApp(vnode, el);
|
|
75
88
|
if (!app) {
|
|
76
89
|
return;
|
|
77
90
|
}
|
|
78
|
-
const entity = getEntityContext(vnode);
|
|
91
|
+
const entity = getEntityContext(vnode, el);
|
|
79
92
|
if (!entity) {
|
|
80
93
|
return;
|
|
81
94
|
}
|