|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <demo |
| 4 | + :demoComp="demoComp" |
| 5 | + :demoEvents="demoEvents" |
| 6 | + :demoMethods="demoMethods" |
| 7 | + :demoProps="demoProps" |
| 8 | + ></demo> |
| 9 | + </div> |
| 10 | +</template> |
| 11 | + |
| 12 | +<script> |
| 13 | +import Demo from '@/views/templates/Demo'; |
| 14 | +
|
| 15 | +export default { |
| 16 | + components: { |
| 17 | + Demo, |
| 18 | + }, |
| 19 | + name: 'EditorDemo', |
| 20 | + data() { |
| 21 | + return { |
| 22 | + demoComp: createComp(), |
| 23 | + demoEvents: [ |
| 24 | + { |
| 25 | + name: 'kup-editor-autosave', |
| 26 | + type: 'CustomEvent', |
| 27 | + }, |
| 28 | + { |
| 29 | + name: 'kup-editor-ready', |
| 30 | + type: 'CustomEvent', |
| 31 | + }, |
| 32 | + { |
| 33 | + name: 'kup-editor-save', |
| 34 | + type: 'CustomEvent', |
| 35 | + }, |
| 36 | + ], |
| 37 | + demoMethods: [ |
| 38 | + { |
| 39 | + name: 'getProps', |
| 40 | + description: |
| 41 | + "Returns the props' values of the component. When invoked giving true as the only argument, returns the props descriptions instead.", |
| 42 | + }, |
| 43 | + { |
| 44 | + name: 'getValueAsHTML', |
| 45 | + description: `Returns the component's internal value as html.`, |
| 46 | + }, |
| 47 | + { |
| 48 | + name: 'getValueAsMarkdown', |
| 49 | + description: `Returns the component's internal value as markdown.`, |
| 50 | + }, |
| 51 | + { |
| 52 | + name: 'refresh', |
| 53 | + description: |
| 54 | + 'This method is used to trigger a new render of the component.', |
| 55 | + }, |
| 56 | + { |
| 57 | + name: 'setProps', |
| 58 | + description: 'Sets the props to the component.', |
| 59 | + }, |
| 60 | + ], |
| 61 | + demoProps: [ |
| 62 | + { |
| 63 | + prop: 'autosaveTimer', |
| 64 | + description: |
| 65 | + 'When specified, the component will emit the kup-editor-save event at regular intervals.', |
| 66 | + type: 'number', |
| 67 | + default: 'undefined', |
| 68 | + try: 'field', |
| 69 | + }, |
| 70 | + { |
| 71 | + prop: 'editorHeight', |
| 72 | + description: 'Sets the height of the component.', |
| 73 | + type: 'string', |
| 74 | + default: '"auto"', |
| 75 | + try: 'field', |
| 76 | + }, |
| 77 | + { |
| 78 | + prop: 'initialEditType', |
| 79 | + description: |
| 80 | + 'The editor type. Supported values: "markdown", "wysiwyg".', |
| 81 | + type: 'KupEditorType', |
| 82 | + default: 'markdown', |
| 83 | + try: 'field', |
| 84 | + }, |
| 85 | + { |
| 86 | + prop: 'initialValue', |
| 87 | + description: 'The initial editor value.', |
| 88 | + type: 'string', |
| 89 | + default: '""', |
| 90 | + try: 'field', |
| 91 | + }, |
| 92 | + { |
| 93 | + prop: 'isReadOnly', |
| 94 | + description: 'Defines whether the editor is disabled or not.', |
| 95 | + type: 'boolean', |
| 96 | + default: 'false', |
| 97 | + try: 'switch', |
| 98 | + }, |
| 99 | + { |
| 100 | + prop: 'previewStyle', |
| 101 | + description: |
| 102 | + 'The editor preview style. Supported values: "tab", "vertical".', |
| 103 | + type: 'KupEditorPreview', |
| 104 | + default: 'vertical', |
| 105 | + try: 'field', |
| 106 | + }, |
| 107 | + { |
| 108 | + prop: 'showSaveButton', |
| 109 | + description: `Defines whether to show the save button in editor's toolbar or not.`, |
| 110 | + type: 'boolean', |
| 111 | + default: 'true', |
| 112 | + try: 'switch', |
| 113 | + }, |
| 114 | + { |
| 115 | + prop: 'showToolbar', |
| 116 | + description: `Defines whether to show the editor's toolbar or not.`, |
| 117 | + type: 'string', |
| 118 | + default: 'boolean', |
| 119 | + try: 'switch', |
| 120 | + }, |
| 121 | + ], |
| 122 | + }; |
| 123 | + }, |
| 124 | +}; |
| 125 | +
|
| 126 | +function createComp() { |
| 127 | + const comp = document.createElement('kup-editor'); |
| 128 | + comp.id = 'demo-component'; |
| 129 | +
|
| 130 | + comp.initialEditType = 'markdown'; |
| 131 | + comp.initialValue = `<p><img src="https://uicdn.toast.com/toastui/img/tui-editor-bi.png" alt="image"></p> |
| 132 | + <h1>Awesome Editor!</h1> |
| 133 | + <p>It has been <em>released as opensource in 2018</em> and has <del>continually</del> evolved to <strong>receive 10k GitHub ⭐️ Stars</strong>.</p> |
| 134 | + <h2>Create Instance</h2> |
| 135 | + <p>You can create an instance with the following code and use <code data-backticks="1">getHtml()</code> and <code data-backticks="1">getMarkdown()</code> of the <a href="https://github.com/nhn/tui.editor">Editor</a>.</p> |
| 136 | + <pre class="lang-js"><code data-language="js">co |
| 137 | +
|
| 138 | + > See the table below for default options |
| 139 | + > > More API information can be found in the document |
| 140 | +
|
| 141 | + | name | type | description | |
| 142 | + | --- | --- | --- | |
| 143 | + | el | HTMLElement | container element | |
| 144 | +
|
| 145 | + ## Featuress |
| 146 | +
|
| 147 | + * CommonMark + GFM Specifications |
| 148 | + * Live Preview |
| 149 | + * Scroll Sync |
| 150 | + * Auto Indent |
| 151 | + * Syntax Highlight |
| 152 | + 1. Markdown |
| 153 | + 2. Preview |
| 154 | +
|
| 155 | + ## Support Wrappers |
| 156 | +
|
| 157 | + > * Wrappers |
| 158 | + > 1. [x] React |
| 159 | + > 2. [x] Vue |
| 160 | + > 3. [ ] Ember<p>My Custom value for editor</p> |
| 161 | + </code></pre> |
| 162 | + `; |
| 163 | + comp.isReadOnly = false; |
| 164 | + comp.previewStyle = 'vertical'; |
| 165 | + comp.showSaveButton = true; |
| 166 | + comp.showToolbar = true; |
| 167 | +
|
| 168 | + return comp; |
| 169 | +} |
| 170 | +</script> |
0 commit comments