commit 4946a73cdfe0a2c6d1a45427a3d6bf66087e5439
parent 3d60aab3ca9eb89de9055020bb8b3257c011e036
Author: unitehenry <unitehenry@gmail.com>
Date: Thu, 24 Oct 2019 09:20:37 -0400
Vue Demo
Diffstat:
2 files changed, 59 insertions(+), 69 deletions(-)
diff --git a/demo/src/App.vue b/demo/src/App.vue
@@ -3,21 +3,14 @@
id="app"
style="font-family: Segoe UI; color: #2c3e50; margin-top: 20vh; display: flex; justify-content: center; align-items: center; flex-direction: column; padding: 0 1rem;"
>
- <striven-editor :placeholder="'Hey there'" v-model="notes" style="min-height:300px;"></striven-editor>
-
- <div style="display: flex; padding: 1rem; width: 100%; justify-content: center;">
- <!-- <div
- ref="editor"
- class="editor"
- style="margin-top: 20px; background-color: #fff; min-height: 300px; width: 600px;"
- ></div> -->
- <br/>
- {{notes}}
- <button @click="notes = null">Clear</button>
- </div>
- <div ref="customButton" class="custom-button" @click="sendContent">
- Send
- </div>
+ <striven-editor
+ ref="editor"
+ :placeholder="'Type something in here...'"
+ style="min-height:300px; width: 600px;"
+ meta-url="http://localhost:4200/meta"
+ :custom-toolbar-button="customButton"
+ ></striven-editor>
+ <div ref="customButton" class="custom-button" @click="sendContent">Send</div>
</div>
</template>
@@ -27,13 +20,10 @@ import { VueStrivenEditor as StrivenEditor } from "@striven-erp/striven-editor";
export default {
name: "app",
- components: {StrivenEditor},
- data(){
- return {notes: ''};
- },
- mounted() {
- const editorOptions = {
- metaUrl: "http://localhost:4200/meta",//"https://mighty-anchorage-82390.herokuapp.com/meta", // metaserver.js
+ components: { StrivenEditor },
+ data() {
+ return {
+ metaUrl: "http://localhost:4200/meta", //"https://mighty-anchorage-82390.herokuapp.com/meta", // metaserver.js
// imageUrl: "http://localhost:4200/image", // imageserver.js
minimal: true,
uploadOnPaste: false,
@@ -50,10 +40,8 @@ export default {
}
this.editor.body.blur();
},
- customToolbarButton: this.$refs.customButton
+ customButton: () => this.$refs.customButton
};
-
- this.editor = new StrivenEditor(this.$refs.editor, editorOptions);
},
methods: {
sendContent() {
diff --git a/src/vue-striveneditor.vue b/src/vue-striveneditor.vue
@@ -1,56 +1,58 @@
<template>
- <div ref="editor"></div>
+ <div ref="editor"></div>
</template>
<script>
import StrivenEditor from "./striveneditor";
export default {
- name: "striven-editor",
- props: {
- toolbarHide: Boolean,
- toolbarBottom: Boolean,
- minimal: Boolean,
- metaUrl: String,
- extensions: Array,
- uploadOnPaste: Boolean,
- toolbarOptionFillColor: String,
- placeholder: String,
- sanitizePaste: String,
- imageUrl: String,
- customToolbarOption: Object,
- activeOptionColor: String,
- submitOnEnter: Function,
- value: String
- },
- mounted() {
- let vm = this;
- // Create new object to avoid mutating props
- let config = {...vm.$props};
- vm.editor = new StrivenEditor(vm.$refs.editor, config);
- // Listen to input event for v-model support
- vm.editor.body.oninput = e => {
- vm.pauseUpdate = true;
- vm.$emit("input", vm.editor.getContent());
-
- };
- },
- data() {
- return {
- editor: {},
- pauseUpdate: false
- };
- },
- watch:{
- value(val){
- // Set the editor content when not modified from within the editor
- if (!this.pauseUpdate){
- this.editor.setContent(val);
- }
+ name: "striven-editor",
+ props: {
+ toolbarHide: Boolean,
+ toolbarBottom: Boolean,
+ minimal: Boolean,
+ metaUrl: String,
+ extensions: Array,
+ uploadOnPaste: Boolean,
+ toolbarOptionFillColor: String,
+ placeholder: String,
+ sanitizePaste: String,
+ imageUrl: String,
+ customToolbarOption: Object,
+ activeOptionColor: String,
+ submitOnEnter: Function,
+ value: String,
+ customToolbarButton: Function
+ },
+ mounted() {
+ let vm = this;
+ // Create new object to avoid mutating props
+ let config = { ...vm.$props, customToolbarButton: vm.customToolbarButton() };
- this.pauseUpdate = false;
- }
+ vm.editor = new StrivenEditor(vm.$refs.editor, config);
+
+ // Listen to input event for v-model support
+ vm.editor.body.oninput = e => {
+ vm.pauseUpdate = true;
+ vm.$emit("input", vm.editor.getContent());
+ };
+ },
+ data() {
+ return {
+ editor: {},
+ pauseUpdate: false
+ };
+ },
+ watch: {
+ value(val) {
+ // Set the editor content when not modified from within the editor
+ if (!this.pauseUpdate) {
+ this.editor.setContent(val);
+ }
+
+ this.pauseUpdate = false;
}
+ }
};
</script>