Skip to content

Commit

Permalink
feat: add extension property
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Apr 17, 2024
1 parent 868a791 commit 5027d73
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/en/guide/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions docs/guide/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface IElement {
};
value: string;
valueList?: IElement[]; // 复合元素(超链接、标题、列表等)使用
extension?: unknown;
// 样式
font?: string;
size?: number;
Expand Down
8 changes: 6 additions & 2 deletions src/editor/core/range/RangeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -449,7 +451,8 @@ export class RangeManager {
listType,
listStyle,
groupIds,
textDecoration
textDecoration,
extension
}
if (rangeStyleChangeListener) {
rangeStyleChangeListener(rangeStyle)
Expand Down Expand Up @@ -490,7 +493,8 @@ export class RangeManager {
listType: null,
listStyle: null,
groupIds: null,
textDecoration: null
textDecoration: null,
extension: null
}
if (rangeStyleChangeListener) {
rangeStyleChangeListener(rangeStyle)
Expand Down
3 changes: 2 additions & 1 deletion src/editor/dataset/constant/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export const EDITOR_ELEMENT_ZIP_ATTR: Array<keyof IElement> = [
'conceptId',
'imgDisplay',
'imgFloatPosition',
'textDecoration'
'textDecoration',
'extension'
]

export const TABLE_TD_ZIP_ATTR: Array<keyof ITd> = [
Expand Down
1 change: 1 addition & 0 deletions src/editor/interface/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface IElementBasic {
id?: string
type?: ElementType
value: string
extension?: unknown
}

export interface IElementStyle {
Expand Down
1 change: 1 addition & 0 deletions src/editor/interface/Listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5027d73

Please sign in to comment.