Skip to content

Build your personal knowledge base with Trilium Notes

Upcast Quill style tags, fixes #39

Tony Narlocka8b958d53755
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3036e1e2d8..64ca4db82a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ Changelog
* #38: You can now boot into a development instance with `yarn start` (supports
live reload)
+* #40 (fixed #39): Support for upcasting Quill style tags
## [27.1.1](https://github.com/isaul32/ckeditor5-math/compare/v27.1.0...v27.1.1) (2021-03-29)
diff --git a/demo/index.html b/demo/index.html
index 26100b3ee8..4177b02f30 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -50,6 +50,8 @@
<div id="editor">
<p><script type="math/tex">e=mc^2</script></p>
<p><script type="math/tex; mode=display">e=mc^2</script></p>
+ <!-- Quill Style Tag -->
+ <p><span class="ql-formula" data-value="e=mc^2"></span></p>
</div>
</body>
</html>
diff --git a/src/mathediting.js b/src/mathediting.js
index 4b7d7cc0b5..8c37945c70 100644
--- a/src/mathediting.js
+++ b/src/mathediting.js
@@ -108,6 +108,21 @@ export default class MathEditing extends Plugin {
return writer.createElement( params.display ? 'mathtex-display' : 'mathtex-inline', params );
}
+ } )
+ // KaTeX from Quill: https://github.com/quilljs/quill/blob/develop/formats/formula.js
+ .elementToElement( {
+ view: {
+ name: 'span',
+ classes: [ 'ql-formula' ]
+ },
+ model: ( viewElement, { writer } ) => {
+ const equation = viewElement.getAttribute( 'data-value' ).trim();
+ return writer.createElement( 'mathtex-inline', {
+ equation,
+ type: mathConfig.forceOutputType ? mathConfig.outputType : 'script',
+ display: false
+ } );
+ }
} );
// Model -> View (element)