Passed
Pull Request — master (#57)
by Michael
03:00
created

script/plugins/Menu/MenuPlugin.js   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 23
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
eloc 9
nc 1
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2
mnd 0
bc 2
fnc 2
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A MenuPlugin.js ➔ MenuPlugin 0 9 1
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