|
引入css
- <link href="_SKIN_/wangeditor/style.css" rel="stylesheet">
- <style>
- #editor—wrapper {
- border: 1px solid #ccc;
- z-index: 100; /* 按需定义 */
- }
- #toolbar-container { border-bottom: 1px solid #ccc; }
- #editor-container { height: 500px; }
- </style>
复制代码 加入富文本框
- <div style="border: 1px solid #ccc;">
- <div id="editor-toolbar" style="border-bottom: 1px solid #ccc;"></div>
- <div id="editor-text-area" style="height: 350px"></div>
- </div>
复制代码 加入js
- <script type="text/javascript" src="_SKIN_/wangEditor/index.js"></script>
- <script>
- const E = window.wangEditor
- // 切换语言
- const LANG = location.href.indexOf('lang=en') > 0 ? 'en' : 'zh-CN'
- E.i18nChangeLanguage(LANG)
- window.editor = E.createEditor({
- selector: '#editor-text-area',
- html: '<p>hello world</p><p><br></p>',
- config: {
- placeholder: 'Type here...',
- MENU_CONF: {
- uploadImage: {
- fieldName: 'your-fileName',
- base64LimitSize: 10 * 1024 * 1024 // 10M 以下插入 base64
- }
- },
- onChange(editor) {
- const html = editor.getHtml()
- // document.getElementById('editor-content-view').innerHTML = html
- document.getElementById('editor-content-textarea').value = html
- }
- }
- })
- window.toolbar = E.createToolbar({
- editor,
- selector: '#editor-toolbar',
- config: {}
- })
- </script>
复制代码
|
|