Переглянути джерело

Add clipboard input from Firefox which is different from Chrome. Small typo fixes.

Mateusz Samsel 6 роки тому
батько
коміт
3f5cfb0ccc

+ 2 - 2
packages/ckeditor5-paste-from-office/src/filters/common.js

@@ -8,7 +8,7 @@
  */
 
 /**
- * Removes <b> tag wrapper added by Google Docs for copied content.
+ * The filter removes `<b>` tag wrapper added by Google Docs for copied content.
  *
  * @param {module:engine/view/documentfragment~DocumentFragment} documentFragment
  * @returns {module:engine/view/documentfragment~DocumentFragment}
@@ -16,7 +16,7 @@
 export function removeBoldTagWrapper( documentFragment ) {
 	const firstChild = documentFragment.getChild( 0 );
 
-	if ( firstChild.name === 'b' && firstChild.getStyle( 'font-weight' ) === 'normal' ) {
+	if ( firstChild && firstChild.is( 'b' ) && firstChild.getStyle( 'font-weight' ) === 'normal' ) {
 		const children = firstChild.getChildren();
 
 		documentFragment._removeChildren( 0 );

+ 11 - 9
packages/ckeditor5-paste-from-office/src/pastefromoffice.js

@@ -47,14 +47,14 @@ export default class PasteFromOffice extends Plugin {
 	}
 
 	/**
-	 * Listener fired during {@link module:clipboard/clipboard~Clipboard#event:inputTransformation} event. Detects if content comes
-	 * from recognized source and normalize it.
+	 * Listener fired during {@link module:clipboard/clipboard~Clipboard#event:inputTransformation `inputTransformation` event}.
+	 * Detects if content comes from a recognized source and normalize it.
 	 *
 	 * **Note**: this function was exposed mainly for testing purposes and should not be called directly.
 	 *
 	 * @private
 	 * @param {module:utils/eventinfo~EventInfo} evt
-	 * @param {Object} data passed with {@link module:clipboard/clipboard~Clipboard#event:inputTransformation}
+	 * @param {Object} data same structure like {@link module:clipboard/clipboard~Clipboard#event:inputTransformation input transformation}
 	 */
 	static _inputTransformationListener( evt, data ) {
 		const html = data.dataTransfer.getData( 'text/html' );
@@ -110,14 +110,16 @@ export default class PasteFromOffice extends Plugin {
 	}
 
 	/**
-	 * Determines if given paste data came from specific office-like application
-	 * Recognized are:
-	 * * 'msword' for Microsoft Words desktop app
-	 * * 'gdocs' for Google Docs online app
+	 * Determines if given paste data came from the specific office-like application.
+	 * Currently recognized are:
+	 * * `'msword'` for Microsoft Words desktop app
+	 * * `'gdocs'` for Google Docs online app
+	 *
+	 * **Note**: this function is exposed mainly for testing purposes and should not be called directly.
 	 *
 	 * @private
-	 * @param {String} html `text/html` string from data transfer
-	 * @return {String|null} type of app which is source of a data or null
+	 * @param {String} html the `text/html` string from data transfer
+	 * @return {String|null} name of source app of an html data or null
 	 */
 	static _getInputType( html ) {
 		if (

+ 17 - 1
packages/ckeditor5-paste-from-office/tests/_data/paste-from-google-docs/index.js

@@ -21,4 +21,20 @@ export const fixtures = {
 	}
 };
 
-export const browserFixtures = {};
+import simpleTextFirefox from './simple-text/input.firefox.html';
+
+import simpleTextNormalizedFirefox from './simple-text/normalized.firefox.html';
+
+export const browserFixtures = {
+	firefox: {
+		input: {
+			simpleText: simpleTextFirefox
+		},
+		normalized: {
+			simpleText: simpleTextNormalizedFirefox
+		},
+		model: {
+			simpleText: simpleTextModel
+		}
+	}
+};

+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/paste-from-google-docs/simple-text/input.firefox.html

@@ -0,0 +1 @@
+<meta charset="utf-8"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt;" id="docs-internal-guid-3b2c962f-7fff-5c68-2ca9-1234567890ab"><span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Hello world</span></p>

+ 1 - 0
packages/ckeditor5-paste-from-office/tests/_data/paste-from-google-docs/simple-text/normalized.firefox.html

@@ -0,0 +1 @@
+<p dir="ltr" id="docs-internal-guid-3b2c962f-7fff-5c68-2ca9-1234567890ab" style="line-height:1.38;margin-bottom:0pt;margin-top:0pt"><span style="background-color:transparent;color:#000000;font-family:Arial;font-size:11pt;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Hello world</span></p>