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.
Merge pull request #230 from ckeditor/t/229
Docs: Documentation for link's decorators. Closes #229.
- Loading branch information
Showing
7 changed files
with
213 additions
and
10 deletions.
There are no files selected for viewing
Empty file.
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,12 @@ | ||
/** | ||
* @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 window */ | ||
|
||
import ClassicEditor from '@ckeditor/ckeditor5-build-classic/src/ckeditor'; | ||
import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config'; | ||
|
||
window.ClassicEditor = ClassicEditor; | ||
window.CS_CONFIG = CS_CONFIG; |
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
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,10 @@ | ||
<div id="snippet-link-decorators"> | ||
<p> | ||
An <a href="https://ckeditor.com">external page</a> and a | ||
<a download="download" href="https://cdn.ckeditor.com/ckeditor5/12.2.0/classic/ckeditor.js">downloadable resource</a>. | ||
</p> | ||
</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,70 @@ | ||
/** | ||
* @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, ClassicEditor, CS_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: { | ||
addTargetToExternalLinks: 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
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