commit f646b8bc0aaf5b80e5da6b06197f7b5dfbdae5c7
parent 2bd329d42e6a0773795d0064f476633734d3889f
Author: Henry Unite <unitehenry@gmail.com>
Date: Mon, 3 Aug 2020 10:34:50 -0400
onPaste and afterPaste exposed events
Diffstat:
4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/demo/src/App.vue b/demo/src/App.vue
@@ -9,12 +9,11 @@
:toolbar-hide="toolbarHide"
:minimal="minimal"
:toolbar-bottom="toolbarBottom"
- :toolbar-options="toolbarOptions"
:placeholder="'Type something in here...'"
style="min-height: 300px; width: 90%;"
- :meta-url="metaUrl"
:on-enter="submitOnEnter"
- :toolbar-template="customButton"
+ :on-paste="onPaste"
+ :after-paste="afterPaste"
></striven-editor>
<!-- TESTING -->
@@ -38,7 +37,7 @@ export default {
components: { StrivenEditor },
data() {
return {
- metaUrl: "https://mighty-anchorage-82390.herokuapp.com/meta", // metaserver.js
+ // metaUrl: "https://mighty-anchorage-82390.herokuapp.com/meta", // metaserver.js
// imageUrl: "http://localhost:4200/image", // imageserver.js
minimal: false,
uploadOnPaste: false,
@@ -73,14 +72,23 @@ export default {
}
},
// customButton: () => this.$refs.customButton,
- editor: null,
- content: ""
+ content: "",
+ editor: null
};
},
mounted() {
this.editor = this.$refs.editor.editor;
},
methods: {
+ afterPaste() {
+ setTimeout(() => {
+ [...this.editor.body.querySelectorAll('.striven-mention')]
+ .forEach(m => (m.outerHTML = m.textContent));
+ }, 0);
+ },
+ onPaste(e) {
+ console.log(e);
+ },
sendContent() {
console.log(this.editor.getContent());
this.editor.clearContent();
diff --git a/package-lock.json b/package-lock.json
@@ -2851,14 +2851,6 @@
}
}
},
- "@simonwep/pickr": {
- "version": "1.5.0",
- "resolved": "https://registry.npmjs.org/@simonwep/pickr/-/pickr-1.5.0.tgz",
- "integrity": "sha512-WamaJhF9XfhvQ+nG18T3SoJgetsp219FVvz4SVuIdyptpwME1teLY77/Hqq5jaRS4vNd+XsOuQuWzBKcGvF0Ug==",
- "requires": {
- "core-js": "^3.6.2"
- }
- },
"@sindresorhus/is": {
"version": "0.14.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
@@ -4099,11 +4091,6 @@
"integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=",
"dev": true
},
- "core-js": {
- "version": "3.6.4",
- "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.4.tgz",
- "integrity": "sha512-4paDGScNgZP2IXXilaffL9X7968RuvwlkK3xWtZRVqgd8SYNiVKRJvkFd1aqqEuPfN7E68ZHEp9hDj6lHj4Hyw=="
- },
"core-js-compat": {
"version": "3.6.5",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.6.5.tgz",
diff --git a/src/striveneditor.js b/src/striveneditor.js
@@ -1012,6 +1012,9 @@ export default class StrivenEditor {
}
}
+ // Editor Paste Handler
+ this.options.onPaste && this.options.onPaste(e);
+
// After the paste
setTimeout(() => {
// Prune inline styles
@@ -1019,6 +1022,9 @@ export default class StrivenEditor {
// Convert all the links
this.convertAndSelectLinks();
+
+ // Editor After Paste Handler
+ this.options.afterPaste && this.options.afterPaste(e);
}, 10);
this.overflow();
diff --git a/src/vue-striveneditor.vue b/src/vue-striveneditor.vue
@@ -23,7 +23,9 @@ export default {
activeOptionColor: String,
onEnter: Function,
value: String,
- toolbarTemplate: Function
+ toolbarTemplate: Function,
+ onPaste: Function,
+ afterPaste: Function
},
mounted() {
let vm = this;