Browse Source

Merge branch 'master' into t/133

Piotrek Koszuliński 6 years ago
parent
commit
06b9addb4f
2 changed files with 9 additions and 163 deletions
  1. 9 32
      packages/ckeditor5-heading/src/title.js
  2. 0 131
      packages/ckeditor5-heading/tests/title.js

+ 9 - 32
packages/ckeditor5-heading/src/title.js

@@ -116,23 +116,12 @@ export default class Title extends Plugin {
 	}
 
 	/**
-	 * Sets the title of the document. This method does not change any content outside the title element.
-	 *
-	 * @param {String} data The data to be set as the document title.
-	 */
-	setTitle( data ) {
-		const editor = this.editor;
-		const titleElement = this._getTitleElement();
-		const titleContentElement = titleElement.getChild( 0 );
-
-		editor.model.insertContent( editor.data.parse( data, 'title-content' ), titleContentElement, 'in' );
-	}
-
-	/**
 	 * Returns the title of the document. Note that because this plugin does not allow any formatting inside
-	 * the title element, the output of this method will be a plain text, with no HTML tags. However, it
-	 * may contain some markers, like comments or suggestions. In such case, a special tag for the
-	 * marker will be included in the title text.
+	 * the title element, the output of this method will be a plain text, with no HTML tags.
+	 *
+	 * Note that it is not recommended to use this method together with features which insert markers to the
+	 * data output, like comments or track changes features. If such markers start in the title and end in the
+	 * body the result of this method might be incorrect.
 	 *
 	 * @returns {String} The title of the document.
 	 */
@@ -144,24 +133,12 @@ export default class Title extends Plugin {
 	}
 
 	/**
-	 * Sets the body of the document.
-	 *
-	 * @returns {String} data The data to be set as a body of the document.
-	 */
-	setBody( data ) {
-		const editor = this.editor;
-		const root = editor.model.document.getRoot();
-		const range = editor.model.createRange(
-			editor.model.createPositionAt( root.getChild( 0 ), 'after' ),
-			editor.model.createPositionAt( root, 'end' )
-		);
-
-		editor.model.insertContent( editor.data.parse( data ), range );
-	}
-
-	/**
 	 * Returns the body of the document.
 	 *
+	 * Note that it is not recommended to use this method together with features which insert markers to the
+	 * data output, like comments or track changes features. If such markers start in the title and end in the
+	 * body the result of this method might be incorrect.
+	 *
 	 * @returns {String} The body of the document.
 	 */
 	getBody() {

+ 0 - 131
packages/ckeditor5-heading/tests/title.js

@@ -364,92 +364,6 @@ describe( 'Title', () => {
 		} );
 	} );
 
-	describe( 'setTitle()', () => {
-		it( 'should set new content of a title element', () => {
-			setData( model,
-				'<title><title-content></title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-
-			editor.plugins.get( 'Title' ).setTitle( 'Biz' );
-
-			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]Biz</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-		} );
-
-		it( 'should replace old content of a title element', () => {
-			setData( model,
-				'<title><title-content>Foo</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-
-			editor.plugins.get( 'Title' ).setTitle( 'Biz' );
-
-			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]Biz</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-		} );
-
-		it( 'should clear content of a title element', () => {
-			setData( model,
-				'<title><title-content>Foo</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-
-			editor.plugins.get( 'Title' ).setTitle( '' );
-
-			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-		} );
-
-		it( 'should properly handle HTML element', () => {
-			setData( model,
-				'<title><title-content></title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-
-			editor.plugins.get( 'Title' ).setTitle( '<p>Foo</p>' );
-
-			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]Foo</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-		} );
-
-		it( 'should properly handle multiple HTML elements', () => {
-			setData( model,
-				'<title><title-content>Foo</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-
-			editor.plugins.get( 'Title' ).setTitle( '<p>Foo</p><p>bar</p>' );
-
-			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]Foobar</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-		} );
-
-		it( 'should do nothing when setting empty content to the empty title', () => {
-			setData( model,
-				'<title><title-content></title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-
-			editor.plugins.get( 'Title' ).setTitle( '' );
-
-			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-		} );
-	} );
-
 	describe( 'getTitle()', () => {
 		it( 'should return content of a title element', () => {
 			setData( model,
@@ -512,51 +426,6 @@ describe( 'Title', () => {
 		} );
 	} );
 
-	describe( 'setBody()', () => {
-		it( 'should set new content to body', () => {
-			setData( model,
-				'<title><title-content>Foo</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-
-			editor.plugins.get( 'Title' ).setBody( 'Biz' );
-
-			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]Foo</title-content></title>' +
-				'<paragraph>Biz</paragraph>'
-			);
-		} );
-
-		it( 'should set empty content to body', () => {
-			setData( model,
-				'<title><title-content>Foo</title-content></title>' +
-				'<paragraph>Bar</paragraph>'
-			);
-
-			editor.plugins.get( 'Title' ).setBody( '' );
-
-			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]Foo</title-content></title>' +
-				'<paragraph></paragraph>'
-			);
-		} );
-
-		it( 'should set html content to body', () => {
-			setData( model,
-				'<title><title-content>Foo</title-content>' +
-				'</title><paragraph>Bar</paragraph>'
-			);
-
-			editor.plugins.get( 'Title' ).setBody( '<blockQuote>Bar</blockQuote><p>Biz</p>' );
-
-			expect( getData( model ) ).to.equal(
-				'<title><title-content>[]Foo</title-content></title>' +
-				'<blockQuote><paragraph>Bar</paragraph></blockQuote>' +
-				'<paragraph>Biz</paragraph>'
-			);
-		} );
-	} );
-
 	describe( 'getBody()', () => {
 		it( 'should return all data except the title element', () => {
 			setData( model,