@techie_doubts/editor-plugin-mermaid 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/td-editor-plugin-mermaid.js +370 -0
- package/dist/toastui-editor-plugin-mermaid.js +370 -0
- package/package.json +50 -0
- package/types/index.d.ts +7 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# TOAST UI Editor : Mermaid Plugin
|
|
2
|
+
|
|
3
|
+
> This plugin adds Mermaid rendering for `$$mermaid ... $$` blocks.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save @techie_doubts/editor-plugin-mermaid
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { Editor } from '@techie_doubts/tui.editor.2026';
|
|
15
|
+
import mermaidPlugin from '@techie_doubts/editor-plugin-mermaid';
|
|
16
|
+
|
|
17
|
+
const editor = new Editor({
|
|
18
|
+
el: document.querySelector('#editor'),
|
|
19
|
+
initialEditType: 'markdown',
|
|
20
|
+
previewStyle: 'vertical',
|
|
21
|
+
plugins: [mermaidPlugin],
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Notes
|
|
26
|
+
|
|
27
|
+
- Rendering is scheduled via `requestAnimationFrame` (Safari-friendly).
|
|
28
|
+
- The CDN build expects Mermaid to be loaded separately.
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* TOAST UI Editor : Mermaid Plugin
|
|
3
|
+
* @version 3.0.1 | Sat Feb 21 2026
|
|
4
|
+
* @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
8
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
9
|
+
module.exports = factory(require("mermaid"));
|
|
10
|
+
else if(typeof define === 'function' && define.amd)
|
|
11
|
+
define(["mermaid"], factory);
|
|
12
|
+
else if(typeof exports === 'object')
|
|
13
|
+
exports["toastui"] = factory(require("mermaid"));
|
|
14
|
+
else
|
|
15
|
+
root["toastui"] = root["toastui"] || {}, root["toastui"]["Editor"] = root["toastui"]["Editor"] || {}, root["toastui"]["Editor"]["plugin"] = root["toastui"]["Editor"]["plugin"] || {}, root["toastui"]["Editor"]["plugin"]["mermaid"] = factory(root["mermaid"]);
|
|
16
|
+
})(self, function(__WEBPACK_EXTERNAL_MODULE__387__) {
|
|
17
|
+
return /******/ (function() { // webpackBootstrap
|
|
18
|
+
/******/ "use strict";
|
|
19
|
+
/******/ var __webpack_modules__ = ({
|
|
20
|
+
|
|
21
|
+
/***/ 387:
|
|
22
|
+
/***/ (function(module) {
|
|
23
|
+
|
|
24
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__387__;
|
|
25
|
+
|
|
26
|
+
/***/ })
|
|
27
|
+
|
|
28
|
+
/******/ });
|
|
29
|
+
/************************************************************************/
|
|
30
|
+
/******/ // The module cache
|
|
31
|
+
/******/ var __webpack_module_cache__ = {};
|
|
32
|
+
/******/
|
|
33
|
+
/******/ // The require function
|
|
34
|
+
/******/ function __webpack_require__(moduleId) {
|
|
35
|
+
/******/ // Check if module is in cache
|
|
36
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
37
|
+
/******/ if (cachedModule !== undefined) {
|
|
38
|
+
/******/ return cachedModule.exports;
|
|
39
|
+
/******/ }
|
|
40
|
+
/******/ // Create a new module (and put it into the cache)
|
|
41
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
42
|
+
/******/ // no module.id needed
|
|
43
|
+
/******/ // no module.loaded needed
|
|
44
|
+
/******/ exports: {}
|
|
45
|
+
/******/ };
|
|
46
|
+
/******/
|
|
47
|
+
/******/ // Execute the module function
|
|
48
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
49
|
+
/******/
|
|
50
|
+
/******/ // Return the exports of the module
|
|
51
|
+
/******/ return module.exports;
|
|
52
|
+
/******/ }
|
|
53
|
+
/******/
|
|
54
|
+
/************************************************************************/
|
|
55
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
56
|
+
/******/ !function() {
|
|
57
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
58
|
+
/******/ __webpack_require__.n = function(module) {
|
|
59
|
+
/******/ var getter = module && module.__esModule ?
|
|
60
|
+
/******/ function() { return module['default']; } :
|
|
61
|
+
/******/ function() { return module; };
|
|
62
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
63
|
+
/******/ return getter;
|
|
64
|
+
/******/ };
|
|
65
|
+
/******/ }();
|
|
66
|
+
/******/
|
|
67
|
+
/******/ /* webpack/runtime/define property getters */
|
|
68
|
+
/******/ !function() {
|
|
69
|
+
/******/ // define getter functions for harmony exports
|
|
70
|
+
/******/ __webpack_require__.d = function(exports, definition) {
|
|
71
|
+
/******/ for(var key in definition) {
|
|
72
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
73
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
74
|
+
/******/ }
|
|
75
|
+
/******/ }
|
|
76
|
+
/******/ };
|
|
77
|
+
/******/ }();
|
|
78
|
+
/******/
|
|
79
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
80
|
+
/******/ !function() {
|
|
81
|
+
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
|
82
|
+
/******/ }();
|
|
83
|
+
/******/
|
|
84
|
+
/************************************************************************/
|
|
85
|
+
var __webpack_exports__ = {};
|
|
86
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
87
|
+
/* harmony export */ "default": function() { return /* binding */ mermaidPlugin; }
|
|
88
|
+
/* harmony export */ });
|
|
89
|
+
/* harmony import */ var mermaid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(387);
|
|
90
|
+
/* harmony import */ var mermaid__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(mermaid__WEBPACK_IMPORTED_MODULE_0__);
|
|
91
|
+
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
92
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
93
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
94
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
95
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
96
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
97
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
101
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
102
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
103
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
104
|
+
function step(op) {
|
|
105
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
106
|
+
while (_) try {
|
|
107
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
108
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
109
|
+
switch (op[0]) {
|
|
110
|
+
case 0: case 1: t = op; break;
|
|
111
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
112
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
113
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
114
|
+
default:
|
|
115
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
116
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
117
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
118
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
119
|
+
if (t[2]) _.ops.pop();
|
|
120
|
+
_.trys.pop(); continue;
|
|
121
|
+
}
|
|
122
|
+
op = body.call(thisArg, _);
|
|
123
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
124
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* @fileoverview Implements mermaid plugin
|
|
129
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
var DEFAULT_CLASS_NAME = 'toastui-mermaid';
|
|
133
|
+
var initialized = false;
|
|
134
|
+
var lastTheme = null;
|
|
135
|
+
var styleInjected = false;
|
|
136
|
+
var exportInProgress = false;
|
|
137
|
+
function escapeHtml(s) {
|
|
138
|
+
return String(s)
|
|
139
|
+
.replaceAll('&', '&')
|
|
140
|
+
.replaceAll('<', '<')
|
|
141
|
+
.replaceAll('>', '>')
|
|
142
|
+
.replaceAll('"', '"')
|
|
143
|
+
.replaceAll("'", ''');
|
|
144
|
+
}
|
|
145
|
+
function ensureInitialized(theme) {
|
|
146
|
+
if (initialized && lastTheme === theme)
|
|
147
|
+
return false;
|
|
148
|
+
if (typeof window !== 'undefined' && !window.mermaid) {
|
|
149
|
+
window.mermaid = (mermaid__WEBPACK_IMPORTED_MODULE_0___default());
|
|
150
|
+
}
|
|
151
|
+
var config = {
|
|
152
|
+
startOnLoad: false,
|
|
153
|
+
securityLevel: 'strict',
|
|
154
|
+
theme: theme,
|
|
155
|
+
};
|
|
156
|
+
if (theme === 'dark') {
|
|
157
|
+
config.themeVariables = {
|
|
158
|
+
background: '#111111',
|
|
159
|
+
primaryColor: '#1f1f1f',
|
|
160
|
+
primaryTextColor: '#ffffff',
|
|
161
|
+
primaryBorderColor: '#4b5563',
|
|
162
|
+
secondaryColor: '#2a2a2a',
|
|
163
|
+
secondaryTextColor: '#ffffff',
|
|
164
|
+
secondaryBorderColor: '#4b5563',
|
|
165
|
+
tertiaryColor: '#1a1a1a',
|
|
166
|
+
tertiaryTextColor: '#ffffff',
|
|
167
|
+
tertiaryBorderColor: '#4b5563',
|
|
168
|
+
lineColor: '#9ca3af',
|
|
169
|
+
clusterBkg: '#1a1a1a',
|
|
170
|
+
clusterBorder: '#4b5563',
|
|
171
|
+
edgeLabelBackground: '#1a1a1a',
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
mermaid__WEBPACK_IMPORTED_MODULE_0___default().initialize(config);
|
|
175
|
+
initialized = true;
|
|
176
|
+
lastTheme = theme;
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
function ensureMermaidStyles() {
|
|
180
|
+
if (styleInjected || typeof document === 'undefined')
|
|
181
|
+
return;
|
|
182
|
+
var style = document.createElement('style');
|
|
183
|
+
style.setAttribute('data-toastui-mermaid-theme', '1');
|
|
184
|
+
style.textContent = "\n.toastui-editor-dark .toastui-mermaid {\n background: #111111;\n border-radius: 4px;\n padding: 6px 8px;\n}\n\n.toastui-editor-dark .toastui-mermaid svg {\n background: #111111 !important;\n}\n\n.toastui-editor-dark .toastui-mermaid svg .node rect,\n.toastui-editor-dark .toastui-mermaid svg .node ellipse,\n.toastui-editor-dark .toastui-mermaid svg .node circle,\n.toastui-editor-dark .toastui-mermaid svg .node polygon {\n fill: #1f1f1f !important;\n stroke: #4b5563 !important;\n}\n\n.toastui-editor-dark .toastui-mermaid svg .edgePath path,\n.toastui-editor-dark .toastui-mermaid svg .flowchart-link {\n stroke: #9ca3af !important;\n}\n\n.toastui-editor-dark .toastui-mermaid svg .label text,\n.toastui-editor-dark .toastui-mermaid svg .label foreignObject,\n.toastui-editor-dark .toastui-mermaid svg .edgeLabel {\n fill: #ffffff !important;\n color: #ffffff !important;\n}\n ".trim();
|
|
185
|
+
document.head.appendChild(style);
|
|
186
|
+
styleInjected = true;
|
|
187
|
+
}
|
|
188
|
+
function resetMermaidNode(node) {
|
|
189
|
+
var mermaidSource = node.dataset.mermaidSource;
|
|
190
|
+
var source = node.textContent || '';
|
|
191
|
+
if (mermaidSource) {
|
|
192
|
+
try {
|
|
193
|
+
source = decodeURIComponent(mermaidSource);
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
source = node.textContent || '';
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
node.textContent = source;
|
|
200
|
+
node.dataset.mermaidRendered = '0';
|
|
201
|
+
node.removeAttribute('data-processed');
|
|
202
|
+
node.querySelectorAll('[data-processed]').forEach(function (el) {
|
|
203
|
+
el.removeAttribute('data-processed');
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function renderMermaidIn(rootEl, forceRerender) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
+
var allNodes, nodes, e_1;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
if (!rootEl)
|
|
213
|
+
return [2 /*return*/];
|
|
214
|
+
allNodes = Array.from(rootEl.querySelectorAll('.mermaid[data-mermaid="1"]'));
|
|
215
|
+
nodes = forceRerender
|
|
216
|
+
? allNodes
|
|
217
|
+
: allNodes.filter(function (node) { return node.dataset.mermaidRendered !== '1'; });
|
|
218
|
+
if (!nodes.length)
|
|
219
|
+
return [2 /*return*/];
|
|
220
|
+
if (forceRerender) {
|
|
221
|
+
nodes.forEach(function (node) { return resetMermaidNode(node); });
|
|
222
|
+
}
|
|
223
|
+
nodes.forEach(function (node) {
|
|
224
|
+
node.dataset.mermaidRendered = '1';
|
|
225
|
+
});
|
|
226
|
+
_a.label = 1;
|
|
227
|
+
case 1:
|
|
228
|
+
_a.trys.push([1, 3, , 4]);
|
|
229
|
+
return [4 /*yield*/, mermaid__WEBPACK_IMPORTED_MODULE_0___default().run({ nodes: nodes, suppressErrors: true })];
|
|
230
|
+
case 2:
|
|
231
|
+
_a.sent();
|
|
232
|
+
return [3 /*break*/, 4];
|
|
233
|
+
case 3:
|
|
234
|
+
e_1 = _a.sent();
|
|
235
|
+
nodes.forEach(function (node) {
|
|
236
|
+
node.dataset.mermaidRendered = '0';
|
|
237
|
+
});
|
|
238
|
+
// eslint-disable-next-line no-console
|
|
239
|
+
console.error('Mermaid render failed:', e_1);
|
|
240
|
+
return [3 /*break*/, 4];
|
|
241
|
+
case 4: return [2 /*return*/];
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function makeMermaidScheduler(getRoots) {
|
|
247
|
+
var _this = this;
|
|
248
|
+
var scheduled = false;
|
|
249
|
+
var lastEffectiveTheme = null;
|
|
250
|
+
var pendingThemeOverride = null;
|
|
251
|
+
var schedule = function (overrideTheme) {
|
|
252
|
+
if (overrideTheme) {
|
|
253
|
+
pendingThemeOverride = overrideTheme;
|
|
254
|
+
}
|
|
255
|
+
if (scheduled || exportInProgress)
|
|
256
|
+
return;
|
|
257
|
+
scheduled = true;
|
|
258
|
+
requestAnimationFrame(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
259
|
+
var _a, previewRoot, wysiwygRoot, theme, themeRoot, isDark, didReinitialize, forceRerender;
|
|
260
|
+
return __generator(this, function (_b) {
|
|
261
|
+
switch (_b.label) {
|
|
262
|
+
case 0:
|
|
263
|
+
scheduled = false;
|
|
264
|
+
if (exportInProgress)
|
|
265
|
+
return [2 /*return*/];
|
|
266
|
+
_a = getRoots(), previewRoot = _a.previewRoot, wysiwygRoot = _a.wysiwygRoot;
|
|
267
|
+
if (pendingThemeOverride) {
|
|
268
|
+
theme = pendingThemeOverride;
|
|
269
|
+
pendingThemeOverride = null;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
themeRoot = (previewRoot === null || previewRoot === void 0 ? void 0 : previewRoot.closest('.toastui-editor-defaultUI')) ||
|
|
273
|
+
(wysiwygRoot === null || wysiwygRoot === void 0 ? void 0 : wysiwygRoot.closest('.toastui-editor-defaultUI'));
|
|
274
|
+
isDark = (themeRoot === null || themeRoot === void 0 ? void 0 : themeRoot.classList.contains('toastui-editor-dark')) || false;
|
|
275
|
+
theme = isDark ? 'dark' : 'default';
|
|
276
|
+
}
|
|
277
|
+
didReinitialize = ensureInitialized(theme);
|
|
278
|
+
forceRerender = theme !== lastEffectiveTheme || didReinitialize;
|
|
279
|
+
lastEffectiveTheme = theme;
|
|
280
|
+
return [4 /*yield*/, renderMermaidIn(previewRoot, forceRerender)];
|
|
281
|
+
case 1:
|
|
282
|
+
_b.sent();
|
|
283
|
+
return [4 /*yield*/, renderMermaidIn(wysiwygRoot, forceRerender)];
|
|
284
|
+
case 2:
|
|
285
|
+
_b.sent();
|
|
286
|
+
return [2 /*return*/];
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}); });
|
|
290
|
+
};
|
|
291
|
+
return { schedule: schedule };
|
|
292
|
+
}
|
|
293
|
+
function findContentsRoot(root) {
|
|
294
|
+
if (!root)
|
|
295
|
+
return null;
|
|
296
|
+
return root.querySelector('.toastui-editor-contents') || root;
|
|
297
|
+
}
|
|
298
|
+
function createMermaidTokens(code, className) {
|
|
299
|
+
var escaped = escapeHtml(code);
|
|
300
|
+
var source = escapeHtml(encodeURIComponent(code));
|
|
301
|
+
var html = "<div class=\"mermaid " + className + "\" data-mermaid=\"1\" data-mermaid-rendered=\"0\" data-mermaid-source=\"" + source + "\">" + escaped + "</div>";
|
|
302
|
+
return [
|
|
303
|
+
{ type: 'openTag', tagName: 'div', outerNewLine: true },
|
|
304
|
+
{ type: 'html', content: html },
|
|
305
|
+
{ type: 'closeTag', tagName: 'div', outerNewLine: true },
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Mermaid plugin
|
|
310
|
+
* @param {Object} context - plugin context for communicating with editor
|
|
311
|
+
* @param {Object} options - options for plugin
|
|
312
|
+
*/
|
|
313
|
+
function mermaidPlugin(context, options) {
|
|
314
|
+
if (options === void 0) { options = {}; }
|
|
315
|
+
ensureMermaidStyles();
|
|
316
|
+
var className = options.className || DEFAULT_CLASS_NAME;
|
|
317
|
+
var instance = context.instance;
|
|
318
|
+
var getRoots = function () {
|
|
319
|
+
var _a;
|
|
320
|
+
var elements = (_a = instance.getEditorElements) === null || _a === void 0 ? void 0 : _a.call(instance);
|
|
321
|
+
return {
|
|
322
|
+
previewRoot: findContentsRoot((elements === null || elements === void 0 ? void 0 : elements.mdPreview) || null),
|
|
323
|
+
wysiwygRoot: findContentsRoot((elements === null || elements === void 0 ? void 0 : elements.wwEditor) || null),
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
var scheduler = makeMermaidScheduler(getRoots);
|
|
327
|
+
context.eventEmitter.listen('change', function () { return scheduler.schedule(); });
|
|
328
|
+
context.eventEmitter.listen('changeMode', function () { return scheduler.schedule(); });
|
|
329
|
+
context.eventEmitter.listen('load', function () { return scheduler.schedule(); });
|
|
330
|
+
context.eventEmitter.listen('loadUI', function () { return scheduler.schedule(); });
|
|
331
|
+
context.eventEmitter.listen('changeTheme', function (theme) {
|
|
332
|
+
scheduler.schedule(theme === 'dark' ? 'dark' : 'default');
|
|
333
|
+
});
|
|
334
|
+
// Render mermaid with light theme for HTML export (bypasses async scheduler).
|
|
335
|
+
// The export plugin sets opts.promises to collect async work it must await.
|
|
336
|
+
context.eventEmitter.listen('beforeExportHtml', function (opts) {
|
|
337
|
+
exportInProgress = true;
|
|
338
|
+
var theme = (opts === null || opts === void 0 ? void 0 : opts.theme) === 'dark' ? 'dark' : 'default';
|
|
339
|
+
ensureInitialized(theme);
|
|
340
|
+
var _a = getRoots(), previewRoot = _a.previewRoot, wysiwygRoot = _a.wysiwygRoot;
|
|
341
|
+
var promises = [];
|
|
342
|
+
if (previewRoot)
|
|
343
|
+
promises.push(renderMermaidIn(previewRoot, true));
|
|
344
|
+
if (wysiwygRoot)
|
|
345
|
+
promises.push(renderMermaidIn(wysiwygRoot, true));
|
|
346
|
+
if (promises.length) {
|
|
347
|
+
opts.promises = opts.promises || [];
|
|
348
|
+
opts.promises.push(Promise.all(promises));
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
context.eventEmitter.listen('afterExportHtml', function () {
|
|
352
|
+
exportInProgress = false;
|
|
353
|
+
lastTheme = null;
|
|
354
|
+
scheduler.schedule();
|
|
355
|
+
});
|
|
356
|
+
scheduler.schedule();
|
|
357
|
+
return {
|
|
358
|
+
toHTMLRenderers: {
|
|
359
|
+
mermaid: function (node) {
|
|
360
|
+
return createMermaidTokens(node.literal || '', className);
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
__webpack_exports__ = __webpack_exports__["default"];
|
|
367
|
+
/******/ return __webpack_exports__;
|
|
368
|
+
/******/ })()
|
|
369
|
+
;
|
|
370
|
+
});
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* TOAST UI Editor : Mermaid Plugin
|
|
3
|
+
* @version 3.0.1 | Fri Feb 20 2026
|
|
4
|
+
* @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
8
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
9
|
+
module.exports = factory(require("mermaid"));
|
|
10
|
+
else if(typeof define === 'function' && define.amd)
|
|
11
|
+
define(["mermaid"], factory);
|
|
12
|
+
else if(typeof exports === 'object')
|
|
13
|
+
exports["toastui"] = factory(require("mermaid"));
|
|
14
|
+
else
|
|
15
|
+
root["toastui"] = root["toastui"] || {}, root["toastui"]["Editor"] = root["toastui"]["Editor"] || {}, root["toastui"]["Editor"]["plugin"] = root["toastui"]["Editor"]["plugin"] || {}, root["toastui"]["Editor"]["plugin"]["mermaid"] = factory(root["mermaid"]);
|
|
16
|
+
})(self, function(__WEBPACK_EXTERNAL_MODULE__387__) {
|
|
17
|
+
return /******/ (function() { // webpackBootstrap
|
|
18
|
+
/******/ "use strict";
|
|
19
|
+
/******/ var __webpack_modules__ = ({
|
|
20
|
+
|
|
21
|
+
/***/ 387:
|
|
22
|
+
/***/ (function(module) {
|
|
23
|
+
|
|
24
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__387__;
|
|
25
|
+
|
|
26
|
+
/***/ })
|
|
27
|
+
|
|
28
|
+
/******/ });
|
|
29
|
+
/************************************************************************/
|
|
30
|
+
/******/ // The module cache
|
|
31
|
+
/******/ var __webpack_module_cache__ = {};
|
|
32
|
+
/******/
|
|
33
|
+
/******/ // The require function
|
|
34
|
+
/******/ function __webpack_require__(moduleId) {
|
|
35
|
+
/******/ // Check if module is in cache
|
|
36
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
37
|
+
/******/ if (cachedModule !== undefined) {
|
|
38
|
+
/******/ return cachedModule.exports;
|
|
39
|
+
/******/ }
|
|
40
|
+
/******/ // Create a new module (and put it into the cache)
|
|
41
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
42
|
+
/******/ // no module.id needed
|
|
43
|
+
/******/ // no module.loaded needed
|
|
44
|
+
/******/ exports: {}
|
|
45
|
+
/******/ };
|
|
46
|
+
/******/
|
|
47
|
+
/******/ // Execute the module function
|
|
48
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
49
|
+
/******/
|
|
50
|
+
/******/ // Return the exports of the module
|
|
51
|
+
/******/ return module.exports;
|
|
52
|
+
/******/ }
|
|
53
|
+
/******/
|
|
54
|
+
/************************************************************************/
|
|
55
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
56
|
+
/******/ !function() {
|
|
57
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
58
|
+
/******/ __webpack_require__.n = function(module) {
|
|
59
|
+
/******/ var getter = module && module.__esModule ?
|
|
60
|
+
/******/ function() { return module['default']; } :
|
|
61
|
+
/******/ function() { return module; };
|
|
62
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
63
|
+
/******/ return getter;
|
|
64
|
+
/******/ };
|
|
65
|
+
/******/ }();
|
|
66
|
+
/******/
|
|
67
|
+
/******/ /* webpack/runtime/define property getters */
|
|
68
|
+
/******/ !function() {
|
|
69
|
+
/******/ // define getter functions for harmony exports
|
|
70
|
+
/******/ __webpack_require__.d = function(exports, definition) {
|
|
71
|
+
/******/ for(var key in definition) {
|
|
72
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
73
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
74
|
+
/******/ }
|
|
75
|
+
/******/ }
|
|
76
|
+
/******/ };
|
|
77
|
+
/******/ }();
|
|
78
|
+
/******/
|
|
79
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
80
|
+
/******/ !function() {
|
|
81
|
+
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
|
82
|
+
/******/ }();
|
|
83
|
+
/******/
|
|
84
|
+
/************************************************************************/
|
|
85
|
+
var __webpack_exports__ = {};
|
|
86
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
87
|
+
/* harmony export */ "default": function() { return /* binding */ mermaidPlugin; }
|
|
88
|
+
/* harmony export */ });
|
|
89
|
+
/* harmony import */ var mermaid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(387);
|
|
90
|
+
/* harmony import */ var mermaid__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(mermaid__WEBPACK_IMPORTED_MODULE_0__);
|
|
91
|
+
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
92
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
93
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
94
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
95
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
96
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
97
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
|
|
101
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
102
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
103
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
104
|
+
function step(op) {
|
|
105
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
106
|
+
while (_) try {
|
|
107
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
108
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
109
|
+
switch (op[0]) {
|
|
110
|
+
case 0: case 1: t = op; break;
|
|
111
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
112
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
113
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
114
|
+
default:
|
|
115
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
116
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
117
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
118
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
119
|
+
if (t[2]) _.ops.pop();
|
|
120
|
+
_.trys.pop(); continue;
|
|
121
|
+
}
|
|
122
|
+
op = body.call(thisArg, _);
|
|
123
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
124
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* @fileoverview Implements mermaid plugin
|
|
129
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
var DEFAULT_CLASS_NAME = 'toastui-mermaid';
|
|
133
|
+
var initialized = false;
|
|
134
|
+
var lastTheme = null;
|
|
135
|
+
var styleInjected = false;
|
|
136
|
+
var exportInProgress = false;
|
|
137
|
+
function escapeHtml(s) {
|
|
138
|
+
return String(s)
|
|
139
|
+
.replaceAll('&', '&')
|
|
140
|
+
.replaceAll('<', '<')
|
|
141
|
+
.replaceAll('>', '>')
|
|
142
|
+
.replaceAll('"', '"')
|
|
143
|
+
.replaceAll("'", ''');
|
|
144
|
+
}
|
|
145
|
+
function ensureInitialized(theme) {
|
|
146
|
+
if (initialized && lastTheme === theme)
|
|
147
|
+
return false;
|
|
148
|
+
if (typeof window !== 'undefined' && !window.mermaid) {
|
|
149
|
+
window.mermaid = (mermaid__WEBPACK_IMPORTED_MODULE_0___default());
|
|
150
|
+
}
|
|
151
|
+
var config = {
|
|
152
|
+
startOnLoad: false,
|
|
153
|
+
securityLevel: 'strict',
|
|
154
|
+
theme: theme,
|
|
155
|
+
};
|
|
156
|
+
if (theme === 'dark') {
|
|
157
|
+
config.themeVariables = {
|
|
158
|
+
background: '#111111',
|
|
159
|
+
primaryColor: '#1f1f1f',
|
|
160
|
+
primaryTextColor: '#ffffff',
|
|
161
|
+
primaryBorderColor: '#4b5563',
|
|
162
|
+
secondaryColor: '#2a2a2a',
|
|
163
|
+
secondaryTextColor: '#ffffff',
|
|
164
|
+
secondaryBorderColor: '#4b5563',
|
|
165
|
+
tertiaryColor: '#1a1a1a',
|
|
166
|
+
tertiaryTextColor: '#ffffff',
|
|
167
|
+
tertiaryBorderColor: '#4b5563',
|
|
168
|
+
lineColor: '#9ca3af',
|
|
169
|
+
clusterBkg: '#1a1a1a',
|
|
170
|
+
clusterBorder: '#4b5563',
|
|
171
|
+
edgeLabelBackground: '#1a1a1a',
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
mermaid__WEBPACK_IMPORTED_MODULE_0___default().initialize(config);
|
|
175
|
+
initialized = true;
|
|
176
|
+
lastTheme = theme;
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
function ensureMermaidStyles() {
|
|
180
|
+
if (styleInjected || typeof document === 'undefined')
|
|
181
|
+
return;
|
|
182
|
+
var style = document.createElement('style');
|
|
183
|
+
style.setAttribute('data-toastui-mermaid-theme', '1');
|
|
184
|
+
style.textContent = "\n.toastui-editor-dark .toastui-mermaid {\n background: #111111;\n border-radius: 4px;\n padding: 6px 8px;\n}\n\n.toastui-editor-dark .toastui-mermaid svg {\n background: #111111 !important;\n}\n\n.toastui-editor-dark .toastui-mermaid svg .node rect,\n.toastui-editor-dark .toastui-mermaid svg .node ellipse,\n.toastui-editor-dark .toastui-mermaid svg .node circle,\n.toastui-editor-dark .toastui-mermaid svg .node polygon {\n fill: #1f1f1f !important;\n stroke: #4b5563 !important;\n}\n\n.toastui-editor-dark .toastui-mermaid svg .edgePath path,\n.toastui-editor-dark .toastui-mermaid svg .flowchart-link {\n stroke: #9ca3af !important;\n}\n\n.toastui-editor-dark .toastui-mermaid svg .label text,\n.toastui-editor-dark .toastui-mermaid svg .label foreignObject,\n.toastui-editor-dark .toastui-mermaid svg .edgeLabel {\n fill: #ffffff !important;\n color: #ffffff !important;\n}\n ".trim();
|
|
185
|
+
document.head.appendChild(style);
|
|
186
|
+
styleInjected = true;
|
|
187
|
+
}
|
|
188
|
+
function resetMermaidNode(node) {
|
|
189
|
+
var mermaidSource = node.dataset.mermaidSource;
|
|
190
|
+
var source = node.textContent || '';
|
|
191
|
+
if (mermaidSource) {
|
|
192
|
+
try {
|
|
193
|
+
source = decodeURIComponent(mermaidSource);
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
source = node.textContent || '';
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
node.textContent = source;
|
|
200
|
+
node.dataset.mermaidRendered = '0';
|
|
201
|
+
node.removeAttribute('data-processed');
|
|
202
|
+
node.querySelectorAll('[data-processed]').forEach(function (el) {
|
|
203
|
+
el.removeAttribute('data-processed');
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function renderMermaidIn(rootEl, forceRerender) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
+
var allNodes, nodes, e_1;
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0:
|
|
212
|
+
if (!rootEl)
|
|
213
|
+
return [2 /*return*/];
|
|
214
|
+
allNodes = Array.from(rootEl.querySelectorAll('.mermaid[data-mermaid="1"]'));
|
|
215
|
+
nodes = forceRerender
|
|
216
|
+
? allNodes
|
|
217
|
+
: allNodes.filter(function (node) { return node.dataset.mermaidRendered !== '1'; });
|
|
218
|
+
if (!nodes.length)
|
|
219
|
+
return [2 /*return*/];
|
|
220
|
+
if (forceRerender) {
|
|
221
|
+
nodes.forEach(function (node) { return resetMermaidNode(node); });
|
|
222
|
+
}
|
|
223
|
+
nodes.forEach(function (node) {
|
|
224
|
+
node.dataset.mermaidRendered = '1';
|
|
225
|
+
});
|
|
226
|
+
_a.label = 1;
|
|
227
|
+
case 1:
|
|
228
|
+
_a.trys.push([1, 3, , 4]);
|
|
229
|
+
return [4 /*yield*/, mermaid__WEBPACK_IMPORTED_MODULE_0___default().run({ nodes: nodes, suppressErrors: true })];
|
|
230
|
+
case 2:
|
|
231
|
+
_a.sent();
|
|
232
|
+
return [3 /*break*/, 4];
|
|
233
|
+
case 3:
|
|
234
|
+
e_1 = _a.sent();
|
|
235
|
+
nodes.forEach(function (node) {
|
|
236
|
+
node.dataset.mermaidRendered = '0';
|
|
237
|
+
});
|
|
238
|
+
// eslint-disable-next-line no-console
|
|
239
|
+
console.error('Mermaid render failed:', e_1);
|
|
240
|
+
return [3 /*break*/, 4];
|
|
241
|
+
case 4: return [2 /*return*/];
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function makeMermaidScheduler(getRoots) {
|
|
247
|
+
var _this = this;
|
|
248
|
+
var scheduled = false;
|
|
249
|
+
var lastEffectiveTheme = null;
|
|
250
|
+
var pendingThemeOverride = null;
|
|
251
|
+
var schedule = function (overrideTheme) {
|
|
252
|
+
if (overrideTheme) {
|
|
253
|
+
pendingThemeOverride = overrideTheme;
|
|
254
|
+
}
|
|
255
|
+
if (scheduled || exportInProgress)
|
|
256
|
+
return;
|
|
257
|
+
scheduled = true;
|
|
258
|
+
requestAnimationFrame(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
259
|
+
var _a, previewRoot, wysiwygRoot, theme, themeRoot, isDark, didReinitialize, forceRerender;
|
|
260
|
+
return __generator(this, function (_b) {
|
|
261
|
+
switch (_b.label) {
|
|
262
|
+
case 0:
|
|
263
|
+
scheduled = false;
|
|
264
|
+
if (exportInProgress)
|
|
265
|
+
return [2 /*return*/];
|
|
266
|
+
_a = getRoots(), previewRoot = _a.previewRoot, wysiwygRoot = _a.wysiwygRoot;
|
|
267
|
+
if (pendingThemeOverride) {
|
|
268
|
+
theme = pendingThemeOverride;
|
|
269
|
+
pendingThemeOverride = null;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
themeRoot = (previewRoot === null || previewRoot === void 0 ? void 0 : previewRoot.closest('.toastui-editor-defaultUI')) ||
|
|
273
|
+
(wysiwygRoot === null || wysiwygRoot === void 0 ? void 0 : wysiwygRoot.closest('.toastui-editor-defaultUI'));
|
|
274
|
+
isDark = (themeRoot === null || themeRoot === void 0 ? void 0 : themeRoot.classList.contains('toastui-editor-dark')) || false;
|
|
275
|
+
theme = isDark ? 'dark' : 'default';
|
|
276
|
+
}
|
|
277
|
+
didReinitialize = ensureInitialized(theme);
|
|
278
|
+
forceRerender = theme !== lastEffectiveTheme || didReinitialize;
|
|
279
|
+
lastEffectiveTheme = theme;
|
|
280
|
+
return [4 /*yield*/, renderMermaidIn(previewRoot, forceRerender)];
|
|
281
|
+
case 1:
|
|
282
|
+
_b.sent();
|
|
283
|
+
return [4 /*yield*/, renderMermaidIn(wysiwygRoot, forceRerender)];
|
|
284
|
+
case 2:
|
|
285
|
+
_b.sent();
|
|
286
|
+
return [2 /*return*/];
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}); });
|
|
290
|
+
};
|
|
291
|
+
return { schedule: schedule };
|
|
292
|
+
}
|
|
293
|
+
function findContentsRoot(root) {
|
|
294
|
+
if (!root)
|
|
295
|
+
return null;
|
|
296
|
+
return root.querySelector('.toastui-editor-contents') || root;
|
|
297
|
+
}
|
|
298
|
+
function createMermaidTokens(code, className) {
|
|
299
|
+
var escaped = escapeHtml(code);
|
|
300
|
+
var source = escapeHtml(encodeURIComponent(code));
|
|
301
|
+
var html = "<div class=\"mermaid " + className + "\" data-mermaid=\"1\" data-mermaid-rendered=\"0\" data-mermaid-source=\"" + source + "\">" + escaped + "</div>";
|
|
302
|
+
return [
|
|
303
|
+
{ type: 'openTag', tagName: 'div', outerNewLine: true },
|
|
304
|
+
{ type: 'html', content: html },
|
|
305
|
+
{ type: 'closeTag', tagName: 'div', outerNewLine: true },
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Mermaid plugin
|
|
310
|
+
* @param {Object} context - plugin context for communicating with editor
|
|
311
|
+
* @param {Object} options - options for plugin
|
|
312
|
+
*/
|
|
313
|
+
function mermaidPlugin(context, options) {
|
|
314
|
+
if (options === void 0) { options = {}; }
|
|
315
|
+
ensureMermaidStyles();
|
|
316
|
+
var className = options.className || DEFAULT_CLASS_NAME;
|
|
317
|
+
var instance = context.instance;
|
|
318
|
+
var getRoots = function () {
|
|
319
|
+
var _a;
|
|
320
|
+
var elements = (_a = instance.getEditorElements) === null || _a === void 0 ? void 0 : _a.call(instance);
|
|
321
|
+
return {
|
|
322
|
+
previewRoot: findContentsRoot((elements === null || elements === void 0 ? void 0 : elements.mdPreview) || null),
|
|
323
|
+
wysiwygRoot: findContentsRoot((elements === null || elements === void 0 ? void 0 : elements.wwEditor) || null),
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
var scheduler = makeMermaidScheduler(getRoots);
|
|
327
|
+
context.eventEmitter.listen('change', function () { return scheduler.schedule(); });
|
|
328
|
+
context.eventEmitter.listen('changeMode', function () { return scheduler.schedule(); });
|
|
329
|
+
context.eventEmitter.listen('load', function () { return scheduler.schedule(); });
|
|
330
|
+
context.eventEmitter.listen('loadUI', function () { return scheduler.schedule(); });
|
|
331
|
+
context.eventEmitter.listen('changeTheme', function (theme) {
|
|
332
|
+
scheduler.schedule(theme === 'dark' ? 'dark' : 'default');
|
|
333
|
+
});
|
|
334
|
+
// Render mermaid with light theme for HTML export (bypasses async scheduler).
|
|
335
|
+
// The export plugin sets opts.promises to collect async work it must await.
|
|
336
|
+
context.eventEmitter.listen('beforeExportHtml', function (opts) {
|
|
337
|
+
exportInProgress = true;
|
|
338
|
+
var theme = (opts === null || opts === void 0 ? void 0 : opts.theme) === 'dark' ? 'dark' : 'default';
|
|
339
|
+
ensureInitialized(theme);
|
|
340
|
+
var _a = getRoots(), previewRoot = _a.previewRoot, wysiwygRoot = _a.wysiwygRoot;
|
|
341
|
+
var promises = [];
|
|
342
|
+
if (previewRoot)
|
|
343
|
+
promises.push(renderMermaidIn(previewRoot, true));
|
|
344
|
+
if (wysiwygRoot)
|
|
345
|
+
promises.push(renderMermaidIn(wysiwygRoot, true));
|
|
346
|
+
if (promises.length) {
|
|
347
|
+
opts.promises = opts.promises || [];
|
|
348
|
+
opts.promises.push(Promise.all(promises));
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
context.eventEmitter.listen('afterExportHtml', function () {
|
|
352
|
+
exportInProgress = false;
|
|
353
|
+
lastTheme = null;
|
|
354
|
+
scheduler.schedule();
|
|
355
|
+
});
|
|
356
|
+
scheduler.schedule();
|
|
357
|
+
return {
|
|
358
|
+
toHTMLRenderers: {
|
|
359
|
+
mermaid: function (node) {
|
|
360
|
+
return createMermaidTokens(node.literal || '', className);
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
__webpack_exports__ = __webpack_exports__["default"];
|
|
367
|
+
/******/ return __webpack_exports__;
|
|
368
|
+
/******/ })()
|
|
369
|
+
;
|
|
370
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@techie_doubts/editor-plugin-mermaid",
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"description": "TOAST UI Editor : Mermaid Plugin",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nhn",
|
|
7
|
+
"nhn cloud",
|
|
8
|
+
"toast",
|
|
9
|
+
"toastui",
|
|
10
|
+
"toast-ui",
|
|
11
|
+
"editor",
|
|
12
|
+
"plugin",
|
|
13
|
+
"mermaid",
|
|
14
|
+
"diagram"
|
|
15
|
+
],
|
|
16
|
+
"main": "dist/td-editor-plugin-mermaid.js",
|
|
17
|
+
"types": "types/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/*.js",
|
|
20
|
+
"types/index.d.ts"
|
|
21
|
+
],
|
|
22
|
+
"browserslist": "last 2 versions, not ie <= 10",
|
|
23
|
+
"author": "NHN Cloud FE Development Lab <dl_javascript@nhn.com>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/nhn/tui.editor.git",
|
|
28
|
+
"directory": "plugins/mermaid"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/nhn/tui.editor/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://ui.toast.com",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"lint": "eslint .",
|
|
36
|
+
"test:types": "tsc",
|
|
37
|
+
"test": "jest --watch",
|
|
38
|
+
"test:ci": "jest",
|
|
39
|
+
"serve": "snowpack dev",
|
|
40
|
+
"serve:ie": "webpack serve",
|
|
41
|
+
"build:cdn": "webpack build --env cdn & webpack build --env cdn minify",
|
|
42
|
+
"build": "webpack build && npm run build:cdn"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"mermaid": "11.12.2"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/types/index.d.ts
ADDED