Browse Source

Use LiteralUnion in EditorEvent

pull/5649/head
Artur Arseniev 3 years ago
parent
commit
44a4bc91c3
  1. 5
      src/common/index.ts
  2. 11
      src/editor/index.ts

5
src/common/index.ts

@ -1,6 +1,8 @@
import Backbone from 'backbone';
export { default as $ } from '../utils/cash-dom';
interface NOOP {}
export type Debounced = Function & { cancel(): void };
export type SetOptions = Backbone.ModelSetOptions & { avoidStore?: boolean };
@ -17,6 +19,9 @@ export type ObjectAny = Record<string, any>;
export type ObjectStrings = Record<string, string>;
// https://github.com/microsoft/TypeScript/issues/29729#issuecomment-1483854699
export type LiteralUnion<T, U> = T | (U & NOOP);
export type Position = {
x: number;
y: number;

11
src/editor/index.ts

@ -60,7 +60,7 @@ import BlockManager, { BlockEvent } from '../block_manager';
import CanvasModule, { CanvasEvent } from '../canvas';
import CodeManagerModule from '../code_manager';
import CommandsModule, { CommandEvent } from '../commands';
import { EventHandler } from '../common';
import { EventHandler, LiteralUnion } from '../common';
import CssComposer from '../css_composer';
import CssRule from '../css_composer/model/CssRule';
import CssRules from '../css_composer/model/CssRules';
@ -98,7 +98,9 @@ export type ParsedRule = {
params?: string;
};
type EditorEvent =
type GeneralEvent = 'canvasScroll' | 'undo' | 'redo' | 'load' | 'update';
type EditorBuiltInEvents =
| ComponentEvent
| BlockEvent
| AssetEvent
@ -110,10 +112,9 @@ type EditorEvent =
| RichTextEditorEvent
| ModalEvent
| CommandEvent
| GeneralEvent
| string;
| GeneralEvent;
type GeneralEvent = 'canvasScroll' | 'undo' | 'redo' | 'load' | 'update';
type EditorEvent = LiteralUnion<EditorBuiltInEvents, string>;
type EditorConfigType = EditorConfig & { pStylePrefix?: string };

Loading…
Cancel
Save