-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a87d4c6
commit 0a89420
Showing
5 changed files
with
113 additions
and
16 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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"bodyparser", | ||
"browserslist", | ||
"chmod", | ||
"clonedeep", | ||
"compositionend", | ||
"compositionstart", | ||
"config", | ||
|
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,91 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>New menu</title> | ||
<link href="https://cdn.bootcdn.net/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet"> | ||
<link href="./css/editor.css" rel="stylesheet"> | ||
<link href="../dist/css/style.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<p>New menu</p> | ||
<p> | ||
<button id="btn-create">create editor</button> | ||
<button id="btn-destroy">destroy editor</button> | ||
</p> | ||
|
||
<div> | ||
<div id="editor-toolbar" class="editor-toolbar"></div> | ||
<div id="editor-text-area" class="editor-text-area"></div> | ||
</div> | ||
|
||
<script src="js/init-content.js"></script> | ||
<script src="../dist/index.js"></script> | ||
<script> | ||
const E = window.wangEditor | ||
|
||
// ---------- 注册新菜单 start ---------- | ||
class MyButtonMenu { | ||
constructor() { | ||
this.title = 'menu1', | ||
this.tag = 'button' | ||
} | ||
getValue() { return '' } | ||
isActive() { return false } | ||
isDisabled() { return false } | ||
exec(editor) { | ||
console.log(editor) | ||
alert('menu1 exec') | ||
} | ||
} | ||
const menuConf = { | ||
key: 'my-menu-1', // menu key ,唯一。注册之后,需通过 toolbarKeys 配置到工具栏 | ||
factory() { | ||
return new MyButtonMenu() | ||
}, | ||
} | ||
E.Boot.registerMenu(menuConf) | ||
// ---------- 注册新菜单 end ---------- | ||
|
||
// editor 配置 | ||
const editorConfig = { | ||
placeholder: '请输入内容...', | ||
onChange(editor) {} | ||
} | ||
|
||
// toolbar 配置 | ||
const toolbarConfig = { | ||
// toolbarKeys: ['headerSelect', 'bold', 'my-menu-1'], | ||
// excludeKeys: [], | ||
insertKeys: { | ||
index: 3, | ||
keys: 'my-menu-1' | ||
} | ||
} | ||
|
||
let editor, toolbar | ||
|
||
// create | ||
document.getElementById('btn-create').addEventListener('click', () => { | ||
editor = E.createEditor({ | ||
selector: '#editor-text-area', | ||
config: editorConfig | ||
}) | ||
|
||
toolbar = E.createToolbar({ | ||
editor, | ||
selector: '#editor-toolbar', | ||
config: toolbarConfig, | ||
}) | ||
}) | ||
|
||
// destroy | ||
document.getElementById('btn-destroy').addEventListener('click', () => { | ||
editor.destroy() | ||
editor = null | ||
}) | ||
</script> | ||
</body> | ||
</html> |
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