1
0
mirror of https://github.com/typemill/typemill.git synced 2025-10-18 16:16:08 +02:00

Version 1.2.19: Modularized Visual Editor

This commit is contained in:
trendschau
2019-11-24 07:25:04 +01:00
parent e1c16529e5
commit 126106bccb
54 changed files with 801 additions and 1465 deletions

View File

@@ -33,7 +33,7 @@ class Math extends Plugin
if($mathSettings['tool'] == 'katex')
{
$this->addJS('/math/public/katex.min.js');
$this->addJS('/math/public/katex.min.js');
$this->addJS('/math/public/auto-render.min.js');
$this->addCSS('/math/public/katex.min.css');
@@ -43,5 +43,14 @@ class Math extends Plugin
$this->addInlineJs('renderMathInElement(document.body);');
}
}
# add math to the blox editor configuration
$this->addEditorJS('/math/public/math.js');
$this->addSvgSymbol('<symbol id="icon-omega" viewBox="0 0 32 32">
<title>omega</title>
<path d="M22 28h8l2-4v8h-12v-6.694c4.097-1.765 7-6.161 7-11.306 0-6.701-4.925-11.946-11-11.946s-11 5.245-11 11.946c0 5.144 2.903 9.541 7 11.306v6.694h-12v-8l2 4h8v-1.018c-5.863-2.077-10-7.106-10-12.982 0-7.732 7.163-14 16-14s16 6.268 16 14c0 5.875-4.137 10.905-10 12.982v1.018z"></path>
</symbol>');
}
}

View File

@@ -1,5 +1,5 @@
name: Math
version: 1.0.2
version: 1.1.0
description: Adds support for katex and mathjax.
author: Sebastian Schürmanns
homepage: https://mathjax.org/

View File

@@ -0,0 +1,54 @@
determiner.math = function(block,lines,firstChar,secondChar,thirdChar){
if( (firstChar == '\\' && secondChar == '[') || (firstChar == '$' && secondChar == '$') )
{
return "math-component";
}
return false;
};
bloxFormats.math = { label: '<svg class="icon icon-omega"><use xlink:href="#icon-omega"></use></svg>', title: 'Math', component: 'math-component' };
formatConfig.push('math');
const mathComponent = Vue.component('math-component', {
props: ['compmarkdown', 'disabled'],
template: '<div>' +
'<input type="hidden" ref="markdown" :value="compmarkdown" :disabled="disabled" @input="updatemarkdown" />' +
'<div class="contenttype"><svg class="icon icon-omega"><use xlink:href="#icon-omega"></use></svg></div>' +
'<textarea class="mdcontent" ref="markdown" v-model="mathblock" :disabled="disabled" @input="createmarkdown"></textarea>' +
'</div>',
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);
},
},
})