Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 23 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { Plugin } from 'prosemirror-state'; |
||
2 | import MenuView from './MenuView'; |
||
3 | |||
4 | /** |
||
5 | * Create a new menu plugin from the given items |
||
6 | * |
||
7 | * @param {[MenuItem]} items The items tp be displayed in the menu |
||
8 | * |
||
9 | * @return {Plugin} a new Prosemirror Plugin |
||
10 | * |
||
11 | * @constructor |
||
12 | */ |
||
13 | function MenuPlugin(items) { |
||
14 | return new Plugin({ |
||
15 | view(editorView) { |
||
16 | const menuView = new MenuView(items, editorView); |
||
17 | editorView.dom.parentNode.insertBefore(menuView.dom, editorView.dom); |
||
18 | return menuView; |
||
19 | }, |
||
20 | }); |
||
21 | } |
||
22 | |||
23 | export default MenuPlugin; |
||
24 |