Skip to content

Commit

Permalink
feat: add control flex direction option #652
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Dec 8, 2024
1 parent 77a2550 commit c599d56
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/en/guide/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ interface IElement {
code: string | null;
min?: number;
max?: number;
flexDirection: FlexDirection;
valueSets: {
value: string;
code: string;
Expand Down
1 change: 1 addition & 0 deletions docs/guide/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ interface IElement {
code: string | null;
min?: number;
max?: number;
flexDirection: FlexDirection;
valueSets: {
value: string;
code: string;
Expand Down
6 changes: 5 additions & 1 deletion src/editor/core/draw/Draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ import { EventBus } from '../event/eventbus/EventBus'
import { EventBusMap } from '../../interface/EventBus'
import { Group } from './interactive/Group'
import { Override } from '../override/Override'
import { ImageDisplay } from '../../dataset/enum/Common'
import { FlexDirection, ImageDisplay } from '../../dataset/enum/Common'
import { PUNCTUATION_REG } from '../../dataset/constant/Regular'
import { LineBreakParticle } from './particle/LineBreakParticle'
import { MouseObserver } from '../observer/MouseObserver'
Expand Down Expand Up @@ -1763,6 +1763,10 @@ export class Draw {
element.imgDisplay === ImageDisplay.INLINE ||
preElement?.listId !== element.listId ||
preElement?.areaId !== element.areaId ||
(element.control?.flexDirection === FlexDirection.COLUMN &&
(element.controlComponent === ControlComponent.CHECKBOX ||
element.controlComponent === ControlComponent.RADIO) &&
preElement?.controlComponent === ControlComponent.VALUE) ||
(i !== 0 && element.value === ZERO)
// 是否宽度不足导致换行
const isWidthNotEnough = curRowWidth > availableWidth
Expand Down
5 changes: 5 additions & 0 deletions src/editor/dataset/enum/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ export enum LocationPosition {
BEFORE = 'before',
AFTER = 'after'
}

export enum FlexDirection {
ROW = 'row',
COLUMN = 'column'
}
9 changes: 7 additions & 2 deletions src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { Command } from './core/command/Command'
import { CommandAdapt } from './core/command/CommandAdapt'
import { Listener } from './core/listener/Listener'
import { RowFlex } from './dataset/enum/Row'
import { ImageDisplay, LocationPosition } from './dataset/enum/Common'
import {
FlexDirection,
ImageDisplay,
LocationPosition
} from './dataset/enum/Common'
import { ElementType } from './dataset/enum/Element'
import { formatElementList } from './utils/element'
import { Register } from './core/register/Register'
Expand Down Expand Up @@ -197,7 +201,8 @@ export {
LineNumberType,
LocationPosition,
AreaMode,
ControlState
ControlState,
FlexDirection
}

// 对外类型
Expand Down
4 changes: 3 additions & 1 deletion src/editor/interface/Control.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LocationPosition } from '../dataset/enum/Common'
import { FlexDirection, LocationPosition } from '../dataset/enum/Common'
import {
ControlType,
ControlIndentation,
Expand Down Expand Up @@ -32,11 +32,13 @@ export interface IControlCheckbox {
code: string | null
min?: number
max?: number
flexDirection: FlexDirection
valueSets: IValueSet[]
}

export interface IControlRadio {
code: string | null
flexDirection: FlexDirection
valueSets: IValueSet[]
}

Expand Down

0 comments on commit c599d56

Please sign in to comment.