diff --git a/docs/en/guide/schema.md b/docs/en/guide/schema.md index 0c5947e..3c8169b 100644 --- a/docs/en/guide/schema.md +++ b/docs/en/guide/schema.md @@ -22,6 +22,7 @@ interface IElement { }; value: string; valueList?: IElement[]; // Use of composite elements (hyperlinks, titles, lists, and so on). + extension?: unknown; // style font?: string; size?: number; diff --git a/docs/guide/schema.md b/docs/guide/schema.md index c173cf6..e8f4eb2 100644 --- a/docs/guide/schema.md +++ b/docs/guide/schema.md @@ -22,6 +22,7 @@ interface IElement { }; value: string; valueList?: IElement[]; // 复合元素(超链接、标题、列表等)使用 + extension?: unknown; // 样式 font?: string; size?: number; diff --git a/src/editor/core/range/RangeManager.ts b/src/editor/core/range/RangeManager.ts index e141bee..af9a2a5 100644 --- a/src/editor/core/range/RangeManager.ts +++ b/src/editor/core/range/RangeManager.ts @@ -429,6 +429,8 @@ export class RangeManager { const redo = this.historyManager.isCanRedo() // 组信息 const groupIds = curElement.groupIds || null + // 扩展字段 + const extension = curElement.extension ?? null const rangeStyle: IRangeStyle = { type, undo, @@ -449,7 +451,8 @@ export class RangeManager { listType, listStyle, groupIds, - textDecoration + textDecoration, + extension } if (rangeStyleChangeListener) { rangeStyleChangeListener(rangeStyle) @@ -490,7 +493,8 @@ export class RangeManager { listType: null, listStyle: null, groupIds: null, - textDecoration: null + textDecoration: null, + extension: null } if (rangeStyleChangeListener) { rangeStyleChangeListener(rangeStyle) diff --git a/src/editor/dataset/constant/Element.ts b/src/editor/dataset/constant/Element.ts index fb541e6..fbfa8f2 100644 --- a/src/editor/dataset/constant/Element.ts +++ b/src/editor/dataset/constant/Element.ts @@ -70,7 +70,8 @@ export const EDITOR_ELEMENT_ZIP_ATTR: Array = [ 'conceptId', 'imgDisplay', 'imgFloatPosition', - 'textDecoration' + 'textDecoration', + 'extension' ] export const TABLE_TD_ZIP_ATTR: Array = [ diff --git a/src/editor/interface/Element.ts b/src/editor/interface/Element.ts index 0da75f8..47cbf5b 100644 --- a/src/editor/interface/Element.ts +++ b/src/editor/interface/Element.ts @@ -16,6 +16,7 @@ export interface IElementBasic { id?: string type?: ElementType value: string + extension?: unknown } export interface IElementStyle { diff --git a/src/editor/interface/Listener.ts b/src/editor/interface/Listener.ts index 55aec0a..feb4649 100644 --- a/src/editor/interface/Listener.ts +++ b/src/editor/interface/Listener.ts @@ -32,6 +32,7 @@ export interface IRangeStyle { listStyle: ListStyle | null groupIds: string[] | null textDecoration: ITextDecoration | null + extension?: unknown | null } export type IRangeStyleChange = (payload: IRangeStyle) => void