Browse Source

Convert Editor Config to ts

pull/4264/head
Alex Ritter 4 years ago
parent
commit
4d0796eefd
  1. 24
      src/editor/config/config.ts
  2. 1
      src/editor/index.ts
  3. 6
      src/editor/model/Editor.ts

24
src/editor/config/config.js → src/editor/config/config.ts

@ -19,7 +19,7 @@ export default {
* If true, will fetch HTML and CSS from selected container * If true, will fetch HTML and CSS from selected container
* @deprecated * @deprecated
*/ */
fromElement: 0, fromElement: false,
/** /**
* Initial project data * Initial project data
@ -95,17 +95,17 @@ export default {
defaultCommand: 'select-comp', defaultCommand: 'select-comp',
// Show a toolbar when the component is selected // Show a toolbar when the component is selected
showToolbar: 1, showToolbar: true,
// Allow script tag importing // Allow script tag importing
// @deprecated in favor of `config.parser.optionsHtml.allowScripts` // @deprecated in favor of `config.parser.optionsHtml.allowScripts`
// allowScripts: 0, // allowScripts: 0,
// If true render a select of available devices // If true render a select of available devices
showDevices: 1, showDevices: true,
// When enabled, on device change media rules won't be created // When enabled, on device change media rules won't be created
devicePreviewMode: 0, devicePreviewMode: false,
// THe condition to use for media queries, eg. 'max-width' // THe condition to use for media queries, eg. 'max-width'
// Comes handy for mobile-first cases // Comes handy for mobile-first cases
@ -118,16 +118,16 @@ export default {
tagVarEnd: ' ]}', tagVarEnd: ' ]}',
// When false, removes empty text nodes when parsed, unless they contain a space // When false, removes empty text nodes when parsed, unless they contain a space
keepEmptyTextNodes: 0, keepEmptyTextNodes: false,
// Return JS of components inside HTML from 'editor.getHtml()' // Return JS of components inside HTML from 'editor.getHtml()'
jsInHtml: true, jsInHtml: true,
// Enable native HTML5 drag and drop // Enable native HTML5 drag and drop
nativeDnD: 1, nativeDnD: true,
// Enable multiple selection // Enable multiple selection
multipleSelection: 1, multipleSelection: true,
// Pass default available options wherever `editor.getHtml()` is called // Pass default available options wherever `editor.getHtml()` is called
optsHtml: {}, optsHtml: {},
@ -140,12 +140,12 @@ export default {
// use of media queries (@media) or even pseudo selectors (eg. :hover). // use of media queries (@media) or even pseudo selectors (eg. :hover).
// When `avoidInlineStyle` is true all styles are inserted inside the css rule // When `avoidInlineStyle` is true all styles are inserted inside the css rule
// @deprecated Don't use this option, we don't support inline styling anymore // @deprecated Don't use this option, we don't support inline styling anymore
avoidInlineStyle: 1, avoidInlineStyle: true,
// Avoid default properties from storable JSON data, like `components` and `styles`. // Avoid default properties from storable JSON data, like `components` and `styles`.
// With this option enabled your data will be smaller (usefull if need to // With this option enabled your data will be smaller (usefull if need to
// save some storage space) // save some storage space)
avoidDefaults: 1, avoidDefaults: true,
// (experimental) // (experimental)
// The structure of components is always on the screen but it's not the same // The structure of components is always on the screen but it's not the same
@ -155,7 +155,7 @@ export default {
// any case where `CssGenerator.build` is used) will be removed automatically. // any case where `CssGenerator.build` is used) will be removed automatically.
// But be careful, not always leaving the style not used mean you wouldn't // But be careful, not always leaving the style not used mean you wouldn't
// use it later, but this option comes really handy when deal with big templates. // use it later, but this option comes really handy when deal with big templates.
clearStyles: 0, clearStyles: false,
// Specify the global drag mode of components. By default, components are moved // Specify the global drag mode of components. By default, components are moved
// following the HTML flow. Two other options are available: // following the HTML flow. Two other options are available:
@ -250,10 +250,10 @@ export default {
textViewCode: 'Code', textViewCode: 'Code',
// Keep unused styles within the editor // Keep unused styles within the editor
keepUnusedStyles: 0, keepUnusedStyles: false,
// TODO // TODO
multiFrames: 0, multiFrames: false,
// Experimental: don't use. // Experimental: don't use.
// Avoid default UI styles // Avoid default UI styles

1
src/editor/index.ts

@ -211,6 +211,7 @@ export default class EditorModule implements IBaseModule<typeof defaults> {
return this.em.get("DeviceManager"); return this.em.get("DeviceManager");
} }
//@deprecated
getConfig(){ getConfig(){
return this.config return this.config
} }

6
src/editor/model/Editor.ts

@ -77,8 +77,8 @@ export default class EditorModel extends Model {
destroyed = false; destroyed = false;
_config: any; _config: any;
attrsOrig: any; attrsOrig: any;
timedInterval?: NodeJS.Timeout; timedInterval?: number;
updateItr?: NodeJS.Timeout; updateItr?: number;
view?: EditorView view?: EditorView
@ -224,6 +224,7 @@ export default class EditorModel extends Model {
const stm = this.get('StorageManager'); const stm = this.get('StorageManager');
const changes = this.getDirtyCount(); const changes = this.getDirtyCount();
this.updateItr && clearTimeout(this.updateItr); this.updateItr && clearTimeout(this.updateItr);
//@ts-ignore
this.updateItr = setTimeout(() => this.trigger('update')); this.updateItr = setTimeout(() => this.trigger('update'));
if (this.config.noticeOnUnload) { if (this.config.noticeOnUnload) {
@ -321,6 +322,7 @@ export default class EditorModel extends Model {
} }
this.timedInterval && clearTimeout(this.timedInterval); this.timedInterval && clearTimeout(this.timedInterval);
//@ts-ignore
this.timedInterval = setTimeout(() => { this.timedInterval = setTimeout(() => {
const curr = this.getDirtyCount() || 0; const curr = this.getDirtyCount() || 0;
const { unset, ...opts } = opt; const { unset, ...opts } = opt;

Loading…
Cancel
Save