mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
+24
-10
@@ -284,15 +284,7 @@ class TabbedEditor extends owl.Component {
|
|||||||
this.setTab = owl.utils.debounce(this.setTab, 250, true);
|
this.setTab = owl.utils.debounce(this.setTab, 250, true);
|
||||||
|
|
||||||
this.sessions = {};
|
this.sessions = {};
|
||||||
for (let tab of ["js", "xml", "css"]) {
|
this._setupSessions(props);
|
||||||
if (props[tab]) {
|
|
||||||
this.sessions[tab] = new ace.EditSession(props[tab], MODES[tab]);
|
|
||||||
this.sessions[tab].setOption("useWorker", false);
|
|
||||||
const tabSize = tab === "xml" ? 2 : 4;
|
|
||||||
this.sessions[tab].setOption("tabSize", tabSize);
|
|
||||||
this.sessions[tab].setUndoManager(new ace.UndoManager());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.editor = null;
|
this.editor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,9 +309,19 @@ class TabbedEditor extends owl.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
willUpdateProps(nextProps) {
|
||||||
|
this._setupSessions(nextProps);
|
||||||
|
}
|
||||||
|
|
||||||
patched() {
|
patched() {
|
||||||
const session = this.sessions[this.state.currentTab];
|
const session = this.sessions[this.state.currentTab];
|
||||||
session.setValue(this.props[this.state.currentTab], -1);
|
let content = this.props[this.state.currentTab];
|
||||||
|
if (content === false) {
|
||||||
|
const tab = this.props.js ? "js" : this.props.xml ? "xml" : "css";
|
||||||
|
content = this.props[tab];
|
||||||
|
this.state.currentTab = tab;
|
||||||
|
}
|
||||||
|
session.setValue(content, -1);
|
||||||
this.editor.setSession(session);
|
this.editor.setSession(session);
|
||||||
this.editor.resize();
|
this.editor.resize();
|
||||||
}
|
}
|
||||||
@@ -347,6 +349,18 @@ class TabbedEditor extends owl.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_setupSessions(props) {
|
||||||
|
for (let tab of ["js", "xml", "css"]) {
|
||||||
|
if (props[tab] && !this.sessions[tab]) {
|
||||||
|
this.sessions[tab] = new ace.EditSession(props[tab], MODES[tab]);
|
||||||
|
this.sessions[tab].setOption("useWorker", false);
|
||||||
|
const tabSize = tab === "xml" ? 2 : 4;
|
||||||
|
this.sessions[tab].setOption("tabSize", tabSize);
|
||||||
|
this.sessions[tab].setUndoManager(new ace.UndoManager());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<TabbedEditor
|
<TabbedEditor
|
||||||
js="state.js"
|
js="state.js"
|
||||||
css="!state.splitLayout and state.css"
|
css="!state.splitLayout and state.css"
|
||||||
xml="!state.splitLayout and state.js"
|
xml="!state.splitLayout and state.xml"
|
||||||
t-att-style="topEditorStyle"/>
|
t-att-style="topEditorStyle"/>
|
||||||
<t t-if="state.splitLayout">
|
<t t-if="state.splitLayout">
|
||||||
<div class="separator horizontal"/>
|
<div class="separator horizontal"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user