xref: /plugin/visualindex/script/VisualIndexView.js (revision 3c9c7f3beeea1dce712c368cb507b309c63f5d06)
1*3c9c7f3bSLORTETclass VisualIndexView {
2*3c9c7f3bSLORTET    constructor(node, outerView, getPos) {
3*3c9c7f3bSLORTET        this.node = node;
4*3c9c7f3bSLORTET        this.outerView = outerView;
5*3c9c7f3bSLORTET        this.getPos = getPos;
6*3c9c7f3bSLORTET
7*3c9c7f3bSLORTET        // Création du DOM
8*3c9c7f3bSLORTET        this.dom = document.createElement('span');
9*3c9c7f3bSLORTET        this.dom.className = 'plugin_visualindex';
10*3c9c7f3bSLORTET        this.dom.setAttribute('data-namespace', node.attrs.namespace);
11*3c9c7f3bSLORTET        this.dom.setAttribute('data-filter', node.attrs.filter);
12*3c9c7f3bSLORTET        this.dom.setAttribute('data-desc', node.attrs.desc ? '1' : '0');
13*3c9c7f3bSLORTET
14*3c9c7f3bSLORTET        this.dom.textContent = `VisualIndex: ${node.attrs.namespace}`;
15*3c9c7f3bSLORTET    }
16*3c9c7f3bSLORTET
17*3c9c7f3bSLORTET    // nécessaire pour ProseMirror
18*3c9c7f3bSLORTET    selectNode() {
19*3c9c7f3bSLORTET        this.dom.classList.add('ProseMirror-selectednode');
20*3c9c7f3bSLORTET    }
21*3c9c7f3bSLORTET
22*3c9c7f3bSLORTET    deselectNode() {
23*3c9c7f3bSLORTET        this.dom.classList.remove('ProseMirror-selectednode');
24*3c9c7f3bSLORTET    }
25*3c9c7f3bSLORTET
26*3c9c7f3bSLORTET    stopEvent(event) {
27*3c9c7f3bSLORTET        return false;
28*3c9c7f3bSLORTET    }
29*3c9c7f3bSLORTET
30*3c9c7f3bSLORTET    ignoreMutation(mutation) {
31*3c9c7f3bSLORTET        return true;
32*3c9c7f3bSLORTET    }
33*3c9c7f3bSLORTET}