Skip to content

Commit

Permalink
insert transcription where cruser is
Browse files Browse the repository at this point in the history
  • Loading branch information
MooseSaeed committed Apr 3, 2022
1 parent 1277757 commit ee9f267
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
23 changes: 20 additions & 3 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17753,7 +17753,7 @@ __webpack_require__.r(__webpack_exports__);
});

if (!_this.keyIncluded) {
textarea.value += transcript + " ";
_this.insertAtCursor(textarea, transcript + " ");
} else {
_this.transcript = transcript;

Expand All @@ -17764,6 +17764,23 @@ __webpack_require__.r(__webpack_exports__);
}
};
});
},
insertAtCursor: function insertAtCursor(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
} //MOZILLA and others
else if (myField.selectionStart || myField.selectionStart == "0") {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
myField.selectionStart = startPos + myValue.length;
myField.selectionEnd = startPos + myValue.length;
} else {
myField.value += myValue;
}
}
}
});
Expand Down Expand Up @@ -19652,8 +19669,8 @@ var MarkdownTableButtonElement = /*#__PURE__*/function (_MarkdownButtonElemen8)

_this9 = _super9.call(this);
styles.set(_assertThisInitialized(_this9), {
prefix: "| Cool Header | Cool Header | \n",
suffix: "| ----------------- | ------------------ |\n| Content Cell | Content Cell |",
prefix: "| Cool Header | Cool Header |\n",
suffix: "| ------------ | ----------- |\n| Content | Content |",
surroundWithNewlines: true
});
return _this9;
Expand Down
2 changes: 1 addition & 1 deletion public/markdowntoolbar/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare global {
MarkdownStrikethroughButtonElement: typeof MarkdownStrikethroughButtonElement;
MarkdownTableButtonElement: typeof MarkdownTableButtonElement;
MarkdownUnderlineButtonElement: typeof MarkdownUnderlineButtonElement;
MarkdownNextLineButtonElement: typeof MarkdownUnderlineButtonElement;
MarkdownNextLineButtonElement: typeof MarkdownNextLineButtonElement;
}
interface HTMLElementTagNameMap {
"markdown-toolbar": MarkdownToolbarElement;
Expand Down
4 changes: 2 additions & 2 deletions public/markdowntoolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class MarkdownTableButtonElement extends MarkdownButtonElement {
constructor() {
super();
styles.set(this, {
prefix: "| Cool Header | Cool Header | \n",
suffix: "| ----------------- | ------------------ |\n| Content Cell | Content Cell |",
prefix: "| Cool Header | Cool Header |\n",
suffix: "| ------------ | ----------- |\n| Content | Content |",
surroundWithNewlines: true,
});
}
Expand Down
23 changes: 22 additions & 1 deletion resources/js/components/Markdowntoolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export default {
});
if (!this.keyIncluded) {
textarea.value += transcript + " ";
this.insertAtCursor(textarea, transcript + " ");
} else {
this.transcript = transcript;
this.vocalCommands();
Expand All @@ -383,6 +383,27 @@ export default {
};
});
},
insertAtCursor(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA and others
else if (myField.selectionStart || myField.selectionStart == "0") {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value =
myField.value.substring(0, startPos) +
myValue +
myField.value.substring(endPos, myField.value.length);
myField.selectionStart = startPos + myValue.length;
myField.selectionEnd = startPos + myValue.length;
} else {
myField.value += myValue;
}
},
},
};
</script>
Expand Down

0 comments on commit ee9f267

Please sign in to comment.