@ckeditor/ckeditor5-clipboard
Advanced tools
Comparing version 22.0.0 to 23.0.0
{ | ||
"name": "@ckeditor/ckeditor5-clipboard", | ||
"version": "22.0.0", | ||
"version": "23.0.0", | ||
"description": "Clipboard integration for CKEditor 5.", | ||
@@ -13,12 +13,12 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^22.0.0", | ||
"@ckeditor/ckeditor5-engine": "^22.0.0", | ||
"@ckeditor/ckeditor5-utils": "^22.0.0" | ||
"@ckeditor/ckeditor5-core": "^23.0.0", | ||
"@ckeditor/ckeditor5-engine": "^23.0.0", | ||
"@ckeditor/ckeditor5-utils": "^23.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^22.0.0", | ||
"@ckeditor/ckeditor5-block-quote": "^22.0.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^22.0.0", | ||
"@ckeditor/ckeditor5-link": "^22.0.0", | ||
"@ckeditor/ckeditor5-paragraph": "^22.0.0" | ||
"@ckeditor/ckeditor5-basic-styles": "^23.0.0", | ||
"@ckeditor/ckeditor5-block-quote": "^23.0.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^23.0.0", | ||
"@ckeditor/ckeditor5-link": "^23.0.0", | ||
"@ckeditor/ckeditor5-paragraph": "^23.0.0" | ||
}, | ||
@@ -25,0 +25,0 @@ "engines": { |
@@ -11,2 +11,3 @@ /** | ||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; | ||
import PastePlainText from './pasteplaintext'; | ||
@@ -42,2 +43,9 @@ import ClipboardObserver from './clipboardobserver'; | ||
*/ | ||
static get requires() { | ||
return [ PastePlainText ]; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
init() { | ||
@@ -82,3 +90,7 @@ const editor = this.editor; | ||
const eventInfo = new EventInfo( this, 'inputTransformation' ); | ||
this.fire( eventInfo, { content, dataTransfer } ); | ||
this.fire( eventInfo, { | ||
content, | ||
dataTransfer, | ||
asPlainText: data.asPlainText | ||
} ); | ||
@@ -109,8 +121,18 @@ // If CKEditor handled the input, do not bubble the original event any further. | ||
// While pasting plain text, apply selection attributes on the text. | ||
if ( isPlainText( modelFragment ) ) { | ||
const node = modelFragment.getChild( 0 ); | ||
// Plain text can be determined based on event flag (#7799) or auto detection (#1006). If detected | ||
// preserve selection attributes on pasted items. | ||
if ( data.asPlainText || isPlainTextFragment( modelFragment ) ) { | ||
// Consider only formatting attributes. | ||
const textAttributes = new Map( Array.from( modelDocument.selection.getAttributes() ).filter( | ||
keyValuePair => editor.model.schema.getAttributeProperties( keyValuePair[ 0 ] ).isFormatting | ||
) ); | ||
model.change( writer => { | ||
writer.setAttributes( modelDocument.selection.getAttributes(), node ); | ||
const range = writer.createRangeIn( modelFragment ); | ||
for ( const item of range.getItems() ) { | ||
if ( item.is( '$text' ) || item.is( '$textProxy' ) ) { | ||
writer.setAttributes( textAttributes, item ); | ||
} | ||
} | ||
} ); | ||
@@ -120,2 +142,3 @@ } | ||
model.insertContent( modelFragment ); | ||
evt.stop(); | ||
@@ -176,2 +199,3 @@ } | ||
* @param {module:clipboard/datatransfer~DataTransfer} data.dataTransfer Data transfer instance. | ||
* @param {Boolean} data.asPlainText If set to `true` content is pasted as plain text. | ||
*/ | ||
@@ -221,3 +245,3 @@ | ||
// @returns {Boolean} | ||
function isPlainText( documentFragment ) { | ||
function isPlainTextFragment( documentFragment ) { | ||
if ( documentFragment.childCount > 1 ) { | ||
@@ -224,0 +248,0 @@ return false; |
@@ -21,4 +21,6 @@ /** | ||
.replace( />/g, '>' ) | ||
// Creates paragraphs for every line breaks. | ||
.replace( /\n/g, '</p><p>' ) | ||
// Creates a paragraph for each double line break. | ||
.replace( /\r?\n\r?\n/g, '</p><p>' ) | ||
// Creates a line break for each single line break. | ||
.replace( /\r?\n/g, '<br>' ) | ||
// Preserve trailing spaces (only the first and last one – the rest is handled below). | ||
@@ -30,3 +32,3 @@ .replace( /^\s/, ' ' ) | ||
if ( text.indexOf( '</p><p>' ) > -1 ) { | ||
if ( text.includes( '</p><p>' ) || text.includes( '<br>' ) ) { | ||
// If we created paragraphs above, add the trailing ones. | ||
@@ -33,0 +35,0 @@ text = `<p>${ text }</p>`; |
@@ -30,2 +30,5 @@ /** | ||
text = viewItem.getAttribute( 'alt' ); | ||
} else if ( viewItem.is( 'element', 'br' ) ) { | ||
// A soft break should be converted into a single line break (#8045). | ||
text = '\n'; | ||
} else { | ||
@@ -32,0 +35,0 @@ // Other elements are document fragments, attribute elements or container elements. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36781
11
606
+ Added@ckeditor/ckeditor5-core@23.1.0(transitive)
+ Added@ckeditor/ckeditor5-engine@23.1.0(transitive)
+ Added@ckeditor/ckeditor5-utils@23.1.0(transitive)
- Removed@ckeditor/ckeditor5-core@22.0.0(transitive)
- Removed@ckeditor/ckeditor5-engine@22.0.0(transitive)
- Removed@ckeditor/ckeditor5-utils@22.0.0(transitive)