Browse Source

Merge branch 'master' into i/8204

Kamil Piechaczek 5 năm trước cách đây
mục cha
commit
85f6f3deed

+ 1 - 1
CHANGELOG.md

@@ -18,7 +18,7 @@ Other than that, we focused on bug fixes and stability improvements. Some highli
 
 Please note that there are some **major breaking changes**. Be sure to review them before upgrading.
 
-<!-- TODO: Add a link to the blog post. -->
+Read more in the blog post: https://ckeditor.com/blog/CKEditor-5-v23.0.0-with-pagination-feature-list-styles-and-improved-image-upload/
 
 ### Collaboration features
 

+ 0 - 1
package.json

@@ -101,7 +101,6 @@
     "http-server": "^0.12.3",
     "husky": "^4.2.5",
     "lint-staged": "^10.2.6",
-    "marked": "^1.1.1",
     "mini-css-extract-plugin": "^0.9.0",
     "minimatch": "^3.0.4",
     "mkdirp": "^1.0.4",

+ 1 - 1
packages/ckeditor5-ckfinder/docs/features/ckfinder.md

@@ -37,7 +37,7 @@ This feature can be used in the rich-text editor in two different ways:
 
 ### Image upload only
 
-This demo shows the integration where the file manager's server connector handles [the image upload](#configuring-the-full-integration) only:
+This demo shows the integration where the file manager's server connector handles [the image upload](#configuring-the-image-upload-only) only:
 
 * Paste the image directly into the rich-text editor content and it will be automatically uploaded using the server-side connector.
 * Use the "Insert image" button in the toolbar to insert an image.

+ 1 - 1
packages/ckeditor5-media-embed/src/automediaembed.js

@@ -16,7 +16,7 @@ import Undo from '@ckeditor/ckeditor5-undo/src/undo';
 import global from '@ckeditor/ckeditor5-utils/src/dom/global';
 import { insertMedia } from './utils';
 
-const URL_REGEXP = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]+$/;
+const URL_REGEXP = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=%]+$/;
 
 /**
  * The auto-media embed plugin. It recognizes media links in the pasted content and embeds

+ 11 - 0
packages/ckeditor5-media-embed/tests/automediaembed.js

@@ -398,6 +398,17 @@ describe( 'AutoMediaEmbed - integration', () => {
 					return newEditor.destroy();
 				} );
 		} );
+
+		it( 'works for URL with %-symbols', () => {
+			setData( editor.model, '<paragraph>[]</paragraph>' );
+			pasteHtml( editor, 'http://youtube.com/watch?v=H08tGjXNHO4%2' );
+
+			clock.tick( 100 );
+
+			expect( getData( editor.model ) ).to.equal(
+				'[<media url="http://youtube.com/watch?v=H08tGjXNHO4%2"></media>]'
+			);
+		} );
 	} );
 
 	describe( 'use real timers', () => {

+ 14 - 14
packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.edge.word2016.html

@@ -2,30 +2,30 @@
 
 <table>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell colspan="4"><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell colspan="4"></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell colspan="2"><paragraph></paragraph></tableCell>
-		<tableCell rowspan="2"><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell colspan="2"></tableCell>
+		<tableCell rowspan="2"></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell rowspan="2"><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell rowspan="2"></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
 	</tableRow>
 </table>
 

+ 8 - 8
packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.safari.word2016.html

@@ -1,20 +1,20 @@
 <paragraph></paragraph>
 <table>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell colspan="2"><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell colspan="2"></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
 	</tableRow>
 </table>
 

+ 14 - 14
packages/ckeditor5-paste-from-office/tests/_data/image/adjacent-groups/model.word2016.html

@@ -1,29 +1,29 @@
 <table>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
+		<tableCell></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell colspan="4"><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell colspan="4"></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell colspan="2"><paragraph></paragraph></tableCell>
-		<tableCell rowspan="2"><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell colspan="2"></tableCell>
+		<tableCell rowspan="2"></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
-		<tableCell rowspan="2"><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
+		<tableCell rowspan="2"></tableCell>
 	</tableRow>
 	<tableRow>
-		<tableCell><paragraph></paragraph></tableCell>
+		<tableCell></tableCell>
 	</tableRow>
 </table>
 

+ 0 - 25
packages/ckeditor5-table/src/converters/upcasttable.js

@@ -84,31 +84,6 @@ export function skipEmptyTableRow() {
 	};
 }
 
-/**
- * A converter that ensures an empty paragraph is inserted in a table cell if no other content was converted.
- *
- * @returns {Function} Conversion helper.
- */
-export function ensureParagraphInTableCell( elementName ) {
-	return dispatcher => {
-		dispatcher.on( `element:${ elementName }`, ( evt, data, conversionApi ) => {
-			// The default converter will create a model range on converted table cell.
-			if ( !data.modelRange ) {
-				return;
-			}
-
-			const tableCell = data.modelRange.start.nodeAfter;
-
-			// Ensure a paragraph in the model for empty table cells for converted table cells.
-			if ( !tableCell.childCount ) {
-				const modelCursor = conversionApi.writer.createPositionAt( tableCell, 0 );
-
-				conversionApi.writer.insertElement( 'paragraph', modelCursor );
-			}
-		}, { priority: 'low' } );
-	};
-}
-
 // Scans table rows and extracts required metadata from the table:
 //
 // headingRows    - The number of rows that go as table headers.

+ 1 - 3
packages/ckeditor5-table/src/tableediting.js

@@ -9,7 +9,7 @@
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 
-import upcastTable, { ensureParagraphInTableCell, skipEmptyTableRow } from './converters/upcasttable';
+import upcastTable, { skipEmptyTableRow } from './converters/upcasttable';
 import {
 	downcastInsertCell,
 	downcastInsertRow,
@@ -106,8 +106,6 @@ export default class TableEditing extends Plugin {
 		// Table cell conversion.
 		conversion.for( 'upcast' ).elementToElement( { model: 'tableCell', view: 'td' } );
 		conversion.for( 'upcast' ).elementToElement( { model: 'tableCell', view: 'th' } );
-		conversion.for( 'upcast' ).add( ensureParagraphInTableCell( 'td' ) );
-		conversion.for( 'upcast' ).add( ensureParagraphInTableCell( 'th' ) );
 
 		conversion.for( 'editingDowncast' ).add( downcastInsertCell() );
 

+ 1 - 1
packages/ckeditor5-table/tests/converters/upcasttable.js

@@ -285,7 +285,7 @@ describe( 'upcastTable()', () => {
 		);
 
 		expectModel(
-			'<fooTable><fooRow><fooCell><paragraph></paragraph></fooCell></fooRow></fooTable>'
+			'<fooTable><fooRow><fooCell></fooCell></fooRow></fooTable>'
 		);
 	} );
 

+ 41 - 0
packages/ckeditor5-table/tests/tableclipboard-paste.js

@@ -3917,6 +3917,36 @@ describe( 'table clipboard', () => {
 				[ '02', '21', '22' ]
 			] ) );
 		} );
+
+		it( 'should not blow up when pasting unsupported element in table', async () => {
+			await createEditor( [ TableCellPropertiesEditing ] );
+
+			pasteHtml( editor,
+				'<table>' +
+					'<tbody>' +
+						'<tr>' +
+							'<td>' +
+								'<div>' +
+									'<table>' +
+										'<tbody>' +
+											'<tr>' +
+												'<td style="border: 2px solid rgb(242, 242, 242);">' +
+													'<p>Test</p>' +
+												'</td>' +
+											'</tr>' +
+										'</tbody>' +
+									'</table>' +
+								'</div>' +
+							'</td>' +
+						'</tr>' +
+					'</tbody>' +
+				'</table>'
+			);
+
+			assertEqualMarkup( getModelData( model, { withoutSelection: true } ), modelTable( [
+				[ '<paragraph>Test</paragraph><paragraph></paragraph>' ]
+			] ) );
+		} );
 	} );
 
 	async function createEditor( extraPlugins = [] ) {
@@ -3930,6 +3960,17 @@ describe( 'table clipboard', () => {
 		tableSelection = editor.plugins.get( 'TableSelection' );
 	}
 
+	function pasteHtml( editor, html ) {
+		const data = {
+			dataTransfer: createDataTransfer(),
+			stopPropagation() {},
+			preventDefault() {}
+		};
+
+		data.dataTransfer.setData( 'text/html', html );
+		editor.editing.view.document.fire( 'paste', data );
+	}
+
 	function pasteTable( tableData, attributes = {} ) {
 		const data = {
 			dataTransfer: createDataTransfer(),

+ 1 - 1
packages/ckeditor5-ui/src/editableui/inline/inlineeditableuiview.js

@@ -47,7 +47,7 @@ export default class InlineEditableUIView extends EditableUIView {
 		editingView.change( writer => {
 			const viewRoot = editingView.document.getRoot( this.name );
 
-			writer.setAttribute( 'aria-label', t( 'Rich Text Editor, %0', [ this.name ] ), viewRoot );
+			writer.setAttribute( 'aria-label', t( 'Rich Text Editor, %0', this.name ), viewRoot );
 		} );
 	}
 }

+ 5 - 5
packages/ckeditor5-utils/tests/locale.js

@@ -157,9 +157,9 @@ describe( 'Locale', () => {
 		it( 'should translate a message supporting plural forms', () => {
 			const t = locale.t;
 
-			expect( t( { string: 'bar', plural: '%0 bars' }, [ 1 ] ), 1 ).to.equal( 'bar_pl_0' );
-			expect( t( { string: 'bar', plural: '%0 bars' }, [ 2 ] ), 2 ).to.equal( '2 bar_pl_1' );
-			expect( t( { string: 'bar', plural: '%0 bars' }, [ 5 ] ), 3 ).to.equal( '5 bar_pl_2' );
+			expect( t( { string: 'bar', plural: '%0 bars' }, 1 ), 1 ).to.equal( 'bar_pl_0' );
+			expect( t( { string: 'bar', plural: '%0 bars' }, 2 ), 2 ).to.equal( '2 bar_pl_1' );
+			expect( t( { string: 'bar', plural: '%0 bars' }, 5 ), 3 ).to.equal( '5 bar_pl_2' );
 		} );
 
 		it( 'should translate a message supporting plural forms with a message id if it was passed', () => {
@@ -181,13 +181,13 @@ describe( 'Locale', () => {
 		it( 'should interpolate a message with provided values', () => {
 			const t = locale.t;
 
-			expect( t( '%0 - %0', [ 'foo' ] ) ).to.equal( 'foo - foo' );
+			expect( t( '%0 - %0', 'foo' ) ).to.equal( 'foo - foo' );
 			expect( t( '%1 - %0 - %2', [ 'a', 'b', 'c' ] ) ).to.equal( 'b - a - c' );
 
 			// Those test make sure that if %0 is really to be used, then it's going to work.
 			// It'd be a super rare case if one would need to use %0 and at the same time interpolate something.
 			expect( t( '%1 - %0 - %2' ) ).to.equal( '%1 - %0 - %2' );
-			expect( t( '%1 - %0 - %2', [ 'a' ] ) ).to.equal( '%1 - a - %2' );
+			expect( t( '%1 - %0 - %2', 'a' ) ).to.equal( '%1 - a - %2' );
 		} );
 
 		it( 'should interpolate a message with a provided value (shorthand version)', () => {

+ 2 - 2
packages/ckeditor5-word-count/src/wordcount.js

@@ -203,7 +203,7 @@ export default class WordCount extends Plugin {
 
 			if ( displayWords || displayWords === undefined ) {
 				this.bind( '_wordsLabel' ).to( this, 'words', words => {
-					return t( 'Words: %0', [ words ] );
+					return t( 'Words: %0', words );
 				} );
 
 				children.push( {
@@ -221,7 +221,7 @@ export default class WordCount extends Plugin {
 
 			if ( displayCharacters || displayCharacters === undefined ) {
 				this.bind( '_charactersLabel' ).to( this, 'characters', words => {
-					return t( 'Characters: %0', [ words ] );
+					return t( 'Characters: %0', words );
 				} );
 
 				children.push( {

+ 23 - 1
scripts/docs/snippetadapter.js

@@ -14,6 +14,7 @@ const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin'
 const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
 const TerserPlugin = require( 'terser-webpack-plugin' );
 const ProgressBarPlugin = require( 'progress-bar-webpack-plugin' );
+const glob = require( 'glob' );
 
 const DEFAULT_LANGUAGE = 'en';
 const MULTI_LANGUAGE = 'multi-language';
@@ -393,7 +394,10 @@ function getWebpackConfig( snippets, config ) {
 		// Configure the paths so building CKEditor 5 snippets work even if the script
 		// is triggered from a directory outside ckeditor5 (e.g. multi-project case).
 		resolve: {
-			modules: getModuleResolvePaths()
+			modules: [
+				...getPackageDependenciesPaths(),
+				...getModuleResolvePaths()
+			]
 		},
 
 		resolveLoader: {
@@ -471,6 +475,24 @@ function getModuleResolvePaths() {
 	];
 }
 
+/**
+ * Returns an array that contains paths to packages' dependencies.
+ * The snippet adapter should use packages' dependencies instead of the documentation builder dependencies.
+ *
+ * See #7916.
+ *
+ * @returns {Array.<String>}
+ */
+function getPackageDependenciesPaths() {
+	const globOptions = {
+		cwd: path.resolve( __dirname, '..', '..' ),
+		absolute: true
+	};
+
+	return glob.sync( 'packages/*/node_modules', globOptions )
+		.concat( glob.sync( 'external/*/packages/*/node_modules', globOptions ) );
+}
+
 /**
  * Reads the snippet's configuration.
  *