@techie_doubts/vue-editor 3.2.3

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 ADDED
@@ -0,0 +1,320 @@
1
+ # TOAST UI Editor for Vue
2
+
3
+ > This is [Vue](https://vuejs.org/) component wrapping [TOAST UI Editor](https://github.com/nhn/tui.editor/tree/master/apps/editor).
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@techie_doubts/vue-editor.svg)](https://www.npmjs.com/package/@techie_doubts/vue-editor)
6
+
7
+ ## 🚩 Table of Contents
8
+
9
+ - [Collect Statistics on the Use of Open Source](#collect-statistics-on-the-use-of-open-source)
10
+ - [Install](#-install)
11
+ - [Editor Usage](#-editor-usage)
12
+ - [Viewer Usage](#-viewer-usage)
13
+
14
+ ## Collect Statistics on the Use of Open Source
15
+
16
+ Vue Wrapper of TOAST UI Editor applies Google Analytics (GA) to collect statistics on the use of open source, in order to identify how widely TOAST UI Editor is used throughout the world. It also serves as important index to determine the future course of projects. location.hostname (e.g. ui.toast.com) is to be collected and the sole purpose is nothing but to measure statistics on the usage. To disable GA, use the following `usageStatistics` options when declare Vue Wrapper component.
17
+
18
+ ```js
19
+ const options = {
20
+ ...
21
+ usageStatistics: false
22
+ }
23
+ ```
24
+
25
+ ## 💾 Install
26
+
27
+ ### Using npm
28
+
29
+ ```sh
30
+ npm install --save @techie_doubts/vue-editor
31
+ ```
32
+
33
+ ## 📝 Editor Usage
34
+
35
+ ### Import
36
+
37
+ You can use Toast UI Editor for Vue as a ECMAScript module or a CommonJS module. As this module does not contain CSS files, you should import `td-editor.css` from `@techie_doubts/tui.editor.2026` in the script.
38
+
39
+ - ES Modules
40
+
41
+ ```js
42
+ import '@techie_doubts/tui.editor.2026/dist/td-editor.css';
43
+
44
+ import { Editor } from '@techie_doubts/vue-editor';
45
+ ```
46
+
47
+ - CommonJS
48
+
49
+ ```js
50
+ require('@techie_doubts/tui.editor.2026/dist/td-editor.css');
51
+
52
+ const { Editor } = require('@techie_doubts/vue-editor');
53
+ ```
54
+
55
+ ### Creating Component
56
+
57
+ First implement `<editor/>` in the template.
58
+
59
+ ```html
60
+ <template>
61
+ <editor />
62
+ </template>
63
+ ```
64
+
65
+ And then add `Editor` to the `components` in your component or Vue instance like this:
66
+
67
+ ```js
68
+ import '@techie_doubts/tui.editor.2026/dist/td-editor.css';
69
+
70
+ import { Editor } from '@techie_doubts/vue-editor';
71
+
72
+ export default {
73
+ components: {
74
+ editor: Editor
75
+ }
76
+ };
77
+ ```
78
+
79
+ or
80
+
81
+ ```js
82
+ import '@techie_doubts/tui.editor.2026/dist/td-editor.css';
83
+
84
+ import { Editor } from '@techie_doubts/vue-editor';
85
+
86
+ new Vue({
87
+ el: '#app',
88
+ components: {
89
+ editor: Editor
90
+ }
91
+ });
92
+ ```
93
+
94
+ ### Props
95
+
96
+ | Name | Type | Default | Description |
97
+ | --------------- | ------ | -------------------------- | --------------------------------------------------------- |
98
+ | initialValue | String | '' | Editor's initial value . |
99
+ | initialEditType | String | 'markdown' | Initial editor type (markdown, wysiwyg). |
100
+ | options | Object | following `defaultOptions` | Options of tui.editor. This is for initailize tui.editor. |
101
+ | height | String | '300px' | This prop can control the height of the editor. |
102
+ | previewStyle | String | 'vertical' | Markdown editor's preview style (tab, vertical). |
103
+
104
+ ```js
105
+ const defaultOptions = {
106
+ minHeight: '200px',
107
+ language: 'en-US',
108
+ useCommandShortcut: true,
109
+ usageStatistics: true,
110
+ hideModeSwitch: false,
111
+ toolbarItems: [
112
+ ['heading', 'bold', 'italic', 'strike'],
113
+ ['hr', 'quote'],
114
+ ['ul', 'ol', 'task', 'indent', 'outdent'],
115
+ ['table', 'image', 'link'],
116
+ ['code', 'codeblock'],
117
+ ['scrollSync'],
118
+ ]
119
+ };
120
+ ```
121
+
122
+ ```html
123
+ <template>
124
+ <editor
125
+ :initialValue="editorText"
126
+ :options="editorOptions"
127
+ height="500px"
128
+ initialEditType="wysiwyg"
129
+ previewStyle="vertical"
130
+ />
131
+ </template>
132
+ <script>
133
+ import '@techie_doubts/tui.editor.2026/dist/td-editor.css';
134
+
135
+ import { Editor } from '@techie_doubts/vue-editor';
136
+
137
+ export default {
138
+ components: {
139
+ editor: Editor
140
+ },
141
+ data() {
142
+ return {
143
+ editorText: 'This is initialValue.',
144
+ editorOptions: {
145
+ hideModeSwitch: true
146
+ }
147
+ };
148
+ }
149
+ };
150
+ </script>
151
+ ```
152
+
153
+ ### Instance Methods
154
+
155
+ If you want to more manipulate the Editor, you can use `invoke` method to call the method of toastui.editor. For more information of method, see [instance methods of TOAST UI Editor](https://nhn.github.io/tui.editor/latest/ToastUIEditor#addHook).
156
+
157
+ First, you need to assign `ref` attribute of `<editor/>` and then you can use `invoke` method through `this.$refs` like this:
158
+
159
+ ```html
160
+ <template>
161
+ <editor ref="toastuiEditor" />
162
+ </template>
163
+ <script>
164
+ import '@techie_doubts/tui.editor.2026/dist/td-editor.css';
165
+
166
+ import { Editor } from '@techie_doubts/vue-editor';
167
+
168
+ export default {
169
+ components: {
170
+ editor: Editor
171
+ },
172
+ methods: {
173
+ scroll() {
174
+ this.$refs.toastuiEditor.invoke('setScrollTop', 10);
175
+ },
176
+ moveTop() {
177
+ this.$refs.toastuiEditor.invoke('moveCursorToStart');
178
+ },
179
+ getHTML() {
180
+ let html = this.$refs.toastuiEditor.invoke('getHTML');
181
+ }
182
+ }
183
+ };
184
+ </script>
185
+ ```
186
+
187
+ ### Events
188
+
189
+ - load : It would be emitted when editor fully load
190
+ - change : It would be emitted when content changed
191
+ - caretChange : It would be emitted when format change by cursor position
192
+ - focus : It would be emitted when editor get focus
193
+ - blur : It would be emitted when editor loose focus
194
+
195
+ ```html
196
+ <template>
197
+ <editor
198
+ @load="onEditorLoad"
199
+ @focus="onEditorFocus"
200
+ @blur="onEditorBlur"
201
+ @change="onEditorChange"
202
+ @caretChange="onEditorCaretChange"
203
+ />
204
+ </template>
205
+ <script>
206
+ import { Editor } from '@techie_doubts/vue-editor';
207
+
208
+ export default {
209
+ components: {
210
+ editor: Editor
211
+ },
212
+ methods: {
213
+ onEditorLoad() {
214
+ // implement your code
215
+ },
216
+ onEditorFocus() {
217
+ // implement your code
218
+ },
219
+ onEditorBlur() {
220
+ // implement your code
221
+ },
222
+ onEditorChange() {
223
+ // implement your code
224
+ },
225
+ onEditorCaretChange() {
226
+ // implement your code
227
+ }
228
+ }
229
+ };
230
+ </script>
231
+ ```
232
+
233
+ ## 📃 Viewer Usage
234
+
235
+ ### Import
236
+
237
+ - ES Modules
238
+
239
+ ```js
240
+ import '@techie_doubts/tui.editor.2026/dist/td-editor-viewer.css';
241
+
242
+ import { Viewer } from '@techie_doubts/vue-editor';
243
+ ```
244
+
245
+ - CommonJS
246
+
247
+ ```js
248
+ require('@techie_doubts/tui.editor.2026/dist/td-editor-viewer.css');
249
+
250
+ const { Viewer } = require('@techie_doubts/vue-editor');
251
+ ```
252
+
253
+ ### Creating Component
254
+
255
+ First implement `<viewer />` in the template.
256
+
257
+ ```html
258
+ <template>
259
+ <viewer />
260
+ </template>
261
+ ```
262
+
263
+ And then add `Viewer` to the `components` in your component or Vue instance like this:
264
+
265
+ ```js
266
+ import '@techie_doubts/tui.editor.2026/dist/td-editor-viewer.css';
267
+
268
+ import { Viewer } from '@techie_doubts/vue-editor';
269
+
270
+ export default {
271
+ components: {
272
+ viewer: Viewer
273
+ }
274
+ };
275
+ ```
276
+
277
+ or
278
+
279
+ ```js
280
+ import '@techie_doubts/tui.editor.2026/dist/td-editor-viewer.css';
281
+
282
+ import { Viewer } from '@techie_doubts/vue-editor';
283
+
284
+ new Vue({
285
+ el: '#app',
286
+ components: {
287
+ viewer: Viewer
288
+ }
289
+ });
290
+ ```
291
+
292
+ ### Props
293
+
294
+ | Name | Type | Default | Description |
295
+ | ------------ | ------ | ------- | ----------------------------------------------- |
296
+ | initialValue | String | '' | Viewer's initial value |
297
+ | height | String | '300px' | This prop can control the height of the viewer. |
298
+ | options | Object | above `defaultOptions` | Options of tui.editor. This is for initailize tui.editor. |
299
+
300
+ ```html
301
+ <template>
302
+ <viewer :initialValue="viewerText" height="500px" />
303
+ </template>
304
+ <script>
305
+ import '@techie_doubts/tui.editor.2026/dist/td-editor-viewer.css';
306
+
307
+ import { Viewer } from '@techie_doubts/vue-editor';
308
+
309
+ export default {
310
+ components: {
311
+ viewer: Viewer
312
+ },
313
+ data() {
314
+ return {
315
+ viewerText: '# This is Viewer.\n Hello World.'
316
+ };
317
+ }
318
+ };
319
+ </script>
320
+ ```