Socket
Socket
Sign inDemoInstall

@ckeditor/ckeditor5-widget

Package Overview
Dependencies
Maintainers
1
Versions
615
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-widget - npm Package Compare versions

Comparing version 0.0.0-nightly-20240827.0 to 0.0.0-nightly-20240828.0

14

package.json
{
"name": "@ckeditor/ckeditor5-widget",
"version": "0.0.0-nightly-20240827.0",
"version": "0.0.0-nightly-20240828.0",
"description": "Widget API for CKEditor 5.",

@@ -15,8 +15,8 @@ "keywords": [

"dependencies": {
"@ckeditor/ckeditor5-core": "0.0.0-nightly-20240827.0",
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-20240827.0",
"@ckeditor/ckeditor5-enter": "0.0.0-nightly-20240827.0",
"@ckeditor/ckeditor5-ui": "0.0.0-nightly-20240827.0",
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-20240827.0",
"@ckeditor/ckeditor5-typing": "0.0.0-nightly-20240827.0",
"@ckeditor/ckeditor5-core": "0.0.0-nightly-20240828.0",
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-20240828.0",
"@ckeditor/ckeditor5-enter": "0.0.0-nightly-20240828.0",
"@ckeditor/ckeditor5-ui": "0.0.0-nightly-20240828.0",
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-20240828.0",
"@ckeditor/ckeditor5-typing": "0.0.0-nightly-20240828.0",
"lodash-es": "4.17.21"

@@ -23,0 +23,0 @@ },

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

import { Delete } from '@ckeditor/ckeditor5-typing';
import { env, keyCodes, getLocalizedArrowKeyCodeDirection } from '@ckeditor/ckeditor5-utils';
import { env, keyCodes, getLocalizedArrowKeyCodeDirection, getRangeFromMouseEvent } from '@ckeditor/ckeditor5-utils';
import WidgetTypeAround from './widgettypearound/widgettypearound.js';

@@ -228,12 +228,21 @@ import verticalNavigationHandler from './verticalnavigation.js';

}
// Do nothing for single or double click inside nested editable.
if (isInsideNestedEditable(element)) {
return;
}
// If target is not a widget element - check if one of the ancestors is.
if (!isWidget(element)) {
element = element.findAncestor(isWidget);
if (!element) {
const editableOrWidgetElement = findClosestEditableOrWidgetAncestor(element);
if (!editableOrWidgetElement) {
return;
}
if (isWidget(editableOrWidgetElement)) {
element = editableOrWidgetElement;
}
else {
// Pick view range from the point where the mouse was clicked.
const clickTargetFromPoint = getElementFromMouseEvent(view, domEventData);
if (clickTargetFromPoint && isWidget(clickTargetFromPoint)) {
element = clickTargetFromPoint;
}
else {
return;
}
}
}

@@ -486,19 +495,46 @@ // On Android selection would jump to the first table cell, on other devices

/**
* Returns `true` when element is a nested editable or is placed inside one.
* Finds the closest ancestor element that is either an editable element or a widget.
*
* @param element The element from which to start searching.
* @returns The closest ancestor element that is either an editable element or a widget, or null if none is found.
*/
function isInsideNestedEditable(element) {
function findClosestEditableOrWidgetAncestor(element) {
let currentElement = element;
while (currentElement) {
if (currentElement.is('editableElement') && !currentElement.is('rootElement')) {
return true;
if (currentElement.is('editableElement') || isWidget(currentElement)) {
return currentElement;
}
// Click on nested widget should select it.
if (isWidget(currentElement)) {
return false;
}
currentElement = currentElement.parent;
}
return false;
return null;
}
/**
* Retrieves the ViewElement associated with a mouse event in the editing view.
*
* @param view The editing view.
* @param domEventData The DOM event data containing the mouse event.
* @returns The ViewElement associated with the mouse event, or null if not found.
*/
function getElementFromMouseEvent(view, domEventData) {
const domRange = getRangeFromMouseEvent(domEventData.domEvent);
if (!domRange) {
return null;
}
const viewRange = view.domConverter.domRangeToView(domRange);
if (!viewRange) {
return null;
}
const viewPosition = viewRange.start;
if (!viewPosition.parent) {
return null;
}
// Click after a widget tend to return position at the end of the editable element
// so use the node before it if range is at the end of a parent.
const viewNode = viewPosition.parent.is('editableElement') && viewPosition.isAtEnd && viewPosition.nodeBefore || viewPosition.parent;
if (viewNode.is('$text')) {
return viewNode.parent;
}
return viewNode;
}
/**
* Checks whether the specified `element` is a child of the `parent` element.

@@ -505,0 +541,0 @@ *

Sorry, the diff of this file is too big to display

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