From e5e78962f0bd9208fdd52da2f177acae117885ec Mon Sep 17 00:00:00 2001 From: Sauli Anto Date: Tue, 1 Oct 2019 17:46:51 +0300 Subject: [PATCH] Remove math paste from office --- src/math.js | 3 +- src/mathpastefromoffice.js | 263 ------------------------------------- src/utils.js | 2 +- 3 files changed, 2 insertions(+), 266 deletions(-) delete mode 100644 src/mathpastefromoffice.js diff --git a/src/math.js b/src/math.js index a828653c5..73f753082 100644 --- a/src/math.js +++ b/src/math.js @@ -4,11 +4,10 @@ import Widget from '@ckeditor/ckeditor5-widget/src/widget'; import MathUI from './mathui'; import MathEditing from './mathediting'; import AutoMath from './automath'; -import MathPasteFromOffice from './mathpastefromoffice'; export default class Math extends Plugin { static get requires() { - return [ MathEditing, MathUI, Widget, AutoMath, MathPasteFromOffice ]; + return [ MathEditing, MathUI, Widget, AutoMath ]; } static get pluginName() { diff --git a/src/mathpastefromoffice.js b/src/mathpastefromoffice.js deleted file mode 100644 index f7bc792fd..000000000 --- a/src/mathpastefromoffice.js +++ /dev/null @@ -1,263 +0,0 @@ -import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; -import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard'; -import UpcastWriter from '@ckeditor/ckeditor5-engine/src/view/upcastwriter'; -import Matcher from '@ckeditor/ckeditor5-engine/src/view/matcher'; -// import Element from '@ckeditor/ckeditor5-engine/src/view/element'; -import { normalizeSpacing, normalizeSpacerunSpans } from '@ckeditor/ckeditor5-paste-from-office/src/filters/space'; - -const BULLET_REGEXP = /(((.|\r?\n)*?)<\/span>)/g; - -export default class MathPasteFromOffice extends Plugin { - static get pluginName() { - return 'MathPasteFromOffice'; - } - - static get requires() { - return [ Clipboard ]; - } - - init() { - const editor = this.editor; - - editor.plugins.get( 'Clipboard' ).on( - 'inputTransformation', - ( evt, data ) => { - console.log( 'isTransformedWithPasteFromOffice', data.isTransformedWithPasteFromOffice ); // eslint-disable-line - console.log( data.content ); // eslint-disable-line - - if ( data.isTransformedWithMathPasteFromOffice ) { - return; - } - - if ( !data.isTransformedWithPasteFromOffice ) { - console.warn( 'Paste from office must be set before this' );// eslint-disable-line - return; - } - - const domParser = new DOMParser(); // eslint-disable-line - - /* - console.log(htmlString); // eslint-disable-line - const { body } = parseHtml( htmlString ); - console.log(body); // eslint-disable-line - */ - - const plainString = data.dataTransfer.getData( 'text/plain' ); - const lines = plainString.split( /\r?\n/ ); // split by new lines - if ( lines.length > 1 ) { - lines.pop(); // Remove last new line - } - // console.log(plainString); // eslint-disable-line - - const htmlMimeType = 'text/html'; - let htmlString = data.dataTransfer.getData( htmlMimeType ); - // console.log(htmlString); // eslint-disable-line - - htmlString = htmlString.replace( /