@@ -43,9 +54,12 @@
import { Component, Emit, Prop, Watch } from "vue-property-decorator"
import FieldBase from "src/components/fields/_FieldBase"
+import { QEditor } from "quasar"
@Component({
- components: { }
+ components: {
+ existingDocumentDialog: () => import("src/components/dialogs/ExistingDocument.vue")
+ }
})
export default class Field_Wysiwyg extends FieldBase {
/****************************************************************/
@@ -145,6 +159,63 @@ export default class Field_Wysiwyg extends FieldBase {
/* eslint-enable */
}
+ existingObjectDialogTrigger: string | false = false
+
+ handleDocumentSelected (id: string) {
+ /*eslint-disable */
+ const editor = this.$refs[`wysiwygField${this.inputDataBluePrint.id}`] as any
+
+ editor.focus()
+ const doc = this.SGET_document(id)
+ // We need to timeout here to give time to the runtime to focus the editor.
+ // when focused the caret will return to it's previous position and we can insert the document link
+ setTimeout(() => {
+ editor.runCmd("insertHtml", `
${doc.label}`)
+ }, 1)
+ /* eslint-enable */
+ }
+
+ existingObjectDialogClose () {
+ this.existingObjectDialogTrigger = false
+ }
+
+ existingObjectAssignUID () {
+ this.existingObjectDialogTrigger = this.generateUID()
+ }
+
+ handleEditorKeypress (evt: any) {
+ /*eslint-disable */
+ if (evt.key === '@' && this.editMode) {
+ const editor = this.$refs[`wysiwygField${this.inputDataBluePrint.id}`] as QEditor
+
+ // We don't want to paste anything special in the source mode editor, let the user do their thing
+ if ((editor as any).isViewingSource)
+ return;
+
+ // Prevent showing up `@` character
+ evt.preventDefault()
+
+ // Open the selector dialog
+ this.existingObjectAssignUID()
+ }
+ /* eslint-enable */
+ }
+
+ handleEditorClick (evt: any) {
+ /*eslint-disable */
+ if (evt.target.tagName.toLowerCase() === 'a') {
+ // Only follow links when ctrl is pressed
+ if (evt.ctrlKey) {
+ const link = evt.target.href
+ console.log(link)
+ console.log(evt.target.tagName)
+ evt.stopPropagation()
+ this.openLink(link)
+ }
+ }
+ /* eslint-enable */
+ }
+
/**
* Subsitution strings for toolbar
*/