@uniformdev/canvas-vue 19.35.1-alpha.8 → 19.35.2
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/index.d.ts +83 -9
- package/dist/index.esm.js +105 -5
- package/dist/index.js +107 -9
- package/dist/index.mjs +105 -5
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as vue_demi from 'vue-demi';
|
|
|
2
2
|
import { PropType, ConcreteComponent, Ref, ComputedRef } from 'vue-demi';
|
|
3
3
|
import * as _uniformdev_canvas from '@uniformdev/canvas';
|
|
4
4
|
import { ComponentInstance, ComponentParameter, RootComponentInstance, UpdateCompositionMessage, SubscribeToCompositionOptions } from '@uniformdev/canvas';
|
|
5
|
-
export { createUniformApiEnhancer } from '@uniformdev/canvas';
|
|
5
|
+
export { GetParameterAttributesProps, createUniformApiEnhancer, getParameterAttributes } from '@uniformdev/canvas';
|
|
6
6
|
import { RichTextNode } from '@uniformdev/richtext';
|
|
7
7
|
|
|
8
8
|
type DefaultNotImplementedComponentProps = {
|
|
@@ -49,15 +49,75 @@ type ComponentProps<TProps = unknown> = TProps & {
|
|
|
49
49
|
};
|
|
50
50
|
type ResolveRenderer = (componentInstance: ComponentInstance) => ConcreteComponent<any>;
|
|
51
51
|
|
|
52
|
-
type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
type UniformTextProps = {
|
|
53
|
+
/**
|
|
54
|
+
* The name of the HTML tag to render.
|
|
55
|
+
* @default "span"
|
|
56
|
+
*/
|
|
57
|
+
as?: string;
|
|
58
|
+
/** The ID of the parameter. */
|
|
59
|
+
parameterId: string;
|
|
60
|
+
/**
|
|
61
|
+
* When set to true, it adds `whiteSpace: 'pre-wrap'` to the styles of the root element to allow the rendering of line breaks.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
isMultiline?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Sets the value to show in Canvas editor when the parameter value is empty.
|
|
67
|
+
* Can be a static string, or a function to generate the placeholder out of parameter info.
|
|
68
|
+
* @default undefined
|
|
69
|
+
*/
|
|
70
|
+
placeholder?: string | ((parameter: {
|
|
71
|
+
id: string;
|
|
72
|
+
}) => string | undefined);
|
|
56
73
|
};
|
|
57
74
|
/**
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
75
|
+
* Adds inline editing capability to text parameters
|
|
76
|
+
* @deprecated This component is unstable, and not ready for production usage.
|
|
77
|
+
**/
|
|
78
|
+
declare const UniformText: vue_demi.DefineComponent<{
|
|
79
|
+
as: {
|
|
80
|
+
type: PropType<string | undefined>;
|
|
81
|
+
default: string;
|
|
82
|
+
};
|
|
83
|
+
parameterId: {
|
|
84
|
+
type: PropType<string>;
|
|
85
|
+
required: true;
|
|
86
|
+
};
|
|
87
|
+
isMultiline: {
|
|
88
|
+
type: PropType<boolean | undefined>;
|
|
89
|
+
default: boolean;
|
|
90
|
+
};
|
|
91
|
+
placeholder: {
|
|
92
|
+
type: PropType<string | ((parameter: {
|
|
93
|
+
id: string;
|
|
94
|
+
}) => string | undefined) | undefined>;
|
|
95
|
+
};
|
|
96
|
+
}, (() => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
97
|
+
[key: string]: any;
|
|
98
|
+
}>) | null, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
|
|
99
|
+
as: {
|
|
100
|
+
type: PropType<string | undefined>;
|
|
101
|
+
default: string;
|
|
102
|
+
};
|
|
103
|
+
parameterId: {
|
|
104
|
+
type: PropType<string>;
|
|
105
|
+
required: true;
|
|
106
|
+
};
|
|
107
|
+
isMultiline: {
|
|
108
|
+
type: PropType<boolean | undefined>;
|
|
109
|
+
default: boolean;
|
|
110
|
+
};
|
|
111
|
+
placeholder: {
|
|
112
|
+
type: PropType<string | ((parameter: {
|
|
113
|
+
id: string;
|
|
114
|
+
}) => string | undefined) | undefined>;
|
|
115
|
+
};
|
|
116
|
+
}>>, {
|
|
117
|
+
as: string | undefined;
|
|
118
|
+
isMultiline: boolean | undefined;
|
|
119
|
+
}>;
|
|
120
|
+
|
|
61
121
|
type UniformComponentProps = {
|
|
62
122
|
/** A dynamic vue component that provides data to the Uniform Canvas SlotContent component via provide/inject */
|
|
63
123
|
data?: ComponentInstance | RootComponentInstance;
|
|
@@ -74,7 +134,21 @@ type UniformComponentProps = {
|
|
|
74
134
|
* Default: onView
|
|
75
135
|
*/
|
|
76
136
|
behaviorTracking?: 'onLoad' | 'onView';
|
|
137
|
+
/**
|
|
138
|
+
* The default placeholder to pass to the parameter component that support inline editing (such as UniformText).
|
|
139
|
+
*/
|
|
140
|
+
contextualEditingDefaultPlaceholder?: UniformTextProps['placeholder'];
|
|
141
|
+
};
|
|
142
|
+
type UniformCurrentComponent = {
|
|
143
|
+
data?: UniformComponentProps['data'];
|
|
144
|
+
resolveRenderer?: UniformComponentProps['resolveRenderer'];
|
|
145
|
+
behaviorTracking?: UniformComponentProps['behaviorTracking'];
|
|
146
|
+
contextualEditingDefaultPlaceholder?: UniformComponentProps['contextualEditingDefaultPlaceholder'];
|
|
77
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* Gets the data of the closest `<UniformComponent />` ancestor.
|
|
150
|
+
*/
|
|
151
|
+
declare const useUniformCurrentComponent: () => UniformCurrentComponent;
|
|
78
152
|
/**
|
|
79
153
|
* Allows the rendering of a Canvas component instance (root or not), and its children if it has any.
|
|
80
154
|
* Note that the actual rendering happens inside `<UniformSlot />`, this component only provides the services needed to achieve that.
|
|
@@ -1573,4 +1647,4 @@ declare const globalCompositionEnhancerInjectionKey = "uniformGlobalCompositionE
|
|
|
1573
1647
|
*/
|
|
1574
1648
|
declare function convertComponentToProps<T = unknown>(component: ComponentInstance): ComponentProps<T>;
|
|
1575
1649
|
|
|
1576
|
-
export { ComponentProps, DefaultNotImplementedComponent, DefaultNotImplementedComponentProps, HeadingRichTextNode, LinkRichTextNode, ListItemRichTextNode, ListRichTextNode, ParagraphRichTextNode, PersonalizeComponent, QuoteRichTextNode, RenderRichTextComponentResolver, ResolveRenderer, RichTextComponentProps, RichTextRendererComponent, RootRichTextNode, TestComponent, TextRichTextNode, UniformComponent, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, convertComponentToProps, globalCompositionEnhancerInjectionKey, useCompositionEventEffect, useUniformContextualEditing, useUniformCurrentComponent, useUniformCurrentComposition };
|
|
1650
|
+
export { ComponentProps, DefaultNotImplementedComponent, DefaultNotImplementedComponentProps, HeadingRichTextNode, LinkRichTextNode, ListItemRichTextNode, ListRichTextNode, ParagraphRichTextNode, PersonalizeComponent, QuoteRichTextNode, RenderRichTextComponentResolver, ResolveRenderer, RichTextComponentProps, RichTextRendererComponent, RootRichTextNode, TestComponent, TextRichTextNode, UniformComponent, UniformComponentProps, UniformComposition, UniformCompositionProps, UniformRichText, UniformRichTextNode, UniformRichTextNodeProps, UniformRichTextProps, UniformSlot, UniformSlotProps, UniformText, UniformTextProps, UseCompositionEventEffectOptions, UseUniformContextualEditingProps, convertComponentToProps, globalCompositionEnhancerInjectionKey, useCompositionEventEffect, useUniformContextualEditing, useUniformCurrentComponent, useUniformCurrentComposition };
|
package/dist/index.esm.js
CHANGED
|
@@ -164,7 +164,7 @@ import {
|
|
|
164
164
|
EMPTY_COMPOSITION,
|
|
165
165
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
|
166
166
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
|
167
|
-
|
|
167
|
+
isUpdateCompositionInternalMessage
|
|
168
168
|
} from "@uniformdev/canvas";
|
|
169
169
|
import { computed as computed2, onMounted, ref, watch } from "vue-demi";
|
|
170
170
|
var registeredCompositionIds = /* @__PURE__ */ new Set();
|
|
@@ -203,8 +203,8 @@ var useUniformContextualEditing = ({
|
|
|
203
203
|
if (!channel.value || registeredCompositionIds.has((_e = initialCompositionValue == null ? void 0 : initialCompositionValue.value) == null ? void 0 : _e._id)) {
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
const unsubscribe = channel.value.on("update-composition", async (message) => {
|
|
207
|
-
if (!
|
|
206
|
+
const unsubscribe = channel.value.on("update-composition-internal", async (message) => {
|
|
207
|
+
if (!isUpdateCompositionInternalMessage(message)) {
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
210
|
const enhancedComposition = await enhance(message);
|
|
@@ -260,7 +260,7 @@ function isInContextEditingMode() {
|
|
|
260
260
|
return isOpenedByInContextEditor && isAllowlistedReferrer;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
// src/
|
|
263
|
+
// src/helpers/constants.ts
|
|
264
264
|
var globalCompositionEnhancerInjectionKey = "uniformGlobalCompositionEnhancer";
|
|
265
265
|
|
|
266
266
|
// src/components/ContextualEditingComponentWrapper.ts
|
|
@@ -592,7 +592,7 @@ import {
|
|
|
592
592
|
import { Personalize, Test } from "@uniformdev/context-vue";
|
|
593
593
|
import { computed as computed5, defineComponent as defineComponent7, h as h18 } from "vue-demi";
|
|
594
594
|
|
|
595
|
-
// src/
|
|
595
|
+
// src/helpers/convertComponentToProps.ts
|
|
596
596
|
function convertComponentToProps(component) {
|
|
597
597
|
var _a;
|
|
598
598
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
@@ -745,6 +745,101 @@ function renderComponent({
|
|
|
745
745
|
return h18("");
|
|
746
746
|
}
|
|
747
747
|
|
|
748
|
+
// src/components/UniformText.ts
|
|
749
|
+
import {
|
|
750
|
+
ATTRIBUTE_PARAMETER_TYPE,
|
|
751
|
+
ATTRIBUTE_PARAMETER_VALUE,
|
|
752
|
+
ATTRIBUTE_PLACEHOLDER
|
|
753
|
+
} from "@uniformdev/canvas";
|
|
754
|
+
import { computed as computed6, defineComponent as defineComponent8, h as h19, ref as ref2 } from "vue-demi";
|
|
755
|
+
var DEFAULT_ELEMENT_TYPE = "span";
|
|
756
|
+
var UniformText = defineComponent8({
|
|
757
|
+
name: "UniformText",
|
|
758
|
+
inheritAttrs: true,
|
|
759
|
+
props: {
|
|
760
|
+
as: {
|
|
761
|
+
type: String,
|
|
762
|
+
default: "span"
|
|
763
|
+
},
|
|
764
|
+
parameterId: {
|
|
765
|
+
type: String,
|
|
766
|
+
required: true
|
|
767
|
+
},
|
|
768
|
+
isMultiline: {
|
|
769
|
+
type: Boolean,
|
|
770
|
+
default: false
|
|
771
|
+
},
|
|
772
|
+
placeholder: {
|
|
773
|
+
type: String
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
setup(props, context) {
|
|
777
|
+
var _a;
|
|
778
|
+
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
779
|
+
const { isContextualEditing } = useUniformCurrentComposition();
|
|
780
|
+
const isFocused = ref2(false);
|
|
781
|
+
const parameter = computed6(
|
|
782
|
+
() => {
|
|
783
|
+
var _a2;
|
|
784
|
+
return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[props.parameterId];
|
|
785
|
+
}
|
|
786
|
+
);
|
|
787
|
+
const value = computed6(() => {
|
|
788
|
+
var _a2;
|
|
789
|
+
return (_a2 = parameter.value) == null ? void 0 : _a2.value;
|
|
790
|
+
});
|
|
791
|
+
const isEditable = computed6(() => {
|
|
792
|
+
var _a2, _b, _c;
|
|
793
|
+
return (_c = (_b = (_a2 = parameter.value) == null ? void 0 : _a2._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
|
|
794
|
+
});
|
|
795
|
+
const shouldSkipCustomRendering = computed6(() => isFocused.value && isEditable.value);
|
|
796
|
+
const handleOnFocus = () => {
|
|
797
|
+
isFocused.value = true;
|
|
798
|
+
};
|
|
799
|
+
const handleOnBlur = () => {
|
|
800
|
+
isFocused.value = false;
|
|
801
|
+
};
|
|
802
|
+
if (!parameter) {
|
|
803
|
+
console.warn(
|
|
804
|
+
`UniformText: The parameterId "${props.parameterId}" was not found in the component of type "${componentData == null ? void 0 : componentData.type}"`
|
|
805
|
+
);
|
|
806
|
+
return null;
|
|
807
|
+
}
|
|
808
|
+
if (!isContextualEditing) {
|
|
809
|
+
return () => {
|
|
810
|
+
var _a2, _b, _c, _d;
|
|
811
|
+
return h19(
|
|
812
|
+
(_a2 = props.as) != null ? _a2 : DEFAULT_ELEMENT_TYPE,
|
|
813
|
+
{ style: props.isMultiline ? { whiteSpace: "pre-wrap" } : {} },
|
|
814
|
+
(_d = (_c = (_b = context.slots).default) == null ? void 0 : _c.call(_b, value.value)) != null ? _d : value.value
|
|
815
|
+
);
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
const placeholderProp = (_a = props.placeholder) != null ? _a : contextualEditingDefaultPlaceholder;
|
|
819
|
+
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: props.parameterId }) : placeholderProp;
|
|
820
|
+
return () => {
|
|
821
|
+
var _a2, _b, _c, _d, _e;
|
|
822
|
+
return h19(
|
|
823
|
+
(_a2 = props.as) != null ? _a2 : DEFAULT_ELEMENT_TYPE,
|
|
824
|
+
{
|
|
825
|
+
...getParameterAttributes({
|
|
826
|
+
component: componentData,
|
|
827
|
+
id: props.parameterId,
|
|
828
|
+
isMultiline: props.isMultiline
|
|
829
|
+
}),
|
|
830
|
+
[ATTRIBUTE_PARAMETER_VALUE]: (_b = value.value) != null ? _b : "",
|
|
831
|
+
[ATTRIBUTE_PARAMETER_TYPE]: "text",
|
|
832
|
+
[ATTRIBUTE_PLACEHOLDER]: computedPlaceholder,
|
|
833
|
+
style: props.isMultiline ? { whiteSpace: "pre-wrap" } : {},
|
|
834
|
+
onFocus: handleOnFocus,
|
|
835
|
+
onBlur: handleOnBlur
|
|
836
|
+
},
|
|
837
|
+
shouldSkipCustomRendering.value ? value.value : (_e = (_d = (_c = context.slots).default) == null ? void 0 : _d.call(_c, value.value)) != null ? _e : value.value
|
|
838
|
+
);
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
|
|
748
843
|
// src/composables/useCompositionEventEffect.ts
|
|
749
844
|
import {
|
|
750
845
|
CANVAS_DRAFT_STATE,
|
|
@@ -781,6 +876,9 @@ async function useCompositionEventEffect({
|
|
|
781
876
|
{ immediate: true }
|
|
782
877
|
);
|
|
783
878
|
}
|
|
879
|
+
|
|
880
|
+
// src/helpers/getParameterAttributes.ts
|
|
881
|
+
import { getParameterAttributes } from "@uniformdev/canvas";
|
|
784
882
|
export {
|
|
785
883
|
DefaultNotImplementedComponent,
|
|
786
884
|
HeadingRichTextNode,
|
|
@@ -796,8 +894,10 @@ export {
|
|
|
796
894
|
UniformRichText,
|
|
797
895
|
UniformRichTextNode,
|
|
798
896
|
UniformSlot,
|
|
897
|
+
UniformText,
|
|
799
898
|
convertComponentToProps,
|
|
800
899
|
createUniformApiEnhancer,
|
|
900
|
+
getParameterAttributes,
|
|
801
901
|
globalCompositionEnhancerInjectionKey,
|
|
802
902
|
useCompositionEventEffect,
|
|
803
903
|
useUniformContextualEditing,
|
package/dist/index.js
CHANGED
|
@@ -34,8 +34,10 @@ __export(src_exports, {
|
|
|
34
34
|
UniformRichText: () => UniformRichText,
|
|
35
35
|
UniformRichTextNode: () => UniformRichTextNode,
|
|
36
36
|
UniformSlot: () => UniformSlot,
|
|
37
|
+
UniformText: () => UniformText,
|
|
37
38
|
convertComponentToProps: () => convertComponentToProps,
|
|
38
39
|
createUniformApiEnhancer: () => import_canvas3.createUniformApiEnhancer,
|
|
40
|
+
getParameterAttributes: () => import_canvas8.getParameterAttributes,
|
|
39
41
|
globalCompositionEnhancerInjectionKey: () => globalCompositionEnhancerInjectionKey,
|
|
40
42
|
useCompositionEventEffect: () => useCompositionEventEffect,
|
|
41
43
|
useUniformContextualEditing: () => useUniformContextualEditing,
|
|
@@ -226,8 +228,8 @@ var useUniformContextualEditing = ({
|
|
|
226
228
|
if (!channel.value || registeredCompositionIds.has((_e = initialCompositionValue == null ? void 0 : initialCompositionValue.value) == null ? void 0 : _e._id)) {
|
|
227
229
|
return;
|
|
228
230
|
}
|
|
229
|
-
const unsubscribe = channel.value.on("update-composition", async (message) => {
|
|
230
|
-
if (!(0, import_canvas3.
|
|
231
|
+
const unsubscribe = channel.value.on("update-composition-internal", async (message) => {
|
|
232
|
+
if (!(0, import_canvas3.isUpdateCompositionInternalMessage)(message)) {
|
|
231
233
|
return;
|
|
232
234
|
}
|
|
233
235
|
const enhancedComposition = await enhance(message);
|
|
@@ -283,7 +285,7 @@ function isInContextEditingMode() {
|
|
|
283
285
|
return isOpenedByInContextEditor && isAllowlistedReferrer;
|
|
284
286
|
}
|
|
285
287
|
|
|
286
|
-
// src/
|
|
288
|
+
// src/helpers/constants.ts
|
|
287
289
|
var globalCompositionEnhancerInjectionKey = "uniformGlobalCompositionEnhancer";
|
|
288
290
|
|
|
289
291
|
// src/components/ContextualEditingComponentWrapper.ts
|
|
@@ -603,7 +605,7 @@ var import_canvas5 = require("@uniformdev/canvas");
|
|
|
603
605
|
var import_context_vue2 = require("@uniformdev/context-vue");
|
|
604
606
|
var import_vue_demi19 = require("vue-demi");
|
|
605
607
|
|
|
606
|
-
// src/
|
|
608
|
+
// src/helpers/convertComponentToProps.ts
|
|
607
609
|
function convertComponentToProps(component) {
|
|
608
610
|
var _a;
|
|
609
611
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
@@ -756,9 +758,100 @@ function renderComponent({
|
|
|
756
758
|
return (0, import_vue_demi19.h)("");
|
|
757
759
|
}
|
|
758
760
|
|
|
759
|
-
// src/
|
|
761
|
+
// src/components/UniformText.ts
|
|
760
762
|
var import_canvas6 = require("@uniformdev/canvas");
|
|
761
763
|
var import_vue_demi20 = require("vue-demi");
|
|
764
|
+
var DEFAULT_ELEMENT_TYPE = "span";
|
|
765
|
+
var UniformText = (0, import_vue_demi20.defineComponent)({
|
|
766
|
+
name: "UniformText",
|
|
767
|
+
inheritAttrs: true,
|
|
768
|
+
props: {
|
|
769
|
+
as: {
|
|
770
|
+
type: String,
|
|
771
|
+
default: "span"
|
|
772
|
+
},
|
|
773
|
+
parameterId: {
|
|
774
|
+
type: String,
|
|
775
|
+
required: true
|
|
776
|
+
},
|
|
777
|
+
isMultiline: {
|
|
778
|
+
type: Boolean,
|
|
779
|
+
default: false
|
|
780
|
+
},
|
|
781
|
+
placeholder: {
|
|
782
|
+
type: String
|
|
783
|
+
}
|
|
784
|
+
},
|
|
785
|
+
setup(props, context) {
|
|
786
|
+
var _a;
|
|
787
|
+
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
788
|
+
const { isContextualEditing } = useUniformCurrentComposition();
|
|
789
|
+
const isFocused = (0, import_vue_demi20.ref)(false);
|
|
790
|
+
const parameter = (0, import_vue_demi20.computed)(
|
|
791
|
+
() => {
|
|
792
|
+
var _a2;
|
|
793
|
+
return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[props.parameterId];
|
|
794
|
+
}
|
|
795
|
+
);
|
|
796
|
+
const value = (0, import_vue_demi20.computed)(() => {
|
|
797
|
+
var _a2;
|
|
798
|
+
return (_a2 = parameter.value) == null ? void 0 : _a2.value;
|
|
799
|
+
});
|
|
800
|
+
const isEditable = (0, import_vue_demi20.computed)(() => {
|
|
801
|
+
var _a2, _b, _c;
|
|
802
|
+
return (_c = (_b = (_a2 = parameter.value) == null ? void 0 : _a2._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
|
|
803
|
+
});
|
|
804
|
+
const shouldSkipCustomRendering = (0, import_vue_demi20.computed)(() => isFocused.value && isEditable.value);
|
|
805
|
+
const handleOnFocus = () => {
|
|
806
|
+
isFocused.value = true;
|
|
807
|
+
};
|
|
808
|
+
const handleOnBlur = () => {
|
|
809
|
+
isFocused.value = false;
|
|
810
|
+
};
|
|
811
|
+
if (!parameter) {
|
|
812
|
+
console.warn(
|
|
813
|
+
`UniformText: The parameterId "${props.parameterId}" was not found in the component of type "${componentData == null ? void 0 : componentData.type}"`
|
|
814
|
+
);
|
|
815
|
+
return null;
|
|
816
|
+
}
|
|
817
|
+
if (!isContextualEditing) {
|
|
818
|
+
return () => {
|
|
819
|
+
var _a2, _b, _c, _d;
|
|
820
|
+
return (0, import_vue_demi20.h)(
|
|
821
|
+
(_a2 = props.as) != null ? _a2 : DEFAULT_ELEMENT_TYPE,
|
|
822
|
+
{ style: props.isMultiline ? { whiteSpace: "pre-wrap" } : {} },
|
|
823
|
+
(_d = (_c = (_b = context.slots).default) == null ? void 0 : _c.call(_b, value.value)) != null ? _d : value.value
|
|
824
|
+
);
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
const placeholderProp = (_a = props.placeholder) != null ? _a : contextualEditingDefaultPlaceholder;
|
|
828
|
+
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: props.parameterId }) : placeholderProp;
|
|
829
|
+
return () => {
|
|
830
|
+
var _a2, _b, _c, _d, _e;
|
|
831
|
+
return (0, import_vue_demi20.h)(
|
|
832
|
+
(_a2 = props.as) != null ? _a2 : DEFAULT_ELEMENT_TYPE,
|
|
833
|
+
{
|
|
834
|
+
...(0, import_canvas8.getParameterAttributes)({
|
|
835
|
+
component: componentData,
|
|
836
|
+
id: props.parameterId,
|
|
837
|
+
isMultiline: props.isMultiline
|
|
838
|
+
}),
|
|
839
|
+
[import_canvas6.ATTRIBUTE_PARAMETER_VALUE]: (_b = value.value) != null ? _b : "",
|
|
840
|
+
[import_canvas6.ATTRIBUTE_PARAMETER_TYPE]: "text",
|
|
841
|
+
[import_canvas6.ATTRIBUTE_PLACEHOLDER]: computedPlaceholder,
|
|
842
|
+
style: props.isMultiline ? { whiteSpace: "pre-wrap" } : {},
|
|
843
|
+
onFocus: handleOnFocus,
|
|
844
|
+
onBlur: handleOnBlur
|
|
845
|
+
},
|
|
846
|
+
shouldSkipCustomRendering.value ? value.value : (_e = (_d = (_c = context.slots).default) == null ? void 0 : _d.call(_c, value.value)) != null ? _e : value.value
|
|
847
|
+
);
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
// src/composables/useCompositionEventEffect.ts
|
|
853
|
+
var import_canvas7 = require("@uniformdev/canvas");
|
|
854
|
+
var import_vue_demi21 = require("vue-demi");
|
|
762
855
|
async function useCompositionEventEffect({
|
|
763
856
|
enabled,
|
|
764
857
|
projectId,
|
|
@@ -766,19 +859,19 @@ async function useCompositionEventEffect({
|
|
|
766
859
|
effect
|
|
767
860
|
}) {
|
|
768
861
|
let unsubscribe;
|
|
769
|
-
(0,
|
|
862
|
+
(0, import_vue_demi21.watch)(
|
|
770
863
|
[() => enabled, () => compositionIdRef.value, () => projectId],
|
|
771
864
|
async () => {
|
|
772
865
|
unsubscribe == null ? void 0 : unsubscribe();
|
|
773
866
|
if (!enabled || !compositionIdRef.value || !projectId) {
|
|
774
867
|
return;
|
|
775
868
|
}
|
|
776
|
-
const eventBus = await (0,
|
|
869
|
+
const eventBus = await (0, import_canvas7.createEventBus)();
|
|
777
870
|
if (eventBus) {
|
|
778
|
-
unsubscribe = (0,
|
|
871
|
+
unsubscribe = (0, import_canvas7.subscribeToComposition)({
|
|
779
872
|
eventBus,
|
|
780
873
|
compositionId: compositionIdRef.value,
|
|
781
|
-
compositionState:
|
|
874
|
+
compositionState: import_canvas7.CANVAS_DRAFT_STATE,
|
|
782
875
|
projectId,
|
|
783
876
|
callback: effect,
|
|
784
877
|
event: "updated"
|
|
@@ -788,6 +881,9 @@ async function useCompositionEventEffect({
|
|
|
788
881
|
{ immediate: true }
|
|
789
882
|
);
|
|
790
883
|
}
|
|
884
|
+
|
|
885
|
+
// src/helpers/getParameterAttributes.ts
|
|
886
|
+
var import_canvas8 = require("@uniformdev/canvas");
|
|
791
887
|
// Annotate the CommonJS export names for ESM import in node:
|
|
792
888
|
0 && (module.exports = {
|
|
793
889
|
DefaultNotImplementedComponent,
|
|
@@ -804,8 +900,10 @@ async function useCompositionEventEffect({
|
|
|
804
900
|
UniformRichText,
|
|
805
901
|
UniformRichTextNode,
|
|
806
902
|
UniformSlot,
|
|
903
|
+
UniformText,
|
|
807
904
|
convertComponentToProps,
|
|
808
905
|
createUniformApiEnhancer,
|
|
906
|
+
getParameterAttributes,
|
|
809
907
|
globalCompositionEnhancerInjectionKey,
|
|
810
908
|
useCompositionEventEffect,
|
|
811
909
|
useUniformContextualEditing,
|
package/dist/index.mjs
CHANGED
|
@@ -164,7 +164,7 @@ import {
|
|
|
164
164
|
EMPTY_COMPOSITION,
|
|
165
165
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
|
166
166
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
|
167
|
-
|
|
167
|
+
isUpdateCompositionInternalMessage
|
|
168
168
|
} from "@uniformdev/canvas";
|
|
169
169
|
import { computed as computed2, onMounted, ref, watch } from "vue-demi";
|
|
170
170
|
var registeredCompositionIds = /* @__PURE__ */ new Set();
|
|
@@ -203,8 +203,8 @@ var useUniformContextualEditing = ({
|
|
|
203
203
|
if (!channel.value || registeredCompositionIds.has((_e = initialCompositionValue == null ? void 0 : initialCompositionValue.value) == null ? void 0 : _e._id)) {
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
const unsubscribe = channel.value.on("update-composition", async (message) => {
|
|
207
|
-
if (!
|
|
206
|
+
const unsubscribe = channel.value.on("update-composition-internal", async (message) => {
|
|
207
|
+
if (!isUpdateCompositionInternalMessage(message)) {
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
210
|
const enhancedComposition = await enhance(message);
|
|
@@ -260,7 +260,7 @@ function isInContextEditingMode() {
|
|
|
260
260
|
return isOpenedByInContextEditor && isAllowlistedReferrer;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
// src/
|
|
263
|
+
// src/helpers/constants.ts
|
|
264
264
|
var globalCompositionEnhancerInjectionKey = "uniformGlobalCompositionEnhancer";
|
|
265
265
|
|
|
266
266
|
// src/components/ContextualEditingComponentWrapper.ts
|
|
@@ -592,7 +592,7 @@ import {
|
|
|
592
592
|
import { Personalize, Test } from "@uniformdev/context-vue";
|
|
593
593
|
import { computed as computed5, defineComponent as defineComponent7, h as h18 } from "vue-demi";
|
|
594
594
|
|
|
595
|
-
// src/
|
|
595
|
+
// src/helpers/convertComponentToProps.ts
|
|
596
596
|
function convertComponentToProps(component) {
|
|
597
597
|
var _a;
|
|
598
598
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
@@ -745,6 +745,101 @@ function renderComponent({
|
|
|
745
745
|
return h18("");
|
|
746
746
|
}
|
|
747
747
|
|
|
748
|
+
// src/components/UniformText.ts
|
|
749
|
+
import {
|
|
750
|
+
ATTRIBUTE_PARAMETER_TYPE,
|
|
751
|
+
ATTRIBUTE_PARAMETER_VALUE,
|
|
752
|
+
ATTRIBUTE_PLACEHOLDER
|
|
753
|
+
} from "@uniformdev/canvas";
|
|
754
|
+
import { computed as computed6, defineComponent as defineComponent8, h as h19, ref as ref2 } from "vue-demi";
|
|
755
|
+
var DEFAULT_ELEMENT_TYPE = "span";
|
|
756
|
+
var UniformText = defineComponent8({
|
|
757
|
+
name: "UniformText",
|
|
758
|
+
inheritAttrs: true,
|
|
759
|
+
props: {
|
|
760
|
+
as: {
|
|
761
|
+
type: String,
|
|
762
|
+
default: "span"
|
|
763
|
+
},
|
|
764
|
+
parameterId: {
|
|
765
|
+
type: String,
|
|
766
|
+
required: true
|
|
767
|
+
},
|
|
768
|
+
isMultiline: {
|
|
769
|
+
type: Boolean,
|
|
770
|
+
default: false
|
|
771
|
+
},
|
|
772
|
+
placeholder: {
|
|
773
|
+
type: String
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
setup(props, context) {
|
|
777
|
+
var _a;
|
|
778
|
+
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
779
|
+
const { isContextualEditing } = useUniformCurrentComposition();
|
|
780
|
+
const isFocused = ref2(false);
|
|
781
|
+
const parameter = computed6(
|
|
782
|
+
() => {
|
|
783
|
+
var _a2;
|
|
784
|
+
return (_a2 = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a2[props.parameterId];
|
|
785
|
+
}
|
|
786
|
+
);
|
|
787
|
+
const value = computed6(() => {
|
|
788
|
+
var _a2;
|
|
789
|
+
return (_a2 = parameter.value) == null ? void 0 : _a2.value;
|
|
790
|
+
});
|
|
791
|
+
const isEditable = computed6(() => {
|
|
792
|
+
var _a2, _b, _c;
|
|
793
|
+
return (_c = (_b = (_a2 = parameter.value) == null ? void 0 : _a2._contextualEditing) == null ? void 0 : _b.isEditable) != null ? _c : false;
|
|
794
|
+
});
|
|
795
|
+
const shouldSkipCustomRendering = computed6(() => isFocused.value && isEditable.value);
|
|
796
|
+
const handleOnFocus = () => {
|
|
797
|
+
isFocused.value = true;
|
|
798
|
+
};
|
|
799
|
+
const handleOnBlur = () => {
|
|
800
|
+
isFocused.value = false;
|
|
801
|
+
};
|
|
802
|
+
if (!parameter) {
|
|
803
|
+
console.warn(
|
|
804
|
+
`UniformText: The parameterId "${props.parameterId}" was not found in the component of type "${componentData == null ? void 0 : componentData.type}"`
|
|
805
|
+
);
|
|
806
|
+
return null;
|
|
807
|
+
}
|
|
808
|
+
if (!isContextualEditing) {
|
|
809
|
+
return () => {
|
|
810
|
+
var _a2, _b, _c, _d;
|
|
811
|
+
return h19(
|
|
812
|
+
(_a2 = props.as) != null ? _a2 : DEFAULT_ELEMENT_TYPE,
|
|
813
|
+
{ style: props.isMultiline ? { whiteSpace: "pre-wrap" } : {} },
|
|
814
|
+
(_d = (_c = (_b = context.slots).default) == null ? void 0 : _c.call(_b, value.value)) != null ? _d : value.value
|
|
815
|
+
);
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
const placeholderProp = (_a = props.placeholder) != null ? _a : contextualEditingDefaultPlaceholder;
|
|
819
|
+
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: props.parameterId }) : placeholderProp;
|
|
820
|
+
return () => {
|
|
821
|
+
var _a2, _b, _c, _d, _e;
|
|
822
|
+
return h19(
|
|
823
|
+
(_a2 = props.as) != null ? _a2 : DEFAULT_ELEMENT_TYPE,
|
|
824
|
+
{
|
|
825
|
+
...getParameterAttributes({
|
|
826
|
+
component: componentData,
|
|
827
|
+
id: props.parameterId,
|
|
828
|
+
isMultiline: props.isMultiline
|
|
829
|
+
}),
|
|
830
|
+
[ATTRIBUTE_PARAMETER_VALUE]: (_b = value.value) != null ? _b : "",
|
|
831
|
+
[ATTRIBUTE_PARAMETER_TYPE]: "text",
|
|
832
|
+
[ATTRIBUTE_PLACEHOLDER]: computedPlaceholder,
|
|
833
|
+
style: props.isMultiline ? { whiteSpace: "pre-wrap" } : {},
|
|
834
|
+
onFocus: handleOnFocus,
|
|
835
|
+
onBlur: handleOnBlur
|
|
836
|
+
},
|
|
837
|
+
shouldSkipCustomRendering.value ? value.value : (_e = (_d = (_c = context.slots).default) == null ? void 0 : _d.call(_c, value.value)) != null ? _e : value.value
|
|
838
|
+
);
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
|
|
748
843
|
// src/composables/useCompositionEventEffect.ts
|
|
749
844
|
import {
|
|
750
845
|
CANVAS_DRAFT_STATE,
|
|
@@ -781,6 +876,9 @@ async function useCompositionEventEffect({
|
|
|
781
876
|
{ immediate: true }
|
|
782
877
|
);
|
|
783
878
|
}
|
|
879
|
+
|
|
880
|
+
// src/helpers/getParameterAttributes.ts
|
|
881
|
+
import { getParameterAttributes } from "@uniformdev/canvas";
|
|
784
882
|
export {
|
|
785
883
|
DefaultNotImplementedComponent,
|
|
786
884
|
HeadingRichTextNode,
|
|
@@ -796,8 +894,10 @@ export {
|
|
|
796
894
|
UniformRichText,
|
|
797
895
|
UniformRichTextNode,
|
|
798
896
|
UniformSlot,
|
|
897
|
+
UniformText,
|
|
799
898
|
convertComponentToProps,
|
|
800
899
|
createUniformApiEnhancer,
|
|
900
|
+
getParameterAttributes,
|
|
801
901
|
globalCompositionEnhancerInjectionKey,
|
|
802
902
|
useCompositionEventEffect,
|
|
803
903
|
useUniformContextualEditing,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-vue",
|
|
3
|
-
"version": "19.35.
|
|
3
|
+
"version": "19.35.2",
|
|
4
4
|
"description": "Vue SDK for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"document": "api-extractor run --local"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@uniformdev/canvas": "19.35.
|
|
27
|
-
"@uniformdev/context-vue": "19.35.
|
|
28
|
-
"@uniformdev/richtext": "19.35.
|
|
26
|
+
"@uniformdev/canvas": "19.35.2",
|
|
27
|
+
"@uniformdev/context-vue": "19.35.2",
|
|
28
|
+
"@uniformdev/richtext": "19.35.2",
|
|
29
29
|
"vue-demi": "^0.14.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "64d3270175087c87cfaa29a283aa4a7b0a98fd2c"
|
|
63
63
|
}
|