From 93b106b694fa0b0a1a9d7fb591dfa84362a89a84 Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Wed, 14 Apr 2021 13:49:55 +0200 Subject: [PATCH] Added `DataProcessor#useFillerType()`. Added `GFMDataProcessor#useFillerType()`. --- .../src/dataprocessor/dataprocessor.jsdoc | 13 ++++++++++ .../src/gfmdataprocessor.js | 6 +++++ .../gfmdataprocessor/gfmdataprocessor.js | 25 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/gfmdataprocessor.js diff --git a/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.jsdoc b/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.jsdoc index 673ef7d8595..a116ceed5a2 100644 --- a/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.jsdoc +++ b/packages/ckeditor5-engine/src/dataprocessor/dataprocessor.jsdoc @@ -49,3 +49,16 @@ * @param {module:engine/view/matcher~MatcherPattern} pattern Pattern matching all view elements whose content should * be treated as plain text. */ + +/** + * If the processor is set to use marked fillers, it will insert nbsp fillers wrapped in spans + * (` `), instead of regular nbsp characters (` `). + * + * This mode allows for more precise handling of block fillers (so they don't leak into editor content) but bloats the editor + * data with additional markup. + * + * This mode may be required by some features and will be turned on by them automatically. + * + * @method #useFillerType + * @param {'default'|'marked'} type Whether to use default or marked nbsp block fillers. + */ diff --git a/packages/ckeditor5-markdown-gfm/src/gfmdataprocessor.js b/packages/ckeditor5-markdown-gfm/src/gfmdataprocessor.js index 7bc6f498fbb..485b513047e 100644 --- a/packages/ckeditor5-markdown-gfm/src/gfmdataprocessor.js +++ b/packages/ckeditor5-markdown-gfm/src/gfmdataprocessor.js @@ -83,4 +83,10 @@ export default class GFMDataProcessor { registerRawContentMatcher( pattern ) { this._htmlDP.registerRawContentMatcher( pattern ); } + + /** + * This method does not have an effect on data processor result. It exists for compatibility with + * {@link module:engine/dataprocessor/dataprocessor~DataProcessor `DataProcessor` interface}. + */ + useFillerType() {} } diff --git a/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/gfmdataprocessor.js b/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/gfmdataprocessor.js new file mode 100644 index 00000000000..8fa6d261862 --- /dev/null +++ b/packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/gfmdataprocessor.js @@ -0,0 +1,25 @@ +/** + * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license + */ + +import GFMDataProcessor from '../../src/gfmdataprocessor'; +import ViewDocument from '@ckeditor/ckeditor5-engine/src/view/document'; +import { StylesProcessor } from '@ckeditor/ckeditor5-engine/src/view/stylesmap'; + +describe( 'GFMDataProcessor', () => { + let dataProcessor, viewDocument; + + beforeEach( () => { + viewDocument = new ViewDocument( new StylesProcessor() ); + dataProcessor = new GFMDataProcessor( viewDocument ); + } ); + + describe( 'useFillerType()', () => { + it( 'should have this method to be compatible with `DataProcessor` interface', () => { + expect( () => { + dataProcessor.useFillerType( 'default' ); + } ).not.to.throw(); + } ); + } ); +} );