@makeswift/runtime 0.25.3 → 0.25.4-canary.0
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/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/controls/rich-text-v2/translation.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/controls/rich-text-v2/translation.js.map +1 -1
- package/dist/types/controls/rich-text-v2/translation.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -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.
|
|
31
|
+
version: "0.25.4-canary.0",
|
|
32
32
|
interactionMode: true,
|
|
33
33
|
clientSideNavigation: false,
|
|
34
34
|
elementFromPoint: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controls/rich-text-v2/translation.ts"],"sourcesContent":["import escapeHtml from 'escape-html'\nimport { Descendant, Editor, Element, Node, Text, Transforms, createEditor } from 'slate'\nimport { jsx } from 'slate-hyperscript'\nimport { parseFragment } from 'parse5'\nimport { ChildNode, DocumentFragment } from 'parse5/dist/tree-adapters/default'\n\nimport { type TranslationDto, Slate } from '@makeswift/controls'\n\nimport { RichTextV2Plugin } from './plugin'\nimport { type MakeswiftEditor, BlockType, InlineType } from '../../slate/types'\n\nfunction createEditorWithPlugins(plugins: RichTextV2Plugin[]): MakeswiftEditor {\n return plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n createEditor(),\n )\n}\n\nfunction pathToString(path: number[]): string {\n return path.join(':')\n}\n\nfunction stringToPath(s: string): number[] {\n return s.split(':').map(a => parseInt(a))\n}\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 type RichTextTranslationDto = Record<string, string>\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\nfunction deserializeTranslationHtmlString(\n el: ChildNode | 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;AAAA,yBAAuB;AACvB,mBAAkF;AAClF,+BAAoB;AACpB,oBAA8B;AAG9B,sBAA2C;AAG3C,mBAA4D;AAE5D,SAAS,wBAAwB,SAA8C;AAC7E,SAAO,QAAQ;AAAA,IACb,CAAC,QAAQ,WAAW,QAAQ,aAAa,MAAM,KAAK;AAAA,QACpD,2BAAa;AAAA,EACf;AACF;AAEA,SAAS,aAAa,MAAwB;AAC5C,SAAO,KAAK,KAAK,GAAG;AACtB;AAEA,SAAS,aAAa,GAAqB;AACzC,SAAO,EAAE,MAAM,GAAG,EAAE,IAAI,OAAK,SAAS,CAAC,CAAC;AAC1C;AAEA,SAAS,8BAA8B,YAAwB,MAAgC;AAC7F,MAAI,kBAAK,OAAO,UAAU,GAAG;AAC3B,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,sBAAM,OAAO,UAAU,KAAK,sBAAM,WAAW,UAA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,EAAE,IAAI,yBAAyB,CAAC;AACxE,gCAAW,WAAW,cAAc,kBAAkB,EAAE,IAAI,yBAAyB,CAAC;AAAA,MACxF,WAAW,sBAAM,SAAS,UAAU,KAAK,sBAAM,SAAS,UAAU,GAAG;AACnE,cAAM,EAAE,gBAAgB,UAAU,GAAG,KAAK,IAAI;AAC9C,gCAAW,SAAS,cAAc,MAAM,EAAE,IAAI,yBAAyB,CAAC;AACxE,gCAAW,WAAW,cAAc,kBAAkB,EAAE,IAAI,yBAAyB,CAAC;AAAA,MACxF;AAAA,IACF;AACA,UAAM,qBAAsB,aAAa,SAAS,GAAG,CAAC,GAAe;AAErE,wBAAO,mBAAmB,cAAc,MAAM;AAC5C,YAAM,KAAK,kBAAK,SAAS,cAAc,SAAS,CAAC,EAC9C,QAAQ,EACR,QAAQ,CAAC,CAAC,GAAG,IAAI,MAAM;AACtB,gCAAW,YAAY,cAAc,EAAE,IAAI,KAAK,CAAC;AAAA,MACnD,CAAC;AAEH,8BAAW,YAAY,cAAc,oBAAoB,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC;AAAA,IACpF,CAAC;AAAA,EACH,CAAC;AAEH,eAAa,mCAAmC;AAChD,sBAAO,UAAU,cAAc,EAAE,OAAO,KAAK,CAAC;AAE9C,SAAO,aAAa;AACtB;","names":["escapeHtml","translationKey"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/controls/rich-text-v2/translation.ts"],"sourcesContent":["import escapeHtml from 'escape-html'\nimport { Descendant, Editor, Element, Node, Text, Transforms, createEditor } from 'slate'\nimport { jsx } from 'slate-hyperscript'\nimport { parseFragment, DefaultTreeAdapterTypes } from 'parse5'\n\nimport { type TranslationDto, Slate } from '@makeswift/controls'\n\nimport { RichTextV2Plugin } from './plugin'\nimport { type MakeswiftEditor, BlockType, InlineType } from '../../slate/types'\n\nfunction createEditorWithPlugins(plugins: RichTextV2Plugin[]): MakeswiftEditor {\n return plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n createEditor(),\n )\n}\n\nfunction pathToString(path: number[]): string {\n return path.join(':')\n}\n\nfunction stringToPath(s: string): number[] {\n return s.split(':').map(a => parseInt(a))\n}\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 type RichTextTranslationDto = Record<string, string>\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\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;AAAA,yBAAuB;AACvB,mBAAkF;AAClF,+BAAoB;AACpB,oBAAuD;AAEvD,sBAA2C;AAG3C,mBAA4D;AAE5D,SAAS,wBAAwB,SAA8C;AAC7E,SAAO,QAAQ;AAAA,IACb,CAAC,QAAQ,WAAW,QAAQ,aAAa,MAAM,KAAK;AAAA,QACpD,2BAAa;AAAA,EACf;AACF;AAEA,SAAS,aAAa,MAAwB;AAC5C,SAAO,KAAK,KAAK,GAAG;AACtB;AAEA,SAAS,aAAa,GAAqB;AACzC,SA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AW,GAAG,wBAAwB;AAE3E,YAAM,CAAC,UAAU,IAAI,oBAAO,KAAK,cAAc,wBAAwB;AAEvE,UAAI,kBAAK,OAAO,UAAU,KAAK,kBAAK,OAAO,UAAU,GAAG;AACtD,cAAM,EAAE,gBAAgB,MAAM,GAAG,KAAK,IAAI;AAC1C,gCAAW,SAAS,cAAc,MAAM,EAAE,IAAI,yBAAyB,CAAC;AACxE,gCAAW,WAAW,cAAc,kBAAkB,EAAE,IAAI,yBAAyB,CAAC;AAAA,MACxF,WAAW,sBAAM,SAAS,UAAU,KAAK,sBAAM,SAAS,UAAU,GAAG;AACnE,cAAM,EAAE,gBAAgB,UAAU,GAAG,KAAK,IAAI;AAC9C,gCAAW,SAAS,cAAc,MAAM,EAAE,IAAI,yBAAyB,CAAC;AACxE,gCAAW,WAAW,cAAc,kBAAkB,EAAE,IAAI,yBAAyB,CAAC;AAAA,MACxF;AAAA,IACF;AACA,UAAM,qBAAsB,aAAa,SAAS,GAAG,CAAC,GAAe;AAErE,wBAAO,mBAAmB,cAAc,MAAM;AAC5C,YAAM,KAAK,kBAAK,SAAS,cAAc,SAAS,CAAC,EAC9C,QAAQ,EACR,QAAQ,CAAC,CAAC,GAAG,IAAI,MAAM;AACtB,gCAAW,YAAY,cAAc,EAAE,IAAI,KAAK,CAAC;AAAA,MACnD,CAAC;AAEH,8BAAW,YAAY,cAAc,oBAAoB,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC;AAAA,IACpF,CAAC;AAAA,EACH,CAAC;AAEH,eAAa,mCAAmC;AAChD,sBAAO,UAAU,cAAc,EAAE,OAAO,KAAK,CAAC;AAE9C,SAAO,aAAa;AACtB;","names":["escapeHtml","translationKey"]}
|
|
@@ -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.
|
|
11
|
+
version: "0.25.4-canary.0",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/controls/rich-text-v2/translation.ts"],"sourcesContent":["import escapeHtml from 'escape-html'\nimport { Descendant, Editor, Element, Node, Text, Transforms, createEditor } from 'slate'\nimport { jsx } from 'slate-hyperscript'\nimport { parseFragment } from 'parse5'\nimport { ChildNode, DocumentFragment } from 'parse5/dist/tree-adapters/default'\n\nimport { type TranslationDto, Slate } from '@makeswift/controls'\n\nimport { RichTextV2Plugin } from './plugin'\nimport { type MakeswiftEditor, BlockType, InlineType } from '../../slate/types'\n\nfunction createEditorWithPlugins(plugins: RichTextV2Plugin[]): MakeswiftEditor {\n return plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n createEditor(),\n )\n}\n\nfunction pathToString(path: number[]): string {\n return path.join(':')\n}\n\nfunction stringToPath(s: string): number[] {\n return s.split(':').map(a => parseInt(a))\n}\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 type RichTextTranslationDto = Record<string, string>\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\nfunction deserializeTranslationHtmlString(\n el: ChildNode | 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,OAAO,gBAAgB;AACvB,SAAqB,QAAiB,MAAM,MAAM,YAAY,oBAAoB;AAClF,SAAS,WAAW;AACpB,SAAS,qBAAqB;AAG9B,SAA8B,aAAa;AAG3C,SAA+B,WAAW,kBAAkB;AAE5D,SAAS,wBAAwB,SAA8C;AAC7E,SAAO,QAAQ;AAAA,IACb,CAAC,QAAQ,WAAW,QAAQ,aAAa,MAAM,KAAK;AAAA,IACpD,aAAa;AAAA,EACf;AACF;AAEA,SAAS,aAAa,MAAwB;AAC5C,SAAO,KAAK,KAAK,GAAG;AACtB;AAEA,SAAS,aAAa,GAAqB;AACzC,SAAO,EAAE,MAAM,GAAG,EAAE,IAAI,OAAK,SAAS,CAAC,CAAC;AAC1C;AAEA,SAAS,8BAA8B,YAAwB,MAAgC;AAC7F,MAAI,KAAK,OAAO,UAAU,GAAG;AAC3B,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,MAAM,OAAO,UAAU,KAAK,MAAM,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,CAAC,aAAa,IAAI,CAAC,GAAG,KAAK;AACtC;AAEA,SAAS,gCACP,YACA,OAAiB,CAAC,GACH;AACf,MAAI,KAAK,OAAO,UAAU,GAAG;AAC3B,QAAI,SAAS,WAAW,WAAW,IAAI;AAEvC,QAAI,WAAW;AAAI,aAAO;AAE1B,QAAI,WAAW,eAAe;AAAW,aAAO;AAEhD,WAAO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Y,cAAc,EAAE,IAAI,KAAK,CAAC;AAAA,MACnD,CAAC;AAEH,iBAAW,YAAY,cAAc,oBAAoB,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC;AAAA,IACpF,CAAC;AAAA,EACH,CAAC;AAEH,eAAa,mCAAmC;AAChD,SAAO,UAAU,cAAc,EAAE,OAAO,KAAK,CAAC;AAE9C,SAAO,aAAa;AACtB;","names":["translationKey"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/controls/rich-text-v2/translation.ts"],"sourcesContent":["import escapeHtml from 'escape-html'\nimport { Descendant, Editor, Element, Node, Text, Transforms, createEditor } from 'slate'\nimport { jsx } from 'slate-hyperscript'\nimport { parseFragment, DefaultTreeAdapterTypes } from 'parse5'\n\nimport { type TranslationDto, Slate } from '@makeswift/controls'\n\nimport { RichTextV2Plugin } from './plugin'\nimport { type MakeswiftEditor, BlockType, InlineType } from '../../slate/types'\n\nfunction createEditorWithPlugins(plugins: RichTextV2Plugin[]): MakeswiftEditor {\n return plugins.reduceRight(\n (editor, plugin) => plugin?.withPlugin?.(editor) ?? editor,\n createEditor(),\n )\n}\n\nfunction pathToString(path: number[]): string {\n return path.join(':')\n}\n\nfunction stringToPath(s: string): number[] {\n return s.split(':').map(a => parseInt(a))\n}\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 type RichTextTranslationDto = Record<string, string>\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\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,OAAO,gBAAgB;AACvB,SAAqB,QAAiB,MAAM,MAAM,YAAY,oBAAoB;AAClF,SAAS,WAAW;AACpB,SAAS,qBAA8C;AAEvD,SAA8B,aAAa;AAG3C,SAA+B,WAAW,kBAAkB;AAE5D,SAAS,wBAAwB,SAA8C;AAC7E,SAAO,QAAQ;AAAA,IACb,CAAC,QAAQ,WAAW,QAAQ,aAAa,MAAM,KAAK;AAAA,IACpD,aAAa;AAAA,EACf;AACF;AAEA,SAAS,aAAa,MAAwB;AAC5C,SAAO,KAAK,KAAK,GAAG;AACtB;AAEA,SAAS,aAAa,GAAqB;AACzC,SAAO,EAAE,MAAM,GAAG,EAAE,IAAI,OAAK,SAAS,CAAC,CAAC;AAC1C;AAEA,SAAS,8BAA8B,YAAwB,MAAgC;AAC7F,MAAI,KAAK,OAAO,UAAU,GAAG;AAC3B,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,MAAM,OAAO,UAAU,KAAK,MAAM,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,CAAC,aAAa,IAAI,CAAC,GAAG,KAAK;AACtC;AAEA,SAAS,gCACP,YACA,OAAiB,CAA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AAe;AAErE,WAAO,mBAAmB,cAAc,MAAM;AAC5C,YAAM,KAAK,KAAK,SAAS,cAAc,SAAS,CAAC,EAC9C,QAAQ,EACR,QAAQ,CAAC,CAAC,GAAG,IAAI,MAAM;AACtB,mBAAW,YAAY,cAAc,EAAE,IAAI,KAAK,CAAC;AAAA,MACnD,CAAC;AAEH,iBAAW,YAAY,cAAc,oBAAoB,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC;AAAA,IACpF,CAAC;AAAA,EACH,CAAC;AAEH,eAAa,mCAAmC;AAChD,SAAO,UAAU,cAAc,EAAE,OAAO,KAAK,CAAC;AAE9C,SAAO,aAAa;AACtB;","names":["translationKey"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../../src/controls/rich-text-v2/translation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../../src/controls/rich-text-v2/translation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuB,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AA0E3C,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE3D,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,EACzB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,sBAAsB,CAcxB;AAqDD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,EACzB,cAAc,EAAE,sBAAsB,EACtC,OAAO,EAAE,gBAAgB,EAAE,GAC1B,KAAK,CAAC,UAAU,EAAE,CAgEpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makeswift/runtime",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.4-canary.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -144,9 +144,6 @@
|
|
|
144
144
|
"@emotion/utils": "^1.4.2",
|
|
145
145
|
"@popmotion/popcorn": "^0.4.4",
|
|
146
146
|
"@reduxjs/toolkit": "^2.8.2",
|
|
147
|
-
"@types/is-hotkey": "^0.1.7",
|
|
148
|
-
"@types/use-sync-external-store": "^1.5.0",
|
|
149
|
-
"@types/uuid": "^9.0.1",
|
|
150
147
|
"@use-gesture/react": "^10.2.24",
|
|
151
148
|
"color": "^3.1.3",
|
|
152
149
|
"cookie": "^1.0.2",
|
|
@@ -164,7 +161,7 @@
|
|
|
164
161
|
"js-base64": "^3.7.7",
|
|
165
162
|
"jwt-decode": "^4.0.0",
|
|
166
163
|
"ot-json0": "^1.1.0",
|
|
167
|
-
"parse5": "^7.
|
|
164
|
+
"parse5": "^7.3.0",
|
|
168
165
|
"path-to-regexp": "^6.2.1",
|
|
169
166
|
"polished": "3.0.3",
|
|
170
167
|
"react-player": "^2.16.1",
|
|
@@ -195,12 +192,15 @@
|
|
|
195
192
|
"@types/color": "^3.0.2",
|
|
196
193
|
"@types/cors": "^2.8.12",
|
|
197
194
|
"@types/escape-html": "^1.0.2",
|
|
195
|
+
"@types/is-hotkey": "^0.1.7",
|
|
198
196
|
"@types/jest": "^29.5.12",
|
|
199
197
|
"@types/jsdom": "^21.1.7",
|
|
200
198
|
"@types/node": "^20.14.8",
|
|
201
199
|
"@types/react": "^18.2.14",
|
|
202
200
|
"@types/react-dom": "^18.2.6",
|
|
203
201
|
"@types/set-cookie-parser": "^2.4.10",
|
|
202
|
+
"@types/use-sync-external-store": "^1.5.0",
|
|
203
|
+
"@types/uuid": "^9.0.1",
|
|
204
204
|
"@typescript/lib-dom": "npm:@types/web@^0.0.243",
|
|
205
205
|
"concurrently": "^5.3.0",
|
|
206
206
|
"expect-type": "^0.19.0",
|