diff --git a/CHANGELOG.md b/CHANGELOG.md index 3036e1e2d..64ca4db82 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 26100b3ee..4177b02f3 100644 --- a/demo/index.html +++ b/demo/index.html @@ -50,6 +50,8 @@

+ +

diff --git a/src/mathediting.js b/src/mathediting.js index 4b7d7cc0b..8c37945c7 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)