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 15
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 #97 from ckeditor/t/96
Feature: Introduced `Editor#isReadOnly` property which disables all commands and prevents from modifying the document. Closes #96. Closes ckeditor/ckeditor5#492.
- Loading branch information
Showing
8 changed files
with
179 additions
and
7 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
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
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,34 @@ | ||
<button id="read-only">Turn on read-only mode</button> | ||
|
||
<div id="editor"> | ||
<h2>Heading 1</h2> | ||
<p>Paragraph</p> | ||
<p><strong>Bold</strong> <i>Italic</i> <a href="foo">Link</a></p> | ||
<ul> | ||
<li>UL List item 1</li> | ||
<li>UL List item 2</li> | ||
</ul> | ||
<ol> | ||
<li>OL List item 1</li> | ||
<li>OL List item 2</li> | ||
</ol> | ||
<figure class="image image-style-side"> | ||
<img alt="bar" src="sample.jpg"> | ||
<figcaption>Caption</figcaption> | ||
</figure> | ||
<blockquote> | ||
<p>Quote</p> | ||
<ul> | ||
<li>Quoted UL List item 1</li> | ||
<li>Quoted UL List item 2</li> | ||
</ul> | ||
<p>Quote</p> | ||
</blockquote> | ||
</div> | ||
|
||
<style> | ||
#read-only { | ||
margin: 10px 0 15px; | ||
font-size: 16px; | ||
} | ||
</style> |
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,34 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/* globals console, window, document */ | ||
|
||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
|
||
import ArticlePreset from '@ckeditor/ckeditor5-presets/src/article'; | ||
import ContextualToolbar from '@ckeditor/ckeditor5-ui/src/toolbar/contextual/contextualtoolbar'; | ||
|
||
ClassicEditor.create( document.querySelector( '#editor' ), { | ||
plugins: [ ArticlePreset, ContextualToolbar ], | ||
toolbar: [ 'headings', 'bold', 'italic', 'link', 'unlink', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ], | ||
image: { | ||
toolbar: [ 'imageStyleFull', 'imageStyleSide', '|', 'imageTextAlternative' ], | ||
}, | ||
contextualToolbar: [ 'bold', 'italic', 'link' ] | ||
} ) | ||
.then( editor => { | ||
window.editor = editor; | ||
|
||
const button = document.querySelector( '#read-only' ); | ||
|
||
button.addEventListener( 'click', () => { | ||
editor.isReadOnly = !editor.isReadOnly; | ||
button.textContent = editor.isReadOnly ? 'Turn off read-only mode' : 'Turn on read-only mode'; | ||
} ); | ||
} ) | ||
.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Read-only | ||
|
||
1. Change a content in the editor. | ||
2. Turn on read-only mode by clicking the button above the editor. | ||
3. Check if undo/redo (by shortcuts) is disabled. | ||
4. Check if modifying content is blocked (input, delete, paste) for collapsed and non-collapsed selection. | ||
5. Check if toolbar buttons are disabled. | ||
6. Check if toolbar buttons reflect selection attributes (eg. when selection is in bold text then bold button should be on). | ||
7. Check 5 and 6 for the ContextualToolbar. | ||
8. Check if link balloon panel opens in read-only mode. | ||
9. Check if image text alternative balloon opens in read-only mode. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.