From 07bcdd02c074d85c66f5624ad1bb7ccd918286e3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 19 Nov 2024 21:48:53 +0300 Subject: [PATCH] Refactoring editor component --- vendor/ace/component/AceEditor.js | 22 ++++++++++++++-------- vendor/ace/component/example.html | 7 ++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/vendor/ace/component/AceEditor.js b/vendor/ace/component/AceEditor.js index c83d26d873..b10b494b76 100644 --- a/vendor/ace/component/AceEditor.js +++ b/vendor/ace/component/AceEditor.js @@ -3,10 +3,11 @@ * config = { * editorType: 'cell'/'slide'/'word' * events: { - * onChangeValue - * onEditorReady + * onChangeValue // text in editor is changed + * onEditorReady // editor is ready for use * onMouseUp * onMouseMove + * onLoad // frame with editor is loaded * } * } * */ @@ -97,15 +98,24 @@ } }; + + var _onLoad = function() { + var handler = (_config.events || {})['onLoad']; + if (handler && typeof handler == "function") { + res = handler.call(_self); + } + }; + if (parentEl) { iframe = createIframe(_config); + iframe.onload = _onLoad; var _msgDispatcher = new MessageDispatcher(_onMessage, this); parentEl.appendChild(iframe); } return { - setValue: _setValue, // string - disableDrop: _disableDrop, // true/false + setValue: _setValue, // string // set text to editor + disableDrop: _disableDrop, // true/false // disable/enable drop elements to editor destroyEditor: _destroyEditor, updateTheme: _updateTheme // type: 'dark'/'light', // colors: {'text-normal': '', 'icon-normal': '', 'background-normal': '', 'background-toolbar': '', 'highlight-button-hover': '', @@ -134,7 +144,6 @@ iframe.align = "top"; iframe.frameBorder = 0; iframe.scrolling = "no"; - iframe.onload = _onLoad; iframe.src = getBasePath() + 'AceEditor.html' + (config.editorType ? '?editorType=' + config.editorType : ''); return iframe; @@ -178,7 +187,4 @@ } }; - function _onLoad() { - } - })(window, document); diff --git a/vendor/ace/component/example.html b/vendor/ace/component/example.html index 08875c4efc..66dbcd7e51 100644 --- a/vendor/ace/component/example.html +++ b/vendor/ace/component/example.html @@ -73,13 +73,18 @@ console.log("onMouseMove"); }; + var onLoad = function (event) { + console.log("onLoad"); + }; + var config = { editorType: 'word', events: { onChangeValue: onChangeValue, onEditorReady: onEditorReady, onMouseUp: onMouseUp, - onMouseMove: onMouseMove + onMouseMove: onMouseMove, + onLoad: onLoad } };