@licium/editor-plugin-uml 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 NHN Cloud Corp.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,186 @@
1
+ # TOAST UI Editor : UML Plugin
2
+
3
+ > This is a plugin of [TOAST UI Editor](https://github.com/nhn/tui.editor/tree/master/apps/editor) to render UML.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@toast-ui/editor-plugin-uml.svg)](https://www.npmjs.com/package/@toast-ui/editor-plugin-uml)
6
+
7
+ ![uml](https://user-images.githubusercontent.com/37766175/121813437-01fe9b80-cca7-11eb-966b-598333c8ec14.png)
8
+
9
+ ## 🚩 Table of Contents
10
+
11
+ - [Bundle File Structure](#-bundle-file-structure)
12
+ - [Usage npm](#-usage-npm)
13
+ - [Usage CDN](#-usage-cdn)
14
+
15
+ ## 📁 Bundle File Structure
16
+
17
+ ### Files Distributed on npm
18
+
19
+ ```
20
+ - node_modules/
21
+ - @toast-ui/
22
+ - editor-plugin-uml/
23
+ - dist/
24
+ - toastui-editor-plugin-uml.js
25
+ ```
26
+
27
+ ### Files Distributed on CDN
28
+
29
+ The bundle files include all dependencies of this plugin.
30
+
31
+ ```
32
+ - uicdn.toast.com/
33
+ - editor-plugin-uml/
34
+ - latest/
35
+ - toastui-editor-plugin-uml.js
36
+ - toastui-editor-plugin-uml.min.js
37
+ ```
38
+
39
+ ## 📦 Usage npm
40
+
41
+ To use the plugin, [`@toast-ui/editor`](https://github.com/nhn/tui.editor/tree/master/apps/editor) must be installed.
42
+
43
+ > Ref. [Getting Started](https://github.com/nhn/tui.editor/blob/master/docs/en/getting-started.md)
44
+
45
+ ### Install
46
+
47
+ ```sh
48
+ $ npm install @toast-ui/editor-plugin-uml
49
+ ```
50
+
51
+ ### Import Plugin
52
+
53
+ #### ES Modules
54
+
55
+ ```js
56
+ import uml from '@toast-ui/editor-plugin-uml';
57
+ ```
58
+
59
+ #### CommonJS
60
+
61
+ ```js
62
+ const uml = require('@toast-ui/editor-plugin-uml');
63
+ ```
64
+
65
+ ### Create Instance
66
+
67
+ #### Basic
68
+
69
+ ```js
70
+ import Editor from '@toast-ui/editor';
71
+ import uml from '@toast-ui/editor-plugin-uml';
72
+
73
+ const editor = new Editor({
74
+ // ...
75
+ plugins: [uml]
76
+ });
77
+ ```
78
+
79
+ #### With Viewer
80
+
81
+ ```js
82
+ import Viewer from '@toast-ui/editor/dist/toustui-editor-viewer';
83
+ import uml from '@toast-ui/editor-plugin-uml';
84
+
85
+ const viewer = new Viewer({
86
+ // ...
87
+ plugins: [uml]
88
+ });
89
+ ```
90
+
91
+ or
92
+
93
+ ```js
94
+ import Editor from '@toast-ui/editor';
95
+ import uml from '@toast-ui/editor-plugin-uml';
96
+
97
+ const viewer = Editor.factory({
98
+ // ...
99
+ plugins: [uml],
100
+ viewer: true
101
+ });
102
+ ```
103
+
104
+ ## 🗂 Usage CDN
105
+
106
+ To use the plugin, the CDN files(CSS, Script) of `@toast-ui/editor` must be included.
107
+
108
+ ### Include Files
109
+
110
+ ```html
111
+ ...
112
+ <body>
113
+ ...
114
+ <!-- Editor -->
115
+ <script src="https://uicdn.toast.com/editor/latest/toastui-editor-all.min.js"></script>
116
+ <!-- Editor's Plugin -->
117
+ <script src="https://uicdn.toast.com/editor-plugin-uml/latest/toastui-editor-plugin-uml.min.js"></script>
118
+ ...
119
+ </body>
120
+ ...
121
+ ```
122
+
123
+ ### Create Instance
124
+
125
+ #### Basic
126
+
127
+ ```js
128
+ const { Editor } = toastui;
129
+ const { uml } = Editor.plugin;
130
+
131
+ const editor = new Editor({
132
+ // ...
133
+ plugins: [uml]
134
+ });
135
+ ```
136
+
137
+ #### With Viewer
138
+
139
+ ```js
140
+ const Viewer = toastui.Editor;
141
+ const { uml } = Viewer.plugin;
142
+
143
+ const viewer = new Viewer({
144
+ // ...
145
+ plugins: [uml]
146
+ });
147
+ ```
148
+
149
+ or
150
+
151
+ ```js
152
+ const { Editor } = toastui;
153
+ const { uml } = Editor.plugin;
154
+
155
+ const viewer = Editor.factory({
156
+ // ...
157
+ plugins: [uml],
158
+ viewer: true
159
+ });
160
+ ```
161
+
162
+ ### [Optional] Use Plugin with Options
163
+
164
+ The `uml` plugin can set options when used. Just add the plugin function and options related to the plugin to the array(`[pluginFn, pluginOptions]`) and push them to the `plugins` option of the editor.
165
+
166
+ The following option is available in the `uml` plugin.
167
+
168
+ | Name | Type | Default Value | Description |
169
+ | ------------- | -------- | ----------------------------------------- | ------------------------- |
170
+ | `rendererURL` | `string` | `'http://www.plantuml.com/plantuml/png/'` | URL of plant uml renderer |
171
+
172
+ ```js
173
+ // ...
174
+
175
+ import Editor from '@toast-ui/editor';
176
+ import uml from '@toast-ui/editor-plugin-uml';
177
+
178
+ const umlOptions = {
179
+ rendererURL: // ...
180
+ };
181
+
182
+ const editor = new Editor({
183
+ // ...
184
+ plugins: [[uml, umlOptions]]
185
+ });
186
+ ```
@@ -0,0 +1,142 @@
1
+ /*!
2
+ * TOAST UI Editor : UML Plugin
3
+ * @version 3.0.1 | Sun Dec 28 2025
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("plantuml-encoder"));
10
+ else if(typeof define === 'function' && define.amd)
11
+ define(["plantuml-encoder"], factory);
12
+ else if(typeof exports === 'object')
13
+ exports["toastui"] = factory(require("plantuml-encoder"));
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"]["uml"] = factory(root["plantuml-encoder"]);
16
+ })(self, function(__WEBPACK_EXTERNAL_MODULE__855__) {
17
+ return /******/ (function() { // webpackBootstrap
18
+ /******/ "use strict";
19
+ /******/ var __webpack_modules__ = ({
20
+
21
+ /***/ 855:
22
+ /***/ (function(module) {
23
+
24
+ module.exports = __WEBPACK_EXTERNAL_MODULE__855__;
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
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
87
+ !function() {
88
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
89
+ /* harmony export */ "default": function() { return /* binding */ umlPlugin; }
90
+ /* harmony export */ });
91
+ /* harmony import */ var plantuml_encoder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(855);
92
+ /* harmony import */ var plantuml_encoder__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(plantuml_encoder__WEBPACK_IMPORTED_MODULE_0__);
93
+ /**
94
+ * @fileoverview Implements uml plugin
95
+ * @author NHN FE Development Lab <dl_javascript@nhn.com>
96
+ */
97
+
98
+ var DEFAULT_RENDERER_URL = '//www.plantuml.com/plantuml/png/';
99
+ function createUMLTokens(text, rendererURL) {
100
+ var renderedHTML;
101
+ try {
102
+ if (!(plantuml_encoder__WEBPACK_IMPORTED_MODULE_0___default())) {
103
+ throw new Error('plantuml-encoder dependency required');
104
+ }
105
+ renderedHTML = "<img src=\"" + rendererURL + plantuml_encoder__WEBPACK_IMPORTED_MODULE_0___default().encode(text) + "\" />";
106
+ }
107
+ catch (err) {
108
+ renderedHTML = "Error occurred on encoding uml: " + err.message;
109
+ }
110
+ return [
111
+ { type: 'openTag', tagName: 'div', outerNewLine: true },
112
+ { type: 'html', content: renderedHTML },
113
+ { type: 'closeTag', tagName: 'div', outerNewLine: true },
114
+ ];
115
+ }
116
+ /**
117
+ * UML plugin
118
+ * @param {Object} context - plugin context for communicating with editor
119
+ * @param {Object} options - options for plugin
120
+ * @param {string} [options.rendererURL] - url of plant uml renderer
121
+ */
122
+ function umlPlugin(_, options) {
123
+ if (options === void 0) { options = {}; }
124
+ var _a = options.rendererURL, rendererURL = _a === void 0 ? DEFAULT_RENDERER_URL : _a;
125
+ return {
126
+ toHTMLRenderers: {
127
+ uml: function (node) {
128
+ return createUMLTokens(node.literal, rendererURL);
129
+ },
130
+ plantUml: function (node) {
131
+ return createUMLTokens(node.literal, rendererURL);
132
+ },
133
+ },
134
+ };
135
+ }
136
+
137
+ }();
138
+ __webpack_exports__ = __webpack_exports__["default"];
139
+ /******/ return __webpack_exports__;
140
+ /******/ })()
141
+ ;
142
+ });
package/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { PluginContext, PluginInfo } from '@licium/editor';
2
+
3
+ export interface PluginOptions {
4
+ rendererURL?: string;
5
+ }
6
+
7
+ export default function umlPlugin(context: PluginContext, options: PluginOptions): PluginInfo;
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@licium/editor-plugin-uml",
3
+ "version": "3.0.1",
4
+ "description": "TOAST UI Editor : UML Plugin",
5
+ "keywords": [
6
+ "nhn",
7
+ "nhn cloud",
8
+ "toast",
9
+ "toastui",
10
+ "toast-ui",
11
+ "editor",
12
+ "plugin",
13
+ "uml"
14
+ ],
15
+ "main": "dist/toastui-editor-plugin-uml.js",
16
+ "types": "index.d.ts",
17
+ "files": [
18
+ "dist/*.js",
19
+ "index.d.ts"
20
+ ],
21
+ "author": "NHN Cloud FE Development Lab <dl_javascript@nhn.com>",
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/nhn/tui.editor.git",
26
+ "directory": "plugins/uml"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/nhn/tui.editor/issues"
30
+ },
31
+ "homepage": "https://ui.toast.com",
32
+ "browserslist": "last 2 versions, not ie <= 10",
33
+ "scripts": {
34
+ "lint": "eslint .",
35
+ "test:types": "tsc",
36
+ "test": "jest --watch",
37
+ "test:ci": "jest",
38
+ "serve": "snowpack dev",
39
+ "serve:ie": "webpack serve",
40
+ "build:cdn": "webpack build --env cdn & webpack build --env cdn minify",
41
+ "build": "webpack build && npm run build:cdn"
42
+ },
43
+ "devDependencies": {
44
+ "@types/plantuml-encoder": "^1.4.0",
45
+ "cross-env": "^6.0.3"
46
+ },
47
+ "dependencies": {
48
+ "plantuml-encoder": "^1.4.0"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "gitHead": "cbc7cab7b3f081a1aaf1d338b8138512ace132b9"
54
+ }