@licium/editor-plugin-chart 3.0.2

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,217 @@
1
+ # TOAST UI Editor : Chart Plugin
2
+
3
+ > This is a plugin of [TOAST UI Editor](https://github.com/nhn/tui.editor/tree/master/apps/editor) to render chart.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@toast-ui/editor-plugin-chart.svg)](https://www.npmjs.com/package/@toast-ui/editor-plugin-chart)
6
+
7
+ ![chart](https://user-images.githubusercontent.com/37766175/121808323-d8d41000-cc92-11eb-9117-b92a435c9b43.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-chart/
23
+ - dist/
24
+ - toastui-editor-plugin-chart.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-chart/
34
+ - latest/
35
+ - toastui-editor-plugin-chart.js
36
+ - toastui-editor-plugin-chart.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-chart
49
+ ```
50
+
51
+ ### Import Plugin
52
+
53
+ Along with the plugin, the plugin's dependency style must be imported. The `chart` plugin has [TOAST UI Chart](https://github.com/nhn/tui.chart) as a dependency, and you need to add a CSS file of TOAST UI Chart.
54
+
55
+ #### ES Modules
56
+
57
+ ```js
58
+ import '@toast-ui/chart/dist/toastui-chart.css';
59
+
60
+ import chart from '@toast-ui/editor-plugin-chart';
61
+ ```
62
+
63
+ #### CommonJS
64
+
65
+ ```js
66
+ require('@toast-ui/chart/dist/toastui-chart.css');
67
+
68
+ const chart = require('@toast-ui/editor-plugin-chart');
69
+ ```
70
+
71
+ ### Create Instance
72
+
73
+ #### Basic
74
+
75
+ ```js
76
+ // ...
77
+ import '@toast-ui/chart/dist/toastui-chart.css';
78
+
79
+ import Editor from '@toast-ui/editor';
80
+ import chart from '@toast-ui/editor-plugin-chart';
81
+
82
+ const editor = new Editor({
83
+ // ...
84
+ plugins: [chart]
85
+ });
86
+ ```
87
+
88
+ #### With Viewer
89
+
90
+ ```js
91
+ // ...
92
+ import '@toast-ui/chart/dist/toastui-chart.css';
93
+
94
+ import Viewer from '@toast-ui/editor/dist/toastui-editor-viewer';
95
+ import chart from '@toast-ui/editor-plugin-chart';
96
+
97
+ const viewer = new Viewer({
98
+ // ...
99
+ plugins: [chart]
100
+ });
101
+ ```
102
+
103
+ or
104
+
105
+ ```js
106
+ // ...
107
+ import '@toast-ui/chart/dist/toastui-chart.css';
108
+
109
+ import Editor from '@toast-ui/editor';
110
+ import chart from '@toast-ui/editor-plugin-chart';
111
+
112
+ const viewer = Editor.factory({
113
+ // ...
114
+ plugins: [chart],
115
+ viewer: true
116
+ });
117
+ ```
118
+
119
+ ## 🗂 Usage CDN
120
+
121
+ To use the plugin, the CDN files(CSS, Script) of `@toast-ui/editor` must be included.
122
+
123
+ ### Include Files
124
+
125
+ ```html
126
+ ...
127
+ <head>
128
+ ...
129
+ <link rel="stylesheet" href="https://uicdn.toast.com/chart/latest/toastui-chart.min.css" />
130
+ ...
131
+ </head>
132
+ <body>
133
+ ...
134
+ <!-- Chart -->
135
+ <script src="https://uicdn.toast.com/chart/latest/toastui-chart.min.js"></script>
136
+ <!-- Editor -->
137
+ <script src="https://uicdn.toast.com/editor/latest/toastui-editor-all.min.js"></script>
138
+ <!-- Editor's Plugin -->
139
+ <script src="https://uicdn.toast.com/editor-plugin-chart/latest/toastui-editor-plugin-chart.min.js"></script>
140
+ ...
141
+ </body>
142
+ ```
143
+
144
+ ### Create Instance
145
+
146
+ #### Basic
147
+
148
+ ```js
149
+ const { Editor } = toastui;
150
+ const { chart } = Editor.plugin;
151
+
152
+ const editor = new Editor({
153
+ // ...
154
+ plugins: [chart]
155
+ });
156
+ ```
157
+
158
+ #### With Viewer
159
+
160
+ ```js
161
+ const Viewer = toastui.Editor;
162
+ const { chart } = Viewer.plugin;
163
+
164
+ const viewer = new Viewer({
165
+ // ...
166
+ plugins: [chart]
167
+ });
168
+ ```
169
+
170
+ or
171
+
172
+ ```js
173
+ const { Editor } = toastui;
174
+ const { chart } = Editor.plugin;
175
+
176
+ const viewer = Editor.factory({
177
+ // ...
178
+ plugins: [chart],
179
+ viewer: true
180
+ });
181
+ ```
182
+
183
+ ### [Optional] Use Plugin with Options
184
+
185
+ The `chart` 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.
186
+
187
+ The following options are available in the `chart` plugin.
188
+ These options are used to set the dimensions of the chart drawn in the editor.
189
+
190
+ | Name | Type | Default Value | Description |
191
+ | ----------- | ---------------- | ------------- | -------------------- |
192
+ | `width` | `number\|string` | `'auto'` | Default width value |
193
+ | `height` | `number\|string` | `'auto'` | Default height value |
194
+ | `minWidth` | `number` | `0` | Minimum width value |
195
+ | `minHeight` | `number` | `0` | Minimum height value |
196
+ | `maxWidth` | `number` | `Infinity` | Maximum width value |
197
+ | `maxHeight` | `number` | `Infinity` | Maximum height value |
198
+
199
+ ```js
200
+ // ...
201
+ import '@toast-ui/chart/dist/toastui-chart.css';
202
+
203
+ import Editor from '@toast-ui/editor';
204
+ import chart from '@toast-ui/editor-plugin-chart';
205
+
206
+ const chartOptions = {
207
+ minWidth: 100,
208
+ maxWidth: 600,
209
+ minHeight: 100,
210
+ maxHeight: 300
211
+ };
212
+
213
+ const editor = new Editor({
214
+ // ...
215
+ plugins: [[chart, chartOptions]]
216
+ });
217
+ ```