@makeswift/runtime 0.25.4-canary.2 → 0.25.4-canary.4

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.
Files changed (53) hide show
  1. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  2. package/dist/cjs/controls/control.js +3 -1
  3. package/dist/cjs/controls/control.js.map +1 -1
  4. package/dist/cjs/controls/rich-text-v2/rich-text-v2.js +2 -15
  5. package/dist/cjs/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  6. package/dist/cjs/controls/rich-text-v2/translations/get-translations.js +96 -0
  7. package/dist/cjs/controls/rich-text-v2/translations/get-translations.js.map +1 -0
  8. package/dist/cjs/controls/rich-text-v2/{translation.js → translations/merge-translations.js} +10 -87
  9. package/dist/cjs/controls/rich-text-v2/translations/merge-translations.js.map +1 -0
  10. package/dist/cjs/controls/rich-text-v2/translations/translations-core.js +45 -0
  11. package/dist/cjs/controls/rich-text-v2/translations/translations-core.js.map +1 -0
  12. package/dist/cjs/controls/visitors/merge-translations-visitor.js +46 -0
  13. package/dist/cjs/controls/visitors/merge-translations-visitor.js.map +1 -0
  14. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  15. package/dist/esm/controls/control.js +3 -1
  16. package/dist/esm/controls/control.js.map +1 -1
  17. package/dist/esm/controls/rich-text-v2/rich-text-v2.js +1 -17
  18. package/dist/esm/controls/rich-text-v2/rich-text-v2.js.map +1 -1
  19. package/dist/esm/controls/rich-text-v2/translations/get-translations.js +62 -0
  20. package/dist/esm/controls/rich-text-v2/translations/get-translations.js.map +1 -0
  21. package/dist/esm/controls/rich-text-v2/{translation.js → translations/merge-translations.js} +4 -70
  22. package/dist/esm/controls/rich-text-v2/translations/merge-translations.js.map +1 -0
  23. package/dist/esm/controls/rich-text-v2/translations/translations-core.js +19 -0
  24. package/dist/esm/controls/rich-text-v2/translations/translations-core.js.map +1 -0
  25. package/dist/esm/controls/visitors/merge-translations-visitor.js +22 -0
  26. package/dist/esm/controls/visitors/merge-translations-visitor.js.map +1 -0
  27. package/dist/types/client/index.d.ts +11 -11
  28. package/dist/types/controls/control.d.ts.map +1 -1
  29. package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts +11 -12
  30. package/dist/types/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
  31. package/dist/types/controls/rich-text-v2/translations/get-translations.d.ts +5 -0
  32. package/dist/types/controls/rich-text-v2/translations/get-translations.d.ts.map +1 -0
  33. package/dist/types/controls/rich-text-v2/translations/merge-translations.d.ts +5 -0
  34. package/dist/types/controls/rich-text-v2/translations/merge-translations.d.ts.map +1 -0
  35. package/dist/types/controls/rich-text-v2/translations/translations-core.d.ts +7 -0
  36. package/dist/types/controls/rich-text-v2/translations/translations-core.d.ts.map +1 -0
  37. package/dist/types/controls/visitors/merge-translations-visitor.d.ts +6 -0
  38. package/dist/types/controls/visitors/merge-translations-visitor.d.ts.map +1 -0
  39. package/dist/types/slate/BlockPlugin/index.d.ts +1 -13
  40. package/dist/types/slate/BlockPlugin/index.d.ts.map +1 -1
  41. package/dist/types/slate/InlinePlugin/index.d.ts +1 -13
  42. package/dist/types/slate/InlinePlugin/index.d.ts.map +1 -1
  43. package/dist/types/slate/LinkPlugin/getValue.d.ts.map +1 -1
  44. package/dist/types/slate/LinkPlugin/index.d.ts.map +1 -1
  45. package/dist/types/slate/TextAlignPlugin/index.d.ts +1 -13
  46. package/dist/types/slate/TextAlignPlugin/index.d.ts.map +1 -1
  47. package/dist/types/slate/TypographyPlugin/getValue.d.ts.map +1 -1
  48. package/dist/types/slate/TypographyPlugin/index.d.ts.map +1 -1
  49. package/package.json +41 -41
  50. package/dist/cjs/controls/rich-text-v2/translation.js.map +0 -1
  51. package/dist/esm/controls/rich-text-v2/translation.js.map +0 -1
  52. package/dist/types/controls/rich-text-v2/translation.d.ts +0 -6
  53. package/dist/types/controls/rich-text-v2/translation.d.ts.map +0 -1
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
28
28
  return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
29
29
  }
30
30
  return import_request_response.ApiResponse.json({
31
- version: "0.25.4-canary.2",
31
+ version: "0.25.4-canary.4",
32
32
  interactionMode: true,
33
33
  clientSideNavigation: false,
34
34
  elementFromPoint: false,
@@ -29,6 +29,7 @@ var import_prop_controllers = require("@makeswift/prop-controllers");
29
29
  var import_descriptors = require("../prop-controllers/descriptors");
30
30
  var import_copy = require("../prop-controllers/copy");
31
31
  var import_prop_controllers2 = require("../prop-controllers");
32
+ var import_merge_translations_visitor = require("./visitors/merge-translations-visitor");
32
33
  function copy(definition, value, context) {
33
34
  if (!(0, import_descriptors.isLegacyDescriptor)(definition)) {
34
35
  return definition.copyData(value, context);
@@ -78,7 +79,8 @@ function mergeTranslatedData(definition, data, translatedData, context) {
78
79
  if (data == null)
79
80
  return data;
80
81
  if (!(0, import_descriptors.isLegacyDescriptor)(definition)) {
81
- return definition.mergeTranslatedData(data, translatedData, context);
82
+ const mergeTranslationsVisitor = new import_merge_translations_visitor.ReactMergeTranslationsVisitor(context);
83
+ return definition.accept(mergeTranslationsVisitor, data, translatedData);
82
84
  }
83
85
  switch (definition.type) {
84
86
  case import_prop_controllers.Types.TextInput:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/controls/control.ts"],"sourcesContent":["import {\n copyRichTextData,\n type CopyContext,\n type Data,\n type MergeContext,\n type MergeTranslatableDataContext,\n} from '@makeswift/controls'\n\nimport {\n GridPropControllerData,\n Types as PropControllerTypes,\n mergeGridPropControllerTranslatedData,\n} from '@makeswift/prop-controllers'\n\nimport { Descriptor, isLegacyDescriptor } from '../prop-controllers/descriptors'\nimport { copy as propControllerCopy } from '../prop-controllers/copy'\nimport { DELETED_PROP_CONTROLLER_TYPES, PropControllerDescriptor } from '../prop-controllers'\n\nexport function copy(definition: Descriptor, value: any, context: CopyContext) {\n if (!isLegacyDescriptor(definition)) {\n return definition.copyData(value, context)\n }\n\n switch (definition.type) {\n case PropControllerTypes.Backgrounds:\n case PropControllerTypes.Grid:\n case PropControllerTypes.NavigationLinks:\n case PropControllerTypes.Link:\n case PropControllerTypes.Shadows:\n case PropControllerTypes.Image:\n case PropControllerTypes.Images:\n case PropControllerTypes.ResponsiveColor:\n case PropControllerTypes.TableFormFields:\n case PropControllerTypes.Table:\n case PropControllerTypes.Border:\n case PropControllerTypes.ElementID:\n return propControllerCopy(definition, value, context)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return copyRichTextData(value, context)\n\n default:\n return value\n }\n}\n\nexport function merge(\n definition: PropControllerDescriptor,\n a: Data,\n b: Data = a,\n context: MergeContext,\n): Data {\n if (!isLegacyDescriptor(definition)) {\n return definition.mergeData(a, b, context)\n }\n\n switch (definition.type) {\n default:\n return b\n }\n}\n\nexport function getTranslatableData(definition: Descriptor, data: Data): Data {\n if (!isLegacyDescriptor(definition)) {\n return definition.getTranslatableData(data)\n }\n\n switch (definition.type) {\n case PropControllerTypes.TextInput:\n case PropControllerTypes.TextArea:\n return data\n\n default:\n return null\n }\n}\n\nexport function mergeTranslatedData(\n definition: PropControllerDescriptor,\n data: Data,\n translatedData: Data,\n context: MergeTranslatableDataContext,\n): Data {\n if (data == null) return data\n if (!isLegacyDescriptor(definition)) {\n return definition.mergeTranslatedData(data, translatedData, context)\n }\n\n switch (definition.type) {\n case PropControllerTypes.TextInput:\n case PropControllerTypes.TextArea:\n if (translatedData == null) return data\n return translatedData\n\n case PropControllerTypes.Grid:\n return mergeGridPropControllerTranslatedData(data as GridPropControllerData, context)\n\n default:\n return data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAMO;AAEP,8BAIO;AAEP,yBAA+C;AAC/C,kBAA2C;AAC3C,IAAAA,2BAAwE;AAEjE,SAAS,KAAK,YAAwB,OAAY,SAAsB;AAC7E,MAAI,KAAC,uCAAmB,UAAU,GAAG;AACnC,WAAO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A,EACrE;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AACvB,UAAI,kBAAkB;AAAM,eAAO;AACnC,aAAO;AAAA,IAET,KAAK,wBAAAA,MAAoB;AACvB,iBAAO,+DAAsC,MAAgC,OAAO;AAAA,IAEtF;AACE,aAAO;AAAA,EACX;AACF;","names":["import_prop_controllers","PropControllerTypes","propControllerCopy"]}
1
+ {"version":3,"sources":["../../../src/controls/control.ts"],"sourcesContent":["import {\n copyRichTextData,\n type CopyContext,\n type Data,\n type MergeContext,\n type MergeTranslatableDataContext,\n} from '@makeswift/controls'\n\nimport {\n GridPropControllerData,\n Types as PropControllerTypes,\n mergeGridPropControllerTranslatedData,\n} from '@makeswift/prop-controllers'\n\nimport { Descriptor, isLegacyDescriptor } from '../prop-controllers/descriptors'\nimport { copy as propControllerCopy } from '../prop-controllers/copy'\nimport { DELETED_PROP_CONTROLLER_TYPES, PropControllerDescriptor } from '../prop-controllers'\nimport { ReactMergeTranslationsVisitor } from './visitors/merge-translations-visitor'\n\nexport function copy(definition: Descriptor, value: any, context: CopyContext) {\n if (!isLegacyDescriptor(definition)) {\n return definition.copyData(value, context)\n }\n\n switch (definition.type) {\n case PropControllerTypes.Backgrounds:\n case PropControllerTypes.Grid:\n case PropControllerTypes.NavigationLinks:\n case PropControllerTypes.Link:\n case PropControllerTypes.Shadows:\n case PropControllerTypes.Image:\n case PropControllerTypes.Images:\n case PropControllerTypes.ResponsiveColor:\n case PropControllerTypes.TableFormFields:\n case PropControllerTypes.Table:\n case PropControllerTypes.Border:\n case PropControllerTypes.ElementID:\n return propControllerCopy(definition, value, context)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return copyRichTextData(value, context)\n\n default:\n return value\n }\n}\n\nexport function merge(\n definition: PropControllerDescriptor,\n a: Data,\n b: Data = a,\n context: MergeContext,\n): Data {\n if (!isLegacyDescriptor(definition)) {\n return definition.mergeData(a, b, context)\n }\n\n switch (definition.type) {\n default:\n return b\n }\n}\n\nexport function getTranslatableData(definition: Descriptor, data: Data): Data {\n if (!isLegacyDescriptor(definition)) {\n return definition.getTranslatableData(data)\n }\n\n switch (definition.type) {\n case PropControllerTypes.TextInput:\n case PropControllerTypes.TextArea:\n return data\n\n default:\n return null\n }\n}\n\nexport function mergeTranslatedData(\n definition: PropControllerDescriptor,\n data: Data,\n translatedData: Data,\n context: MergeTranslatableDataContext,\n): Data {\n if (data == null) return data\n if (!isLegacyDescriptor(definition)) {\n const mergeTranslationsVisitor = new ReactMergeTranslationsVisitor(context)\n return definition.accept(mergeTranslationsVisitor, data, translatedData)\n }\n\n switch (definition.type) {\n case PropControllerTypes.TextInput:\n case PropControllerTypes.TextArea:\n if (translatedData == null) return data\n return translatedData\n\n case PropControllerTypes.Grid:\n return mergeGridPropControllerTranslatedData(data as GridPropControllerData, context)\n\n default:\n return data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAMO;AAEP,8BAIO;AAEP,yBAA+C;AAC/C,kBAA2C;AAC3C,IAAAA,2BAAwE;AACxE,wCAA8C;AAEvC,SAAS,KAAK,YAAwB,OAAY,SAAsB;AAC7E,MAAI,KAAC,uCAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,SAAS,OAAO,OAAO;AAAA,EAC3C;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,wBAAAC,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AACvB,iBAAO,YAAAC,MAAmB,YAAY,OAAO,OAAO;AAAA,IAEtD,KAAK,uDAA8B;AACjC,iBAAO,kCAAiB,OAAO,OAAO;AAAA,IAExC;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,MACd,YACA,GACA,IAAU,GACV,SACM;AACN,MAAI,KAAC,uCAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,UAAU,GAAG,GAAG,OAAO;AAAA,EAC3C;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,oBAAoB,YAAwB,MAAkB;AAC5E,MAAI,KAAC,uCAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,oBAAoB,IAAI;AAAA,EAC5C;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,wBAAAD,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AACvB,aAAO;AAAA,IAET;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,oBACd,YACA,MACA,gBACA,SACM;AACN,MAAI,QAAQ;AAAM,WAAO;AACzB,MAAI,KAAC,uCAAmB,UAAU,GAAG;AACnC,UAAM,2BAA2B,IAAI,gEAA8B,OAAO;AAC1E,WAAO,WAAW,OAAO,0BAA0B,MAAM,cAAc;AAAA,EACzE;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,wBAAAA,MAAoB;AAAA,IACzB,KAAK,wBAAAA,MAAoB;AACvB,UAAI,kBAAkB;AAAM,eAAO;AACnC,aAAO;AAAA,IAET,KAAK,wBAAAA,MAAoB;AACvB,iBAAO,+DAAsC,MAAgC,OAAO;AAAA,IAEtF;AACE,aAAO;AAAA,EACX;AACF;","names":["import_prop_controllers","PropControllerTypes","propControllerCopy"]}
@@ -46,7 +46,7 @@ var import_utils = require("../../slate/utils");
46
46
  var import_rich_text_v2 = require("../../runtimes/react/controls/rich-text-v2");
47
47
  var import_plugin = require("./plugin");
48
48
  var import_control = require("./control");
49
- var import_translation = require("./translation");
49
+ var import_get_translations = require("./translations/get-translations");
50
50
  class Definition extends import_controls.RichTextDefinition {
51
51
  constructor({ mode, defaultValue }, plugins) {
52
52
  super({
@@ -113,20 +113,7 @@ class Definition extends import_controls.RichTextDefinition {
113
113
  getTranslatableData(data) {
114
114
  if (data == null)
115
115
  return null;
116
- return (0, import_translation.getTranslatableData)(Definition.dataToNodes(data), this.config.plugins);
117
- }
118
- mergeTranslatedData(data, translatedData, _context) {
119
- if (data == null || translatedData == null)
120
- return data;
121
- const { descendants, ...rest } = Definition.normalizeData(data);
122
- return {
123
- ...rest,
124
- descendants: (0, import_translation.mergeTranslatedNodes)(
125
- descendants,
126
- translatedData,
127
- this.config.plugins
128
- )
129
- };
116
+ return (0, import_get_translations.getTranslatableData)(Definition.dataToNodes(data), this.config.plugins);
130
117
  }
131
118
  serialize() {
132
119
  const { plugins, ...config } = this.config;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/controls/rich-text-v2/rich-text-v2.ts"],"sourcesContent":["import { ReactNode } from 'react'\nimport { z } from 'zod'\n// @ts-expect-error: there are no types for 'corporate-ipsum'\nimport ipsum from 'corporate-ipsum'\n\nimport {\n RichTextDefinition as BaseRichTextDefinition,\n isNotNil,\n ControlDefinition,\n SerializationSchema,\n serialize,\n StableValue,\n type Data,\n type Resolvable,\n type SendMessage,\n type SerializedRecord,\n type DeserializedRecord,\n type SchemaType,\n type SchemaTypeAny,\n type MergeTranslatableDataContext,\n type RichTextPluginControl,\n type ResourceResolver,\n type Stylesheet,\n type RichTextMode,\n} from '@makeswift/controls'\n\nimport { LinkPlugin } from '../../slate/LinkPlugin'\nimport { InlinePlugin } from '../../slate/InlinePlugin'\nimport { TextAlignPlugin } from '../../slate/TextAlignPlugin'\nimport { BlockPlugin } from '../../slate/BlockPlugin'\nimport { TypographyPlugin } from '../../slate/TypographyPlugin'\nimport { InlineModePlugin } from '../../slate/InlineModePlugin'\nimport { toText } from '../../slate/utils'\n\nimport { renderRichTextV2 } from '../../runtimes/react/controls/rich-text-v2'\n\nimport { RichTextV2Plugin, Plugin } from './plugin'\nimport { RichTextV2Control } from './control'\nimport {\n getTranslatableData,\n mergeTranslatedNodes,\n type RichTextTranslationDto,\n} from './translation'\n\ntype DataType = z.infer<typeof Definition.schema.data>\ntype DataV2Type = z.infer<typeof Definition.schema.dataV2>\ntype InstanceType = RichTextV2Control\ntype UserConfig = z.infer<typeof Definition.schema.userConfig>\ntype Config = UserConfig & {\n defaultValue: string\n plugins: RichTextV2Plugin[]\n}\n\nclass Definition extends BaseRichTextDefinition<ReactNode, Config, InstanceType> {\n constructor({ mode, defaultValue }: UserConfig, plugins?: RichTextV2Plugin[]) {\n super({\n mode,\n defaultValue:\n defaultValue ??\n (mode === Definition.Mode.Inline ? 'Edit this text' : Definition.generateParagraph()),\n plugins:\n plugins ??\n (mode === Definition.Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\n })\n }\n\n static generateParagraph(): string {\n return ipsum(3)\n }\n\n static deserialize(\n data: DeserializedRecord,\n deserializeCallback: (r: DeserializedRecord) => ControlDefinition,\n ): RichTextV2Definition {\n if (data.type !== Definition.type) {\n throw new Error(`RichText: expected type ${Definition.type}, got ${data.type}`)\n }\n\n const { config } = Definition.fullSchema({\n pluginDef: SerializationSchema.deserializedRecord,\n }).definition.parse(data)\n\n const { plugins, ...userConfig } = config\n\n return new RichTextV2Definition(\n userConfig,\n plugins.map(({ control }) =>\n control ? { control: { definition: deserializeCallback(control?.definition) } } : {},\n ),\n )\n }\n\n static fullSchema<S extends SchemaTypeAny>({ pluginDef }: { pluginDef: S }) {\n const baseSchema = super.schema\n const plugin = z.object({\n control: z\n .object({\n definition: pluginDef,\n })\n .optional(),\n })\n\n const config = baseSchema.userConfig.extend({\n defaultValue: z.string(),\n plugins: z.array(plugin),\n })\n\n return {\n ...baseSchema,\n config,\n definition: z.object({\n type: baseSchema.type,\n config,\n }),\n }\n }\n\n get configSchema(): SchemaType<Config> {\n return Definition.fullSchema({ pluginDef: z.any() as SchemaType<ControlDefinition> }).config\n }\n\n createInstance(sendMessage: SendMessage): InstanceType {\n return new RichTextV2Control(sendMessage, this)\n }\n\n resolveValue(\n data: DataType | undefined,\n _resolver: ResourceResolver,\n _stylesheet: Stylesheet,\n control?: InstanceType,\n ): Resolvable<ReactNode | undefined> {\n const stableValue = StableValue({\n name: Definition.type,\n read: () => renderRichTextV2(data, this, control ?? null),\n })\n\n return {\n ...stableValue,\n triggerResolve: async () => {},\n }\n }\n\n getTranslatableData(data: DataType | undefined): Data {\n if (data == null) return null\n return getTranslatableData(Definition.dataToNodes(data), this.config.plugins)\n }\n\n mergeTranslatedData(\n data: DataType | undefined,\n translatedData: Data,\n _context: MergeTranslatableDataContext,\n ): Data {\n if (data == null || translatedData == null) return data as Data\n\n const { descendants, ...rest } = Definition.normalizeData(data)\n return {\n ...rest,\n descendants: mergeTranslatedNodes(\n descendants,\n translatedData as RichTextTranslationDto,\n this.config.plugins,\n ),\n }\n }\n\n serialize(): [SerializedRecord, Transferable[]] {\n const { plugins, ...config } = this.config\n\n // serialize only the plugin control definition, if any\n const pluginDefs = plugins.map(({ control }) =>\n control\n ? {\n control: {\n definition: control.definition,\n // FIXME: remove getValue/onChange stubs once we released a version of the builder\n // built against the runtime where these can be optional\n getValue: () => undefined,\n onChange: () => {},\n },\n }\n : {},\n )\n\n return serialize(\n { ...config, plugins: pluginDefs },\n {\n type: Definition.type,\n },\n )\n }\n\n get pluginControls(): RichTextPluginControl[] {\n return this.config.plugins.map(plugin => plugin.control).filter(isNotNil)\n }\n\n pluginControlAt(index: number): RichTextPluginControl | undefined {\n return this.pluginControls[index]\n }\n\n toText(data: DataType | undefined): string {\n if (data == null) return ''\n return toText(Definition.dataToNodes(data), this.config.mode ?? Definition.Mode.Block)\n }\n}\n\nexport class RichTextV2Definition extends Definition {}\n\nexport function RichText(config?: UserConfig): RichTextV2Definition {\n return new RichTextV2Definition(config ?? {})\n}\n\nRichText.Mode = Definition.Mode\nRichText.isV1Data = Definition.isV1Data\nRichText.dataToNodes = Definition.dataToNodes\nRichText.Plugin = Plugin\n\nexport { RichTextMode as RichTextV2Mode, type DataV2Type as RichTextDataV2, RichTextV2Control }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAkB;AAElB,6BAAkB;AAElB,sBAmBO;AAEP,wBAA2B;AAC3B,0BAA6B;AAC7B,6BAAgC;AAChC,yBAA4B;AAC5B,8BAAiC;AACjC,8BAAiC;AACjC,mBAAuB;AAEvB,0BAAiC;AAEjC,oBAAyC;AACzC,qBAAkC;AAClC,yBAIO;AAWP,MAAM,mBAAmB,gBAAAA,mBAAwD;AAAA,EAC/E,YAAY,EAAE,MAAM,aAAa,GAAe,SAA8B;AAC5E,UAAM;AAAA,MACJ;AAAA,MACA,cACE,iBACC,SAAS,WAAW,KAAK,SAAS,mBAAmB,WAAW,kBAAkB;AAAA,MACrF,SACE,YACC,SAAS,WAAW,KAAK,SACtB,KAAC,0CAAiB,CAAC,IACnB,KAAC,gCAAY,OAAG,0CAAiB,OAAG,wCAAgB,OAAG,kCAAa,OAAG,8BAAW,CAAC;AAAA,IAC3F,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,oBAA4B;AACjC,eAAO,uBAAAC,SAAM,CAAC;AAAA,EAChB;AAAA,EAEA,OAAO,YACL,MACA,qBACsB;AACtB,QAAI,KAAK,SAAS,WAAW,MAAM;AACjC,YAAM,IAAI,MAAM,2BAA2B,WAAW,IAAI,SAAS,KAAK,IAAI,EAAE;AAAA,IAChF;AAEA,UAAM,EAAE,OAAO,IAAI,WAAW,WAAW;AAAA,MACvC,WAAW,oCAAoB;AAAA,IACjC,CAAC,EAAE,WAAW,MA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,cAAc,WAAW;AAClC,SAAS,SAAS;","names":["BaseRichTextDefinition","ipsum"]}
1
+ {"version":3,"sources":["../../../../src/controls/rich-text-v2/rich-text-v2.ts"],"sourcesContent":["import { ReactNode } from 'react'\nimport { z } from 'zod'\n// @ts-expect-error: there are no types for 'corporate-ipsum'\nimport ipsum from 'corporate-ipsum'\n\nimport {\n RichTextDefinition as BaseRichTextDefinition,\n isNotNil,\n ControlDefinition,\n SerializationSchema,\n serialize,\n StableValue,\n type Data,\n type Resolvable,\n type SendMessage,\n type SerializedRecord,\n type DeserializedRecord,\n type SchemaType,\n type SchemaTypeAny,\n type RichTextPluginControl,\n type ResourceResolver,\n type Stylesheet,\n type RichTextMode,\n} from '@makeswift/controls'\n\nimport { LinkPlugin } from '../../slate/LinkPlugin'\nimport { InlinePlugin } from '../../slate/InlinePlugin'\nimport { TextAlignPlugin } from '../../slate/TextAlignPlugin'\nimport { BlockPlugin } from '../../slate/BlockPlugin'\nimport { TypographyPlugin } from '../../slate/TypographyPlugin'\nimport { InlineModePlugin } from '../../slate/InlineModePlugin'\nimport { toText } from '../../slate/utils'\n\nimport { renderRichTextV2 } from '../../runtimes/react/controls/rich-text-v2'\n\nimport { RichTextV2Plugin, Plugin } from './plugin'\nimport { RichTextV2Control } from './control'\nimport { getTranslatableData } from './translations/get-translations'\n\ntype DataType = z.infer<typeof Definition.schema.data>\ntype DataV2Type = z.infer<typeof Definition.schema.dataV2>\ntype InstanceType = RichTextV2Control\ntype UserConfig = z.infer<typeof Definition.schema.userConfig>\ntype Config = UserConfig & {\n defaultValue: string\n plugins: RichTextV2Plugin[]\n}\n\nclass Definition extends BaseRichTextDefinition<ReactNode, Config, InstanceType> {\n constructor({ mode, defaultValue }: UserConfig, plugins?: RichTextV2Plugin[]) {\n super({\n mode,\n defaultValue:\n defaultValue ??\n (mode === Definition.Mode.Inline ? 'Edit this text' : Definition.generateParagraph()),\n plugins:\n plugins ??\n (mode === Definition.Mode.Inline\n ? [InlineModePlugin()]\n : [BlockPlugin(), TypographyPlugin(), TextAlignPlugin(), InlinePlugin(), LinkPlugin()]),\n })\n }\n\n static generateParagraph(): string {\n return ipsum(3)\n }\n\n static deserialize(\n data: DeserializedRecord,\n deserializeCallback: (r: DeserializedRecord) => ControlDefinition,\n ): RichTextV2Definition {\n if (data.type !== Definition.type) {\n throw new Error(`RichText: expected type ${Definition.type}, got ${data.type}`)\n }\n\n const { config } = Definition.fullSchema({\n pluginDef: SerializationSchema.deserializedRecord,\n }).definition.parse(data)\n\n const { plugins, ...userConfig } = config\n\n return new RichTextV2Definition(\n userConfig,\n plugins.map(({ control }) =>\n control ? { control: { definition: deserializeCallback(control?.definition) } } : {},\n ),\n )\n }\n\n static fullSchema<S extends SchemaTypeAny>({ pluginDef }: { pluginDef: S }) {\n const baseSchema = super.schema\n const plugin = z.object({\n control: z\n .object({\n definition: pluginDef,\n })\n .optional(),\n })\n\n const config = baseSchema.userConfig.extend({\n defaultValue: z.string(),\n plugins: z.array(plugin),\n })\n\n return {\n ...baseSchema,\n config,\n definition: z.object({\n type: baseSchema.type,\n config,\n }),\n }\n }\n\n get configSchema(): SchemaType<Config> {\n return Definition.fullSchema({ pluginDef: z.any() as SchemaType<ControlDefinition> }).config\n }\n\n createInstance(sendMessage: SendMessage): InstanceType {\n return new RichTextV2Control(sendMessage, this)\n }\n\n resolveValue(\n data: DataType | undefined,\n _resolver: ResourceResolver,\n _stylesheet: Stylesheet,\n control?: InstanceType,\n ): Resolvable<ReactNode | undefined> {\n const stableValue = StableValue({\n name: Definition.type,\n read: () => renderRichTextV2(data, this, control ?? null),\n })\n\n return {\n ...stableValue,\n triggerResolve: async () => {},\n }\n }\n\n getTranslatableData(data: DataType | undefined): Data {\n if (data == null) return null\n return getTranslatableData(Definition.dataToNodes(data), this.config.plugins)\n }\n\n serialize(): [SerializedRecord, Transferable[]] {\n const { plugins, ...config } = this.config\n\n // serialize only the plugin control definition, if any\n const pluginDefs = plugins.map(({ control }) =>\n control\n ? {\n control: {\n definition: control.definition,\n // FIXME: remove getValue/onChange stubs once we released a version of the builder\n // built against the runtime where these can be optional\n getValue: () => undefined,\n onChange: () => {},\n },\n }\n : {},\n )\n\n return serialize(\n { ...config, plugins: pluginDefs },\n {\n type: Definition.type,\n },\n )\n }\n\n get pluginControls(): RichTextPluginControl[] {\n return this.config.plugins.map(plugin => plugin.control).filter(isNotNil)\n }\n\n pluginControlAt(index: number): RichTextPluginControl | undefined {\n return this.pluginControls[index]\n }\n\n toText(data: DataType | undefined): string {\n if (data == null) return ''\n return toText(Definition.dataToNodes(data), this.config.mode ?? Definition.Mode.Block)\n }\n}\n\nexport class RichTextV2Definition extends Definition {}\n\nexport function RichText(config?: UserConfig): RichTextV2Definition {\n return new RichTextV2Definition(config ?? {})\n}\n\nRichText.Mode = Definition.Mode\nRichText.isV1Data = Definition.isV1Data\nRichText.dataToNodes = Definition.dataToNodes\nRichText.Plugin = Plugin\n\nexport { RichTextMode as RichTextV2Mode, type DataV2Type as RichTextDataV2, RichTextV2Control }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAkB;AAElB,6BAAkB;AAElB,sBAkBO;AAEP,wBAA2B;AAC3B,0BAA6B;AAC7B,6BAAgC;AAChC,yBAA4B;AAC5B,8BAAiC;AACjC,8BAAiC;AACjC,mBAAuB;AAEvB,0BAAiC;AAEjC,oBAAyC;AACzC,qBAAkC;AAClC,8BAAoC;AAWpC,MAAM,mBAAmB,gBAAAA,mBAAwD;AAAA,EAC/E,YAAY,EAAE,MAAM,aAAa,GAAe,SAA8B;AAC5E,UAAM;AAAA,MACJ;AAAA,MACA,cACE,iBACC,SAAS,WAAW,KAAK,SAAS,mBAAmB,WAAW,kBAAkB;AAAA,MACrF,SACE,YACC,SAAS,WAAW,KAAK,SACtB,KAAC,0CAAiB,CAAC,IACnB,KAAC,gCAAY,OAAG,0CAAiB,OAAG,wCAAgB,OAAG,kCAAa,O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AAO,IAAI,qBAAqB,UAAU,CAAC,CAAC;AAC9C;AAEA,SAAS,OAAO,WAAW;AAC3B,SAAS,WAAW,WAAW;AAC/B,SAAS,cAAc,WAAW;AAClC,SAAS,SAAS;","names":["BaseRichTextDefinition","ipsum"]}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var get_translations_exports = {};
30
+ __export(get_translations_exports, {
31
+ getTranslatableData: () => getTranslatableData
32
+ });
33
+ module.exports = __toCommonJS(get_translations_exports);
34
+ var import_escape_html = __toESM(require("escape-html"));
35
+ var import_slate = require("slate");
36
+ var import_controls = require("@makeswift/controls");
37
+ var import_types = require("../../../slate/types");
38
+ var import_translations_core = require("./translations-core");
39
+ function getDescendantTranslatableData(descendant, path) {
40
+ if (import_slate.Text.isText(descendant)) {
41
+ return {};
42
+ }
43
+ if (import_controls.Slate.isList(descendant) || import_controls.Slate.isListItem(descendant)) {
44
+ return descendant.children.reduce(
45
+ (acc, d, j) => ({ ...acc, ...getDescendantTranslatableData(d, [...path, j]) }),
46
+ {}
47
+ );
48
+ }
49
+ const text = getInlineOrTextTranslatableData(descendant);
50
+ if (text == null)
51
+ return {};
52
+ return { [(0, import_translations_core.pathToString)(path)]: text };
53
+ }
54
+ function getInlineOrTextTranslatableData(descendant, path = []) {
55
+ if (import_slate.Text.isText(descendant)) {
56
+ let string = (0, import_escape_html.default)(descendant.text);
57
+ if (string === "")
58
+ return null;
59
+ if (descendant.typography === void 0)
60
+ return string;
61
+ return `<span key="${(0, import_translations_core.pathToString)(path)}">${string}</span>`;
62
+ }
63
+ const children = descendant.children.map((child, i) => getInlineOrTextTranslatableData(child, [...path, i])).join("");
64
+ if (children === "")
65
+ return null;
66
+ switch (descendant.type) {
67
+ case import_types.InlineType.Link:
68
+ return `<a key="${(0, import_translations_core.pathToString)(path)}">${children}</a>`;
69
+ case import_types.InlineType.SuperScript:
70
+ return `<sup key="${(0, import_translations_core.pathToString)(path)}">${children}</sup>`;
71
+ case import_types.InlineType.SubScript:
72
+ return `<sub key="${(0, import_translations_core.pathToString)(path)}">${children}</sub>`;
73
+ case import_types.InlineType.Code:
74
+ return `<code key="${(0, import_translations_core.pathToString)(path)}">${children}</code>`;
75
+ default:
76
+ return children;
77
+ }
78
+ }
79
+ function getTranslatableData(nodes, plugins) {
80
+ const editor = (0, import_translations_core.createEditorWithPlugins)(plugins);
81
+ editor.children = nodes;
82
+ editor.typographyNormalizationDirection = "up";
83
+ import_slate.Editor.normalize(editor, { force: true });
84
+ return editor.children.reduce(
85
+ (acc, descendant, i) => ({
86
+ ...acc,
87
+ ...getDescendantTranslatableData(descendant, [i])
88
+ }),
89
+ {}
90
+ );
91
+ }
92
+ // Annotate the CommonJS export names for ESM import in node:
93
+ 0 && (module.exports = {
94
+ getTranslatableData
95
+ });
96
+ //# sourceMappingURL=get-translations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/controls/rich-text-v2/translations/get-translations.ts"],"sourcesContent":["import escapeHtml from 'escape-html'\nimport { Descendant, Editor, Text } from 'slate'\n\nimport { type TranslationDto, Slate } from '@makeswift/controls'\n\nimport { RichTextV2Plugin } from '../plugin'\nimport { InlineType } from '../../../slate/types'\nimport { createEditorWithPlugins, pathToString, RichTextTranslationDto } from './translations-core'\n\nfunction getDescendantTranslatableData(descendant: Descendant, path: number[]): TranslationDto {\n if (Text.isText(descendant)) {\n return {}\n }\n\n if (Slate.isList(descendant) || Slate.isListItem(descendant)) {\n return descendant.children.reduce(\n (acc, d, j) => ({ ...acc, ...getDescendantTranslatableData(d, [...path, j]) }),\n {},\n )\n }\n\n const text = getInlineOrTextTranslatableData(descendant)\n if (text == null) return {}\n\n return { [pathToString(path)]: text }\n}\n\nfunction getInlineOrTextTranslatableData(\n descendant: Descendant,\n path: number[] = [],\n): string | null {\n if (Text.isText(descendant)) {\n let string = escapeHtml(descendant.text)\n\n if (string === '') return null\n\n if (descendant.typography === undefined) return string\n\n return `<span key=\"${pathToString(path)}\">${string}</span>`\n }\n\n const children = descendant.children\n .map((child: Descendant, i: number) => getInlineOrTextTranslatableData(child, [...path, i]))\n .join('')\n\n if (children === '') return null\n\n switch (descendant.type) {\n case InlineType.Link:\n return `<a key=\"${pathToString(path)}\">${children}</a>`\n\n case InlineType.SuperScript:\n return `<sup key=\"${pathToString(path)}\">${children}</sup>`\n\n case InlineType.SubScript:\n return `<sub key=\"${pathToString(path)}\">${children}</sub>`\n\n case InlineType.Code:\n return `<code key=\"${pathToString(path)}\">${children}</code>`\n\n default:\n return children\n }\n}\n\nexport function getTranslatableData(\n nodes: Slate.Descendant[],\n plugins: RichTextV2Plugin[],\n): RichTextTranslationDto {\n const editor = createEditorWithPlugins(plugins)\n\n editor.children = nodes\n editor.typographyNormalizationDirection = 'up'\n Editor.normalize(editor, { force: true })\n\n return editor.children.reduce(\n (acc, descendant: Descendant, i) => ({\n ...acc,\n ...getDescendantTranslatableData(descendant, [i]),\n }),\n {},\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAuB;AACvB,mBAAyC;AAEzC,sBAA2C;AAG3C,mBAA2B;AAC3B,+BAA8E;AAE9E,SAAS,8BAA8B,YAAwB,MAAgC;AAC7F,MAAI,kBAAK,OAAO,UAAU,GAAG;AAC3B,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,sBAAM,OAAO,UAAU,KAAK,sBAAM,WAAW,UAAU,GAAG;AAC5D,WAAO,WAAW,SAAS;AAAA,MACzB,CAAC,KAAK,GAAG,OAAO,EAAE,GAAG,KAAK,GAAG,8BAA8B,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE;AAAA,MAC5E,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,OAAO,gCAAgC,UAAU;AACvD,MAAI,QAAQ;AAAM,WAAO,CAAC;AAE1B,SAAO,EAAE,KAAC,uCAAa,IAAI,CAAC,GAAG,KAAK;AACtC;AAEA,SAAS,gCACP,YACA,OAAiB,CAAC,GACH;AACf,MAAI,kBAAK,OAAO,UAAU,GAAG;AAC3B,QAAI,aAAS,mBAAAA,SAAW,WAAW,IAAI;AAEvC,QAAI,WAAW;AAAI,aAAO;AAE1B,QAAI,WAAW,eAAe;AAAW,aAAO;AAEhD,WAAO,kBAAc,uCAAa,IAAI,CAAC,KAAK,MAAM;AAAA,EACpD;AAEA,QAAM,WAAW,WAAW,SACzB,IAAI,CAAC,OAAmB,MAAc,gCAAgC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAC1F,KAAK,EAAE;AAEV,MAAI,aAAa;AAAI,WAAO;AAE5B,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,wBAAW;AACd,aAAO,eAAW,uCAAa,IAAI,CAAC,KAAK,QAAQ;AAAA,IAEnD,KAAK,wBAAW;AACd,aAAO,iBAAa,uCAAa,IAAI,CAAC,KAAK,QAAQ;AAAA,IAErD,KAAK,wBAAW;AACd,aAAO,iBAAa,uCAAa,IAAI,CAAC,KAAK,QAAQ;AAAA,IAErD,KAAK,wBAAW;AACd,aAAO,kBAAc,uCAAa,IAAI,CAAC,KAAK,QAAQ;AAAA,IAEtD;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,oBACd,OACA,SACwB;AACxB,QAAM,aAAS,kDAAwB,OAAO;AAE9C,SAAO,WAAW;AAClB,SAAO,mCAAmC;AAC1C,sBAAO,UAAU,QAAQ,EAAE,OAAO,KAAK,CAAC;AAExC,SAAO,OAAO,SAAS;AAAA,IACrB,CAAC,KAAK,YAAwB,OAAO;AAAA,MACnC,GAAG;AAAA,MACH,GAAG,8BAA8B,YAAY,CAAC,CAAC,CAAC;AAAA,IAClD;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":["escapeHtml"]}
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,92 +15,18 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var translation_exports = {};
30
- __export(translation_exports, {
31
- getTranslatableData: () => getTranslatableData,
19
+ var merge_translations_exports = {};
20
+ __export(merge_translations_exports, {
32
21
  mergeTranslatedNodes: () => mergeTranslatedNodes
33
22
  });
34
- module.exports = __toCommonJS(translation_exports);
35
- var import_escape_html = __toESM(require("escape-html"));
23
+ module.exports = __toCommonJS(merge_translations_exports);
36
24
  var import_slate = require("slate");
37
25
  var import_slate_hyperscript = require("slate-hyperscript");
38
26
  var import_parse5 = require("parse5");
39
27
  var import_controls = require("@makeswift/controls");
40
- var import_types = require("../../slate/types");
41
- function createEditorWithPlugins(plugins) {
42
- return plugins.reduceRight(
43
- (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,
44
- (0, import_slate.createEditor)()
45
- );
46
- }
47
- function pathToString(path) {
48
- return path.join(":");
49
- }
50
- function stringToPath(s) {
51
- return s.split(":").map((a) => parseInt(a));
52
- }
53
- function getDescendantTranslatableData(descendant, path) {
54
- if (import_slate.Text.isText(descendant)) {
55
- return {};
56
- }
57
- if (import_controls.Slate.isList(descendant) || import_controls.Slate.isListItem(descendant)) {
58
- return descendant.children.reduce(
59
- (acc, d, j) => ({ ...acc, ...getDescendantTranslatableData(d, [...path, j]) }),
60
- {}
61
- );
62
- }
63
- const text = getInlineOrTextTranslatableData(descendant);
64
- if (text == null)
65
- return {};
66
- return { [pathToString(path)]: text };
67
- }
68
- function getInlineOrTextTranslatableData(descendant, path = []) {
69
- if (import_slate.Text.isText(descendant)) {
70
- let string = (0, import_escape_html.default)(descendant.text);
71
- if (string === "")
72
- return null;
73
- if (descendant.typography === void 0)
74
- return string;
75
- return `<span key="${pathToString(path)}">${string}</span>`;
76
- }
77
- const children = descendant.children.map((child, i) => getInlineOrTextTranslatableData(child, [...path, i])).join("");
78
- if (children === "")
79
- return null;
80
- switch (descendant.type) {
81
- case import_types.InlineType.Link:
82
- return `<a key="${pathToString(path)}">${children}</a>`;
83
- case import_types.InlineType.SuperScript:
84
- return `<sup key="${pathToString(path)}">${children}</sup>`;
85
- case import_types.InlineType.SubScript:
86
- return `<sub key="${pathToString(path)}">${children}</sub>`;
87
- case import_types.InlineType.Code:
88
- return `<code key="${pathToString(path)}">${children}</code>`;
89
- default:
90
- return children;
91
- }
92
- }
93
- function getTranslatableData(nodes, plugins) {
94
- const editor = createEditorWithPlugins(plugins);
95
- editor.children = nodes;
96
- editor.typographyNormalizationDirection = "up";
97
- import_slate.Editor.normalize(editor, { force: true });
98
- return editor.children.reduce(
99
- (acc, descendant, i) => ({
100
- ...acc,
101
- ...getDescendantTranslatableData(descendant, [i])
102
- }),
103
- {}
104
- );
105
- }
28
+ var import_types = require("../../../slate/types");
29
+ var import_translations_core = require("./translations-core");
106
30
  function deserializeTranslationHtmlString(el, translationKey) {
107
31
  if (el.nodeName === "#document-fragment") {
108
32
  const children = Array.from(el.childNodes).map((element) => deserializeTranslationHtmlString(element)).flat();
@@ -136,13 +60,13 @@ function deserializeTranslationHtmlString(el, translationKey) {
136
60
  return [];
137
61
  }
138
62
  function mergeTranslatedNodes(nodes, translatedData, plugins) {
139
- const sourceEditor = createEditorWithPlugins(plugins);
140
- const targetEditor = createEditorWithPlugins(plugins);
63
+ const sourceEditor = (0, import_translations_core.createEditorWithPlugins)(plugins);
64
+ const targetEditor = (0, import_translations_core.createEditorWithPlugins)(plugins);
141
65
  sourceEditor.children = nodes;
142
66
  sourceEditor.typographyNormalizationDirection = "up";
143
67
  import_slate.Editor.normalize(sourceEditor, { force: true });
144
68
  Object.entries(translatedData).reverse().forEach(([blockStringPath, htmlString]) => {
145
- const blockPath = stringToPath(blockStringPath);
69
+ const blockPath = (0, import_translations_core.stringToPath)(blockStringPath);
146
70
  if (blockPath.length === 0)
147
71
  return;
148
72
  const html = (0, import_parse5.parseFragment)(htmlString);
@@ -154,7 +78,7 @@ function mergeTranslatedNodes(nodes, translatedData, plugins) {
154
78
  if (!import_slate.Text.isText(descendant) && !import_controls.Slate.isInline(descendant) || descendant.translationKey == null || descendant.translationKey === "") {
155
79
  continue;
156
80
  }
157
- const relativePathToSourceNode = stringToPath(descendant.translationKey);
81
+ const relativePathToSourceNode = (0, import_translations_core.stringToPath)(descendant.translationKey);
158
82
  const absolutePathToSourceNode = [...blockPath, ...relativePathToSourceNode];
159
83
  const [sourceNode] = import_slate.Editor.node(sourceEditor, absolutePathToSourceNode);
160
84
  if (import_slate.Text.isText(sourceNode) && import_slate.Text.isText(descendant)) {
@@ -181,7 +105,6 @@ function mergeTranslatedNodes(nodes, translatedData, plugins) {
181
105
  }
182
106
  // Annotate the CommonJS export names for ESM import in node:
183
107
  0 && (module.exports = {
184
- getTranslatableData,
185
108
  mergeTranslatedNodes
186
109
  });
187
- //# sourceMappingURL=translation.js.map
110
+ //# sourceMappingURL=merge-translations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/controls/rich-text-v2/translations/merge-translations.ts"],"sourcesContent":["import { Descendant, Editor, Element, Node, Text, Transforms } from 'slate'\nimport { jsx } from 'slate-hyperscript'\nimport { parseFragment, DefaultTreeAdapterTypes } from 'parse5'\n\nimport { Slate } from '@makeswift/controls'\n\nimport { RichTextV2Plugin } from '../plugin'\nimport { BlockType, InlineType } from '../../../slate/types'\nimport { createEditorWithPlugins, RichTextTranslationDto, stringToPath } from './translations-core'\n\nfunction deserializeTranslationHtmlString(\n el: DefaultTreeAdapterTypes.ChildNode | DefaultTreeAdapterTypes.DocumentFragment,\n translationKey?: string,\n): Descendant[] {\n if (el.nodeName === '#document-fragment') {\n const children = Array.from(el.childNodes)\n .map(element => deserializeTranslationHtmlString(element))\n .flat()\n\n if (children.length === 0) {\n children.push(jsx('text', {}, ''))\n }\n\n return children\n }\n\n if (el.nodeName === '#text' && 'value' in el) {\n return [jsx('text', { translationKey: translationKey ?? undefined }, el.value)]\n }\n\n if ('namespaceURI' in el) {\n const translationKey = el.attrs.find(a => a.name === 'key')?.value ?? undefined\n const children = Array.from(el.childNodes)\n .map(element => deserializeTranslationHtmlString(element, translationKey))\n .flat()\n\n if (children.length === 0) {\n children.push(jsx('text', {}, ''))\n }\n\n switch (el.nodeName) {\n case 'code':\n return [jsx('element', { type: InlineType.Code, translationKey }, children)]\n\n case 'sub':\n return [jsx('element', { type: InlineType.SubScript, translationKey }, children)]\n\n case 'sup':\n return [jsx('element', { type: InlineType.SuperScript, translationKey }, children)]\n\n case 'a':\n return [jsx('element', { type: InlineType.Link, translationKey }, children)]\n\n default:\n return children\n }\n }\n\n return []\n}\n\nexport function mergeTranslatedNodes(\n nodes: Slate.Descendant[],\n translatedData: RichTextTranslationDto,\n plugins: RichTextV2Plugin[],\n): Slate.Descendant[] {\n const sourceEditor = createEditorWithPlugins(plugins)\n const targetEditor = createEditorWithPlugins(plugins)\n\n sourceEditor.children = nodes\n sourceEditor.typographyNormalizationDirection = 'up'\n Editor.normalize(sourceEditor, { force: true })\n\n Object.entries(translatedData)\n .reverse()\n .forEach(([blockStringPath, htmlString]) => {\n const blockPath = stringToPath(blockStringPath)\n if (blockPath.length === 0) return\n\n const html = parseFragment(htmlString)\n const inlineDescendants = deserializeTranslationHtmlString(html)\n\n targetEditor.children = [{ type: BlockType.Default, children: inlineDescendants }]\n\n targetEditor.typographyNormalizationDirection = 'neutral'\n Editor.normalize(targetEditor, { force: true })\n\n for (const [descendant, absolutePathToTargetNode] of Node.descendants(targetEditor)) {\n if (\n (!Text.isText(descendant) && !Slate.isInline(descendant)) ||\n descendant.translationKey == null ||\n descendant.translationKey === ''\n ) {\n continue\n }\n\n const relativePathToSourceNode = stringToPath(descendant.translationKey)\n\n const absolutePathToSourceNode = [...blockPath, ...relativePathToSourceNode]\n\n const [sourceNode] = Editor.node(sourceEditor, absolutePathToSourceNode)\n\n if (Text.isText(sourceNode) && Text.isText(descendant)) {\n const { translationKey, text, ...rest } = sourceNode\n Transforms.setNodes(targetEditor, rest, { at: absolutePathToTargetNode })\n Transforms.unsetNodes(targetEditor, 'translationKey', { at: absolutePathToTargetNode })\n } else if (Slate.isInline(sourceNode) && Slate.isInline(descendant)) {\n const { translationKey, children, ...rest } = sourceNode\n Transforms.setNodes(targetEditor, rest, { at: absolutePathToTargetNode })\n Transforms.unsetNodes(targetEditor, 'translationKey', { at: absolutePathToTargetNode })\n }\n }\n const translatedChildren = (targetEditor.children.at(0) as Element)?.children\n\n Editor.withoutNormalizing(sourceEditor, () => {\n Array.from(Node.children(sourceEditor, blockPath))\n .reverse()\n .forEach(([_, path]) => {\n Transforms.removeNodes(sourceEditor, { at: path })\n })\n\n Transforms.insertNodes(sourceEditor, translatedChildren, { at: [...blockPath, 0] })\n })\n })\n\n sourceEditor.typographyNormalizationDirection = 'down'\n Editor.normalize(sourceEditor, { force: true })\n\n return sourceEditor.children\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoE;AACpE,+BAAoB;AACpB,oBAAuD;AAEvD,sBAAsB;AAGtB,mBAAsC;AACtC,+BAA8E;AAE9E,SAAS,iCACP,IACA,gBACc;AACd,MAAI,GAAG,aAAa,sBAAsB;AACxC,UAAM,WAAW,MAAM,KAAK,GAAG,UAAU,EACtC,IAAI,aAAW,iCAAiC,OAAO,CAAC,EACxD,KAAK;AAER,QAAI,SAAS,WAAW,GAAG;AACzB,eAAS,SAAK,8BAAI,QAAQ,CAAC,GAAG,EAAE,CAAC;AAAA,IACnC;AAEA,WAAO;AAAA,EACT;AAEA,MAAI,GAAG,aAAa,WAAW,WAAW,IAAI;AAC5C,WAAO,KAAC,8BAAI,QAAQ,EAAE,gBAAgB,kBAAkB,OAAU,GAAG,GAAG,KAAK,CAAC;AAAA,EAChF;AAEA,MAAI,kBAAkB,IAAI;AACxB,UAAMA,kBAAiB,GAAG,MAAM,KAAK,OAAK,EAAE,SAAS,KAAK,GAAG,SAAS;AACtE,UAAM,WA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C;AAAA,EACH,CAAC;AAEH,eAAa,mCAAmC;AAChD,sBAAO,UAAU,cAAc,EAAE,OAAO,KAAK,CAAC;AAE9C,SAAO,aAAa;AACtB;","names":["translationKey"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var translations_core_exports = {};
20
+ __export(translations_core_exports, {
21
+ createEditorWithPlugins: () => createEditorWithPlugins,
22
+ pathToString: () => pathToString,
23
+ stringToPath: () => stringToPath
24
+ });
25
+ module.exports = __toCommonJS(translations_core_exports);
26
+ var import_slate = require("slate");
27
+ function createEditorWithPlugins(plugins) {
28
+ return plugins.reduceRight(
29
+ (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,
30
+ (0, import_slate.createEditor)()
31
+ );
32
+ }
33
+ function pathToString(path) {
34
+ return path.join(":");
35
+ }
36
+ function stringToPath(s) {
37
+ return s.split(":").map((a) => parseInt(a));
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ createEditorWithPlugins,
42
+ pathToString,
43
+ stringToPath
44
+ });
45
+ //# sourceMappingURL=translations-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/controls/rich-text-v2/translations/translations-core.ts"],"sourcesContent":["import { createEditor } from 'slate'\nimport { MakeswiftEditor } from '../../../slate'\nimport { RichTextV2Plugin } from '../plugin'\n\nexport function createEditorWithPlugins(plugins: RichTextV2Plugin[]): MakeswiftEditor {\n return plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n createEditor(),\n )\n}\n\nexport function pathToString(path: number[]): string {\n return path.join(':')\n}\n\nexport function stringToPath(s: string): number[] {\n return s.split(':').map(a => parseInt(a))\n}\n\nexport type RichTextTranslationDto = Record<string, string>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6B;AAItB,SAAS,wBAAwB,SAA8C;AACpF,SAAO,QAAQ;AAAA,IACb,CAAC,QAAQ,WAAW,QAAQ,aAAa,MAAM,KAAK;AAAA,QACpD,2BAAa;AAAA,EACf;AACF;AAEO,SAAS,aAAa,MAAwB;AACnD,SAAO,KAAK,KAAK,GAAG;AACtB;AAEO,SAAS,aAAa,GAAqB;AAChD,SAAO,EAAE,MAAM,GAAG,EAAE,IAAI,OAAK,SAAS,CAAC,CAAC;AAC1C;","names":[]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var merge_translations_visitor_exports = {};
20
+ __export(merge_translations_visitor_exports, {
21
+ ReactMergeTranslationsVisitor: () => ReactMergeTranslationsVisitor
22
+ });
23
+ module.exports = __toCommonJS(merge_translations_visitor_exports);
24
+ var import_controls = require("@makeswift/controls");
25
+ var import_rich_text_v2 = require("../rich-text-v2");
26
+ var import_merge_translations = require("../rich-text-v2/translations/merge-translations");
27
+ class ReactMergeTranslationsVisitor extends import_controls.MergeTranslationsVisitor {
28
+ visitRichTextV2(def, data, translatedData) {
29
+ if (data == null || translatedData == null)
30
+ return data;
31
+ const { descendants, ...rest } = import_rich_text_v2.RichTextV2Definition.normalizeData(data);
32
+ return {
33
+ ...rest,
34
+ descendants: (0, import_merge_translations.mergeTranslatedNodes)(
35
+ descendants,
36
+ translatedData,
37
+ def.config.plugins
38
+ )
39
+ };
40
+ }
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ ReactMergeTranslationsVisitor
45
+ });
46
+ //# sourceMappingURL=merge-translations-visitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/controls/visitors/merge-translations-visitor.ts"],"sourcesContent":["import { Data, DataType, MergeTranslationsVisitor } from '@makeswift/controls'\n\nimport { RichTextV2Definition } from '../rich-text-v2'\nimport { RichTextTranslationDto } from '../rich-text-v2/translations/translations-core'\nimport { mergeTranslatedNodes } from '../rich-text-v2/translations/merge-translations'\n\nexport class ReactMergeTranslationsVisitor extends MergeTranslationsVisitor {\n visitRichTextV2(\n def: RichTextV2Definition,\n data: DataType<RichTextV2Definition> | undefined,\n translatedData: Data,\n ): Data {\n if (data == null || translatedData == null) return data\n\n const { descendants, ...rest } = RichTextV2Definition.normalizeData(data)\n\n return {\n ...rest,\n descendants: mergeTranslatedNodes(\n descendants,\n translatedData as RichTextTranslationDto,\n def.config.plugins,\n ),\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyD;AAEzD,0BAAqC;AAErC,gCAAqC;AAE9B,MAAM,sCAAsC,yCAAyB;AAAA,EAC1E,gBACE,KACA,MACA,gBACM;AACN,QAAI,QAAQ,QAAQ,kBAAkB;AAAM,aAAO;AAEnD,UAAM,EAAE,aAAa,GAAG,KAAK,IAAI,yCAAqB,cAAc,IAAI;AAExE,WAAO;AAAA,MACL,GAAG;AAAA,MACH,iBAAa;AAAA,QACX;AAAA,QACA;AAAA,QACA,IAAI,OAAO;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
8
8
  return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
9
9
  }
10
10
  return ApiResponse.json({
11
- version: "0.25.4-canary.2",
11
+ version: "0.25.4-canary.4",
12
12
  interactionMode: true,
13
13
  clientSideNavigation: false,
14
14
  elementFromPoint: false,
@@ -8,6 +8,7 @@ import {
8
8
  import { isLegacyDescriptor } from "../prop-controllers/descriptors";
9
9
  import { copy as propControllerCopy } from "../prop-controllers/copy";
10
10
  import { DELETED_PROP_CONTROLLER_TYPES } from "../prop-controllers";
11
+ import { ReactMergeTranslationsVisitor } from "./visitors/merge-translations-visitor";
11
12
  function copy(definition, value, context) {
12
13
  if (!isLegacyDescriptor(definition)) {
13
14
  return definition.copyData(value, context);
@@ -57,7 +58,8 @@ function mergeTranslatedData(definition, data, translatedData, context) {
57
58
  if (data == null)
58
59
  return data;
59
60
  if (!isLegacyDescriptor(definition)) {
60
- return definition.mergeTranslatedData(data, translatedData, context);
61
+ const mergeTranslationsVisitor = new ReactMergeTranslationsVisitor(context);
62
+ return definition.accept(mergeTranslationsVisitor, data, translatedData);
61
63
  }
62
64
  switch (definition.type) {
63
65
  case PropControllerTypes.TextInput:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/controls/control.ts"],"sourcesContent":["import {\n copyRichTextData,\n type CopyContext,\n type Data,\n type MergeContext,\n type MergeTranslatableDataContext,\n} from '@makeswift/controls'\n\nimport {\n GridPropControllerData,\n Types as PropControllerTypes,\n mergeGridPropControllerTranslatedData,\n} from '@makeswift/prop-controllers'\n\nimport { Descriptor, isLegacyDescriptor } from '../prop-controllers/descriptors'\nimport { copy as propControllerCopy } from '../prop-controllers/copy'\nimport { DELETED_PROP_CONTROLLER_TYPES, PropControllerDescriptor } from '../prop-controllers'\n\nexport function copy(definition: Descriptor, value: any, context: CopyContext) {\n if (!isLegacyDescriptor(definition)) {\n return definition.copyData(value, context)\n }\n\n switch (definition.type) {\n case PropControllerTypes.Backgrounds:\n case PropControllerTypes.Grid:\n case PropControllerTypes.NavigationLinks:\n case PropControllerTypes.Link:\n case PropControllerTypes.Shadows:\n case PropControllerTypes.Image:\n case PropControllerTypes.Images:\n case PropControllerTypes.ResponsiveColor:\n case PropControllerTypes.TableFormFields:\n case PropControllerTypes.Table:\n case PropControllerTypes.Border:\n case PropControllerTypes.ElementID:\n return propControllerCopy(definition, value, context)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return copyRichTextData(value, context)\n\n default:\n return value\n }\n}\n\nexport function merge(\n definition: PropControllerDescriptor,\n a: Data,\n b: Data = a,\n context: MergeContext,\n): Data {\n if (!isLegacyDescriptor(definition)) {\n return definition.mergeData(a, b, context)\n }\n\n switch (definition.type) {\n default:\n return b\n }\n}\n\nexport function getTranslatableData(definition: Descriptor, data: Data): Data {\n if (!isLegacyDescriptor(definition)) {\n return definition.getTranslatableData(data)\n }\n\n switch (definition.type) {\n case PropControllerTypes.TextInput:\n case PropControllerTypes.TextArea:\n return data\n\n default:\n return null\n }\n}\n\nexport function mergeTranslatedData(\n definition: PropControllerDescriptor,\n data: Data,\n translatedData: Data,\n context: MergeTranslatableDataContext,\n): Data {\n if (data == null) return data\n if (!isLegacyDescriptor(definition)) {\n return definition.mergeTranslatedData(data, translatedData, context)\n }\n\n switch (definition.type) {\n case PropControllerTypes.TextInput:\n case PropControllerTypes.TextArea:\n if (translatedData == null) return data\n return translatedData\n\n case PropControllerTypes.Grid:\n return mergeGridPropControllerTranslatedData(data as GridPropControllerData, context)\n\n default:\n return data\n }\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAKK;AAEP;AAAA,EAEE,SAAS;AAAA,EACT;AAAA,OACK;AAEP,SAAqB,0BAA0B;AAC/C,SAAS,QAAQ,0BAA0B;AAC3C,SAAS,qCAA+D;AAEjE,SAAS,KAAK,YAAwB,OAAY,SAAsB;AAC7E,MAAI,CAAC,mBAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,SAAS,OAAO,OAAO;AAAA,EAC3C;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AACvB,aAAO,mBAAmB,YAAY,OAAO,OAAO;AAAA,IAEtD,KAAK,8BAA8B;AACjC,aAAO,iBAAiB,OAAO,OAAO;AAAA,IAExC;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,MACd,YACA,GACA,IAAU,GACV,SACM;AACN,MAAI,CAAC,mBAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,UAAU,GAAG,GAAG,OAAO;AAAA,EAC3C;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,oBAAoB,YAAwB,MAAkB;AAC5E,MAAI,CAAC,mBAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,oBAAoB,IAAI;AAAA,EAC5C;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AACvB,aAAO;AAAA,IAET;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,oBACd,YACA,MACA,gBACA,SACM;AACN,MAAI,QAAQ;AAAM,WAAO;AACzB,MAAI,CAAC,mBAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,oBAAoB,MAAM,gBAAgB,OAAO;AAAA,EACrE;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AACvB,UAAI,kBAAkB;AAAM,eAAO;AACnC,aAAO;AAAA,IAET,KAAK,oBAAoB;AACvB,aAAO,sCAAsC,MAAgC,OAAO;AAAA,IAEtF;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/controls/control.ts"],"sourcesContent":["import {\n copyRichTextData,\n type CopyContext,\n type Data,\n type MergeContext,\n type MergeTranslatableDataContext,\n} from '@makeswift/controls'\n\nimport {\n GridPropControllerData,\n Types as PropControllerTypes,\n mergeGridPropControllerTranslatedData,\n} from '@makeswift/prop-controllers'\n\nimport { Descriptor, isLegacyDescriptor } from '../prop-controllers/descriptors'\nimport { copy as propControllerCopy } from '../prop-controllers/copy'\nimport { DELETED_PROP_CONTROLLER_TYPES, PropControllerDescriptor } from '../prop-controllers'\nimport { ReactMergeTranslationsVisitor } from './visitors/merge-translations-visitor'\n\nexport function copy(definition: Descriptor, value: any, context: CopyContext) {\n if (!isLegacyDescriptor(definition)) {\n return definition.copyData(value, context)\n }\n\n switch (definition.type) {\n case PropControllerTypes.Backgrounds:\n case PropControllerTypes.Grid:\n case PropControllerTypes.NavigationLinks:\n case PropControllerTypes.Link:\n case PropControllerTypes.Shadows:\n case PropControllerTypes.Image:\n case PropControllerTypes.Images:\n case PropControllerTypes.ResponsiveColor:\n case PropControllerTypes.TableFormFields:\n case PropControllerTypes.Table:\n case PropControllerTypes.Border:\n case PropControllerTypes.ElementID:\n return propControllerCopy(definition, value, context)\n\n case DELETED_PROP_CONTROLLER_TYPES.RichText:\n return copyRichTextData(value, context)\n\n default:\n return value\n }\n}\n\nexport function merge(\n definition: PropControllerDescriptor,\n a: Data,\n b: Data = a,\n context: MergeContext,\n): Data {\n if (!isLegacyDescriptor(definition)) {\n return definition.mergeData(a, b, context)\n }\n\n switch (definition.type) {\n default:\n return b\n }\n}\n\nexport function getTranslatableData(definition: Descriptor, data: Data): Data {\n if (!isLegacyDescriptor(definition)) {\n return definition.getTranslatableData(data)\n }\n\n switch (definition.type) {\n case PropControllerTypes.TextInput:\n case PropControllerTypes.TextArea:\n return data\n\n default:\n return null\n }\n}\n\nexport function mergeTranslatedData(\n definition: PropControllerDescriptor,\n data: Data,\n translatedData: Data,\n context: MergeTranslatableDataContext,\n): Data {\n if (data == null) return data\n if (!isLegacyDescriptor(definition)) {\n const mergeTranslationsVisitor = new ReactMergeTranslationsVisitor(context)\n return definition.accept(mergeTranslationsVisitor, data, translatedData)\n }\n\n switch (definition.type) {\n case PropControllerTypes.TextInput:\n case PropControllerTypes.TextArea:\n if (translatedData == null) return data\n return translatedData\n\n case PropControllerTypes.Grid:\n return mergeGridPropControllerTranslatedData(data as GridPropControllerData, context)\n\n default:\n return data\n }\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAKK;AAEP;AAAA,EAEE,SAAS;AAAA,EACT;AAAA,OACK;AAEP,SAAqB,0BAA0B;AAC/C,SAAS,QAAQ,0BAA0B;AAC3C,SAAS,qCAA+D;AACxE,SAAS,qCAAqC;AAEvC,SAAS,KAAK,YAAwB,OAAY,SAAsB;AAC7E,MAAI,CAAC,mBAAmB,UAAU,GAAG;AACnC,WAAO,WAAW,SAAS,OAAO,OAAO;AAAA,EAC3C;AAEA,UAAQ,WAAW,MAAM;AAAA,IACvB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KAAK,oBAAoB;AAAA,IACzB,KA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@@ import { toText } from "../../slate/utils";
17
17
  import { renderRichTextV2 } from "../../runtimes/react/controls/rich-text-v2";
18
18
  import { Plugin } from "./plugin";
19
19
  import { RichTextV2Control } from "./control";
20
- import {
21
- getTranslatableData,
22
- mergeTranslatedNodes
23
- } from "./translation";
20
+ import { getTranslatableData } from "./translations/get-translations";
24
21
  class Definition extends BaseRichTextDefinition {
25
22
  constructor({ mode, defaultValue }, plugins) {
26
23
  super({
@@ -89,19 +86,6 @@ class Definition extends BaseRichTextDefinition {
89
86
  return null;
90
87
  return getTranslatableData(Definition.dataToNodes(data), this.config.plugins);
91
88
  }
92
- mergeTranslatedData(data, translatedData, _context) {
93
- if (data == null || translatedData == null)
94
- return data;
95
- const { descendants, ...rest } = Definition.normalizeData(data);
96
- return {
97
- ...rest,
98
- descendants: mergeTranslatedNodes(
99
- descendants,
100
- translatedData,
101
- this.config.plugins
102
- )
103
- };
104
- }
105
89
  serialize() {
106
90
  const { plugins, ...config } = this.config;
107
91
  const pluginDefs = plugins.map(