A smarter way to launch CKeditor with JavaScript.
Permalink
Hello. I'm developing custom block and package for client. Providing more rich UI to operate package system, I use Vue CLI to develop UI in my package. Vue CLI system lives in /application/js directory and compiled js files are read by C5's asset system. Developing package UI with Vue is going well.
But launching CKEditor to get rich text data(HTML) has problem on that way. I know how to launch C5's page selector and file selector by javascript.
In controller
In views's javaScript(or within script tag )
It's easy and clearly. All I have to do is load the required assets in my controller and call the above method on Vue. But to use CKEditor,
I have to load the js file for launching CKEditor in view template directory. The way I hope is I just specify the asset in the controller and js file having methods to launch CKeditor will load at view file.
like this
Do you know how to read that js file or another way?
But launching CKEditor to get rich text data(HTML) has problem on that way. I know how to launch C5's page selector and file selector by javascript.
In controller
$this->requireAsset('core/file-manager'); $this->requireAsset('core/sitemap');
In views's javaScript(or within script tag )
<div class="fileSelector" data-file-selector="photo"></div> <div class="pageSelector" data-field="entry-link-page-selector-select"></div> <script> $('.fileSelector').concreteFileSelector({ "inputName": "fID[]", "fID": null, "filters": [], "chooseText": "Please Select the File." }); $('.pageSelector' + this.counts).concretePageSelector({ 'inputName': 'cID[]', 'cID': null, "filters": [], "chooseText": "Please Select the Page." });
Viewing 15 lines of 16 lines. View entire code block.
It's easy and clearly. All I have to do is load the required assets in my controller and call the above method on Vue. But to use CKEditor,
<?php $editorJavascript = Core::make('editor')->outputStandardEditorInitJSFunction(); ?> <script> // !? var launchEditor = <?=$editorJavascript; ?>; launchEditor($('#textareaClassName')); </script>
I have to load the js file for launching CKEditor in view template directory. The way I hope is I just specify the asset in the controller and js file having methods to launch CKeditor will load at view file.
like this
//controller $this->requireAsset('core/ckeditor');
Do you know how to read that js file or another way?
x)
I have to load the js file for launching CKEditor in view template directory.
OK)
I have to directly load the js file for launching CKEditor in view template with php.