This repository has been archived by the owner on Apr 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sohee Lee
committed
Mar 25, 2019
1 parent
00bb7b3
commit 3bc692e
Showing
8 changed files
with
244 additions
and
244 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,127 @@ | ||
<template> | ||
<div ref="tuiEditor"></div> | ||
<div ref="tuiEditor"></div> | ||
</template> | ||
<script> | ||
import Editor from 'tui-editor'; | ||
import Editor from "tui-editor"; | ||
import editorEvents from './editorEvents'; | ||
import editorDefaultOptions from './editorDefaultOptions'; | ||
import valueUpdateMethod from './valueUpdateMethod'; | ||
import editorEvents from "./editorEvents"; | ||
import editorDefaultOptions from "./editorDefaultOptions"; | ||
import valueUpdateMethod from "./valueUpdateMethod"; | ||
export default { | ||
name: 'TuiEditor', | ||
props: { | ||
previewStyle: { | ||
type: String, | ||
default: 'tab' | ||
}, | ||
height: { | ||
type: String, | ||
default: '300px' | ||
}, | ||
value: { | ||
type: String, | ||
default: '' | ||
}, | ||
mode: { | ||
type: String, | ||
default: 'markdown' | ||
}, | ||
options: { | ||
type: Object, | ||
default() { | ||
return editorDefaultOptions; | ||
} | ||
}, | ||
html: { | ||
type: String | ||
}, | ||
visible: { | ||
type: Boolean, | ||
default: true | ||
} | ||
name: "TuiEditor", | ||
props: { | ||
previewStyle: { | ||
type: String, | ||
default: "tab" | ||
}, | ||
data() { | ||
return { | ||
editor: null | ||
}; | ||
height: { | ||
type: String, | ||
default: "300px" | ||
}, | ||
computed: { | ||
editorOptions() { | ||
const options = Object.assign({}, editorDefaultOptions, this.options); | ||
options.initialValue = this.value; | ||
options.initialEditType = this.mode; | ||
options.height = this.height; | ||
options.previewStyle = this.previewStyle; | ||
return options; | ||
} | ||
value: { | ||
type: String, | ||
default: "" | ||
}, | ||
watch: { | ||
previewStyle(newValue) { | ||
this.editor.changePreviewStyle(newValue); | ||
}, | ||
value(newValue, preValue) { | ||
if (newValue !== preValue && newValue !== this.editor.getValue()) { | ||
this.editor.setValue(newValue); | ||
} | ||
}, | ||
height(newValue) { | ||
this.editor.height(newValue); | ||
}, | ||
mode(newValue) { | ||
this.editor.changeMode(newValue); | ||
}, | ||
html(newValue) { | ||
this.editor.setHtml(newValue); | ||
this.$emit('input', this.editor.getValue()); | ||
}, | ||
visible(newValue) { | ||
if (newValue) { | ||
this.editor.show(); | ||
} else { | ||
this.editor.hide(); | ||
} | ||
} | ||
mode: { | ||
type: String, | ||
default: "markdown" | ||
}, | ||
mounted() { | ||
const eventOption = {}; | ||
editorEvents.forEach(event => { | ||
eventOption[event] = (...args) => { | ||
this.$emit(event, ...args); | ||
}; | ||
}); | ||
const options = Object.assign(this.editorOptions, { | ||
el: this.$refs.tuiEditor, | ||
events: eventOption | ||
}); | ||
options: { | ||
type: Object, | ||
default() { | ||
return editorDefaultOptions; | ||
} | ||
}, | ||
html: { | ||
type: String | ||
}, | ||
visible: { | ||
type: Boolean, | ||
default: true | ||
} | ||
}, | ||
data() { | ||
return { | ||
editor: null | ||
}; | ||
}, | ||
computed: { | ||
editorOptions() { | ||
const options = Object.assign({}, editorDefaultOptions, this.options); | ||
options.initialValue = this.value; | ||
options.initialEditType = this.mode; | ||
options.height = this.height; | ||
options.previewStyle = this.previewStyle; | ||
this.editor = new Editor(options); | ||
if (this.$listeners.input) { | ||
this.editor.on('change', () => { | ||
this.$emit('input', this.editor.getValue()); | ||
}); | ||
} | ||
return options; | ||
} | ||
}, | ||
watch: { | ||
previewStyle(newValue) { | ||
this.editor.changePreviewStyle(newValue); | ||
}, | ||
value(newValue, preValue) { | ||
if (newValue !== preValue && newValue !== this.editor.getValue()) { | ||
this.editor.setValue(newValue); | ||
} | ||
}, | ||
height(newValue) { | ||
this.editor.height(newValue); | ||
}, | ||
mode(newValue) { | ||
this.editor.changeMode(newValue); | ||
}, | ||
destroyed() { | ||
editorEvents.forEach(event => { | ||
this.editor.off(event); | ||
}); | ||
this.editor.remove(); | ||
html(newValue) { | ||
this.editor.setHtml(newValue); | ||
this.$emit("input", this.editor.getValue()); | ||
}, | ||
methods: { | ||
invoke(methodName, ...args) { | ||
let result = null; | ||
if (this.editor[methodName]) { | ||
result = this.editor[methodName](...args); | ||
if (valueUpdateMethod.indexOf(methodName) > -1) { | ||
this.$emit('input', this.editor.getValue()); | ||
} | ||
} | ||
visible(newValue) { | ||
if (newValue) { | ||
this.editor.show(); | ||
} else { | ||
this.editor.hide(); | ||
} | ||
} | ||
}, | ||
mounted() { | ||
const eventOption = {}; | ||
editorEvents.forEach(event => { | ||
eventOption[event] = (...args) => { | ||
this.$emit(event, ...args); | ||
}; | ||
}); | ||
const options = Object.assign(this.editorOptions, { | ||
el: this.$refs.tuiEditor, | ||
events: eventOption | ||
}); | ||
return result; | ||
this.editor = new Editor(options); | ||
if (this.$listeners.input) { | ||
this.editor.on("change", () => { | ||
this.$emit("input", this.editor.getValue()); | ||
}); | ||
} | ||
}, | ||
destroyed() { | ||
editorEvents.forEach(event => { | ||
this.editor.off(event); | ||
}); | ||
this.editor.remove(); | ||
}, | ||
methods: { | ||
invoke(methodName, ...args) { | ||
let result = null; | ||
if (this.editor[methodName]) { | ||
result = this.editor[methodName](...args); | ||
if (valueUpdateMethod.indexOf(methodName) > -1) { | ||
this.$emit("input", this.editor.getValue()); | ||
} | ||
} | ||
return result; | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
<template> | ||
<div ref="tuiEditorViewer"></div> | ||
<div ref="tuiEditorViewer"></div> | ||
</template> | ||
<script> | ||
import Viewer from 'tui-editor/dist/tui-editor-Viewer'; | ||
import Viewer from "tui-editor/dist/tui-editor-Viewer"; | ||
import editorEvents from './editorEvents'; | ||
import editorEvents from "./editorEvents"; | ||
export default { | ||
name: 'TuiEditorViewer', | ||
props: { | ||
height: { | ||
type: String, | ||
default: '300px' | ||
}, | ||
value: { | ||
type: String, | ||
default: '' | ||
} | ||
name: "TuiEditorViewer", | ||
props: { | ||
height: { | ||
type: String, | ||
default: "300px" | ||
}, | ||
data() { | ||
return { | ||
editor: null | ||
}; | ||
}, | ||
watch: { | ||
value(val, preVal) { | ||
if (val !== preVal) { | ||
this.editor.setValue(val); | ||
} | ||
} | ||
}, | ||
mounted() { | ||
const eventOption = {}; | ||
editorEvents.forEach(event => { | ||
eventOption[event] = (...args) => { | ||
this.$emit(event, ...args); | ||
}; | ||
}); | ||
this.editor = new Viewer({ | ||
el: this.$refs.tuiEditorViewer, | ||
events: eventOption, | ||
initialValue: this.value, | ||
height: this.height | ||
}); | ||
}, | ||
destroyed() { | ||
editorEvents.forEach(event => { | ||
this.editor.off(event); | ||
}); | ||
this.editor.remove(); | ||
value: { | ||
type: String, | ||
default: "" | ||
} | ||
}, | ||
data() { | ||
return { | ||
editor: null | ||
}; | ||
}, | ||
watch: { | ||
value(val, preVal) { | ||
if (val !== preVal) { | ||
this.editor.setValue(val); | ||
} | ||
} | ||
}, | ||
mounted() { | ||
const eventOption = {}; | ||
editorEvents.forEach(event => { | ||
eventOption[event] = (...args) => { | ||
this.$emit(event, ...args); | ||
}; | ||
}); | ||
this.editor = new Viewer({ | ||
el: this.$refs.tuiEditorViewer, | ||
events: eventOption, | ||
initialValue: this.value, | ||
height: this.height | ||
}); | ||
}, | ||
destroyed() { | ||
editorEvents.forEach(event => { | ||
this.editor.off(event); | ||
}); | ||
this.editor.remove(); | ||
} | ||
}; | ||
</script> |
Oops, something went wrong.