Skip to content

Commit

Permalink
feat(field): add tinymce field
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya authored and kevinchappell committed Oct 18, 2024
1 parent bf5a455 commit 4b00192
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/js/components/controls/html/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import HeaderControl from './header'
import ParagraphControl from './paragraph'
import HRControl from './hr'
import TinyMCEControl from './tinymce'

export default [HeaderControl, ParagraphControl, HRControl]
export default [HeaderControl, ParagraphControl, HRControl, TinyMCEControl]
36 changes: 36 additions & 0 deletions src/js/components/controls/html/tinymce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Control from '../control'

class TinyMCEControl extends Control {
constructor() {
const textAreaConfig = {
tag: 'textarea',
config: {
label: 'WYSIWYG',
editableContent: true,
},
meta: {
group: 'html',
icon: 'rich-text',
id: 'tinymce',
},
attrs: {
required: false,
},
action: {
onRender: evt => {
if (evt.id) {
this.textareaID = evt.id
console.log('render ', evt.id)
window.tinymce.remove('textarea#' + evt.id)
window.tinymce.init({
selector: 'textarea#' + evt.id,
})
}
},
},
}
super(textAreaConfig)
}
}

export default TinyMCEControl
5 changes: 5 additions & 0 deletions src/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ export class FormeoEditor {
* @return {void}
*/
render() {
const script = document.createElement('script')
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.9.11/tinymce.min.js'

document.head.appendChild(script)

this.stages = Object.values(Components.get('stages'))
if (this.opts.controlOnLeft) {
this.stages.forEach(stage => {
Expand Down

0 comments on commit 4b00192

Please sign in to comment.