Browse Source

Update name

ts-style-manager
Artur Arseniev 4 years ago
parent
commit
72e73b93d1
  1. 4
      src/commands/config/config.ts
  2. 16
      src/commands/index.ts
  3. 4
      src/commands/view/CanvasClear.ts
  4. 4
      src/commands/view/CanvasMove.ts
  5. 6
      src/commands/view/CommandAbstract.ts
  6. 4
      src/commands/view/ComponentDelete.ts
  7. 4
      src/commands/view/ComponentDrag.ts
  8. 4
      src/commands/view/ComponentEnter.ts
  9. 4
      src/commands/view/ComponentExit.ts
  10. 4
      src/commands/view/ComponentNext.ts
  11. 4
      src/commands/view/ComponentPrev.ts
  12. 4
      src/commands/view/ComponentStyleClear.ts
  13. 4
      src/commands/view/CopyComponent.ts
  14. 4
      src/commands/view/DeleteComponent.ts
  15. 4
      src/commands/view/ExportTemplate.ts
  16. 4
      src/commands/view/Fullscreen.ts
  17. 4
      src/commands/view/MoveComponent.ts
  18. 4
      src/commands/view/OpenAssets.ts
  19. 4
      src/commands/view/OpenBlocks.ts
  20. 4
      src/commands/view/OpenLayers.ts
  21. 4
      src/commands/view/OpenStyleManager.ts
  22. 4
      src/commands/view/OpenTraitManager.ts
  23. 4
      src/commands/view/PasteComponent.ts
  24. 4
      src/commands/view/Preview.ts
  25. 4
      src/commands/view/Resize.ts
  26. 4
      src/commands/view/SelectComponent.ts
  27. 4
      src/commands/view/SelectPosition.ts
  28. 4
      src/commands/view/ShowOffset.ts
  29. 4
      src/commands/view/SwitchVisibility.ts

4
src/commands/config/config.ts

@ -1,4 +1,4 @@
import { CustomCommand } from '../view/CommandAbstract';
import { CommandObject } from '../view/CommandAbstract';
export interface CommandsConfig {
/**
@ -11,7 +11,7 @@ export interface CommandsConfig {
* Default commands
* @default {}
*/
defaults: Record<string, CustomCommand>;
defaults: Record<string, CommandObject>;
/**
* If true, stateful commands (with `run` and `stop` methods) can't be executed multiple times.

16
src/commands/index.ts

@ -43,7 +43,7 @@
*/
import { isFunction, includes } from 'underscore';
import CommandAbstract, { Command, CommandOptions, CustomCommand } from './view/CommandAbstract';
import CommandAbstract, { Command, CommandOptions, CommandObject } from './view/CommandAbstract';
import defaults, { CommandsConfig } from './config/config';
import { Module } from '../abstract';
import { eventDrag } from '../dom_components/model/Component';
@ -79,7 +79,7 @@ const commandsDef = [
export default class CommandsModule extends Module<CommandsConfig & { pStylePrefix?: string }> {
CommandAbstract = CommandAbstract;
defaultCommands: Record<string, Command> = {};
commands: Record<string, CustomCommand> = {};
commands: Record<string, CommandObject> = {};
active: Record<string, any> = {};
/**
@ -232,7 +232,7 @@ export default class CommandsModule extends Module<CommandsConfig & { pStylePref
* commands.add('myCommand2', editor => { ... });
* */
add(id: string, command: Command) {
let result: CustomCommand = isFunction(command) ? { run: command } : command;
let result: CommandObject = isFunction(command) ? { run: command } : command;
if (!result.stop) {
result.noStop = true;
@ -254,7 +254,7 @@ export default class CommandsModule extends Module<CommandsConfig & { pStylePref
* var myCommand = commands.get('myCommand');
* myCommand.run();
* */
get(id: string): CustomCommand | undefined {
get(id: string): CommandObject | undefined {
let command: any = this.commands[id];
if (isFunction(command)) {
@ -279,7 +279,7 @@ export default class CommandsModule extends Module<CommandsConfig & { pStylePref
* }
* });
* */
extend(id: string, cmd: CustomCommand = {}) {
extend(id: string, cmd: CommandObject = {}) {
const command = this.get(id);
if (command) {
@ -374,7 +374,7 @@ export default class CommandsModule extends Module<CommandsConfig & { pStylePref
* @return {*} Result of the command
* @private
*/
runCommand(command?: CustomCommand, options: CommandOptions = {}) {
runCommand(command?: CommandObject, options: CommandOptions = {}) {
let result;
if (command && command.run) {
@ -402,7 +402,7 @@ export default class CommandsModule extends Module<CommandsConfig & { pStylePref
* @return {*} Result of the command
* @private
*/
stopCommand(command?: CustomCommand, options: CommandOptions = {}) {
stopCommand(command?: CommandObject, options: CommandOptions = {}) {
let result;
if (command && command.run) {
@ -426,7 +426,7 @@ export default class CommandsModule extends Module<CommandsConfig & { pStylePref
* @return {Command}
* @private
* */
create(command: CustomCommand) {
create(command: CommandObject) {
if (!command.stop) command.noStop = true;
const cmd = CommandAbstract.extend(command);
return new cmd(this.config);

4
src/commands/view/CanvasClear.ts

@ -1,8 +1,8 @@
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(ed) {
ed.DomComponents.clear();
ed.CssComposer.clear();
},
} as CustomCommand;
} as CommandObject;

4
src/commands/view/CanvasMove.ts

@ -1,7 +1,7 @@
import { bindAll } from 'underscore';
import { on, off, getKeyChar } from '../../utils/mixins';
import Dragger from '../../utils/Dragger';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(ed) {
@ -75,7 +75,7 @@ export default {
methodsEv[methodEv](canvas, 'mousedown', this.enableDragger);
methodsEv[methodEv](document, 'mouseup', this.disableDragger);
},
} as CustomCommand<
} as CommandObject<
any,
{
[key: string]: any;

6
src/commands/view/CommandAbstract.ts

@ -12,17 +12,17 @@ interface ICommand<O extends AnyObject = any> {
export type CommandFunction<O extends AnyObject = any> = CommandAbstract<O>['run'];
export type Command = CustomCommand | CommandFunction;
export type Command = CommandObject | CommandFunction;
export type CommandOptions = Record<string, any>;
type AnyObject = Record<string, any>;
export type CustomCommand<O extends AnyObject = any, T extends AnyObject = {}> = ICommand<O> &
export type CommandObject<O extends AnyObject = any, T extends AnyObject = {}> = ICommand<O> &
T &
ThisType<T & CommandAbstract<O>>;
export function defineCommand<O extends AnyObject = any, T extends AnyObject = {}>(def: CustomCommand<O, T>) {
export function defineCommand<O extends AnyObject = any, T extends AnyObject = {}>(def: CommandObject<O, T>) {
return def;
}

4
src/commands/view/ComponentDelete.ts

@ -1,8 +1,8 @@
import { isArray } from 'underscore';
import Component from '../../dom_components/model/Component';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
const command: CustomCommand<{ component?: Component }> = {
const command: CommandObject<{ component?: Component }> = {
run(ed, s, opts = {}) {
const toSelect: Component[] = [];
let components = opts.component || ed.getSelectedAll();

4
src/commands/view/ComponentDrag.ts

@ -1,6 +1,6 @@
import { keys, bindAll, each, isUndefined, debounce } from 'underscore';
import Dragger from '../../utils/Dragger';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
type Rect = { left: number; width: number; top: number; height: number };
type OrigRect = { left: number; width: number; top: number; height: number; rect: Rect };
@ -462,7 +462,7 @@ export default {
classes.forEach(cls => body.classList[methodCls](cls));
Canvas[enable ? 'startAutoscroll' : 'stopAutoscroll']();
},
} as CustomCommand<
} as CommandObject<
any,
{
guidesStatic?: Guide[];

4
src/commands/view/ComponentEnter.ts

@ -1,5 +1,5 @@
import Component from '../../dom_components/model/Component';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(ed) {
@ -14,4 +14,4 @@ export default {
toSelect.length && ed.select(toSelect);
},
} as CustomCommand;
} as CommandObject;

4
src/commands/view/ComponentExit.ts

@ -1,5 +1,5 @@
import Component from '../../dom_components/model/Component';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(ed, snd, opts = {}) {
@ -19,4 +19,4 @@ export default {
toSelect.length && ed.select(toSelect);
},
} as CustomCommand;
} as CommandObject;

4
src/commands/view/ComponentNext.ts

@ -1,5 +1,5 @@
import Component from '../../dom_components/model/Component';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(ed) {
@ -27,4 +27,4 @@ export default {
toSelect.length && ed.select(toSelect);
},
} as CustomCommand;
} as CommandObject;

4
src/commands/view/ComponentPrev.ts

@ -1,5 +1,5 @@
import Component from '../../dom_components/model/Component';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(ed) {
@ -26,4 +26,4 @@ export default {
toSelect.length && ed.select(toSelect);
},
} as CustomCommand;
} as CommandObject;

4
src/commands/view/ComponentStyleClear.ts

@ -1,6 +1,6 @@
import { flatten } from 'underscore';
import CssRule from '../../css_composer/model/CssRule';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(ed, s, opts = {}) {
@ -24,4 +24,4 @@ export default {
return toRemove;
},
} as CustomCommand;
} as CommandObject;

4
src/commands/view/CopyComponent.ts

@ -1,4 +1,4 @@
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(ed) {
@ -6,4 +6,4 @@ export default {
const models = [...ed.getSelectedAll()];
models.length && em.set('clipboard', models);
},
} as CustomCommand;
} as CommandObject;

4
src/commands/view/DeleteComponent.ts

@ -1,7 +1,7 @@
import { extend, bindAll } from 'underscore';
import Backbone from 'backbone';
import SelectComponent from './SelectComponent';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
import Component from '../../dom_components/model/Component';
const $ = Backbone.$;
@ -73,4 +73,4 @@ export default extend({}, SelectComponent, {
updateBadgeLabel(model: Component) {
this.badge.html('Remove ' + model.getName());
},
} as CustomCommand<{}, { [k: string]: any }>);
} as CommandObject<{}, { [k: string]: any }>);

4
src/commands/view/ExportTemplate.ts

@ -1,5 +1,5 @@
import Backbone from 'backbone';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
const $ = Backbone.$;
export default {
@ -56,4 +56,4 @@ export default {
return { el, $el };
},
} as CustomCommand<{}, { [k: string]: any }>;
} as CommandObject<{}, { [k: string]: any }>;

4
src/commands/view/Fullscreen.ts

@ -1,5 +1,5 @@
import { isElement } from 'underscore';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
/**
@ -80,4 +80,4 @@ export default {
this.disable();
if (editor) editor.trigger('change:canvasOffset');
},
} as CustomCommand<{ target?: HTMLElement | string }, { [k: string]: any }>;
} as CommandObject<{ target?: HTMLElement | string }, { [k: string]: any }>;

4
src/commands/view/MoveComponent.ts

@ -3,7 +3,7 @@ import Backbone from 'backbone';
import { on, off } from '../../utils/mixins';
import SelectComponent from './SelectComponent';
import SelectPosition from './SelectPosition';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
import Component from '../../dom_components/model/Component';
const $ = Backbone.$;
@ -170,4 +170,4 @@ export default extend({}, SelectPosition, SelectComponent, {
var wp = this.$wrapper;
wp.css('cursor', '').unbind().removeClass(this.noSelClass);
},
} as CustomCommand<{}, { [k: string]: any }>);
} as CommandObject<{}, { [k: string]: any }>);

4
src/commands/view/OpenAssets.ts

@ -1,7 +1,7 @@
import { isFunction } from 'underscore';
import Asset from '../../asset_manager/model/Asset';
import { createEl } from '../../utils/dom';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
open(content: string) {
@ -73,4 +73,4 @@ export default {
this.editor = editor;
this.close(this.rendered);
},
} as CustomCommand<any, { [k: string]: any }>;
} as CommandObject<any, { [k: string]: any }>;

4
src/commands/view/OpenBlocks.ts

@ -1,6 +1,6 @@
import { isFunction } from 'underscore';
import { createEl } from '../../utils/dom';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
open() {
@ -55,4 +55,4 @@ export default {
stop() {
this.close();
},
} as CustomCommand<{}, { [k: string]: any }>;
} as CommandObject<{}, { [k: string]: any }>;

4
src/commands/view/OpenLayers.ts

@ -1,4 +1,4 @@
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(editor) {
@ -31,4 +31,4 @@ export default {
const { layers } = this;
layers && (layers.style.display = 'none');
},
} as CustomCommand<{}, { [k: string]: any }>;
} as CommandObject<{}, { [k: string]: any }>;

4
src/commands/view/OpenStyleManager.ts

@ -1,5 +1,5 @@
import Backbone from 'backbone';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
const $ = Backbone.$;
export default {
@ -85,4 +85,4 @@ export default {
this.$cn2?.hide();
this.$header?.hide();
},
} as CustomCommand<{}, { [k: string]: any }>;
} as CommandObject<{}, { [k: string]: any }>;

4
src/commands/view/OpenTraitManager.ts

@ -1,5 +1,5 @@
import Backbone from 'backbone';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
const $ = Backbone.$;
@ -63,4 +63,4 @@ export default {
this.$cn2 && this.$cn2.hide();
this.$header && this.$header.hide();
},
} as CustomCommand<{}, { [k: string]: any }>;
} as CommandObject<{}, { [k: string]: any }>;

4
src/commands/view/PasteComponent.ts

@ -1,6 +1,6 @@
import { isArray, contains } from 'underscore';
import Component from '../../dom_components/model/Component';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(ed, s, opts = {}) {
@ -37,4 +37,4 @@ export default {
lastSelected.emitUpdate();
}
},
} as CustomCommand;
} as CommandObject;

4
src/commands/view/Preview.ts

@ -1,6 +1,6 @@
import { each } from 'underscore';
import Editor from '../../editor';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
const cmdOutline = 'core:component-outline';
@ -96,4 +96,4 @@ export default {
editor.refresh();
this.tglEffects();
},
} as CustomCommand<{}, { [k: string]: any }>;
} as CommandObject<{}, { [k: string]: any }>;

4
src/commands/view/Resize.ts

@ -1,5 +1,5 @@
import Resizer from '../../utils/Resizer';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
run(editor, sender, opts) {
@ -30,4 +30,4 @@ export default {
stop() {
this.canvasResizer?.blur();
},
} as CustomCommand<{ options?: {}; forceNew?: boolean; el: HTMLElement }, { canvasResizer?: Resizer }>;
} as CommandObject<{ options?: {}; forceNew?: boolean; el: HTMLElement }, { canvasResizer?: Resizer }>;

4
src/commands/view/SelectComponent.ts

@ -4,7 +4,7 @@ import { on, off, getUnitFromValue, isTaggableNode, getViewEl, hasWin } from '..
import { isVisible, isDoc } from '../../utils/dom';
import ToolbarView from '../../dom_components/view/ToolbarView';
import Toolbar from '../../dom_components/model/Toolbar';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
import Component from '../../dom_components/model/Component';
const $ = Backbone.$;
@ -727,4 +727,4 @@ export default {
this.toggleToolsEl();
editor && editor.stopCommand('resize');
},
} as CustomCommand<any, { [k: string]: any }>;
} as CommandObject<any, { [k: string]: any }>;

4
src/commands/view/SelectPosition.ts

@ -1,5 +1,5 @@
import Backbone from 'backbone';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
const $ = Backbone.$;
export default {
@ -105,4 +105,4 @@ export default {
this.$wrapper.css('cursor', '');
this.$wrapper.unbind();
},
} as CustomCommand<{}, { [k: string]: any }>;
} as CommandObject<{}, { [k: string]: any }>;

4
src/commands/view/ShowOffset.ts

@ -1,7 +1,7 @@
import Backbone from 'backbone';
import { isUndefined } from 'underscore';
import { isTextNode } from '../../utils/mixins';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
const $ = Backbone.$;
export default {
@ -177,4 +177,4 @@ export default {
var offsetViewer = canvas[method](opts.view);
offsetViewer.style.opacity = 0;
},
} as CustomCommand<any, { [k: string]: any }>;
} as CommandObject<any, { [k: string]: any }>;

4
src/commands/view/SwitchVisibility.ts

@ -1,7 +1,7 @@
import { bindAll } from 'underscore';
import Frame from '../../canvas/model/Frame';
import Editor from '../../editor';
import { CustomCommand } from './CommandAbstract';
import { CommandObject } from './CommandAbstract';
export default {
init() {
@ -33,7 +33,7 @@ export default {
const method = active ? 'add' : 'remove';
frame.view?.getBody().classList[method](`${this.ppfx}dashed`);
},
} as CustomCommand<
} as CommandObject<
{},
{
[key: string]: any;

Loading…
Cancel
Save