Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 10.6.1 #102

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"ResourceModules": {
"ext.mermaid": {
"scripts": [
"packageFiles": [
"resources/ext.mermaid.js",
"resources/mermaid.min.js"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
]
},
"dependencies": {
"mermaid": "8.14.0"
"mermaid": "10.8.0"
},
"files": [
"lib"
Expand Down
61 changes: 33 additions & 28 deletions resources/ext.mermaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,38 @@
* @author mwjames
*/

/*global jQuery, mediaWiki, smw */
/*global jQuery, mediaWiki, mermaid */
/*jslint white: true */

( function( $, mw ) {

'use strict';

var config = mw.config.get( 'mermaid' );

mw.loader.using( [ 'mediawiki.api', 'ext.mermaid' ] ).then( function () {

$( document ).ready( function() {

$( '.ext-mermaid' ).each( function() {

var that = $( this );

var id = 'ext-mermaid-' + ( new Date().getTime() );
var data = that.data( 'mermaid' );

that.find( '.mermaid-dots' ).hide();
that.append( '<div id=' + id + '> ' + data.content + ' </div>' );

mermaid.initialize( data.config );
mermaid.init( undefined, $( "#" + id ) );
} );
} );
} );

}( jQuery, mediaWiki ) );
let mermaid = require('./mermaid.min.js');

const generateString = (length) =>
Array(length)
.fill("")
.map(() => Math.random().toString(36).charAt(2))
.join("");

async function init_mermaid(){
let items = document.querySelectorAll('.ext-mermaid');

await Promise.all(Array.from(items).map( async (item) => {
let id = "ext-mermaid-" + generateString(10);
let data = JSON.parse(item.dataset['mermaid']);

// Hide animated dots!
let dots = item.children[0];
dots.style.display = "none";

// Render graph
mermaid.initialize(data.config);
const { svg } = await mermaid.render(id + '-svg', data.content);

// Add graph to DOM
let graph = document.createElement('div');
graph.id = id;
graph.innerHTML = svg;
item.appendChild(graph);
}));
}
// No longer need to wait for document to load or wrap in closure
init_mermaid();
1,762 changes: 1,759 additions & 3 deletions resources/mermaid.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion resources/mermaid.min.js.map

This file was deleted.

Loading
Loading