1jQuery(document).on('PROSEMIRROR_API_INITIALIZED', () => { 2 // define diagrams schema 3 window.Prosemirror.pluginSchemas.push((nodes, marks) => { 4 nodes = nodes.addToEnd('diagrams', { 5 inline: true, 6 selectable: true, 7 attrs: { 8 data: {}, 9 id: {}, 10 title: {default: null}, 11 width: {default: null}, 12 height: {default: null}, 13 align: {default: ''} 14 }, 15 group: "inline", 16 draggable: false, 17 toDOM: function toDOM(node) { 18 const ref = node.attrs; 19 const data = ref.data; 20 const id = ref.id; 21 const width = ref.width; 22 const height = ref.height; 23 const title = ref.title; 24 let alignclass = ref.align; 25 26 if (alignclass.length !== 0) { 27 alignclass = ` media${alignclass}`; 28 } 29 30 return [ 31 'img', 32 { 33 type: 'image/svg+xml', 34 className: 'media diagrams-svg' + alignclass, 35 title: title, 36 src: data, 37 'data-id': id, 38 //width: width, 39 //height: height, 40 } 41 ] 42 } 43 }); 44 return {nodes, marks}; 45 }); 46 47 // extend plugin menu 48 const AbstractMenuItemDispatcher = window.Prosemirror.classes.AbstractMenuItemDispatcher; 49 const MenuItem = window.Prosemirror.classes.MenuItem; 50 const KeyValueForm = window.Prosemirror.classes.KeyValueForm; 51 const AbstractNodeView = window.AbstractNodeView; // FIXME this should be moved to the prosemirror.classes namespace 52 53 /* DOKUWIKI:include script/DiagramsForm.js */ 54 /* DOKUWIKI:include script/DiagramsView.js */ 55 /* DOKUWIKI:include script/DiagramsMenuItemDispatcher.js */ 56 57 58 window.Prosemirror.pluginNodeViews.diagrams = function diagrams(node, outerview, getPos) { 59 return new DiagramsView(node, outerview, getPos); 60 }; 61 62 window.Prosemirror.pluginMenuItemDispatchers.push(DiagramsMenuItemDispatcher); 63}); 64