-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4007 from node-red-hitachi/add-markdown-mermaid-d…
…iagram Add support for mermaid diagram to markdown editor
- Loading branch information
Showing
10 changed files
with
115 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/node_modules/@node-red/editor-client/src/js/ui/mermaid.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Mermaid diagram stub library for on-demand dynamic loading | ||
// Will be overwritten after script loading by $.getScript | ||
var mermaid = (function () { | ||
var enabled /* = undefined */; | ||
|
||
var initializing = false; | ||
var initCalled = false; | ||
|
||
function initialize(opt) { | ||
if (enabled === undefined) { | ||
if (RED.settings.markdownEditor && | ||
RED.settings.markdownEditor.mermaid) { | ||
enabled = RED.settings.markdownEditor.mermaid.enabled; | ||
} | ||
else { | ||
enabled = true; | ||
} | ||
} | ||
if (enabled) { | ||
initializing = true; | ||
$.getScript("vendor/mermaid/mermaid.min.js", | ||
function (data, stat, jqxhr) { | ||
$(".mermaid").show(); | ||
// invoke loaded mermaid API | ||
initializing = false; | ||
mermaid.initialize(opt); | ||
if (initCalled) { | ||
mermaid.init(); | ||
initCalled = false; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function init() { | ||
if (initializing) { | ||
$(".mermaid").hide(); | ||
initCalled = true; | ||
} | ||
} | ||
|
||
return { | ||
initialize: initialize, | ||
init: init, | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters