Skip to content

Commit 68da503

Browse files
committed
feat: add group deletable option #1134
1 parent 595eb07 commit 68da503

File tree

5 files changed

+7
-3
lines changed

5 files changed

+7
-3
lines changed

docs/en/guide/option.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ interface IEditorOption {
6666
cursor?: ICursorOption // Cursor style. {width?: number; color?: string; dragWidth?: number; dragColor?: string; dragFloatImageDisabled?: boolean;}
6767
title?: ITitleOption // Title configuration.{ defaultFirstSize?: number; defaultSecondSize?: number; defaultThirdSize?: number defaultFourthSize?: number; defaultFifthSize?: number; defaultSixthSize?: number;}
6868
placeholder?: IPlaceholder // Placeholder text
69-
group?: IGroup // Group option. {opacity?:number; backgroundColor?:string; activeOpacity?:number; activeBackgroundColor?:string; disabled?:boolean}
69+
group?: IGroup // Group option. {opacity?:number; backgroundColor?:string; activeOpacity?:number; activeBackgroundColor?:string; disabled?:boolean; deletable?:boolean;}
7070
pageBreak?: IPageBreak // PageBreak option。{font?:string; fontSize?:number; lineDash?:number[];}
7171
zone?: IZoneOption // Zone option。{tipDisabled?:boolean;}
7272
background?: IBackgroundOption // Background option. {color?:string; image?:string; size?:BackgroundSize; repeat?:BackgroundRepeat; applyPageNumbers?:number[]}。default: {color: '#FFFFFF'}

docs/guide/option.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ interface IEditorOption {
6666
cursor?: ICursorOption // 光标样式。{width?: number; color?: string; dragWidth?: number; dragColor?: string; dragFloatImageDisabled?: boolean;}
6767
title?: ITitleOption // 标题配置。{ defaultFirstSize?: number; defaultSecondSize?: number; defaultThirdSize?: number defaultFourthSize?: number; defaultFifthSize?: number; defaultSixthSize?: number;}
6868
placeholder?: IPlaceholder // 编辑器空白占位文本
69-
group?: IGroup // 成组配置。{opacity?:number; backgroundColor?:string; activeOpacity?:number; activeBackgroundColor?:string; disabled?:boolean}
69+
group?: IGroup // 成组配置。{opacity?:number; backgroundColor?:string; activeOpacity?:number; activeBackgroundColor?:string; disabled?:boolean; deletable?:boolean;}
7070
pageBreak?: IPageBreak // 分页符配置。{font?:string; fontSize?:number; lineDash?:number[];}
7171
zone?: IZoneOption // 编辑器区域配置。{tipDisabled?:boolean;}
7272
background?: IBackgroundOption // 背景配置。{color?:string; image?:string; size?:BackgroundSize; repeat?:BackgroundRepeat; applyPageNumbers?:number[]}。默认:{color: '#FFFFFF'}

src/editor/core/draw/Draw.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ export class Draw {
784784
options?: ISpliceElementListOption
785785
) {
786786
const { isIgnoreDeletedRule = false } = options || {}
787+
const { group } = this.options
787788
if (deleteCount > 0) {
788789
// 当最后元素与开始元素列表信息不一致时:清除当前列表信息
789790
const endIndex = start + deleteCount
@@ -824,6 +825,7 @@ export class Draw {
824825
(tdDeletable !== false &&
825826
deleteElement?.control?.deletable !== false &&
826827
deleteElement?.title?.deletable !== false &&
828+
(group.deletable !== false || !deleteElement.groupIds?.length) &&
827829
(deleteElement?.area?.deletable !== false ||
828830
deleteElement?.areaIndex !== 0))
829831
) {

src/editor/dataset/constant/Group.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export const defaultGroupOption: Readonly<Required<IGroup>> = {
55
backgroundColor: '#E99D00',
66
activeOpacity: 0.5,
77
activeBackgroundColor: '#E99D00',
8-
disabled: false
8+
disabled: false,
9+
deletable: true
910
}

src/editor/interface/Group.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export interface IGroup {
44
activeOpacity?: number
55
activeBackgroundColor?: string
66
disabled?: boolean
7+
deletable?: boolean
78
}

0 commit comments

Comments
 (0)