Browse Source

Docs: Added code sample to the decorators demo in the feature guide. Closes #237. [skip ci]

Aleksander Nowodzinski 6 years ago
parent
commit
85012283be
1 changed files with 31 additions and 0 deletions
  1. 31 0
      packages/ckeditor5-link/docs/features/link.md

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

@@ -42,6 +42,37 @@ In the editor below, all **external** links get the `target="_blank"` and `rel="
 
 {@snippet features/linkdecorators}
 
+The following code was used to run the editor. Learn more about the [configuration](#configuration) of the feature.
+
+```js
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		toolbar: {
+			items: [
+				// ...
+				'link'
+			],
+		},
+		link: {
+			// Automatically add target="_blank" and rel="noopener noreferrer" to all external links.
+			addTargetToExternalLinks: true,
+
+			// Allow users control the "downloadable" attribute of each link.
+			decorators: [
+				{
+					mode: 'manual',
+					label: 'Downloadable',
+					attributes: {
+						download: 'download'
+					}
+				}
+			]
+		}
+	} )
+	.then( ... )
+	.catch( ... );
+```
+
 ### Configuration
 
 Decorators are configured via definitions in {@link module:link/link~LinkConfig#decorators `config.link.decorators`}. Each decorator definition must have its own unique name. In case of [manual decorators](#adding-attributes-to-links-using-the-ui-manual-decorators), that name also represents the decorator in the {@link framework/guides/architecture/editing-engine#text-attributes document model}.