Browse Source

Merge branch 'master' into t/ckeditor5/1655

Kamil Piechaczek 6 years ago
parent
commit
97eab63516

+ 1 - 1
packages/ckeditor5-widget/.eslintrc.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /* eslint-env node */

+ 1 - 5
packages/ckeditor5-widget/.travis.yml

@@ -1,12 +1,8 @@
 sudo: required
 dist: trusty
 addons:
+  chrome: stable
   firefox: latest
-  apt:
-    sources:
-    - google-chrome
-    packages:
-    - google-chrome-stable
 language: node_js
 node_js:
 - '8'

+ 7 - 0
packages/ckeditor5-widget/CHANGELOG.md

@@ -1,6 +1,13 @@
 Changelog
 =========
 
+## [11.0.1](https://github.com/ckeditor/ckeditor5-widget/compare/v11.0.0...v11.0.1) (2019-04-10)
+
+### Bug fixes
+
+* Triple clicking inside a nested editable should not select the entire widget in Safari. Closes [ckeditor/ckeditor5#1463](https://github.com/ckeditor/ckeditor5/issues/1463). ([b7c4765](https://github.com/ckeditor/ckeditor5-widget/commit/b7c4765))
+
+
 ## [11.0.0](https://github.com/ckeditor/ckeditor5-widget/compare/v10.3.1...v11.0.0) (2019-02-28)
 
 ### Bug fixes

+ 16 - 16
packages/ckeditor5-widget/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@ckeditor/ckeditor5-widget",
-  "version": "11.0.0",
+  "version": "11.0.1",
   "description": "Widget API for CKEditor 5.",
   "keywords": [
     "ckeditor",
@@ -9,23 +9,23 @@
     "ckeditor5-lib"
   ],
   "dependencies": {
-    "@ckeditor/ckeditor5-core": "^12.0.0",
-    "@ckeditor/ckeditor5-engine": "^13.0.0",
-    "@ckeditor/ckeditor5-ui": "^12.0.0",
-    "@ckeditor/ckeditor5-utils": "^12.0.0"
+    "@ckeditor/ckeditor5-core": "^12.1.0",
+    "@ckeditor/ckeditor5-engine": "^13.1.0",
+    "@ckeditor/ckeditor5-ui": "^12.1.0",
+    "@ckeditor/ckeditor5-utils": "^12.1.0"
   },
   "devDependencies": {
-    "@ckeditor/ckeditor5-basic-styles": "^11.0.0",
-    "@ckeditor/ckeditor5-clipboard": "^11.0.0",
-    "@ckeditor/ckeditor5-editor-balloon": "^12.0.0",
-    "@ckeditor/ckeditor5-editor-classic": "^12.0.0",
-    "@ckeditor/ckeditor5-enter": "^11.0.0",
-    "@ckeditor/ckeditor5-essentials": "^11.0.0",
-    "@ckeditor/ckeditor5-heading": "^11.0.0",
-    "@ckeditor/ckeditor5-paragraph": "^11.0.0",
-    "@ckeditor/ckeditor5-table": "^12.0.0",
-    "@ckeditor/ckeditor5-typing": "^12.0.0",
-    "@ckeditor/ckeditor5-undo": "^11.0.0",
+    "@ckeditor/ckeditor5-basic-styles": "^11.1.0",
+    "@ckeditor/ckeditor5-clipboard": "^11.0.1",
+    "@ckeditor/ckeditor5-editor-balloon": "^12.1.0",
+    "@ckeditor/ckeditor5-editor-classic": "^12.1.0",
+    "@ckeditor/ckeditor5-enter": "^11.0.1",
+    "@ckeditor/ckeditor5-essentials": "^11.0.1",
+    "@ckeditor/ckeditor5-heading": "^11.0.1",
+    "@ckeditor/ckeditor5-paragraph": "^11.0.1",
+    "@ckeditor/ckeditor5-table": "^12.0.1",
+    "@ckeditor/ckeditor5-typing": "^12.0.1",
+    "@ckeditor/ckeditor5-undo": "^11.0.1",
     "eslint": "^5.5.0",
     "eslint-config-ckeditor5": "^1.0.11",
     "husky": "^1.3.1",

+ 1 - 1
packages/ckeditor5-widget/src/highlightstack.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /**

+ 6 - 6
packages/ckeditor5-widget/src/utils.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /**
@@ -355,11 +355,11 @@ function getFillerOffset() {
 	return null;
 }
 
-// Adds a drag handler to the editable element.
+// Adds a drag handler to the widget.
 //
-// @param {module:engine/view/editableelement~EditableElement}
+// @param {module:engine/view/containerelement~ContainerElement}
 // @param {module:engine/view/downcastwriter~DowncastWriter} writer
-function addSelectionHandler( editable, writer ) {
+function addSelectionHandler( widgetElement, writer ) {
 	const selectionHandler = writer.createUIElement( 'div', { class: 'ck ck-widget__selection-handler' }, function( domDocument ) {
 		const domElement = this.toDomElement( domDocument );
 
@@ -376,6 +376,6 @@ function addSelectionHandler( editable, writer ) {
 	} );
 
 	// Append the selection handler into the widget wrapper.
-	writer.insert( writer.createPositionAt( editable, 0 ), selectionHandler );
-	writer.addClass( [ 'ck-widget_with-selection-handler' ], editable );
+	writer.insert( writer.createPositionAt( widgetElement, 0 ), selectionHandler );
+	writer.addClass( [ 'ck-widget_with-selection-handler' ], widgetElement );
 }

+ 6 - 3
packages/ckeditor5-widget/src/widget.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /**
@@ -121,9 +121,12 @@ export default class Widget extends Plugin {
 			// For such event, we select the entire nested editable element.
 			// See: https://github.com/ckeditor/ckeditor5/issues/1463.
 			if ( env.isSafari && domEventData.domEvent.detail >= 3 ) {
-				this.editor.editing.view.change( writer => {
+				const mapper = editor.editing.mapper;
+				const modelElement = mapper.toModelElement( element );
+
+				this.editor.model.change( writer => {
 					domEventData.preventDefault();
-					writer.setSelection( element, 'in' );
+					writer.setSelection( modelElement, 'in' );
 				} );
 			}
 

+ 1 - 1
packages/ckeditor5-widget/src/widgettoolbarrepository.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /**

+ 1 - 1
packages/ckeditor5-widget/tests/highlightstack.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 import HighlightStack from '../src/highlightstack';

+ 4 - 0
packages/ckeditor5-widget/tests/manual/inline-widget.html

@@ -14,6 +14,10 @@
 		padding: 4px 2px;
 		outline-offset: -2px;
 		line-height: 1em;
+		/* Set margins before and after the inline widget so the cursor between two instances is visible when one of them is focused.
+		   Optimized for Firefox due to bug in rendering selection in ZWS on Chrome. See ckeditor5#1607. */
+		margin-right: 1px;
+		margin-left: 3px;
 	}
 
 	placeholder::selection {

+ 1 - 1
packages/ckeditor5-widget/tests/manual/inline-widget.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /* global console, window */

+ 1 - 1
packages/ckeditor5-widget/tests/manual/nested-widgets.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /* globals console, window, document, setInterval */

+ 1 - 1
packages/ckeditor5-widget/tests/manual/widget-with-nestededitable.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /* globals console, window, document */

+ 1 - 1
packages/ckeditor5-widget/tests/utils.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /* global document */

+ 19 - 5
packages/ckeditor5-widget/tests/widget-integration.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /* global document */
@@ -11,7 +11,10 @@ import Widget from '../src/widget';
 import DomEventData from '@ckeditor/ckeditor5-engine/src/view/observer/domeventdata';
 
 import { toWidget } from '../src/utils';
-import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+import {
+	setData as setModelData,
+	getData as getModelData
+} from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
 import env from '@ckeditor/ckeditor5-utils/src/env';
@@ -118,6 +121,8 @@ describe( 'Widget - integration', () => {
 		expect( getViewData( view ) ).to.equal(
 			'[]<div class="ck-widget" contenteditable="false"><figcaption contenteditable="true">foo bar</figcaption></div>'
 		);
+
+		expect( getModelData( model ) ).to.equal( '[]<widget><nested>foo bar</nested></widget>' );
 	} );
 
 	it( 'should select the entire nested editable if triple clicked', () => {
@@ -137,8 +142,9 @@ describe( 'Widget - integration', () => {
 		sinon.assert.called( preventDefault );
 
 		expect( getViewData( view ) ).to.equal(
-			'<div class="ck-widget" contenteditable="false"><figcaption contenteditable="true">[foo bar]</figcaption></div>'
+			'<div class="ck-widget" contenteditable="false"><figcaption contenteditable="true">{foo bar}</figcaption></div>'
 		);
+		expect( getModelData( model ) ).to.equal( '<widget><nested>[foo bar]</nested></widget>' );
 	} );
 
 	it( 'should select proper nested editable if triple clicked', () => {
@@ -160,9 +166,11 @@ describe( 'Widget - integration', () => {
 		expect( getViewData( view ) ).to.equal(
 			'<div class="ck-widget" contenteditable="false">' +
 				'<figcaption contenteditable="true">foo</figcaption>' +
-				'<figcaption contenteditable="true">[bar]</figcaption>' +
+				'<figcaption contenteditable="true">{bar}</figcaption>' +
 			'</div>'
 		);
+
+		expect( getModelData( model ) ).to.equal( '<widget><nested>foo</nested><nested>[bar]</nested></widget>' );
 	} );
 
 	it( 'should select the entire nested editable if quadra clicked', () => {
@@ -182,8 +190,10 @@ describe( 'Widget - integration', () => {
 		sinon.assert.called( preventDefault );
 
 		expect( getViewData( view ) ).to.equal(
-			'<div class="ck-widget" contenteditable="false"><figcaption contenteditable="true">[foo bar]</figcaption></div>'
+			'<div class="ck-widget" contenteditable="false"><figcaption contenteditable="true">{foo bar}</figcaption></div>'
 		);
+
+		expect( getModelData( model ) ).to.equal( '<widget><nested>[foo bar]</nested></widget>' );
 	} );
 
 	it( 'should select the inline widget if triple clicked', () => {
@@ -205,6 +215,8 @@ describe( 'Widget - integration', () => {
 		expect( getViewData( view ) ).to.equal(
 			'<p>Foo{<span class="ck-widget ck-widget_selected" contenteditable="false">foo bar</span>}Bar</p>'
 		);
+
+		expect( getModelData( model ) ).to.equal( '<paragraph>Foo[<inline-widget>foo bar</inline-widget>]Bar</paragraph>' );
 	} );
 
 	it( 'should does nothing for non-Safari browser', () => {
@@ -228,5 +240,7 @@ describe( 'Widget - integration', () => {
 		expect( getViewData( view ) ).to.equal(
 			'[]<div class="ck-widget" contenteditable="false"><figcaption contenteditable="true">foo bar</figcaption></div>'
 		);
+
+		expect( getModelData( model ) ).to.equal( '[]<widget><nested>foo bar</nested></widget>' );
 	} );
 } );

+ 1 - 1
packages/ckeditor5-widget/tests/widget.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';

+ 1 - 1
packages/ckeditor5-widget/tests/widgettoolbarrepository.js

@@ -1,6 +1,6 @@
 /**
  * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 /* global document */

+ 1 - 1
packages/ckeditor5-widget/theme/widget.css

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
 .ck .ck-widget.ck-widget_with-selection-handler {