From cb16457b91db0f22b34481c90ef7c77a31060c78 Mon Sep 17 00:00:00 2001 From: arcovery Date: Fri, 13 Dec 2024 17:35:10 +0800 Subject: [PATCH] feat(video-module): add text alignment attribute (#429) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在解析视频元素 HTML 时,优化了文本对齐方式的获取逻辑 - 此修改使得视频元素可以正确地继承父元素的文本对齐方式 - 更新了相关测试用例,增加了对文本对齐属性的检查 - https://github.com/cycleccc/wangEditor-next/discussions/428 --- packages/video-module/__tests__/parse-html.test.ts | 2 ++ packages/video-module/src/module/parse-elem-html.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/video-module/__tests__/parse-html.test.ts b/packages/video-module/__tests__/parse-html.test.ts index cda5840e1..b76b0f67a 100644 --- a/packages/video-module/__tests__/parse-html.test.ts +++ b/packages/video-module/__tests__/parse-html.test.ts @@ -76,6 +76,7 @@ describe('video - parse html', () => { width: '500', height: '300', style: {}, + textAlign: 'center', children: [{ text: '' }], // void 元素有一个空 text }) }) @@ -99,6 +100,7 @@ describe('video - parse html', () => { width: 'auto', height: 'auto', style: {}, + textAlign: 'center', children: [{ text: '' }], // void 元素有一个空 text }) }) diff --git a/packages/video-module/src/module/parse-elem-html.ts b/packages/video-module/src/module/parse-elem-html.ts index 3ffe9fc00..2392dd486 100644 --- a/packages/video-module/src/module/parse-elem-html.ts +++ b/packages/video-module/src/module/parse-elem-html.ts @@ -16,6 +16,7 @@ function genVideoElem( width = 'auto', height = 'auto', style: videoStyle = {}, + textAlign = 'center', ): VideoElement { return { type: 'video', @@ -25,6 +26,7 @@ function genVideoElem( height, style, children: [{ text: '' }], // void 元素有一个空 text + textAlign, } } @@ -35,7 +37,7 @@ function parseHtml(elem: DOMElement, _children: Descendant[], _editor: IDomEdito let width = 'auto' let height = 'auto' let style = {} - + let textAlign = 'center' //