Jelajahi Sumber

Merge pull request #7685 from ckeditor/i/7683

Internal (link): Fix autolink mailto: link creation. Closes #7683.

Docs (link): Fix autolink link example.
Piotrek Koszuliński 5 tahun lalu
induk
melakukan
495d80e817

+ 1 - 1
packages/ckeditor5-link/docs/_snippets/features/autolink.html

@@ -1,4 +1,4 @@
 <div id="snippet-autolink">
-	<p>Type space, or Enter or Shift+Enter after a link: ckeditor.com</p>
+	<p>Type space, or Enter or Shift+Enter after a link: https://ckeditor.com</p>
 	<p>Will link to E-mail addresses also: example@example.com</p>
 </div>

+ 9 - 15
packages/ckeditor5-link/docs/features/link.md

@@ -240,29 +240,22 @@ ClassicEditor
 
 ## Autolink feature
 
-You can enable automatic linking of URLs typed or pasted into editor. The `AutoLink` feature will automatically add links to URLs or e-mail addresses.
+You can enable automatic linking of URLs typed or pasted into editor. The {@link module:link/autolink~AutoLink `AutoLink`} feature will automatically add turn URLs or e-mail addresses into real links.
 
 <info-box>
-	Autolink action can be always reverted using undo (<kbd>CTRL</kbd>+<kbd>Z</kbd>).
+	Autolink action can always be reverted by the undo feature (<kbd>CTRL</kbd>+<kbd>Z</kbd>).
 </info-box>
 
 {@snippet features/autolink}
 
-```js
-import AutoLink from '@ckeditor/ckeditor5-link/src/autolink';
-
-ClassicEditor
-	.create( document.querySelector( '#editor' ), {
-		plugins: [ Link, AutoLink, ... ]
-	} )
-	.then( ... )
-	.catch( ... );
-```
+The `Autolink` plugin is not available in any of the builds. See the [Installation](#installation) section to learn how to enable it.
 
 ## Installation
 
 <info-box info>
-	This feature is enabled by default in all builds. The installation instructions are for developers interested in building their own, custom rich text editor.
+	This base link feature is enabled by default in all builds. The installation instructions are for developers interested in building their own, custom rich text editor.
+
+	The autolink feature is not available in any of the builds and needs to be installed first. Read more about {@link builds/guides/integration/installing-plugins installing plugins}.
 </info-box>
 
 To add this feature to your editor, install the [`@ckeditor/ckeditor5-link`](https://www.npmjs.com/package/@ckeditor/ckeditor5-link) package:
@@ -271,14 +264,15 @@ To add this feature to your editor, install the [`@ckeditor/ckeditor5-link`](htt
 npm install --save @ckeditor/ckeditor5-link
 ```
 
-Then add the `Link` plugin to your plugin list:
+Then add the `Link` and `AutoLink` plugins to your plugin list:
 
 ```js
 import Link from '@ckeditor/ckeditor5-link/src/link';
+import AutoLink from '@ckeditor/ckeditor5-link/src/autolink';
 
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
-		plugins: [ Link, ... ],
+		plugins: [ Link, AutoLink, ... ],
 		toolbar: [ 'link', ... ],
 	} )
 	.then( ... )

+ 1 - 1
packages/ckeditor5-link/src/autolink.js

@@ -221,7 +221,7 @@ export default class AutoLink extends Plugin {
 
 		// Enqueue change to make undo step.
 		model.enqueueChange( writer => {
-			const linkHrefValue = isEmail( url ) ? `mailto://${ url }` : url;
+			const linkHrefValue = isEmail( url ) ? `mailto:${ url }` : url;
 
 			writer.setAttribute( 'linkHref', linkHrefValue, range );
 		} );

+ 3 - 3
packages/ckeditor5-link/tests/autolink.js

@@ -151,17 +151,17 @@ describe( 'AutoLink', () => {
 
 			expect( getData( model ) ).to.equal(
 				'<paragraph>' +
-					'<$text linkHref="https://www.cksource.com">https://www.cksource.com</$text>' +
+				'<$text linkHref="https://www.cksource.com">https://www.cksource.com</$text>' +
 				'</paragraph>' +
 				'<paragraph>[]</paragraph>'
 			);
 		} );
 
-		it( 'adds "mailto://" to link of detected email addresses', () => {
+		it( 'adds "mailto:" to link of detected email addresses', () => {
 			simulateTyping( 'newsletter@cksource.com ' );
 
 			expect( getData( model ) ).to.equal(
-				'<paragraph><$text linkHref="mailto://newsletter@cksource.com">newsletter@cksource.com</$text> []</paragraph>'
+				'<paragraph><$text linkHref="mailto:newsletter@cksource.com">newsletter@cksource.com</$text> []</paragraph>'
 			);
 		} );