Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature tinymce #347

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/demo/js/options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const editorOptions = {
// debug: true,
sessionStorage: true,
editPanelOrder: ['attrs', 'options'],
// controlOnLeft: true,
}

export const renderOptions = {
Expand Down
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
10 changes: 10 additions & 0 deletions src/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,17 @@ 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 => {
stage.dom.style.order = 1
})
}
const elemConfig = {
attrs: {
className: 'formeo formeo-editor',
Expand Down