Socket
Socket
Sign inDemoInstall

@ckeditor/ckeditor5-paste-from-office

Package Overview
Dependencies
Maintainers
1
Versions
633
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-paste-from-office - npm Package Compare versions

Comparing version 23.1.0 to 24.0.0

36

package.json
{
"name": "@ckeditor/ckeditor5-paste-from-office",
"version": "23.1.0",
"version": "24.0.0",
"description": "Paste from Office feature for CKEditor 5.",

@@ -13,21 +13,21 @@ "keywords": [

"dependencies": {
"@ckeditor/ckeditor5-clipboard": "^23.1.0",
"@ckeditor/ckeditor5-core": "^23.1.0",
"@ckeditor/ckeditor5-engine": "^23.1.0"
"@ckeditor/ckeditor5-clipboard": "^24.0.0",
"@ckeditor/ckeditor5-core": "^24.0.0",
"@ckeditor/ckeditor5-engine": "^24.0.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^23.1.0",
"@ckeditor/ckeditor5-cloud-services": "^23.1.0",
"@ckeditor/ckeditor5-easy-image": "^23.1.0",
"@ckeditor/ckeditor5-editor-classic": "^23.1.0",
"@ckeditor/ckeditor5-enter": "^23.1.0",
"@ckeditor/ckeditor5-font": "^23.1.0",
"@ckeditor/ckeditor5-heading": "^23.1.0",
"@ckeditor/ckeditor5-image": "^23.1.0",
"@ckeditor/ckeditor5-link": "^23.1.0",
"@ckeditor/ckeditor5-list": "^23.1.0",
"@ckeditor/ckeditor5-paragraph": "^23.1.0",
"@ckeditor/ckeditor5-page-break": "^23.1.0",
"@ckeditor/ckeditor5-table": "^23.1.0",
"@ckeditor/ckeditor5-utils": "^23.1.0"
"@ckeditor/ckeditor5-basic-styles": "^24.0.0",
"@ckeditor/ckeditor5-cloud-services": "^24.0.0",
"@ckeditor/ckeditor5-easy-image": "^24.0.0",
"@ckeditor/ckeditor5-editor-classic": "^24.0.0",
"@ckeditor/ckeditor5-enter": "^24.0.0",
"@ckeditor/ckeditor5-font": "^24.0.0",
"@ckeditor/ckeditor5-heading": "^24.0.0",
"@ckeditor/ckeditor5-image": "^24.0.0",
"@ckeditor/ckeditor5-link": "^24.0.0",
"@ckeditor/ckeditor5-list": "^24.0.0",
"@ckeditor/ckeditor5-paragraph": "^24.0.0",
"@ckeditor/ckeditor5-page-break": "^24.0.0",
"@ckeditor/ckeditor5-table": "^24.0.0",
"@ckeditor/ckeditor5-utils": "^24.0.0"
},

@@ -34,0 +34,0 @@ "engines": {

@@ -59,3 +59,2 @@ /**

currentList = insertNewEmptyList( listStyle, lastListItemChild, writer );
currentIndentation += 1;

@@ -66,3 +65,2 @@ } else if ( itemLikeElement.indent < currentIndentation ) {

currentList = findParentListAtLevel( currentList, differentIndentation );
currentIndentation = parseInt( itemLikeElement.indent );

@@ -163,5 +161,5 @@ }

// @returns {String} result.type List type, could be `ul` or `ol`.
// @returns {String} result.style List style, for example: `decimal`, `lower-roman`, etc. It is extracted
// directly from Word stylesheet without further processing and may be not compatible
// with CSS `list-style-type` property accepted values.
// @returns {String|null} result.style List style, for example: `decimal`, `lower-roman`, etc. It is extracted
// directly from Word stylesheet and adjusted to represent proper values for the CSS `list-style-type` property.
// If it cannot be adjusted, the `null` value is returned.
function detectListStyle( listLikeItem, stylesString ) {

@@ -174,2 +172,4 @@ const listStyleRegexp = new RegExp( `@list l${ listLikeItem.id }:level${ listLikeItem.indent }\\s*({[^}]*)`, 'gi' );

let listStyleType = 'decimal'; // Decimal is default one.
let type = 'ol'; // <ol> is default list.
if ( listStyleMatch && listStyleMatch[ 1 ] ) {

@@ -180,11 +180,94 @@ const listStyleTypeMatch = listStyleTypeRegex.exec( listStyleMatch[ 1 ] );

listStyleType = listStyleTypeMatch[ 1 ].trim();
type = listStyleType !== 'bullet' && listStyleType !== 'image' ? 'ol' : 'ul';
}
// Styles for the numbered lists are always defined in Word CSS stylesheet.
// Unordered lists MAY contain a value for the Word CSS definition `mso-level-text` but sometimes
// the tag is missing. And because of that, we cannot depend on that. We need to predict the list style value based on
// the list style marker element.
if ( listStyleType === 'bullet' ) {
const bulletedStyle = findBulletedListStyle( listLikeItem.element );
if ( bulletedStyle ) {
listStyleType = bulletedStyle;
}
}
}
return {
type: listStyleType !== 'bullet' && listStyleType !== 'image' ? 'ol' : 'ul',
style: listStyleType
type,
style: mapListStyleDefinition( listStyleType )
};
}
// Tries extract the `list-style-type` value based on the marker element for bulleted list.
//
// @param {module:engine/view/element~Element} element
// @returns {module:engine/view/element~Element|null}
function findBulletedListStyle( element ) {
const listMarkerElement = findListMarkerNode( element );
if ( !listMarkerElement ) {
return null;
}
const listMarker = listMarkerElement._data;
if ( listMarker === 'o' ) {
return 'circle';
} else if ( listMarker === '·' ) {
return 'disc';
}
// Word returns '§' instead of '■' for the square list style.
else if ( listMarker === '§' ) {
return 'square';
}
return null;
}
// Tries to find a text node that represents the marker element (list-style-type).
//
// @param {module:engine/view/element~Element} element
// @returns {module:engine/view/text~Text|null}
function findListMarkerNode( element ) {
// If the first child is a text node, it is a value for the element.
if ( element.getChild( 0 ).is( '$text' ) ) {
return null;
}
const textNodeOrElement = element.getChild( 0 ).getChild( 0 );
if ( textNodeOrElement.is( '$text' ) ) {
return textNodeOrElement;
}
return textNodeOrElement.getChild( 0 );
}
// Parses the `list-style-type` value extracted directly from the Word CSS stylesheet and returns proper CSS definition.
//
// @param {String|null} value
// @returns {String|null}
function mapListStyleDefinition( value ) {
switch ( value ) {
case 'arabic-leading-zero':
return 'decimal-leading-zero';
case 'alpha-upper':
return 'upper-alpha';
case 'alpha-lower':
return 'lower-alpha';
case 'roman-upper':
return 'upper-roman';
case 'roman-lower':
return 'lower-roman';
case 'circle':
case 'disc':
case 'square':
return value;
default:
return null;
}
}
// Creates empty list of a given type and inserts it after a specified element.

@@ -205,2 +288,8 @@ //

// We do not support modifying the marker for particular list item.
// Set the value for the `list-style-type` property directly to the list container.
if ( listStyle.style ) {
writer.setStyle( 'list-style-type', listStyle.style, list );
}
return list;

@@ -281,2 +370,7 @@ }

//
// However, it's quite easy to change the `id` attribute for nested lists in Word. It will break the list feature while pasting.
// Let's check also the `indent` attribute. If between those two elements, the difference is equal to 1, we can assume that
// the `currentItem` is a beginning of the nested list because lists in CKEditor 5 always starts with the `indent=0` attribute.
// See: https://github.com/ckeditor/ckeditor5/issues/7805.
//
// @param {Object} previousItem

@@ -291,2 +385,10 @@ // @param {Object} currentItem

if ( previousItem.id !== currentItem.id ) {
// See: https://github.com/ckeditor/ckeditor5/issues/7805.
//
// * List item 1.
// - Nested list item 1.
if ( currentItem.indent - previousItem.indent === 1 ) {
return false;
}
return true;

@@ -293,0 +395,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc