8
0
Maciej Gołaszewski 5 лет назад
Родитель
Сommit
7c560ef5b0

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

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

+ 23 - 0
packages/ckeditor5-link/docs/_snippets/features/autolink.js

@@ -0,0 +1,23 @@
+/**
+ * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/* globals console, window, document, ClassicEditor, CS_CONFIG, CKEditorPlugins */
+
+ClassicEditor
+	.create( document.querySelector( '#snippet-autolink' ), {
+		cloudServices: CS_CONFIG,
+		extraPlugins: [
+			CKEditorPlugins.AutoLink
+		],
+		toolbar: {
+			viewportTopOffset: window.getViewportTopOffsetConfig()
+		}
+	} )
+	.then( editor => {
+		window.editor = editor;
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 5 - 0
packages/ckeditor5-link/docs/_snippets/features/build-link-source.js

@@ -7,6 +7,11 @@
 
 import ClassicEditor from '@ckeditor/ckeditor5-build-classic/src/ckeditor';
 import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';
+import AutoLink from '@ckeditor/ckeditor5-link/src/autolink';
+
+window.CKEditorPlugins = {
+	AutoLink
+};
 
 window.ClassicEditor = ClassicEditor;
 window.CS_CONFIG = CS_CONFIG;

+ 21 - 0
packages/ckeditor5-link/docs/features/link.md

@@ -236,6 +236,27 @@ ClassicEditor
 	.catch( ... );
 ```
 
+## 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.
+
+<info-box>
+	Autolink action can be always reverted using undo (<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( ... );
+```
+
 ## Installation
 
 <info-box info>