Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ckeditor/ckeditor5-image

Package Overview
Dependencies
Maintainers
1
Versions
706
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-image - npm Package Compare versions

Comparing version 12.0.0 to 13.0.0

lang/translations/az.po

25

CHANGELOG.md
Changelog
=========
## [13.0.0](https://github.com/ckeditor/ckeditor5-image/compare/v12.0.0...v13.0.0) (2019-02-28)
### Features
* Enable images in table cells. ([3a4d2ca](https://github.com/ckeditor/ckeditor5-image/commit/3a4d2ca))
### Bug fixes
* Insert missing caption for images that are nested in other elements. Closes https://github.com/ckeditor/ckeditor5/issues/1524. ([0e3a7c5](https://github.com/ckeditor/ckeditor5-image/commit/0e3a7c5))
* The text alternative input should be blurred before the form is removed from the DOM. Closes ckeditor/ckeditor5/issues#1501. ([f89fe04](https://github.com/ckeditor/ckeditor5-image/commit/f89fe04))
* Fixed memory leaks during editor initialization and destruction (see [ckeditor/ckeditor5#1341](https://github.com/ckeditor/ckeditor5/issues/1341)). ([205f119](https://github.com/ckeditor/ckeditor5-image/commit/205f119))
### Other changes
* Aligned to the new `WidgetToolbarRepository` API. Replaced the `isImageWidgetSelected()` utility with `getSelectedImageWidget()` (see [ckeditor/ckeditor5-widget#60](https://github.com/ckeditor/ckeditor5-widget/issues/60)). ([699d586](https://github.com/ckeditor/ckeditor5-image/commit/699d586))
* Remove `ImageEditing` plugin from requires method of `ImageStyleEditing`. Closes [#261](https://github.com/ckeditor/ckeditor5-image/issues/261). ([5dea054](https://github.com/ckeditor/ckeditor5-image/commit/5dea054))
* The image uploading listener for handling `base64/blob` images no longer stops `inputTransformation` event. Closes [#263](https://github.com/ckeditor/ckeditor5-image/issues/263). Closes [ckeditor/ckeditor5-paste-from-office#44](https://github.com/ckeditor/ckeditor5-paste-from-office/issues/44). ([8c5b4fc](https://github.com/ckeditor/ckeditor5-image/commit/8c5b4fc))
* Updated translations. ([1f4e70d](https://github.com/ckeditor/ckeditor5-image/commit/1f4e70d)) ([6c9e15c](https://github.com/ckeditor/ckeditor5-image/commit/6c9e15c)) ([a1b03b9](https://github.com/ckeditor/ckeditor5-image/commit/a1b03b9))
### BREAKING CHANGES
* Upgraded minimal versions of Node to `8.0.0` and npm to `5.7.1`. See: [ckeditor/ckeditor5#1507](https://github.com/ckeditor/ckeditor5/issues/1507). ([612ea3c](https://github.com/ckeditor/ckeditor5-cloud-services/commit/612ea3c))
* The `isImageWidgetSelected()` utility has been replaced by `getSelectedImageWidget()` and returns an editing `View` element instead of `Boolean`.
## [12.0.0](https://github.com/ckeditor/ckeditor5-image/compare/v11.0.0...v12.0.0) (2018-12-05)

@@ -5,0 +30,0 @@

2

LICENSE.md

@@ -5,3 +5,3 @@ Software License Agreement

**CKEditor 5 Image Feature** – https://github.com/ckeditor/ckeditor5-image <br>
Copyright (c) 2003-2018, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.
Copyright (c) 2003-2019, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.

@@ -8,0 +8,0 @@ Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).

{
"name": "@ckeditor/ckeditor5-image",
"version": "12.0.0",
"version": "13.0.0",
"description": "Image feature for CKEditor 5.",

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

"dependencies": {
"@ckeditor/ckeditor5-core": "^11.1.0",
"@ckeditor/ckeditor5-engine": "^12.0.0",
"@ckeditor/ckeditor5-theme-lark": "^12.0.0",
"@ckeditor/ckeditor5-ui": "^11.2.0",
"@ckeditor/ckeditor5-upload": "^10.0.4",
"@ckeditor/ckeditor5-utils": "^11.1.0",
"@ckeditor/ckeditor5-widget": "^10.3.1"
"@ckeditor/ckeditor5-core": "^12.0.0",
"@ckeditor/ckeditor5-engine": "^13.0.0",
"@ckeditor/ckeditor5-theme-lark": "^13.0.0",
"@ckeditor/ckeditor5-ui": "^12.0.0",
"@ckeditor/ckeditor5-upload": "^11.0.0",
"@ckeditor/ckeditor5-utils": "^12.0.0",
"@ckeditor/ckeditor5-widget": "^11.0.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^10.1.0",
"@ckeditor/ckeditor5-clipboard": "^10.0.4",
"@ckeditor/ckeditor5-editor-classic": "^11.0.2",
"@ckeditor/ckeditor5-enter": "^10.1.3",
"@ckeditor/ckeditor5-essentials": "^10.1.3",
"@ckeditor/ckeditor5-heading": "^10.1.1",
"@ckeditor/ckeditor5-link": "^10.1.0",
"@ckeditor/ckeditor5-list": "^11.0.3",
"@ckeditor/ckeditor5-paragraph": "^10.0.4",
"@ckeditor/ckeditor5-typing": "^11.0.2",
"@ckeditor/ckeditor5-undo": "^10.0.4",
"@ckeditor/ckeditor5-basic-styles": "^11.0.0",
"@ckeditor/ckeditor5-clipboard": "^11.0.0",
"@ckeditor/ckeditor5-editor-classic": "^12.0.0",
"@ckeditor/ckeditor5-enter": "^11.0.0",
"@ckeditor/ckeditor5-essentials": "^11.0.0",
"@ckeditor/ckeditor5-heading": "^11.0.0",
"@ckeditor/ckeditor5-link": "^11.0.0",
"@ckeditor/ckeditor5-list": "^12.0.0",
"@ckeditor/ckeditor5-paragraph": "^11.0.0",
"@ckeditor/ckeditor5-typing": "^12.0.0",
"@ckeditor/ckeditor5-undo": "^11.0.0",
"eslint": "^5.5.0",
"eslint-config-ckeditor5": "^1.0.7",
"husky": "^0.14.3",
"eslint-config-ckeditor5": "^1.0.11",
"husky": "^1.3.1",
"lint-staged": "^7.0.0"
},
"engines": {
"node": ">=6.9.0",
"npm": ">=3.0.0"
"node": ">=8.0.0",
"npm": ">=5.7.1"
},
"author": "CKSource (http://cksource.com/)",
"license": "GPL-2.0-or-later",
"homepage": "https://ckeditor.com",
"homepage": "https://ckeditor.com/ckeditor-5",
"bugs": "https://github.com/ckeditor/ckeditor5-image/issues",

@@ -57,4 +57,3 @@ "repository": {

"scripts": {
"lint": "eslint --quiet '**/*.js'",
"precommit": "lint-staged"
"lint": "eslint --quiet '**/*.js'"
},

@@ -69,3 +68,8 @@ "lint-staged": {

"packages/**"
]
],
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -21,4 +21,2 @@ */

import { downcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
import { upcastElementToElement, upcastAttributeToAttribute } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters';
import ImageInsertCommand from './imageinsertcommand';

@@ -58,11 +56,11 @@

conversion.for( 'dataDowncast' ).add( downcastElementToElement( {
conversion.for( 'dataDowncast' ).elementToElement( {
model: 'image',
view: ( modelElement, viewWriter ) => createImageViewElement( viewWriter )
} ) );
} );
conversion.for( 'editingDowncast' ).add( downcastElementToElement( {
conversion.for( 'editingDowncast' ).elementToElement( {
model: 'image',
view: ( modelElement, viewWriter ) => toImageWidget( createImageViewElement( viewWriter ), viewWriter, t( 'image widget' ) )
} ) );
} );

@@ -75,3 +73,3 @@ conversion.for( 'downcast' )

conversion.for( 'upcast' )
.add( upcastElementToElement( {
.elementToElement( {
view: {

@@ -84,4 +82,4 @@ name: 'img',

model: ( viewImage, modelWriter ) => modelWriter.createElement( 'image', { src: viewImage.getAttribute( 'src' ) } )
} ) )
.add( upcastAttributeToAttribute( {
} )
.attributeToAttribute( {
view: {

@@ -92,4 +90,4 @@ name: 'img',

model: 'alt'
} ) )
.add( upcastAttributeToAttribute( {
} )
.attributeToAttribute( {
view: {

@@ -113,3 +111,3 @@ name: 'img',

}
} ) )
} )
.add( viewFigureToModel() );

@@ -116,0 +114,0 @@

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -11,3 +11,3 @@ */

import BalloonPanelView from '@ckeditor/ckeditor5-ui/src/panel/balloon/balloonpanelview';
import { isImageWidgetSelected } from '../utils';
import { getSelectedImageWidget } from '../utils';

@@ -24,3 +24,3 @@ /**

if ( isImageWidgetSelected( editor.editing.view.document.selection ) ) {
if ( getSelectedImageWidget( editor.editing.view.document.selection ) ) {
const position = getBalloonPositionData( editor );

@@ -27,0 +27,0 @@

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -12,4 +12,2 @@ */

const imageSymbol = Symbol( 'isImage' );
/**

@@ -26,3 +24,3 @@ * Converts a given {@link module:engine/view/element~Element} to an image widget:

export function toImageWidget( viewElement, writer, label ) {
writer.setCustomProperty( imageSymbol, true, viewElement );
writer.setCustomProperty( 'image', true, viewElement );

@@ -46,15 +44,19 @@ return toWidget( viewElement, writer, { label: labelCreator } );

export function isImageWidget( viewElement ) {
return !!viewElement.getCustomProperty( imageSymbol ) && isWidget( viewElement );
return !!viewElement.getCustomProperty( 'image' ) && isWidget( viewElement );
}
/**
* Checks if an image widget is the only selected element.
* Returns an image widget editing view element if one is selected.
*
* @param {module:engine/view/selection~Selection|module:engine/view/documentselection~DocumentSelection} selection
* @returns {Boolean}
* @returns {module:engine/view/element~Element|null}
*/
export function isImageWidgetSelected( selection ) {
export function getSelectedImageWidget( selection ) {
const viewElement = selection.getSelectedElement();
return !!( viewElement && isImageWidget( viewElement ) );
if ( viewElement && isImageWidget( viewElement ) ) {
return viewElement;
}
return null;
}

@@ -106,3 +108,5 @@

return isImageAllowedInParent( selection, schema, model ) && checkSelectionWithObject( selection, schema );
return isImageAllowedInParent( selection, schema, model ) &&
!checkSelectionOnObject( selection, schema ) &&
isInOtherImage( selection );
}

@@ -119,15 +123,14 @@

// Check used in image commands for additional cases when the command should be disabled:
// Check if selection is on object.
//
// - selection is on object
// - selection is inside object
//
// @returns {Boolean}
function checkSelectionWithObject( selection, schema ) {
function checkSelectionOnObject( selection, schema ) {
const selectedElement = selection.getSelectedElement();
const isSelectionOnObject = !!selectedElement && schema.isObject( selectedElement );
const isSelectionInObject = !![ ...selection.focus.getAncestors() ].find( ancestor => schema.isObject( ancestor ) );
return selectedElement && schema.isObject( selectedElement );
}
return !isSelectionOnObject && !isSelectionInObject;
// Checks if selection is placed in other image (ie. in caption).
function isInOtherImage( selection ) {
return [ ...selection.focus.getAncestors() ].every( ancestor => !ancestor.is( 'image' ) );
}

@@ -139,6 +142,6 @@

let parent = insertAt.parent;
const parent = insertAt.parent;
if ( !parent.is( '$root' ) ) {
parent = parent.parent;
if ( parent.isEmpty && !parent.is( '$root' ) ) {
return parent.parent;
}

@@ -145,0 +148,0 @@

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -11,9 +11,4 @@ */

import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import { upcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters';
import { isImage } from '../image/utils';
import {
captionElementCreator,
getCaptionFromImage,
matchImageCaption
} from './utils';
import { captionElementCreator, getCaptionFromImage, matchImageCaption } from './utils';

@@ -59,6 +54,6 @@ /**

// View to model converter for the data pipeline.
editor.conversion.for( 'upcast' ).add( upcastElementToElement( {
editor.conversion.for( 'upcast' ).elementToElement( {
view: matchImageCaption,
model: 'caption'
} ) );
} );

@@ -188,13 +183,28 @@ // Model to view converter for the data pipeline.

const imagesWithoutCaption = [];
for ( const entry of changes ) {
if ( entry.type == 'insert' && entry.name == 'image' ) {
if ( entry.type == 'insert' && entry.name != '$text' ) {
const item = entry.position.nodeAfter;
if ( !getCaptionFromImage( item ) ) {
writer.appendElement( 'caption', item );
if ( item.is( 'image' ) && !getCaptionFromImage( item ) ) {
imagesWithoutCaption.push( item );
}
return true;
// Check elements with children for nested images.
if ( !item.is( 'image' ) && item.childCount ) {
for ( const nestedItem of model.createRangeIn( item ).getItems() ) {
if ( nestedItem.is( 'image' ) && !getCaptionFromImage( nestedItem ) ) {
imagesWithoutCaption.push( nestedItem );
}
}
}
}
}
for ( const image of imagesWithoutCaption ) {
writer.appendElement( 'caption', image );
}
return !!imagesWithoutCaption.length;
}

@@ -243,3 +253,3 @@ }

// @param {module:engine/view/containerelement~ContainerElement} viewImage
// @param {Object} conversionApi
// @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi
function insertViewCaptionAndBind( viewCaption, modelCaption, viewImage, conversionApi ) {

@@ -246,0 +256,0 @@ const viewPosition = conversionApi.writer.createPositionAt( viewImage, 'end' );

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -10,7 +10,5 @@ */

import { attachPlaceholder } from '@ckeditor/ckeditor5-engine/src/view/placeholder';
import { enablePlaceholder } from '@ckeditor/ckeditor5-engine/src/view/placeholder';
import { toWidgetEditable } from '@ckeditor/ckeditor5-widget/src/utils';
const captionSymbol = Symbol( 'imageCaption' );
/**

@@ -26,5 +24,10 @@ * Returns a function that creates a caption editable element for the given {@link module:engine/view/document~Document}.

const editable = writer.createEditableElement( 'figcaption' );
writer.setCustomProperty( captionSymbol, true, editable );
attachPlaceholder( view, editable, placeholderText );
writer.setCustomProperty( 'imageCaption', true, editable );
enablePlaceholder( {
view,
element: editable,
text: placeholderText
} );
return toWidgetEditable( editable, writer );

@@ -41,3 +44,3 @@ };

export function isCaption( viewElement ) {
return !!viewElement.getCustomProperty( captionSymbol );
return !!viewElement.getCustomProperty( 'imageCaption' );
}

@@ -44,0 +47,0 @@

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

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

import ImageStyleCommand from './imagestylecommand';
import ImageEditing from '../image/imageediting';
import { viewToModelStyleAttribute, modelToViewStyleAttribute } from './converters';

@@ -27,9 +26,2 @@ import { normalizeImageStyles } from './utils';

*/
static get requires() {
return [ ImageEditing ];
}
/**
* @inheritDoc
*/
static get pluginName() {

@@ -36,0 +28,0 @@ return 'ImageStyleEditing';

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -24,2 +24,9 @@ */

/**
* @inheritDoc
*/
static get pluginName() {
return 'ImageStyleUI';
}
/**
* Returns the default localized style titles provided by the plugin.

@@ -26,0 +33,0 @@ *

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -98,5 +98,3 @@ */

export function normalizeImageStyles( configuredStyles = [] ) {
return configuredStyles
.map( _normalizeStyle )
.map( style => Object.assign( {}, style ) );
return configuredStyles.map( _normalizeStyle );
}

@@ -103,0 +101,0 @@

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -17,3 +17,3 @@ */

import { repositionContextualBalloon, getBalloonPositionData } from '../image/ui/utils';
import { isImageWidgetSelected } from '../image/utils';
import { getSelectedImageWidget } from '../image/utils';

@@ -38,2 +38,9 @@ /**

*/
static get pluginName() {
return 'ImageTextAlternativeUI';
}
/**
* @inheritDoc
*/
init() {

@@ -45,2 +52,12 @@ this._createButton();

/**
* @inheritDoc
*/
destroy() {
super.destroy();
// Destroy created UI components as they are not automatically destroyed (see ckeditor5#1341).
this._form.destroy();
}
/**
* Creates a button showing the balloon panel for changing the image text alternative and

@@ -122,3 +139,3 @@ * registers it in the editor {@link module:ui/componentfactory~ComponentFactory ComponentFactory}.

this.listenTo( editor.ui, 'update', () => {
if ( !isImageWidgetSelected( viewDocument.selection ) ) {
if ( !getSelectedImageWidget( viewDocument.selection ) ) {
this._hideForm( true );

@@ -181,2 +198,6 @@ } else if ( this._isVisible ) {

// Blur the input element before removing it from DOM to prevent issues in some browsers.
// See https://github.com/ckeditor/ckeditor5/issues/1501.
this._form.saveButtonView.focus();
this._balloon.remove( this._form );

@@ -183,0 +204,0 @@

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -11,3 +11,3 @@ */

import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import { isImageWidgetSelected } from './image/utils';
import { getSelectedImageWidget } from './image/utils';
import WidgetToolbarRepository from '@ckeditor/ckeditor5-widget/src/widgettoolbarrepository';

@@ -52,3 +52,3 @@

items: editor.config.get( 'image.toolbar' ) || [],
visibleWhen: isImageWidgetSelected,
getRelatedElement: getSelectedImageWidget,
} );

@@ -55,0 +55,0 @@ }

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -18,3 +18,3 @@ */

*
* For a detailed overview, check the {@glink features/image-upload image upload feature} documentation.
* For a detailed overview, check the {@glink features/image-upload/image-upload image upload feature} documentation.
*

@@ -21,0 +21,0 @@ * This plugin does not do anything directly, but it loads a set of specific plugins to enable image uploading:

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -4,0 +4,0 @@ */

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

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

import UpcastWriter from '@ckeditor/ckeditor5-engine/src/view/upcastwriter';
import { upcastAttributeToAttribute } from '@ckeditor/ckeditor5-engine/src/conversion/upcast-converters';

@@ -53,3 +52,3 @@ import ImageUploadCommand from '../../src/imageupload/imageuploadcommand';

conversion.for( 'upcast' )
.add( upcastAttributeToAttribute( {
.attributeToAttribute( {
view: {

@@ -60,3 +59,3 @@ name: 'img',

model: 'uploadId'
} ) );
} );

@@ -104,36 +103,27 @@ // Handle pasted images.

// (see Document#change listener below).
this.listenTo( editor.plugins.get( 'Clipboard' ), 'inputTransformation', ( evt, data ) => {
const fetchableImages = Array.from( editor.editing.view.createRangeIn( data.content ) )
.filter( value => isLocalImage( value.item ) && !value.item.getAttribute( 'uploadProcessed' ) )
.map( value => fetchLocalImage( value.item ) );
if ( editor.plugins.has( 'Clipboard' ) ) {
this.listenTo( editor.plugins.get( 'Clipboard' ), 'inputTransformation', ( evt, data ) => {
const fetchableImages = Array.from( editor.editing.view.createRangeIn( data.content ) )
.filter( value => isLocalImage( value.item ) && !value.item.getAttribute( 'uploadProcessed' ) )
.map( value => { return { promise: fetchLocalImage( value.item ), imageElement: value.item }; } );
if ( !fetchableImages.length ) {
return;
}
if ( !fetchableImages.length ) {
return;
}
evt.stop();
Promise.all( fetchableImages ).then( items => {
const writer = new UpcastWriter();
for ( const item of items ) {
if ( !item.file ) {
// Failed to fetch image or create a file instance, remove image element.
writer.remove( item.image );
} else {
// Set attribute marking the image as processed.
writer.setAttribute( 'uploadProcessed', true, item.image );
for ( const fetchableImage of fetchableImages ) {
// Set attribute marking that the image was processed already.
writer.setAttribute( 'uploadProcessed', true, fetchableImage.imageElement );
const loader = fileRepository.createLoader( item.file );
const loader = fileRepository.createLoader( fetchableImage.promise );
if ( loader ) {
writer.setAttribute( 'src', '', item.image );
writer.setAttribute( 'uploadId', loader.id, item.image );
}
if ( loader ) {
writer.setAttribute( 'src', '', fetchableImage.imageElement );
writer.setAttribute( 'uploadId', loader.id, fetchableImage.imageElement );
}
}
editor.plugins.get( 'Clipboard' ).fire( 'inputTransformation', data );
} );
} );
}

@@ -235,3 +225,3 @@ // Prevents from the browser redirecting to the dropped image.

// Might be 'aborted'.
if ( loader.status == 'error' ) {
if ( loader.status == 'error' && error ) {
notification.showWarning( error, {

@@ -274,3 +264,3 @@ title: t( 'Upload failed' ),

const srcsetAttribute = Object.keys( data )
// Filter out keys that are not integers.
// Filter out keys that are not integers.
.filter( key => {

@@ -277,0 +267,0 @@ const width = parseInt( key, 10 );

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -58,4 +58,3 @@ */

* @param {Object} data Additional information about the change.
* @param {module:engine/conversion/modelconsumable~ModelConsumable} consumable Values to consume.
* @param {Object} conversionApi
* @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi
*/

@@ -119,8 +118,2 @@ uploadStatusChange( evt, data, conversionApi ) {

// Symbol added to progress bar UIElement to distinguish it from other elements.
const progressBarSymbol = Symbol( 'progress-bar' );
// Symbol added to placeholder UIElement to distinguish it from other elements.
const placeholderSymbol = Symbol( 'placeholder' );
// Adds ck-appear class to the image figure if one is not already applied.

@@ -160,3 +153,3 @@ //

if ( !_getUIElement( viewFigure, placeholderSymbol ) ) {
if ( !_getUIElement( viewFigure, 'placeholder' ) ) {
writer.insert( writer.createPositionAfter( viewImg ), _createPlaceholder( writer ) );

@@ -175,3 +168,3 @@ }

_removeUIElement( viewFigure, writer, placeholderSymbol );
_removeUIElement( viewFigure, writer, 'placeholder' );
}

@@ -203,3 +196,3 @@

function _hideProgressBar( viewFigure, writer ) {
_removeUIElement( viewFigure, writer, progressBarSymbol );
_removeUIElement( viewFigure, writer, 'progressBar' );
}

@@ -230,3 +223,3 @@

writer.setCustomProperty( progressBarSymbol, true, progressBar );
writer.setCustomProperty( 'progressBar', true, progressBar );

@@ -244,3 +237,3 @@ return progressBar;

writer.setCustomProperty( placeholderSymbol, true, placeholder );
writer.setCustomProperty( 'placeholder', true, placeholder );

@@ -255,3 +248,3 @@ return placeholder;

// @param {module:engine/view/element~Element} imageFigure
// @param {Symbol} uniqueProperty
// @param {String} uniqueProperty
// @returns {module:engine/view/uielement~UIElement|undefined}

@@ -271,3 +264,3 @@ function _getUIElement( imageFigure, uniqueProperty ) {

// @param {module:engine/view/downcastwriter~DowncastWriter} writer
// @param {Symbol} uniqueProperty
// @param {String} uniqueProperty
function _removeUIElement( viewFigure, writer, uniqueProperty ) {

@@ -274,0 +267,0 @@ const element = _getUIElement( viewFigure, uniqueProperty );

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -18,3 +18,3 @@ */

*
* For a detailed overview, check the {@glink features/image-upload Image upload feature} documentation.
* For a detailed overview, check the {@glink features/image-upload/image-upload Image upload feature} documentation.
*

@@ -21,0 +21,0 @@ * Adds the `'imageUpload'` button to the {@link module:ui/componentfactory~ComponentFactory UI component factory}.

/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.

@@ -25,16 +25,17 @@ */

/**
* Creates a promise which fetches the image local source (base64 or blob) and returns as a `File` object.
* Creates a promise which fetches the image local source (base64 or blob) and resolves with a `File` object.
*
* @param {module:engine/view/element~Element} image Image which source to fetch.
* @returns {Promise} A promise which resolves when image source is fetched and converted to `File` instance.
* It resolves with object holding initial image element (as `image`) and its file source (as `file`). If
* the `file` attribute is null, it means fetching failed.
* @returns {Promise.<File>} A promise which resolves when image source is fetched and converted to `File` instance.
* It resolves with a `File` object. If there were any errors during file processing the promise will be rejected.
*/
export function fetchLocalImage( image ) {
return new Promise( resolve => {
return new Promise( ( resolve, reject ) => {
const imageSrc = image.getAttribute( 'src' );
// Fetch works asynchronously and so does not block browser UI when processing data.
fetch( image.getAttribute( 'src' ) )
fetch( imageSrc )
.then( resource => resource.blob() )
.then( blob => {
const mimeType = getImageMimeType( blob, image.getAttribute( 'src' ) );
const mimeType = getImageMimeType( blob, imageSrc );
const ext = mimeType.replace( 'image/', '' );

@@ -44,8 +45,5 @@ const filename = `image.${ ext }`;

resolve( { image, file } );
file ? resolve( file ) : reject();
} )
.catch( () => {
// We always resolve a promise so `Promise.all` will not reject if one of many fetch fails.
resolve( { image, file: null } );
} );
.catch( reject );
} );

@@ -52,0 +50,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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