Browse Source

Up comments

pull/4389/head
Artur Arseniev 4 years ago
parent
commit
dd447fb402
  1. 1
      package.json
  2. 28
      src/canvas/model/Frame.ts
  3. 17
      src/canvas/view/FrameView.ts

1
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"
]

28
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<CanvasModule> {
}
view?: FrameView;
/**
* @hideconstructor
*/
constructor(module: CanvasModule, props: any) {
super(module, props);
const { em } = this;
@ -58,7 +61,7 @@ export default class Frame extends Model<CanvasModule> {
// 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<CanvasModule> {
!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<CanvasModule> {
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<CanvasModule> {
if (obj[key] === value) delete obj[key];
});
forEach(['attributes', 'head'], (prop) => {
forEach(['attributes', 'head'], prop => {
if (isEmpty(obj[prop])) delete obj[prop];
});

17
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<Frame, HTMLIFrameElement> {
//@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<Frame, HTMLIFrameElement> {
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<Frame, HTMLIFrameElement> {
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: [] });

Loading…
Cancel
Save