Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
refactor: tabsize 4 to 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohee Lee committed Mar 25, 2019
1 parent 00bb7b3 commit 3bc692e
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 244 deletions.
98 changes: 49 additions & 49 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"babel-eslint": "^9.0.0",
"babel-loader": "^8.0.2",
"eslint": "^5.5.0",
"eslint-config-tui": "^1.0.3",
"eslint-config-tui": "^2.1.0",
"eslint-loader": "^2.1.0",
"eslint-plugin-vue": "^4.7.1",
"vue": "^2.5.17",
Expand Down
218 changes: 109 additions & 109 deletions src/Editor.vue
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>
90 changes: 45 additions & 45 deletions src/Viewer.vue
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>
Loading

0 comments on commit 3bc692e

Please sign in to comment.