mathlive
Version:
Render and edit beautifully typeset math
3 lines (2 loc) • 1.73 kB
JavaScript
/* MathLive 0.59.0 */
var t={name:"mathlive-mathfield",template:'<div class="mathfield" :id="id"><slot></slot></div>',props:{id:{type:String,default:""},value:{type:String,default:""},options:{type:Object,default:()=>({})},onKeystroke:{type:Function,default:function(t,e){return!0}},onMoveOutOf:{type:Function,default:function(t){return!0}},onTabOutOf:{type:Function,default:function(t){return!0}}},install:function(t,e){Object.defineProperty(t.prototype,"$mathlive",{value:e}),t.component("mathlive-mathfield",this)},watch:{value:function(t,e){t!==e&&this.$el.mathfield.setValue(t,{suppressChangeNotifications:!0})},options:{deep:!0,handler:function(t){this.$el.mathfield.setOptions(t)}}},mounted:function(){this.$nextTick(()=>{this.$mathlive.makeMathField(this.$el,{...this.options,onContentDidChange:t=>{this.$emit("input",this.$el.mathfield.getValue())},onFocus:t=>{this.$emit("focus")},onBlur:t=>{this.$emit("blur")},onUndoStateDidChange:(t,e)=>{this.$emit("undo-state-did-change",e)},onVirtualKeyboardToggle:(t,e,i)=>{this.$emit("virtual-keyboard-toggle",e,i)},onReadAloudStatus:(t,e)=>{this.$emit("read-aloud-status-change",e)},onKeystroke:(t,e,i)=>this.onKeystroke(e,i),onMoveOutOf:(t,e)=>this.onMoveOutOf(e),onTabOutOf:(t,e)=>this.onTabOutOf(e)})})},methods:{executeCommand:function(t){this.$el.mathfield.executeCommand(t)},hasFocus:function(){return this.$el.mathfield.hasFocus()},focus:function(){this.$el.mathfield.focus()},blur:function(){this.$el.mathfield.blur()},getValue:function(t){return this.$el.mathfield.getValue(t)},selectedText:function(t){return this.$el.mathfield.$selectedText(t)},insert:function(t,e){this.$el.mathfield.insert(t,e)},select:function(){this.$el.mathfield.select()}}};export default t;