@blokkli/editor 2.0.0-alpha.51 → 2.0.0-alpha.52
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/BlokkliEditable.d.vue.ts +2 -1
- package/dist/runtime/components/BlokkliEditable.vue +57 -41
- package/dist/runtime/components/BlokkliEditable.vue.d.ts +2 -1
- package/dist/runtime/components/BlokkliItem.d.vue.ts +1 -1
- package/dist/runtime/components/BlokkliItem.vue.d.ts +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,7 +2,7 @@ type __VLS_Props = {
|
|
|
2
2
|
/**
|
|
3
3
|
* The (machine) name of the field that is editable.
|
|
4
4
|
*/
|
|
5
|
-
name
|
|
5
|
+
name?: string | null;
|
|
6
6
|
/**
|
|
7
7
|
* The text value.
|
|
8
8
|
*/
|
|
@@ -20,6 +20,7 @@ type __VLS_Slots = {
|
|
|
20
20
|
}): any;
|
|
21
21
|
};
|
|
22
22
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
23
|
+
name: string | null;
|
|
23
24
|
value: string;
|
|
24
25
|
tag: string;
|
|
25
26
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<component
|
|
3
3
|
:is="tag"
|
|
4
4
|
ref="root"
|
|
5
|
-
:data-blokkli-editable-field="
|
|
5
|
+
:data-blokkli-editable-field="isEditingBuild ? name : void 0"
|
|
6
6
|
>
|
|
7
7
|
<slot :value="renderedValue" />
|
|
8
8
|
</component>
|
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
inject,
|
|
16
16
|
onMounted,
|
|
17
17
|
onBeforeUnmount,
|
|
18
|
-
useTemplateRef
|
|
18
|
+
useTemplateRef,
|
|
19
|
+
watch
|
|
19
20
|
} from "#imports";
|
|
20
21
|
import {
|
|
21
22
|
INJECT_APP,
|
|
@@ -25,62 +26,77 @@ import {
|
|
|
25
26
|
INJECT_IS_IN_REUSABLE
|
|
26
27
|
} from "#blokkli/helpers/injections";
|
|
27
28
|
const props = defineProps({
|
|
28
|
-
name: { type: String, required:
|
|
29
|
+
name: { type: [String, null], required: false, default: null },
|
|
29
30
|
value: { type: String, required: false, default: "" },
|
|
30
31
|
tag: { type: String, required: false, default: "div" }
|
|
31
32
|
});
|
|
32
33
|
defineSlots();
|
|
34
|
+
const isEditingBuild = import.meta.blokkliEditing;
|
|
33
35
|
const root = useTemplateRef("root");
|
|
34
36
|
const valueOverride = ref("");
|
|
35
|
-
const isEditing = inject(INJECT_IS_EDITING, false);
|
|
36
|
-
const entity = inject(INJECT_ENTITY_CONTEXT, null);
|
|
37
|
-
const editContext = inject(INJECT_EDIT_CONTEXT, null);
|
|
38
|
-
const app = inject(INJECT_APP, null);
|
|
39
|
-
const isInReusable = inject(INJECT_IS_IN_REUSABLE, false);
|
|
40
|
-
if (!entity) {
|
|
41
|
-
throw new Error("Missing entity context.");
|
|
42
|
-
}
|
|
43
|
-
function getValueCallback() {
|
|
44
|
-
return props.value;
|
|
45
|
-
}
|
|
46
37
|
const renderedValue = computed(() => valueOverride.value || props.value || "");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (!isEditing || !editContext || !app || isInReusable) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
editContext.eventBus.on("editable:update", onEditableUpdateValue);
|
|
60
|
-
editContext.eventBus.on("state:reloaded", onStateReloaded);
|
|
61
|
-
if (root.value instanceof HTMLElement && entity) {
|
|
38
|
+
if (isEditingBuild) {
|
|
39
|
+
let getValueCallback = function() {
|
|
40
|
+
return props.value;
|
|
41
|
+
}, onStateReloaded = function() {
|
|
42
|
+
valueOverride.value = "";
|
|
43
|
+
}, registerDirective = function(name) {
|
|
44
|
+
if (!name || !app || !(root.value instanceof HTMLElement) || !entity) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
62
47
|
app.directive.registerDirectiveElement(
|
|
63
48
|
root.value,
|
|
64
|
-
|
|
49
|
+
name,
|
|
65
50
|
entity,
|
|
66
51
|
"editable",
|
|
67
52
|
true,
|
|
68
53
|
getValueCallback
|
|
69
54
|
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
editContext.eventBus.off("editable:update", onEditableUpdateValue);
|
|
75
|
-
editContext.eventBus.off("state:reloaded", onStateReloaded);
|
|
76
|
-
}
|
|
77
|
-
if (app && root.value instanceof HTMLElement && entity) {
|
|
55
|
+
}, unregisterDirective = function(name) {
|
|
56
|
+
if (!name || !app || !(root.value instanceof HTMLElement) || !entity) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
78
59
|
app.directive.unregisterDirectiveElement(
|
|
79
60
|
root.value,
|
|
80
|
-
|
|
61
|
+
name,
|
|
81
62
|
entity,
|
|
82
63
|
"editable"
|
|
83
64
|
);
|
|
84
|
-
}
|
|
85
|
-
|
|
65
|
+
};
|
|
66
|
+
const isEditing = inject(INJECT_IS_EDITING, false);
|
|
67
|
+
const entity = inject(INJECT_ENTITY_CONTEXT, null);
|
|
68
|
+
const editContext = inject(INJECT_EDIT_CONTEXT, null);
|
|
69
|
+
const app = inject(INJECT_APP, null);
|
|
70
|
+
const isInReusable = inject(INJECT_IS_IN_REUSABLE, false);
|
|
71
|
+
const onEditableUpdateValue = (e) => {
|
|
72
|
+
if (e.name === props.name && e.entityUuid === entity?.uuid) {
|
|
73
|
+
valueOverride.value = e.value;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
onMounted(() => {
|
|
77
|
+
if (!isEditing || !editContext || !app || isInReusable) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
editContext.eventBus.on("editable:update", onEditableUpdateValue);
|
|
81
|
+
editContext.eventBus.on("state:reloaded", onStateReloaded);
|
|
82
|
+
registerDirective(props.name);
|
|
83
|
+
});
|
|
84
|
+
watch(
|
|
85
|
+
() => props.name,
|
|
86
|
+
(newName, oldName) => {
|
|
87
|
+
if (!isEditing || !app || !entity || isInReusable) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
unregisterDirective(oldName);
|
|
91
|
+
registerDirective(newName);
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
onBeforeUnmount(() => {
|
|
95
|
+
if (editContext) {
|
|
96
|
+
editContext.eventBus.off("editable:update", onEditableUpdateValue);
|
|
97
|
+
editContext.eventBus.off("state:reloaded", onStateReloaded);
|
|
98
|
+
}
|
|
99
|
+
unregisterDirective(props.name);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
86
102
|
</script>
|
|
@@ -2,7 +2,7 @@ type __VLS_Props = {
|
|
|
2
2
|
/**
|
|
3
3
|
* The (machine) name of the field that is editable.
|
|
4
4
|
*/
|
|
5
|
-
name
|
|
5
|
+
name?: string | null;
|
|
6
6
|
/**
|
|
7
7
|
* The text value.
|
|
8
8
|
*/
|
|
@@ -20,6 +20,7 @@ type __VLS_Slots = {
|
|
|
20
20
|
}): any;
|
|
21
21
|
};
|
|
22
22
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
23
|
+
name: string | null;
|
|
23
24
|
value: string;
|
|
24
25
|
tag: string;
|
|
25
26
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -22,10 +22,10 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
22
22
|
parentType?: string;
|
|
23
23
|
isEditing?: boolean;
|
|
24
24
|
}> & Readonly<{}>, {
|
|
25
|
-
isEditing: boolean;
|
|
26
25
|
props: any;
|
|
27
26
|
parentType: string;
|
|
28
27
|
options: any;
|
|
29
28
|
editContext: BlockEditContext;
|
|
30
29
|
index: number;
|
|
30
|
+
isEditing: boolean;
|
|
31
31
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -22,10 +22,10 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
22
22
|
parentType?: string;
|
|
23
23
|
isEditing?: boolean;
|
|
24
24
|
}> & Readonly<{}>, {
|
|
25
|
-
isEditing: boolean;
|
|
26
25
|
props: any;
|
|
27
26
|
parentType: string;
|
|
28
27
|
options: any;
|
|
29
28
|
editContext: BlockEditContext;
|
|
30
29
|
index: number;
|
|
30
|
+
isEditing: boolean;
|
|
31
31
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|