@vc-shell/framework 1.1.55 → 1.1.56
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/CHANGELOG.md +9 -0
- package/core/services/widget-service.ts +17 -8
- package/dist/core/services/widget-service.d.ts +2 -2
- package/dist/core/services/widget-service.d.ts.map +1 -1
- package/dist/framework.js +2801 -2789
- package/dist/index.css +1 -1
- package/dist/shared/composables/useExternalWidgets.d.ts +1 -1
- package/dist/shared/composables/useExternalWidgets.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/vc-widget-container.vue.d.ts.map +1 -1
- package/dist/{vendor-tiptap-core-BRY37Sb2.js → vendor-tiptap-core-CczYXVC4.js} +1 -1
- package/dist/{vendor-tiptap-extension-blockquote-CPd5qv-9.js → vendor-tiptap-extension-blockquote-Dm7YbSqy.js} +1 -1
- package/dist/{vendor-tiptap-extension-bold-B0GwBNks.js → vendor-tiptap-extension-bold-YKANgJQB.js} +1 -1
- package/dist/{vendor-tiptap-extension-bubble-menu-B0sZZld7.js → vendor-tiptap-extension-bubble-menu-gh-OpViI.js} +2 -2
- package/dist/{vendor-tiptap-extension-bullet-list-CQm4ReOu.js → vendor-tiptap-extension-bullet-list-CZWmGEbV.js} +1 -1
- package/dist/{vendor-tiptap-extension-code-C8cy6bRj.js → vendor-tiptap-extension-code-Bg0UZ8tC.js} +1 -1
- package/dist/{vendor-tiptap-extension-code-block-BqTchNEf.js → vendor-tiptap-extension-code-block-DQJ_tCBi.js} +1 -1
- package/dist/{vendor-tiptap-extension-document-Dka1Uu0g.js → vendor-tiptap-extension-document-CpCZXWQI.js} +1 -1
- package/dist/{vendor-tiptap-extension-dropcursor-CFSh-BuE.js → vendor-tiptap-extension-dropcursor-BVniwBbO.js} +1 -1
- package/dist/{vendor-tiptap-extension-floating-menu-H8PB4zeI.js → vendor-tiptap-extension-floating-menu-FkBnPfW6.js} +2 -2
- package/dist/{vendor-tiptap-extension-gapcursor-CzwfD_IT.js → vendor-tiptap-extension-gapcursor-XdrpVWvW.js} +1 -1
- package/dist/{vendor-tiptap-extension-hard-break-Rm6aVcrK.js → vendor-tiptap-extension-hard-break-N0r28gea.js} +1 -1
- package/dist/{vendor-tiptap-extension-heading-CavI6u1v.js → vendor-tiptap-extension-heading-CY1DvT1I.js} +1 -1
- package/dist/{vendor-tiptap-extension-history-WEN1_74D.js → vendor-tiptap-extension-history-BUL3NsZ9.js} +1 -1
- package/dist/{vendor-tiptap-extension-horizontal-rule-DZkUEL6s.js → vendor-tiptap-extension-horizontal-rule-D27m_G1b.js} +1 -1
- package/dist/{vendor-tiptap-extension-image-B67_mxGM.js → vendor-tiptap-extension-image-CbjGZU8i.js} +1 -1
- package/dist/{vendor-tiptap-extension-italic-BshxBFou.js → vendor-tiptap-extension-italic-zyDDu_SW.js} +1 -1
- package/dist/{vendor-tiptap-extension-link-CJAQIgui.js → vendor-tiptap-extension-link-Bcv4UeMa.js} +55 -47
- package/dist/{vendor-tiptap-extension-list-item-DF-iMpqO.js → vendor-tiptap-extension-list-item-DZU6bwbc.js} +1 -1
- package/dist/{vendor-tiptap-extension-ordered-list-CN8MF-kN.js → vendor-tiptap-extension-ordered-list-BXSeGf29.js} +1 -1
- package/dist/{vendor-tiptap-extension-paragraph-DI577lM5.js → vendor-tiptap-extension-paragraph-PDX7FACk.js} +1 -1
- package/dist/{vendor-tiptap-extension-placeholder-DwAtlfAF.js → vendor-tiptap-extension-placeholder-Ue_ElAEg.js} +1 -1
- package/dist/{vendor-tiptap-extension-strike-CIty09KN.js → vendor-tiptap-extension-strike-rl2UQZzW.js} +1 -1
- package/dist/{vendor-tiptap-extension-table-C5nv-GUb.js → vendor-tiptap-extension-table-B59LhE4D.js} +1 -1
- package/dist/{vendor-tiptap-extension-table-cell-DXbBhJW3.js → vendor-tiptap-extension-table-cell-9N0NKfpg.js} +1 -1
- package/dist/{vendor-tiptap-extension-table-header-rtggsYXA.js → vendor-tiptap-extension-table-header-DJTZtK2Z.js} +1 -1
- package/dist/{vendor-tiptap-extension-table-row-67khjMDt.js → vendor-tiptap-extension-table-row-D7Upcsrg.js} +1 -1
- package/dist/{vendor-tiptap-extension-text-D1OHb_a1.js → vendor-tiptap-extension-text-Buc1GYNc.js} +1 -1
- package/dist/{vendor-tiptap-extension-underline-IqWixw3m.js → vendor-tiptap-extension-underline-COmEda96.js} +1 -1
- package/dist/{vendor-tiptap-markdown-DVxB1hbO.js → vendor-tiptap-markdown-QcGJtrvN.js} +1 -1
- package/dist/{vendor-tiptap-starter-kit-CPH9gu2X.js → vendor-tiptap-starter-kit-rn_ARLXy.js} +19 -19
- package/dist/{vendor-tiptap-vue-3-CkBe4_xM.js → vendor-tiptap-vue-3-KDP_yBZF.js} +3 -3
- package/package.json +12 -12
- package/shared/composables/useExternalWidgets.ts +53 -13
- package/ui/components/molecules/vc-editor/vc-editor.vue +9 -0
- package/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/vc-widget-container.vue +31 -13
|
@@ -1,29 +1,63 @@
|
|
|
1
1
|
import { computed, inject, onMounted, watchEffect, Ref, ComputedRef } from "vue";
|
|
2
2
|
import { WidgetServiceKey, BladeInstance } from "../../injection-keys";
|
|
3
|
-
import { IWidget
|
|
3
|
+
import { IWidget } from "../../core/services/widget-service";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Deep comparison function to check if props have changed
|
|
7
|
+
*/
|
|
8
|
+
function isPropsChanged(oldProps: Record<string, unknown>, newProps: Record<string, unknown>): boolean {
|
|
9
|
+
const oldKeys = Object.keys(oldProps);
|
|
10
|
+
const newKeys = Object.keys(newProps);
|
|
11
|
+
|
|
12
|
+
// Quick check for key count difference
|
|
13
|
+
if (oldKeys.length !== newKeys.length) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Check each key for changes
|
|
18
|
+
return newKeys.some((key) => {
|
|
19
|
+
const oldValue = oldProps[key];
|
|
20
|
+
const newValue = newProps[key];
|
|
21
|
+
|
|
22
|
+
// For objects and arrays, do a shallow comparison
|
|
23
|
+
if (typeof oldValue === "object" && typeof newValue === "object") {
|
|
24
|
+
if (oldValue === null || newValue === null) {
|
|
25
|
+
return oldValue !== newValue;
|
|
26
|
+
}
|
|
27
|
+
// For now, consider objects as changed if they're different references
|
|
28
|
+
// In future, we might want to implement deep comparison
|
|
29
|
+
return oldValue !== newValue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return oldValue !== newValue;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
4
35
|
|
|
5
36
|
export interface UseExternalWidgetsOptions {
|
|
6
|
-
|
|
37
|
+
bladeId: string;
|
|
7
38
|
bladeData: Ref<Record<string, unknown>> | ComputedRef<Record<string, unknown>>;
|
|
8
39
|
autoRegister?: boolean; // Automatic registration when mounted
|
|
9
40
|
autoUpdateProps?: boolean; // Automatic update of props when data changes
|
|
10
41
|
}
|
|
11
42
|
|
|
12
43
|
export function useExternalWidgets(options: UseExternalWidgetsOptions) {
|
|
13
|
-
const {
|
|
44
|
+
const { bladeId, bladeData, autoRegister = true, autoUpdateProps = true } = options;
|
|
14
45
|
|
|
15
46
|
const widgetService = inject(WidgetServiceKey);
|
|
16
47
|
const blade = inject(BladeInstance);
|
|
17
48
|
|
|
49
|
+
// Normalize bladeId to lowercase for consistency
|
|
50
|
+
const normalizedBladeId = computed(() => bladeId.toLowerCase());
|
|
51
|
+
|
|
18
52
|
const registeredExternalWidgetIds = new Set<string>();
|
|
19
53
|
|
|
20
54
|
const registerExternalWidgets = () => {
|
|
21
|
-
if (!widgetService || !
|
|
55
|
+
if (!widgetService || !normalizedBladeId.value) {
|
|
22
56
|
console.warn("Widget service or blade ID not available");
|
|
23
57
|
return;
|
|
24
58
|
}
|
|
25
59
|
|
|
26
|
-
const externalWidgets = widgetService.getExternalWidgetsForBlade(
|
|
60
|
+
const externalWidgets = widgetService.getExternalWidgetsForBlade(normalizedBladeId.value);
|
|
27
61
|
|
|
28
62
|
externalWidgets.forEach((externalWidget) => {
|
|
29
63
|
// Check if the widget is already registered
|
|
@@ -46,7 +80,7 @@ export function useExternalWidgets(options: UseExternalWidgetsOptions) {
|
|
|
46
80
|
};
|
|
47
81
|
|
|
48
82
|
try {
|
|
49
|
-
widgetService.registerWidget(widget,
|
|
83
|
+
widgetService.registerWidget(widget, normalizedBladeId.value);
|
|
50
84
|
registeredExternalWidgetIds.add(externalWidget.id);
|
|
51
85
|
} catch (error) {
|
|
52
86
|
console.error(`Failed to register external widget '${externalWidget.id}':`, error);
|
|
@@ -65,11 +99,17 @@ export function useExternalWidgets(options: UseExternalWidgetsOptions) {
|
|
|
65
99
|
try {
|
|
66
100
|
const resolvedProps = widgetService.resolveWidgetProps(widget, bladeData.value);
|
|
67
101
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
102
|
+
// Only update if props have actually changed to avoid unnecessary re-renders
|
|
103
|
+
const currentProps = widget.props || {};
|
|
104
|
+
const hasChanged = isPropsChanged(currentProps, resolvedProps);
|
|
105
|
+
|
|
106
|
+
if (hasChanged) {
|
|
107
|
+
widgetService.updateWidget({
|
|
108
|
+
id: widget.id,
|
|
109
|
+
bladeId: normalizedBladeId.value,
|
|
110
|
+
widget: { props: resolvedProps },
|
|
111
|
+
});
|
|
112
|
+
}
|
|
73
113
|
} catch (error) {
|
|
74
114
|
console.error(`Failed to update props for widget '${widget.id}':`, error);
|
|
75
115
|
}
|
|
@@ -79,11 +119,11 @@ export function useExternalWidgets(options: UseExternalWidgetsOptions) {
|
|
|
79
119
|
|
|
80
120
|
// Unregister external widgets when unmounted
|
|
81
121
|
const unregisterExternalWidgets = () => {
|
|
82
|
-
if (!widgetService || !
|
|
122
|
+
if (!widgetService || !normalizedBladeId.value) return;
|
|
83
123
|
|
|
84
124
|
registeredExternalWidgetIds.forEach((widgetId) => {
|
|
85
125
|
try {
|
|
86
|
-
widgetService.unregisterWidget(widgetId,
|
|
126
|
+
widgetService.unregisterWidget(widgetId, normalizedBladeId.value);
|
|
87
127
|
} catch (error) {
|
|
88
128
|
console.error(`Failed to unregister external widget '${widgetId}':`, error);
|
|
89
129
|
}
|
package/ui/components/organisms/vc-blade/_internal/vc-blade-widget-container/vc-widget-container.vue
CHANGED
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<script setup lang="ts">
|
|
17
|
-
import { computed, toValue, inject } from "vue";
|
|
17
|
+
import { computed, toValue, inject, isRef } from "vue";
|
|
18
18
|
import { useWidgets } from "../../../../../../core/composables/useWidgets";
|
|
19
19
|
import { WidgetContainerDesktop, WidgetContainerMobile } from "./_internal";
|
|
20
20
|
import { BladeInstance } from "../../../../../../injection-keys";
|
|
21
21
|
import { IBladeInstance } from "../../../../../../shared/components/blade-navigation/types";
|
|
22
|
+
import { IWidget } from "../../../../../../core/services";
|
|
22
23
|
|
|
23
24
|
interface Props {
|
|
24
25
|
bladeId: string;
|
|
@@ -28,20 +29,37 @@ const props = defineProps<Props>();
|
|
|
28
29
|
const normalizedBladeId = computed(() => props.bladeId.toLowerCase());
|
|
29
30
|
const widgetService = useWidgets();
|
|
30
31
|
const widgets = computed(() => widgetService.getWidgets(normalizedBladeId.value));
|
|
32
|
+
|
|
31
33
|
const bladeInstance = inject<IBladeInstance>(BladeInstance);
|
|
32
34
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
const isWidgetVisible = (widget: IWidget, bladeInstance: IBladeInstance | undefined): boolean => {
|
|
36
|
+
const { isVisible } = widget;
|
|
37
|
+
|
|
38
|
+
// Default to visible if isVisible is not specified
|
|
39
|
+
if (isVisible === undefined) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Handle function: call with blade instance context
|
|
44
|
+
if (typeof isVisible === "function") {
|
|
45
|
+
return isVisible(toValue(bladeInstance));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Handle reactive reference: unwrap the value
|
|
49
|
+
if (isRef(isVisible)) {
|
|
50
|
+
return toValue(isVisible);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Handle boolean: return as-is
|
|
54
|
+
if (typeof isVisible === "boolean") {
|
|
55
|
+
return isVisible;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Fallback: attempt to unwrap any other reactive value
|
|
59
|
+
return toValue(isVisible);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const visibleWidgets = computed(() => widgets.value.filter((widget) => isWidgetVisible(widget, bladeInstance)));
|
|
45
63
|
</script>
|
|
46
64
|
|
|
47
65
|
<style lang="scss">
|