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 6
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 #58 from ckeditor/t/57
Fix: Selection converter will mark only the topmost widget in case of selecting a widget with another widget nested inside it. Closes #57.
- Loading branch information
Showing
7 changed files
with
275 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<head> | ||
<style> | ||
body { | ||
max-width: 800px; | ||
margin: 20px auto; | ||
} | ||
|
||
.ck-content .widget { | ||
background: rgba( 0, 0, 0, 0.1 ); | ||
padding: 20px !important; | ||
min-height: 50px; | ||
} | ||
</style> | ||
</head> | ||
<div id="editor"> | ||
<h2>Heading 1</h2> | ||
<p>Paragraph</p> | ||
<div class="widget"> | ||
<div class="widget"></div> | ||
<div class="widget"></div> | ||
</div> | ||
<p>Paragraph</p> | ||
</div> |
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,78 @@ | ||
/** | ||
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/* globals console, window, document, setInterval */ | ||
|
||
import Widget from '../../src/widget'; | ||
import { toWidget } from '../../src/utils'; | ||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset'; | ||
import { downcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters'; | ||
import { upcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters'; | ||
import { getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; | ||
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view'; | ||
|
||
function MyPlugin( editor ) { | ||
editor.model.schema.register( 'div', { | ||
allowIn: [ '$root', 'div' ], | ||
isObject: true | ||
} ); | ||
|
||
editor.model.schema.extend( '$text', { | ||
allowIn: 'div' | ||
} ); | ||
|
||
editor.conversion.for( 'downcast' ).add( downcastElementToElement( { | ||
model: 'div', | ||
view: ( modelElement, writer ) => { | ||
return toWidget( writer.createContainerElement( 'div', { class: 'widget' } ), writer ); | ||
} | ||
} ) ); | ||
|
||
editor.conversion.for( 'upcast' ).add( upcastElementToElement( { | ||
model: 'div', | ||
view: 'div' | ||
} ) ); | ||
} | ||
|
||
ClassicEditor | ||
.create( document.querySelector( '#editor' ), { | ||
plugins: [ ArticlePluginSet, Widget, MyPlugin ], | ||
toolbar: [ | ||
'heading', | ||
'|', | ||
'bold', | ||
'italic', | ||
'link', | ||
'bulletedList', | ||
'numberedList', | ||
'blockQuote', | ||
'insertTable', | ||
'mediaEmbed', | ||
'undo', | ||
'redo' | ||
], | ||
image: { | ||
toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ] | ||
}, | ||
table: { | ||
contentToolbar: [ | ||
'tableColumn', | ||
'tableRow', | ||
'mergeTableCells' | ||
] | ||
} | ||
} ) | ||
.then( editor => { | ||
window.editor = editor; | ||
|
||
setInterval( () => { | ||
console.log( getModelData( editor.model ) ); | ||
console.log( getViewData( editor.editing.view ) ); | ||
}, 3000 ); | ||
} ) | ||
.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,3 @@ | ||
# Nested widgets | ||
|
||
* When selecting the most top-outer widget, nested widgets should not be selected. |
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