From dd447fb402e70adfc32179cd7f82419ca83494dd Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 14 Jun 2022 14:35:10 +0200 Subject: [PATCH] Up comments --- package.json | 1 + src/canvas/model/Frame.ts | 28 +++++++++++++--------------- src/canvas/view/FrameView.ts | 17 ++++++++++------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index a9da87b4e..45699b675 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ }, "lint-staged": { "{src,test}/**/*.(t|j)s": [ + "npm run lint -- --fix", "prettier --single-quote --print-width 120 --arrow-parens avoid --write", "git add" ] diff --git a/src/canvas/model/Frame.ts b/src/canvas/model/Frame.ts index 61532be40..ac12ec05f 100644 --- a/src/canvas/model/Frame.ts +++ b/src/canvas/model/Frame.ts @@ -1,6 +1,6 @@ import { result, forEach, isEmpty, isString } from 'underscore'; -import { Model } from "../../abstract"; -import CanvasModule from ".."; +import { Model } from '../../abstract'; +import CanvasModule from '..'; import ComponentWrapper from '../../dom_components/model/ComponentWrapper'; import { isComponent, isObject } from '../../utils/mixins'; import FrameView from '../view/FrameView'; @@ -35,6 +35,9 @@ export default class Frame extends Model { } view?: FrameView; + /** + * @hideconstructor + */ constructor(module: CanvasModule, props: any) { super(module, props); const { em } = this; @@ -58,7 +61,7 @@ export default class Frame extends Model { // Avoid losing styles on remapped components const idMapKeys = Object.keys(idMap); if (idMapKeys.length && Array.isArray(styles)) { - styles.forEach((style) => { + styles.forEach(style => { const sel = style.selectors; if (sel && sel.length == 1) { const sSel = sel[0]; @@ -83,8 +86,8 @@ export default class Frame extends Model { !props.height && this.set(keyAutoH, 1); } - get head(): {tag: string, attributes: any}[]{ - return this.get("head"); + get head(): { tag: string; attributes: any }[] { + return this.get('head'); } onRemove() { @@ -120,21 +123,16 @@ export default class Frame extends Model { return [...this.head]; } - setHead(value: {tag: string, attributes: any}[]) { - return this.set("head", [...value]); + setHead(value: { tag: string; attributes: any }[]) { + return this.set('head', [...value]); } - addHeadItem(item: {tag: string, attributes: any}) { + addHeadItem(item: { tag: string; attributes: any }) { this.head.push(item); } getHeadByAttr(attr: string, value: any, tag: string) { - return this.head.filter( - (item) => - item.attributes && - item.attributes[attr] == value && - (!tag || tag === item.tag) - )[0]; + return this.head.filter(item => item.attributes && item.attributes[attr] == value && (!tag || tag === item.tag))[0]; } removeHeadByAttr(attr: string, value: any, tag: string) { @@ -202,7 +200,7 @@ export default class Frame extends Model { if (obj[key] === value) delete obj[key]; }); - forEach(['attributes', 'head'], (prop) => { + forEach(['attributes', 'head'], prop => { if (isEmpty(obj[prop])) delete obj[prop]; }); diff --git a/src/canvas/view/FrameView.ts b/src/canvas/view/FrameView.ts index 99be66830..fa3091cee 100644 --- a/src/canvas/view/FrameView.ts +++ b/src/canvas/view/FrameView.ts @@ -10,11 +10,14 @@ import ComponentWrapper from '../../dom_components/model/ComponentWrapper'; import FrameWrapView from './FrameWrapView'; export default class FrameView extends View { - //@ts-ignore - get tagName(){return 'iframe'}; + get tagName() { + return 'iframe'; + } //@ts-ignore - get attributes() {return { allowfullscreen: 'allowfullscreen' }}; + get attributes() { + return { allowfullscreen: 'allowfullscreen' }; + } dragging = false; droppable?: Droppable; @@ -23,13 +26,12 @@ export default class FrameView extends View { lastClientY?: number; lastMaxHeight = 0; private jsContainer?: HTMLElement; - private tools: {[key: string]: HTMLElement} = {}; + private tools: { [key: string]: HTMLElement } = {}; private wrapper?: any; private frameWrapView?: FrameWrapView; - constructor(model: Frame, view?: FrameWrapView) { - super({model}); + super({ model }); bindAll(this, 'updateClientY', 'stopAutoscroll', 'autoscroll', '_emitUpdate'); const { el, em } = this; //el = em.config.el @@ -331,7 +333,8 @@ export default class FrameView extends View { const body = this.getBody(); const win = this.getWindow(); const conf = em.config; - //@ts-ignore TODO I don't understand why this needed nowhere else is used + //@ts-ignore This could be used inside component-related scripts to check if the + // script is executed inside the editor. win._isEditor = true; this.renderStyles({ prev: [] });