This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for link decorators.
- Loading branch information
Mateusz Samsel
committed
Jun 17, 2019
1 parent
53bcb89
commit 1493e0b
Showing
3 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div id="snippet-link-decorators"> | ||
<h2>Links list</h2> | ||
<ol> | ||
<li> | ||
<a href="https://ckeditor.com">Link to external page</a> | ||
</li> | ||
<li> | ||
<a href="/">Link to internal page</a> | ||
</li> | ||
</ol> | ||
</div> | ||
<pre class="highlight"> | ||
<code class="html hljs" id="output-link-decorators"></code> | ||
</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/* globals console, window, document, Worker, setTimeout */ | ||
|
||
import ClassicEditor from '@ckeditor/ckeditor5-build-classic/src/ckeditor'; | ||
import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config'; | ||
|
||
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: { | ||
targetDecorator: true, | ||
decorators: [ | ||
{ | ||
mode: 'manual', | ||
label: 'Downloadable', | ||
attributes: { | ||
download: 'download' | ||
} | ||
} | ||
] | ||
} | ||
} ) | ||
.then( editor => { | ||
if ( !window.editors ) { | ||
window.editors = {}; | ||
} | ||
window.editors.decorators = editor; | ||
|
||
const outputElement = document.querySelector( '#output-link-decorators' ); | ||
const worker = new Worker( window.umberto.relativeAppPath + '/highlight.worker.js' ); | ||
|
||
worker.addEventListener( 'message', evt => { | ||
const data = JSON.parse( evt.data ); | ||
|
||
outputElement.innerHTML = data.payload; | ||
} ); | ||
|
||
editor.model.document.on( 'change', () => { | ||
worker.postMessage( JSON.stringify( { | ||
payload: editor.getData(), | ||
language: 'html' | ||
} ) ); | ||
} ); | ||
|
||
setTimeout( () => { | ||
worker.postMessage( JSON.stringify( { | ||
payload: editor.getData(), | ||
language: 'html' | ||
} ) ); | ||
}, 500 ); | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters