determiner.math = function(block,lines,firstChar,secondChar,thirdChar){
if( (firstChar == '\\' && secondChar == '[') || (firstChar == '$' && secondChar == '$') )
{
return "math-component";
}
return false;
};
bloxFormats.math = { label: '', title: 'Math', component: 'math-component' };
formatConfig.push('math');
const mathComponent = Vue.component('math-component', {
props: ['compmarkdown', 'disabled'],
template: '
',
data: function(){
return {
mathblock: ''
}
},
mounted: function(){
this.$refs.markdown.focus();
if(this.compmarkdown)
{
var dollarMath = new RegExp(/^\$\$[\S\s]+\$\$$/m);
var bracketMath = new RegExp(/^\\\[[\S\s]+\\\]$/m);
if(dollarMath.test(this.compmarkdown) || bracketMath.test(this.compmarkdown))
{
var mathExpression = this.compmarkdown.substring(2,this.compmarkdown.length-2);
this.mathblock = mathExpression.trim();
}
}
this.$nextTick(function () {
autosize(document.querySelectorAll('textarea'));
});
},
methods: {
createmarkdown: function(event)
{
this.codeblock = event.target.value;
var codeblock = '$$\n' + event.target.value + '\n$$';
this.updatemarkdown(codeblock);
},
updatemarkdown: function(codeblock)
{
this.$emit('updatedMarkdown', codeblock);
},
},
})