|
|
@ -11,19 +11,23 @@ export function configureTerm(term: Term): void { |
|
|
|
Object.entries(options).forEach(([key, value]) => { |
|
|
|
term.setOption(key, value); |
|
|
|
}); |
|
|
|
const config = JSON.stringify(options, null, 2); |
|
|
|
if (!_.isNull(editor)) { |
|
|
|
editor.value = config; |
|
|
|
editor.addEventListener('keyup', onInput(term)); |
|
|
|
const toggle = document.querySelector('#options .toggler'); |
|
|
|
const optionsElem = document.getElementById('options'); |
|
|
|
if (!_.isNull(toggle) && !_.isNull(optionsElem)) { |
|
|
|
toggle.addEventListener('click', e => { |
|
|
|
optionsElem.classList.toggle('opened'); |
|
|
|
e.preventDefault(); |
|
|
|
}); |
|
|
|
} |
|
|
|
const toggle = document.querySelector('#options .toggler'); |
|
|
|
const optionsElem = document.getElementById('options'); |
|
|
|
if (editor == null || toggle == null || optionsElem == null) throw new Error("Couldn't initialize configuration menu"); |
|
|
|
|
|
|
|
function editorOnLoad() { |
|
|
|
(editor.contentWindow as any).loadOptions(loadOptions()); |
|
|
|
(editor.contentWindow as any).wetty_close_config = () => { optionsElem!.classList.toggle('opened'); }; |
|
|
|
(editor.contentWindow as any).wetty_save_config = (newConfig: any) => { onInput(term, newConfig); }; |
|
|
|
} |
|
|
|
if ((editor.contentDocument || editor.contentWindow!.document).readyState === "complete") editorOnLoad(); |
|
|
|
editor.addEventListener("load", editorOnLoad); |
|
|
|
|
|
|
|
toggle.addEventListener('click', e => { |
|
|
|
(editor.contentWindow as any).loadOptions(loadOptions()); |
|
|
|
optionsElem.classList.toggle('opened'); |
|
|
|
e.preventDefault(); |
|
|
|
}); |
|
|
|
|
|
|
|
term.attachCustomKeyEventHandler(copyShortcut); |
|
|
|
|
|
|
|