Browse Source

refactor: remove unused default options and enhance guide matching type definitions

carlos/505-improve-grapesjs-absolute-mode
Carlos 11 months ago
parent
commit
387a87f4ad
  1. 13
      packages/core/src/commands/config/config.ts
  2. 35
      packages/core/src/commands/view/ComponentDrag.ts

13
packages/core/src/commands/config/config.ts

@ -57,18 +57,7 @@ const config: () => CommandsConfig = () => ({
stylePrefix: 'com-',
defaults: {},
strict: true,
defaultOptions: {
'core:component-drag': {
run: (options: CommandOptions) => ({
...options,
// skipGuidesRender: true,
// debug: true,
// addStyle({ component, styles, partial }) {
// component.addStyle(styles, { partial });
// },
}),
},
},
defaultOptions: {},
});
export default config;

35
packages/core/src/commands/view/ComponentDrag.ts

@ -609,6 +609,7 @@ type ComponentDragOpts = {
onDrag?: (data: any) => Editor;
onEnd?: (ev: Event, opt: any, data: any) => void;
};
/**
* Represents the properties of the drag events.
*/
@ -695,20 +696,50 @@ type Guide = {
guideEl?: HTMLElement;
/**
* Indicates whether the guide is active.
* @todo Check if this property is used. The `active` property is not set in the code, but the value is changing.
* @todo The `active` property is not set in the code, but the value is changing.
*/
active?: boolean;
};
/**
* Represents a matched guide during component dragging.
*/
type GuideMatched = {
guide: Guide;
/**
* The static guides used for matching.
*/
guidesStatic: Guide[];
/**
* The origin component guide.
*/
guide: Guide;
/**
* The matched component guide.
*/
matched: Guide;
/**
* The primary position of the guide (either x or y depending on the axis).
*/
posFirst: number;
/**
* The secondary position of the guide (the opposite axis of posFirst).
*/
posSecond: number;
/**
* The distance between the two matched guides.
*/
size: number;
/**
* The raw distance between the two matched guides.
*/
sizeRaw: number;
/**
* The HTML element representing the guide info (line between the guides).
*/
elGuideInfo: HTMLElement;
/**
* The container element for the guide info (text content of the line).
*/
elGuideInfoCnt: HTMLElement;
};

Loading…
Cancel
Save