@voiceflow/utils-designer 1.2.2 → 1.2.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.
@@ -1,14 +1,14 @@
|
|
1
1
|
import type { Entity, Markup, MarkupSpan, Variable } from '@voiceflow/dtos';
|
2
2
|
import type { MultiAdapter } from 'bidirectional-adapter';
|
3
|
-
|
4
|
-
|
5
|
-
interface MarkupSpanText extends Omit<MarkupSpan, 'text'> {
|
3
|
+
export type MarkupItem = Markup[number];
|
4
|
+
export declare const ENTITY_OR_VARIABLE_TEXT_REGEXP: RegExp;
|
5
|
+
export interface MarkupSpanText extends Omit<MarkupSpan, 'text'> {
|
6
6
|
text: [string];
|
7
7
|
attributes: {
|
8
8
|
__type: 'text';
|
9
9
|
};
|
10
10
|
}
|
11
|
-
interface MarkupSpanLink extends MarkupSpan {
|
11
|
+
export interface MarkupSpanLink extends MarkupSpan {
|
12
12
|
attributes: {
|
13
13
|
__type: 'link';
|
14
14
|
url: string;
|
@@ -51,8 +51,5 @@ export declare const replaceMarkupEntity: (markup: Markup, { oldEntityID, newEnt
|
|
51
51
|
}) => Markup;
|
52
52
|
export declare const fillMarkupWithVariablesValues: (promptText: string, variables: Record<string, string>) => string;
|
53
53
|
export declare const markupToString: MultiAdapter<Markup, string, [MarkupToStringFromOptions], [MarkupToStringToOptions]>;
|
54
|
-
export declare const markupToSlate: MultiAdapter<Markup, Descendant[], [] | [{
|
55
|
-
iteration?: number | undefined;
|
56
|
-
}], []>;
|
57
54
|
export {};
|
58
55
|
//# sourceMappingURL=markup.util.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"markup.util.d.ts","sourceRoot":"","sources":["../../src/markup.util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"markup.util.d.ts","sourceRoot":"","sources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yBAAyB;IACjC,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACpD,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,UAAU,uBAAuB;IAC/B,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;CACvD;AAiBD,eAAO,MAAM,kBAAkB,8BAAwE,CAAC;AAiBxG,eAAO,MAAM,oBAAoB,8BAA0E,CAAC;AAE5G,eAAO,MAAM,mBAAmB;iBAEe,MAAM;iBAAe,MAAM;YAWzE,CAAC;AAEF,eAAO,MAAM,6BAA6B,eAAgB,MAAM,aAAa,OAAO,MAAM,EAAE,MAAM,CAAC,WAOlG,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,yBAAyB,CAAC,EAAE,CAAC,uBAAuB,CAAC,CA8E7G,CAAC"}
|
package/build/cjs/markup.util.js
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.markupToString = exports.fillMarkupWithVariablesValues = exports.replaceMarkupEntity = exports.getMarkupVariableIDs = exports.getMarkupEntityIDs = exports.isMarkupWithEntities = exports.isMarkupEmpty = exports.isMarkupVariable = exports.isMarkupString = exports.isMarkupEntity = exports.isMarkupSpanLink = exports.isMarkupSpanText = exports.isMarkupSpan = exports.markupFactory = exports.isMarkupEntityReference = exports.isMarkupVariableReference = exports.ENTITY_OR_VARIABLE_TEXT_REGEXP = void 0;
|
4
4
|
const common_1 = require("@voiceflow/common");
|
5
|
-
const ui_next_1 = require("@voiceflow/ui-next");
|
6
5
|
const bidirectional_adapter_1 = require("bidirectional-adapter");
|
7
|
-
const slate_1 = require("slate");
|
8
6
|
const ts_pattern_1 = require("ts-pattern");
|
9
|
-
|
7
|
+
exports.ENTITY_OR_VARIABLE_TEXT_REGEXP = /{(\w*)}/g;
|
10
8
|
const isMarkupVariableReference = (markupItem) => {
|
11
9
|
return markupItem.variableID !== undefined;
|
12
10
|
};
|
@@ -110,7 +108,7 @@ exports.markupToString = (0, bidirectional_adapter_1.createMultiAdapter)((markup
|
|
110
108
|
? ''
|
111
109
|
: `{${variablesMapByID[variableID]?.name ?? variableID}}`)
|
112
110
|
.exhaustive(), ''), (text, { entitiesMapByName, variablesMapByName }) => {
|
113
|
-
const matches = [...text.matchAll(ENTITY_OR_VARIABLE_TEXT_REGEXP)];
|
111
|
+
const matches = [...text.matchAll(exports.ENTITY_OR_VARIABLE_TEXT_REGEXP)];
|
114
112
|
if (!matches.length)
|
115
113
|
return [{ text: [text] }];
|
116
114
|
const span = {
|
@@ -150,86 +148,3 @@ exports.markupToString = (0, bidirectional_adapter_1.createMultiAdapter)((markup
|
|
150
148
|
}
|
151
149
|
return [span];
|
152
150
|
});
|
153
|
-
exports.markupToSlate = (0, bidirectional_adapter_1.createMultiAdapter)((markup, { iteration = 0 } = {}) => {
|
154
|
-
if (!markup.length)
|
155
|
-
return iteration === 0 ? ui_next_1.SlateEditor.StaticEditor.createTextState('') : [{ text: '' }];
|
156
|
-
if (markup.length === 1 && typeof markup[0] === 'string')
|
157
|
-
return iteration === 0 ? ui_next_1.SlateEditor.StaticEditor.createTextState(markup[0]) : [{ text: markup[0] }];
|
158
|
-
return markup.reduce((acc, item) => [
|
159
|
-
...acc,
|
160
|
-
(0, ts_pattern_1.match)(item)
|
161
|
-
.when(exports.isMarkupString, (item) => ({ text: item }))
|
162
|
-
.when(exports.isMarkupEntity, ({ entityID }) => ({
|
163
|
-
type: ui_next_1.SlateEditor.ElementType.VARIABLE,
|
164
|
-
children: [{ text: '' }],
|
165
|
-
variableID: entityID,
|
166
|
-
variableVariant: ui_next_1.SlateEditor.VariableElementVariant.ENTITY,
|
167
|
-
}))
|
168
|
-
.when(exports.isMarkupVariable, ({ variableID }) => ({
|
169
|
-
type: ui_next_1.SlateEditor.ElementType.VARIABLE,
|
170
|
-
children: [{ text: '' }],
|
171
|
-
variableID,
|
172
|
-
variableVariant: ui_next_1.SlateEditor.VariableElementVariant.VARIABLE,
|
173
|
-
}))
|
174
|
-
.when(exports.isMarkupSpan, (span) => (0, ts_pattern_1.match)(span)
|
175
|
-
.when(exports.isMarkupSpanText, ({ text: [text], attributes: { __type, ...attrs } }) => ({ ...attrs, text }))
|
176
|
-
.when(exports.isMarkupSpanLink, ({ text, attributes: { url } }) => ({
|
177
|
-
url,
|
178
|
-
type: ui_next_1.SlateEditor.ElementType.LINK,
|
179
|
-
children: exports.markupToSlate.fromDB(text, { iteration: iteration + 1 }),
|
180
|
-
}))
|
181
|
-
.otherwise(({ text, attributes: { __type, ...attrs } = {} }) => ({
|
182
|
-
...attrs,
|
183
|
-
children: exports.markupToSlate.fromDB(text, { iteration: iteration + 1 }),
|
184
|
-
})))
|
185
|
-
.exhaustive(),
|
186
|
-
], []);
|
187
|
-
},
|
188
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
189
|
-
(slate) => {
|
190
|
-
if (ui_next_1.SlateEditor.StaticEditor.isEmptyState(slate))
|
191
|
-
return (0, exports.markupFactory)();
|
192
|
-
return slate.reduce((acc, item) => [
|
193
|
-
...acc,
|
194
|
-
(0, ts_pattern_1.match)(item)
|
195
|
-
.when(ui_next_1.SlateEditor.StaticEditor.isLink, (item) => {
|
196
|
-
const { url = '', children } = item;
|
197
|
-
return {
|
198
|
-
text: exports.markupToSlate.toDB(children),
|
199
|
-
attributes: { __type: 'link', url },
|
200
|
-
};
|
201
|
-
})
|
202
|
-
.when(ui_next_1.SlateEditor.StaticEditor.isVariable, (item) => {
|
203
|
-
const { variableID, variableVariant } = item;
|
204
|
-
return variableVariant === ui_next_1.SlateEditor.VariableElementVariant.VARIABLE
|
205
|
-
? { variableID }
|
206
|
-
: { entityID: variableID };
|
207
|
-
})
|
208
|
-
.when(slate_1.Text.isText, (item) => {
|
209
|
-
// TODO: fix any
|
210
|
-
const { text, color, italic, underline, fontWeight, fontFamily, strikeThrough, backgroundColor } = item;
|
211
|
-
if (!color && !italic && !underline && !fontWeight && !fontFamily && !strikeThrough && !backgroundColor) {
|
212
|
-
return text;
|
213
|
-
}
|
214
|
-
return {
|
215
|
-
text: [text],
|
216
|
-
attributes: {
|
217
|
-
__type: 'text',
|
218
|
-
...(color && { color }),
|
219
|
-
...(italic && { italic }),
|
220
|
-
...(underline && { underline }),
|
221
|
-
...(fontWeight && { fontWeight }),
|
222
|
-
...(fontFamily && { fontFamily }),
|
223
|
-
...(strikeThrough && { strikeThrough }),
|
224
|
-
...(backgroundColor && { backgroundColor }),
|
225
|
-
},
|
226
|
-
};
|
227
|
-
})
|
228
|
-
.otherwise(
|
229
|
-
// TODO: fix any
|
230
|
-
({ type: _, children, textAlign }) => ({
|
231
|
-
text: exports.markupToSlate.toDB(children),
|
232
|
-
...(textAlign && { attributes: { textAlign } }),
|
233
|
-
})),
|
234
|
-
], []);
|
235
|
-
});
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import type { Entity, Markup, MarkupSpan, Variable } from '@voiceflow/dtos';
|
2
2
|
import type { MultiAdapter } from 'bidirectional-adapter';
|
3
|
-
|
4
|
-
|
5
|
-
interface MarkupSpanText extends Omit<MarkupSpan, 'text'> {
|
3
|
+
export type MarkupItem = Markup[number];
|
4
|
+
export declare const ENTITY_OR_VARIABLE_TEXT_REGEXP: RegExp;
|
5
|
+
export interface MarkupSpanText extends Omit<MarkupSpan, 'text'> {
|
6
6
|
text: [string];
|
7
7
|
attributes: {
|
8
8
|
__type: 'text';
|
9
9
|
};
|
10
10
|
}
|
11
|
-
interface MarkupSpanLink extends MarkupSpan {
|
11
|
+
export interface MarkupSpanLink extends MarkupSpan {
|
12
12
|
attributes: {
|
13
13
|
__type: 'link';
|
14
14
|
url: string;
|
@@ -51,8 +51,5 @@ export declare const replaceMarkupEntity: (markup: Markup, { oldEntityID, newEnt
|
|
51
51
|
}) => Markup;
|
52
52
|
export declare const fillMarkupWithVariablesValues: (promptText: string, variables: Record<string, string>) => string;
|
53
53
|
export declare const markupToString: MultiAdapter<Markup, string, [MarkupToStringFromOptions], [MarkupToStringToOptions]>;
|
54
|
-
export declare const markupToSlate: MultiAdapter<Markup, Descendant[], [] | [{
|
55
|
-
iteration?: number | undefined;
|
56
|
-
}], []>;
|
57
54
|
export {};
|
58
55
|
//# sourceMappingURL=markup.util.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"markup.util.d.ts","sourceRoot":"","sources":["../../src/markup.util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"markup.util.d.ts","sourceRoot":"","sources":["../../src/markup.util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAExC,eAAO,MAAM,8BAA8B,QAAa,CAAC;AAEzD,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC;IAC9D,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;IACf,UAAU,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,UAAU,EAAE;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,8BAA0E,CAAC;AAE5G,eAAO,MAAM,mBAAmB;iBAEe,MAAM;iBAAe,MAAM;YAWzE,CAAC;AAEF,eAAO,MAAM,6BAA6B,eAAgB,MAAM,aAAa,OAAO,MAAM,EAAE,MAAM,CAAC,WAOlG,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,yBAAyB,CAAC,EAAE,CAAC,uBAAuB,CAAC,CA8E7G,CAAC"}
|
package/build/esm/markup.util.js
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
import { Utils } from '@voiceflow/common';
|
2
|
-
import { SlateEditor } from '@voiceflow/ui-next';
|
3
2
|
import { createMultiAdapter } from 'bidirectional-adapter';
|
4
|
-
import { Text } from 'slate';
|
5
3
|
import { match } from 'ts-pattern';
|
6
|
-
const ENTITY_OR_VARIABLE_TEXT_REGEXP = /{(\w*)}/g;
|
4
|
+
export const ENTITY_OR_VARIABLE_TEXT_REGEXP = /{(\w*)}/g;
|
7
5
|
export const isMarkupVariableReference = (markupItem) => {
|
8
6
|
return markupItem.variableID !== undefined;
|
9
7
|
};
|
@@ -132,86 +130,3 @@ export const markupToString = createMultiAdapter((markup, { entitiesMapByID, var
|
|
132
130
|
}
|
133
131
|
return [span];
|
134
132
|
});
|
135
|
-
export const markupToSlate = createMultiAdapter((markup, { iteration = 0 } = {}) => {
|
136
|
-
if (!markup.length)
|
137
|
-
return iteration === 0 ? SlateEditor.StaticEditor.createTextState('') : [{ text: '' }];
|
138
|
-
if (markup.length === 1 && typeof markup[0] === 'string')
|
139
|
-
return iteration === 0 ? SlateEditor.StaticEditor.createTextState(markup[0]) : [{ text: markup[0] }];
|
140
|
-
return markup.reduce((acc, item) => [
|
141
|
-
...acc,
|
142
|
-
match(item)
|
143
|
-
.when(isMarkupString, (item) => ({ text: item }))
|
144
|
-
.when(isMarkupEntity, ({ entityID }) => ({
|
145
|
-
type: SlateEditor.ElementType.VARIABLE,
|
146
|
-
children: [{ text: '' }],
|
147
|
-
variableID: entityID,
|
148
|
-
variableVariant: SlateEditor.VariableElementVariant.ENTITY,
|
149
|
-
}))
|
150
|
-
.when(isMarkupVariable, ({ variableID }) => ({
|
151
|
-
type: SlateEditor.ElementType.VARIABLE,
|
152
|
-
children: [{ text: '' }],
|
153
|
-
variableID,
|
154
|
-
variableVariant: SlateEditor.VariableElementVariant.VARIABLE,
|
155
|
-
}))
|
156
|
-
.when(isMarkupSpan, (span) => match(span)
|
157
|
-
.when(isMarkupSpanText, ({ text: [text], attributes: { __type, ...attrs } }) => ({ ...attrs, text }))
|
158
|
-
.when(isMarkupSpanLink, ({ text, attributes: { url } }) => ({
|
159
|
-
url,
|
160
|
-
type: SlateEditor.ElementType.LINK,
|
161
|
-
children: markupToSlate.fromDB(text, { iteration: iteration + 1 }),
|
162
|
-
}))
|
163
|
-
.otherwise(({ text, attributes: { __type, ...attrs } = {} }) => ({
|
164
|
-
...attrs,
|
165
|
-
children: markupToSlate.fromDB(text, { iteration: iteration + 1 }),
|
166
|
-
})))
|
167
|
-
.exhaustive(),
|
168
|
-
], []);
|
169
|
-
},
|
170
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
171
|
-
(slate) => {
|
172
|
-
if (SlateEditor.StaticEditor.isEmptyState(slate))
|
173
|
-
return markupFactory();
|
174
|
-
return slate.reduce((acc, item) => [
|
175
|
-
...acc,
|
176
|
-
match(item)
|
177
|
-
.when(SlateEditor.StaticEditor.isLink, (item) => {
|
178
|
-
const { url = '', children } = item;
|
179
|
-
return {
|
180
|
-
text: markupToSlate.toDB(children),
|
181
|
-
attributes: { __type: 'link', url },
|
182
|
-
};
|
183
|
-
})
|
184
|
-
.when(SlateEditor.StaticEditor.isVariable, (item) => {
|
185
|
-
const { variableID, variableVariant } = item;
|
186
|
-
return variableVariant === SlateEditor.VariableElementVariant.VARIABLE
|
187
|
-
? { variableID }
|
188
|
-
: { entityID: variableID };
|
189
|
-
})
|
190
|
-
.when(Text.isText, (item) => {
|
191
|
-
// TODO: fix any
|
192
|
-
const { text, color, italic, underline, fontWeight, fontFamily, strikeThrough, backgroundColor } = item;
|
193
|
-
if (!color && !italic && !underline && !fontWeight && !fontFamily && !strikeThrough && !backgroundColor) {
|
194
|
-
return text;
|
195
|
-
}
|
196
|
-
return {
|
197
|
-
text: [text],
|
198
|
-
attributes: {
|
199
|
-
__type: 'text',
|
200
|
-
...(color && { color }),
|
201
|
-
...(italic && { italic }),
|
202
|
-
...(underline && { underline }),
|
203
|
-
...(fontWeight && { fontWeight }),
|
204
|
-
...(fontFamily && { fontFamily }),
|
205
|
-
...(strikeThrough && { strikeThrough }),
|
206
|
-
...(backgroundColor && { backgroundColor }),
|
207
|
-
},
|
208
|
-
};
|
209
|
-
})
|
210
|
-
.otherwise(
|
211
|
-
// TODO: fix any
|
212
|
-
({ type: _, children, textAlign }) => ({
|
213
|
-
text: markupToSlate.toDB(children),
|
214
|
-
...(textAlign && { attributes: { textAlign } }),
|
215
|
-
})),
|
216
|
-
], []);
|
217
|
-
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@voiceflow/utils-designer",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.3",
|
4
4
|
"exports": {
|
5
5
|
".": {
|
6
6
|
"types": "./build/cjs/main.d.ts",
|
@@ -37,9 +37,7 @@
|
|
37
37
|
"dependencies": {
|
38
38
|
"@voiceflow/common": "8.2.2",
|
39
39
|
"@voiceflow/dtos": "1.10.0",
|
40
|
-
"@voiceflow/ui-next": "npm:@voiceflow/ui@2.115.1",
|
41
40
|
"bidirectional-adapter": "1.2.1",
|
42
|
-
"slate": "0.94.1",
|
43
41
|
"ts-pattern": "^5.0.5"
|
44
42
|
},
|
45
43
|
"devDependencies": {
|
@@ -50,5 +48,5 @@
|
|
50
48
|
"tsd": {
|
51
49
|
"directory": "src"
|
52
50
|
},
|
53
|
-
"gitHead": "
|
51
|
+
"gitHead": "f676981c3604883c5fd045db0fdb0cd2c8e17c94"
|
54
52
|
}
|