-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from lanfisis/master
Switch form PEL to SunEditor as default WYSIWYG editor
- Loading branch information
Showing
22 changed files
with
394 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ | |
/.phpunit.result.cache | ||
/node_modules | ||
/yarn.lock | ||
|
||
/src/Resources/public/js/*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'suneditor/src/assets/css/suneditor.css' | ||
import 'suneditor/src/assets/css/suneditor-contents.css' | ||
import suneditor from 'suneditor' | ||
import lang from 'suneditor/src/lang' | ||
import suneditorPlugins from 'suneditor/src/plugins' | ||
import CodeMirror from 'codemirror' | ||
import 'codemirror/mode/htmlmixed/htmlmixed' | ||
import 'codemirror/lib/codemirror.css' | ||
|
||
const currentEditors = []; | ||
|
||
const initEditor = () => { | ||
return suneditor.init({ | ||
codeMirror: CodeMirror, | ||
height: 'auto', | ||
plugins: suneditorPlugins, | ||
buttonList: [] | ||
}); | ||
} | ||
|
||
export default { | ||
init(target) { | ||
const editorModel = initEditor(); | ||
target.querySelectorAll('[data-component="wysiwyg-editor"][data-editor-type="suneditor"]').forEach((component) => { | ||
|
||
// SundEditor is ID based, so we need to make sure that the ID is unique | ||
if (currentEditors.includes(component.id)) { | ||
component.id = `${component.id}-${Math.random().toString(36).substring(7)}`; | ||
} | ||
|
||
const buttonList = JSON.parse(component.dataset.editorButtons); | ||
const height = component.dataset.editorHeight; | ||
const locale = component.dataset.editorLocale; | ||
const customConfig = JSON.parse(component.dataset.editorCustomConfig); | ||
const config = { | ||
height, | ||
buttonList, | ||
lang: lang[locale], | ||
...customConfig | ||
}; | ||
const editor = editorModel.create(component, config); | ||
editor.onChange = () => { | ||
editor.save(); | ||
}; | ||
|
||
currentEditors.push(component.id); | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.