From 9aaabaca182ac41b8c3853711de25b4c1a4dd043 Mon Sep 17 00:00:00 2001 From: Artem Nistuley Date: Thu, 26 Feb 2026 13:06:56 +0200 Subject: [PATCH 1/2] fix: text highlight on export --- .../src/core/super-converter/v3/handlers/utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/super-editor/src/core/super-converter/v3/handlers/utils.js b/packages/super-editor/src/core/super-converter/v3/handlers/utils.js index fa6ebe0205..9809ee2c27 100644 --- a/packages/super-editor/src/core/super-converter/v3/handlers/utils.js +++ b/packages/super-editor/src/core/super-converter/v3/handlers/utils.js @@ -317,7 +317,9 @@ export function decodeProperties(params, translatorsBySdName, properties) { if (translator) { const result = translator.decode({ ...params, node: { attrs: { [key]: properties[key] } } }); if (result != null) { - result.name = translator.xmlName; + if (result.name == null) { + result.name = translator.xmlName; + } elements.push(result); } } From 67f0dcfa34f6067b7585e76562f7f9a594402fb8 Mon Sep 17 00:00:00 2001 From: Artem Nistuley Date: Thu, 26 Feb 2026 13:12:00 +0200 Subject: [PATCH 2/2] chore: add tests --- .../super-converter/v3/handlers/utils.test.js | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 packages/super-editor/src/core/super-converter/v3/handlers/utils.test.js diff --git a/packages/super-editor/src/core/super-converter/v3/handlers/utils.test.js b/packages/super-editor/src/core/super-converter/v3/handlers/utils.test.js new file mode 100644 index 0000000000..abfc1ead3e --- /dev/null +++ b/packages/super-editor/src/core/super-converter/v3/handlers/utils.test.js @@ -0,0 +1,51 @@ +import { describe, expect, it } from 'vitest'; +import { decodeProperties } from './utils.js'; + +describe('decodeProperties', () => { + it('preserves explicit node name returned by translator.decode', () => { + const translator = { + xmlName: 'w:highlight', + sdNodeOrKeyName: 'highlight', + decode: () => ({ + name: 'w:shd', + attributes: { + 'w:color': 'auto', + 'w:val': 'clear', + 'w:fill': 'E4668C', + }, + }), + }; + + const elements = decodeProperties({ node: { attrs: {} } }, { highlight: translator }, { highlight: '#E4668C' }); + + expect(elements).toEqual([ + { + name: 'w:shd', + attributes: { + 'w:color': 'auto', + 'w:val': 'clear', + 'w:fill': 'E4668C', + }, + }, + ]); + }); + + it('falls back to translator xmlName when decode result has no name', () => { + const translator = { + xmlName: 'w:b', + sdNodeOrKeyName: 'bold', + decode: () => ({ + attributes: {}, + }), + }; + + const elements = decodeProperties({ node: { attrs: {} } }, { bold: translator }, { bold: true }); + + expect(elements).toEqual([ + { + name: 'w:b', + attributes: {}, + }, + ]); + }); +});