Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into t/ckeditor5/1098-poc
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed Dec 11, 2019
2 parents 33a1450 + 47da3c3 commit d37ad60
Show file tree
Hide file tree
Showing 39 changed files with 428 additions and 248 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Suggested merge commit message ([convention](https://github.com/ckeditor/ckeditor5-design/wiki/Git-commit-message-convention))

Type: Message. Closes #000.
Type: Message. Closes ckeditor/ckeditor5#000.

---

Expand Down
3 changes: 3 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "stylelint-config-ckeditor5"
}
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
sudo: required
dist: trusty
dist: xenial
addons:
chrome: stable
firefox: latest
language: node_js
services:
- xvfb
node_js:
- '8'
cache:
Expand All @@ -13,8 +15,6 @@ branches:
- stable
before_install:
- export START_TIME=$( date +%s )
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm i -g yarn
install:
- yarn add @ckeditor/ckeditor5-dev-tests
Expand Down
36 changes: 35 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
Changelog
=========

## [16.0.0](https://github.com/ckeditor/ckeditor5-link/compare/v15.0.0...v16.0.0) (2019-12-04)

### Bug fixes

* Link preview in the balloon should have `rel="noopener noreferrer"` set for security reasons. Closes [ckeditor/ckeditor5#5746](https://github.com/ckeditor/ckeditor5/issues/5746). ([5b921b4](https://github.com/ckeditor/ckeditor5-link/commit/5b921b4))

### Other changes

* Updated translations. ([5c84f57](https://github.com/ckeditor/ckeditor5-link/commit/5c84f57))


## [15.0.0](https://github.com/ckeditor/ckeditor5-link/compare/v11.1.2...v15.0.0) (2019-10-23)

### Other changes

* Added `pluginName` property to editing plugin. ([a3bf928](https://github.com/ckeditor/ckeditor5-link/commit/a3bf928))
* Updated translations. ([34b5552](https://github.com/ckeditor/ckeditor5-link/commit/34b5552)) ([9653092](https://github.com/ckeditor/ckeditor5-link/commit/9653092))


## [11.1.2](https://github.com/ckeditor/ckeditor5-link/compare/v11.1.1...v11.1.2) (2019-08-26)

### Bug fixes

* Add missing return value for link post-fixer. Closes [#241](https://github.com/ckeditor/ckeditor5-link/issues/241). ([14e5803](https://github.com/ckeditor/ckeditor5-link/commit/14e5803))
* Improved balloon positioning when there is more than one stack in the rotator. ([d6c45df](https://github.com/ckeditor/ckeditor5-link/commit/d6c45df))
* The UI buttons should be marked as toggleable for better assistive technologies support (see [ckeditor/ckeditor5#1403](https://github.com/ckeditor/ckeditor5/issues/1403)). ([b9e31a0](https://github.com/ckeditor/ckeditor5-link/commit/b9e31a0))

### Other changes

* The issue tracker for this package was moved to https://github.com/ckeditor/ckeditor5/issues. See [ckeditor/ckeditor5#1988](https://github.com/ckeditor/ckeditor5/issues/1988). ([cea8fa2](https://github.com/ckeditor/ckeditor5-link/commit/cea8fa2))
* Passed editor content direction to the `bindTwoStepCaretToAttribute()` helper in the `LinkEditing` plugin. See [ckeditor/ckeditor5#1151](https://github.com/ckeditor/ckeditor5/issues/1151). ([73bf132](https://github.com/ckeditor/ckeditor5-link/commit/73bf132))
* Updated translations. ([4345546](https://github.com/ckeditor/ckeditor5-link/commit/4345546))


## [11.1.1](https://github.com/ckeditor/ckeditor5-link/compare/v11.1.0...v11.1.1) (2019-07-10)

### Other changes

* Updated translations. ([6b720be](https://github.com/ckeditor/ckeditor5-link/commit/6b720be))
* Updated translations. ([6b720be](https://github.com/ckeditor/ckeditor5-link/commit/6b720be))


## [11.1.0](https://github.com/ckeditor/ckeditor5-link/compare/v11.0.2...v11.1.0) (2019-07-04)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
CKEditor 5 link feature
========================================

[![Join the chat at https://gitter.im/ckeditor/ckeditor5](https://badges.gitter.im/ckeditor/ckeditor5.svg)](https://gitter.im/ckeditor/ckeditor5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-link.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-link)
[![Build Status](https://travis-ci.org/ckeditor/ckeditor5-link.svg?branch=master)](https://travis-ci.org/ckeditor/ckeditor5-link)
[![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5-link/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5-link?branch=master)
Expand Down
12 changes: 0 additions & 12 deletions docs/_snippets/features/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ ClassicEditor
.create( document.querySelector( '#snippet-link' ), {
cloudServices: CS_CONFIG,
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'blockQuote',
'undo',
'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
}
} )
Expand Down
12 changes: 0 additions & 12 deletions docs/_snippets/features/linkdecorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ ClassicEditor
.create( document.querySelector( '#snippet-link-decorators' ), {
cloudServices: CS_CONFIG,
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'blockQuote',
'undo',
'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
},
link: {
Expand Down
2 changes: 1 addition & 1 deletion docs/api/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ The source code of this package is available on GitHub in https://github.com/cke

* [`@ckeditor/ckeditor5-link` on npm](https://www.npmjs.com/package/@ckeditor/ckeditor5-link)
* [`ckeditor/ckeditor5-link` on GitHub](https://github.com/ckeditor/ckeditor5-link)
* [Issue tracker](https://github.com/ckeditor/ckeditor5-link/issues)
* [Issue tracker](https://github.com/ckeditor/ckeditor5/issues)
* [Changelog](https://github.com/ckeditor/ckeditor5-link/blob/master/CHANGELOG.md)
36 changes: 20 additions & 16 deletions docs/features/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ category: features

{@snippet features/build-link-source}

The {@link module:link/link~Link} feature brings support for link editing to the editor. It allows for inserting hyperlinks into the edited content and offers the UI to create and edit them.
The {@link module:link/link~Link} feature brings support for link editing to the rich-text editor. It allows for inserting hyperlinks into the edited content and offers the UI to create and edit them.

## Demo

Expand All @@ -27,13 +27,15 @@ CKEditor 5 allows for typing both at inner and outer boundaries of links to make

## Custom link attributes (decorators)

By default, all links created in the editor have the `href="..."` attribute in the {@link builds/guides/integration/basic-api#getting-the-editor-data editor data}. If you want your links to have additional link attributes, {@link module:link/link~LinkConfig#decorators link decorators} provide an easy way to configure and manage them. There are two types of link decorators you can make use of:
By default, all links created in the editor have the `href="..."` attribute in the {@link builds/guides/integration/basic-api#getting-the-editor-data editor data}. If you want your links to have additional link attributes, {@link module:link/link~LinkConfig#decorators link decorators} provide an easy way to configure and manage them.

* [**automatic**](#adding-attributes-to-links-based-on-predefined-rules-automatic-decorators) – they match links against pre–defined rules and manage their attributes based on the results,
* [**manual**](#adding-attributes-to-links-using-the-ui-manual-decorators) – they allow users to control link attributes individually using the editor UI.
There are two types of link decorators you can use:

* [**Automatic**](#adding-attributes-to-links-based-on-predefined-rules-automatic-decorators) – They match links against pre–defined rules and manage their attributes based on the results.
* [**Manual**](#adding-attributes-to-links-using-the-ui-manual-decorators) – They allow users to control link attributes individually using the editor UI.

<info-box>
Link decorators are disabled by default and it takes a proper [configuration](#configuration) to enable them in your editor. If you do not want to use them in your application, you do not need to do anything.
Link decorators are disabled by default and it takes a proper [configuration](#configuration) to enable them in your rich-text editor.
</info-box>

### Demo
Expand All @@ -57,7 +59,7 @@ ClassicEditor
// Automatically add target="_blank" and rel="noopener noreferrer" to all external links.
addTargetToExternalLinks: true,

// Allow users control the "download" attribute of each link.
// Let the users control the "download" attribute of each link.
decorators: [
{
mode: 'manual',
Expand All @@ -75,15 +77,17 @@ ClassicEditor

### 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}.
Decorators are configured through definitions provided in the {@link module:link/link~LinkConfig#decorators `config.link.decorators`} configuration option.

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}.

<info-box warning>
Link decorators work independently and no conflict resolution mechanism exists. For example, configuring the `target` attribute using both an automatic and a manual decorator at a time could end up with quirky results. The same applies if multiple manual or automatic decorators were defined for the same attribute.
Link decorators work independently of one another and no conflict resolution mechanism exists. For example, configuring the `target` attribute using both an automatic and a manual decorator at the same time could end up with quirky results. The same applies if multiple manual or automatic decorators were defined for the same attribute.
</info-box>

#### Adding `target` and `rel` attributes to external links

A very common use case for (automatic) link decorators is adding `target="_blank"` and `rel="noopener noreferrer"` attributes to all external links in the document. A dedicated {@link module:link/link~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`} configuration has been created for that purpose. When this option is set `true`, all links starting with `http://`, `https://` or `//` are "decorated" with `target` and `rel` attributes.
A very common use case for (automatic) link decorators is adding `target="_blank"` and `rel="noopener noreferrer"` attributes to all external links in the document. A dedicated {@link module:link/link~LinkConfig#addTargetToExternalLinks `config.link.addTargetToExternalLinks`} configuration has been created for that purpose. When this option is set to `true`, all links starting with `http://`, `https://` or `//` are "decorated" with `target` and `rel` attributes.

```js
ClassicEditor
Expand Down Expand Up @@ -120,17 +124,17 @@ ClassicEditor
.catch( ... );
```

**Note**: If you want to leave the decision whether a link should open in new tab to the users, do not use the `config.link.addTargetToExternalLinks` configuration but define a new [manual decorator](#adding-attributes-to-links-using-the-ui-manual-decorators) with the proper definition:
If you want to leave the decision whether a link should open in a new tab to the users, do not use the `config.link.addTargetToExternalLinks` configuration but define a new [manual decorator](#adding-attributes-to-links-using-the-ui-manual-decorators) with the following definition instead:

```js
ClassicEditor
.create( document.querySelector( '#editor' ), {
// ...
link: {
decorators: {
addTargetToLinks: {
addTargetToExternalLinks: {
mode: 'manual',
label: 'Open link in a new tab',
label: 'Open in a new tab',
attributes: {
target: '_blank',
rel: 'noopener noreferrer'
Expand All @@ -145,7 +149,7 @@ ClassicEditor

#### Adding attributes to links based on pre–defined rules (automatic decorators)

Automatic link decorators match all links in the editor content against a {@link module:link/link~LinkDecoratorAutomaticDefinition function} which decides whether the link should gain some set of attributes or not, considering the URL (`href`) of the link. These decorators work silently being applied during {@link framework/guides/architecture/editing-engine#conversion data downcast} only.
Automatic link decorators match all links in the editor content against a {@link module:link/link~LinkDecoratorAutomaticDefinition function} which decides whether the link should receive some set of attributes, considering the URL (`href`) of the link. These decorators work silently and are being applied during the {@link framework/guides/architecture/editing-engine#conversion data downcast} only.

For instance, to create an automatic decorator that adds the `download="file.pdf"` attribute to all links ending with the `".pdf"` extension, you should add the following {@link module:link/link~LinkDecoratorAutomaticDefinition definition} to {@link module:link/link~LinkConfig#decorators `config.link.decorators`}:

Expand All @@ -170,12 +174,12 @@ ClassicEditor
```

<info-box>
If you want `target` and `rel` attributes to be added to all external links in your content, we prepared a [dedicated configuration](#adding-target-and-rel-attributes-to-external-links) exactly for that purpose so you do not have to define the automatic decorator by yourself.
If you want the `target` and `rel` attributes to be added to all external links in your content, we prepared a [dedicated configuration](#adding-target-and-rel-attributes-to-external-links) exactly for that purpose so you do not have to define the automatic decorator by yourself.
</info-box>

#### Adding attributes to links using the UI (manual decorators)

Manual link decorators are represented in the link editing balloon as switch buttons users can use to control the presence of attributes of a particular link (check out the [demo](#demo) to learn more). Each manual decorator {@link module:link/link~LinkDecoratorManualDefinition definition} contains a human–readable label displayed next to the switch button in the link editing balloon. Make sure it is compact and precise for the convenience of the users.
Manual link decorators are represented in the link editing balloon as switch buttons that the users can use to control the presence of attributes of a particular link (check out the [demo](#demo) to learn more). Each manual decorator {@link module:link/link~LinkDecoratorManualDefinition definition} contains a human–readable label displayed next to the switch button in the link editing balloon. Make sure it is compact and precise for the convenience of the users.

To configure a "Downloadable" switch button in the link editing balloon that adds the `download="file"` attribute to the link when turned on, add the following definition to {@link module:link/link~LinkConfig#decorators `config.link.decorators`}:

Expand Down Expand Up @@ -246,7 +250,7 @@ editor.execute( 'link', 'http://example.com', { linkIsExternal: true } );
editor.execute( 'unlink' );
```

Links are represented in the {@link module:engine/model/model~Model model} using the `linkHref` attribute. [Manual link decorators](#adding-attributes-to-links-using-the-ui-manual-decorators) are represented in the model using text attributes corresponding to their names as configured in {@link module:link/link~LinkConfig#decorators `config.link.decorators`}.
Links are represented in the {@link module:engine/model/model~Model model} using the `linkHref` attribute. [Manual link decorators](#adding-attributes-to-links-using-the-ui-manual-decorators) are represented in the model using text attributes corresponding to their names, as configured in {@link module:link/link~LinkConfig#decorators `config.link.decorators`}.

<info-box>
We recommend using the official {@link framework/guides/development-tools#ckeditor-5-inspector CKEditor 5 inspector} for development and debugging. It will give you tons of useful information about the state of the editor such as internal data structures, selection, commands, and many more.
Expand Down
4 changes: 2 additions & 2 deletions lang/translations/az.po
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ msgstr "Bu linkdə URL yoxdur"

msgctxt "The label of the switch button that controls whether the edited link will open in a new tab."
msgid "Open in a new tab"
msgstr ""
msgstr "Yeni pəncərədə aç"

msgctxt "The label of the switch button that controls whether the edited link refers to downloadable resource."
msgid "Downloadable"
msgstr ""
msgstr "Yüklənə bilər"
4 changes: 2 additions & 2 deletions lang/translations/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ msgstr "Tento odkaz nemá žádnou URL"

msgctxt "The label of the switch button that controls whether the edited link will open in a new tab."
msgid "Open in a new tab"
msgstr ""
msgstr "Otevřít v nové kartě"

msgctxt "The label of the switch button that controls whether the edited link refers to downloadable resource."
msgid "Downloadable"
msgstr ""
msgstr "Ke stažení"
10 changes: 5 additions & 5 deletions lang/translations/da.po
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ msgstr "Link URL"

msgctxt "Button opening the Link URL editing balloon."
msgid "Edit link"
msgstr ""
msgstr "Redigér link"

msgctxt "Button opening the link in new browser tab."
msgid "Open link in new tab"
msgstr ""
msgstr "Åben link i ny fane"

msgctxt "Label explaining that a link has no URL set (the URL is empty)."
msgid "This link has no URL"
msgstr ""
msgstr "Dette link har ingen URL"

msgctxt "The label of the switch button that controls whether the edited link will open in a new tab."
msgid "Open in a new tab"
msgstr ""
msgstr "Åben i ny fane"

msgctxt "The label of the switch button that controls whether the edited link refers to downloadable resource."
msgid "Downloadable"
msgstr ""
msgstr "Kan downloades"
49 changes: 49 additions & 0 deletions lang/translations/en-gb.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
#
# !!! IMPORTANT !!!
#
# Before you edit this file, please keep in mind that contributing to the project
# translations is possible ONLY via the Transifex online service.
#
# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
#
# To learn more, check out the official contributor's guide:
# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
#
msgid ""
msgstr ""
"Language-Team: English (United Kingdom) (https://www.transifex.com/ckeditor/teams/11143/en_GB/)\n"
"Language: en_GB\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgctxt "Toolbar button tooltip for the Unlink feature."
msgid "Unlink"
msgstr "Unlink"

msgctxt "Toolbar button tooltip for the Link feature."
msgid "Link"
msgstr "Link"

msgctxt "Label for the URL input in the Link URL editing balloon."
msgid "Link URL"
msgstr "Link URL"

msgctxt "Button opening the Link URL editing balloon."
msgid "Edit link"
msgstr "Edit link"

msgctxt "Button opening the link in new browser tab."
msgid "Open link in new tab"
msgstr "Open link in new tab"

msgctxt "Label explaining that a link has no URL set (the URL is empty)."
msgid "This link has no URL"
msgstr "This link has no URL"

msgctxt "The label of the switch button that controls whether the edited link will open in a new tab."
msgid "Open in a new tab"
msgstr "Open in a new tab"

msgctxt "The label of the switch button that controls whether the edited link refers to downloadable resource."
msgid "Downloadable"
msgstr "Downloadable"
4 changes: 2 additions & 2 deletions lang/translations/et.po
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ msgstr "Sellel lingil puudub URL"

msgctxt "The label of the switch button that controls whether the edited link will open in a new tab."
msgid "Open in a new tab"
msgstr ""
msgstr "Ava uuel kaardil"

msgctxt "The label of the switch button that controls whether the edited link refers to downloadable resource."
msgid "Downloadable"
msgstr ""
msgstr "Allalaaditav"
4 changes: 2 additions & 2 deletions lang/translations/fa.po
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ msgstr "این پیوند نشانی اینترنتی ندارد"

msgctxt "The label of the switch button that controls whether the edited link will open in a new tab."
msgid "Open in a new tab"
msgstr ""
msgstr "بازکردن در برگه جدید"

msgctxt "The label of the switch button that controls whether the edited link refers to downloadable resource."
msgid "Downloadable"
msgstr ""
msgstr "قابل بارگیری"

0 comments on commit d37ad60

Please sign in to comment.