Completed
Push — master ( a8c4d7...401d4c )
by Michael
12s queued 10s
created

script/plugins/Menu/MenuView.js   A

Complexity

Total Complexity 6
Complexity/F 1.2

Size

Lines of Code 41
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
eloc 14
nc 1
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 6
mnd 0
bc 4
fnc 5
bpm 0.8
cpm 1.2
noi 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A MenuView.js ➔ constructor 0 9 1
A MenuView.js ➔ destroy 0 3 1
A MenuView.js ➔ update 0 5 1
1
class MenuView {
2
    /**
3
     * @param {[MenuItem]} items
4
     * @param {EditorView} editorView
5
     *
6
     * @return {void}
7
     */
8
    constructor(items, editorView) {
9
        this.items = items;
10
        this.editorView = editorView;
11
12
        this.dom = document.createElement('div');
13
        this.dom.className = 'menubar';
14
        items.forEach(menuItem => this.dom.appendChild(menuItem.render(editorView)));
15
        this.update(editorView);
16
    }
17
18
    /**
19
     * Called by Prosemirror when the state of the editor changes
20
     *
21
     * @param {EditorView} editorView
22
     *
23
     * @return {void}
24
     */
25
    update(editorView) {
26
        this.items.forEach((item) => {
27
            item.update(editorView);
28
        });
29
    }
30
31
    /**
32
     * Called by Prosemirror when the menu is removed
33
     *
34
     * @return {void}
35
     */
36
    destroy() {
37
        this.dom.remove();
38
    }
39
}
40
41
export default MenuView;
42