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

@blocksuite/inline

Package Overview
Dependencies
Maintainers
2
Versions
622
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blocksuite/inline - npm Package Compare versions

Comparing version 0.12.0 to 0.13.0-canary-202403050653-934469c

34

dist/services/event.js

@@ -1,2 +0,2 @@

import { findDocumentOrShadowRoot, isInEmbedElement, } from '../utils/index.js';
import { findDocumentOrShadowRoot, isInEmbedElement, isInEmbedGap, } from '../utils/index.js';
import { isMaybeInlineRangeEqual } from '../utils/inline-range.js';

@@ -161,13 +161,27 @@ import { transformInput } from '../utils/transform-input.js';

return;
const targetRanges = event.getTargetRanges();
if (targetRanges.length > 0) {
const staticRange = targetRanges[0];
const range = document.createRange();
range.setStart(staticRange.startContainer, staticRange.startOffset);
range.setEnd(staticRange.endContainer, staticRange.endOffset);
const inlineRange = this.editor.toInlineRange(range);
if (!isMaybeInlineRangeEqual(this.editor.getInlineRange(), inlineRange)) {
this.editor.setInlineRange(inlineRange, false);
if (isInEmbedGap(range.commonAncestorContainer) &&
event.inputType.startsWith('delete')) {
const inlineRange = this.editor.getInlineRange();
if (!inlineRange)
return;
if (inlineRange.length === 0 && inlineRange.index > 0) {
this.editor.setInlineRange({
index: inlineRange.index - 1,
length: 1,
});
}
}
else {
const targetRanges = event.getTargetRanges();
if (targetRanges.length > 0) {
const staticRange = targetRanges[0];
const range = document.createRange();
range.setStart(staticRange.startContainer, staticRange.startOffset);
range.setEnd(staticRange.endContainer, staticRange.endOffset);
const inlineRange = this.editor.toInlineRange(range);
if (!isMaybeInlineRangeEqual(this.editor.getInlineRange(), inlineRange)) {
this.editor.setInlineRange(inlineRange, false);
}
}
}
const inlineRange = this.editor.getInlineRange();

@@ -174,0 +188,0 @@ if (!inlineRange)

@@ -16,16 +16,6 @@ import { VElement } from '../components/v-element.js';

export function isInEmbedGap(node) {
if (node instanceof Element) {
const vText = node.closest('[data-v-text="true"]');
if (vText && vText.dataset.vEmbedGap === 'true') {
return true;
}
const el = node instanceof Element ? node : node.parentElement;
if (!el)
return false;
}
else {
const vText = node.parentElement?.closest('[data-v-text="true"]');
if (vText && vText.dataset.vEmbedGap === 'true') {
return true;
}
return false;
}
return !!el.closest('[data-v-embed-gap="true"]');
}

@@ -32,0 +22,0 @@ export function transformDeltasToEmbedDeltas(editor, deltas) {

{
"name": "@blocksuite/inline",
"version": "0.12.0",
"version": "0.13.0-canary-202403050653-934469c",
"description": "A micro editor.",

@@ -33,3 +33,3 @@ "type": "module",

"zod": "^3.22.4",
"@blocksuite/global": "0.12.0"
"@blocksuite/global": "0.13.0-canary-202403050653-934469c"
},

@@ -36,0 +36,0 @@ "scripts": {

@@ -7,2 +7,3 @@ import type { InlineEditor } from '../inline-editor.js';

isInEmbedElement,
isInEmbedGap,
} from '../utils/index.js';

@@ -243,12 +244,28 @@ import { isMaybeInlineRangeEqual } from '../utils/inline-range.js';

const targetRanges = event.getTargetRanges();
if (targetRanges.length > 0) {
const staticRange = targetRanges[0];
const range = document.createRange();
range.setStart(staticRange.startContainer, staticRange.startOffset);
range.setEnd(staticRange.endContainer, staticRange.endOffset);
const inlineRange = this.editor.toInlineRange(range);
if (
isInEmbedGap(range.commonAncestorContainer) &&
event.inputType.startsWith('delete')
) {
const inlineRange = this.editor.getInlineRange();
if (!inlineRange) return;
if (inlineRange.length === 0 && inlineRange.index > 0) {
this.editor.setInlineRange({
index: inlineRange.index - 1,
length: 1,
});
}
} else {
const targetRanges = event.getTargetRanges();
if (targetRanges.length > 0) {
const staticRange = targetRanges[0];
const range = document.createRange();
range.setStart(staticRange.startContainer, staticRange.startOffset);
range.setEnd(staticRange.endContainer, staticRange.endOffset);
const inlineRange = this.editor.toInlineRange(range);
if (!isMaybeInlineRangeEqual(this.editor.getInlineRange(), inlineRange)) {
this.editor.setInlineRange(inlineRange, false);
if (
!isMaybeInlineRangeEqual(this.editor.getInlineRange(), inlineRange)
) {
this.editor.setInlineRange(inlineRange, false);
}
}

@@ -255,0 +272,0 @@ }

@@ -20,15 +20,5 @@ import { VElement } from '../components/v-element.js';

export function isInEmbedGap(node: Node): boolean {
if (node instanceof Element) {
const vText = node.closest('[data-v-text="true"]');
if (vText && (vText as HTMLElement).dataset.vEmbedGap === 'true') {
return true;
}
return false;
} else {
const vText = node.parentElement?.closest('[data-v-text="true"]');
if (vText && (vText as HTMLElement).dataset.vEmbedGap === 'true') {
return true;
}
return false;
}
const el = node instanceof Element ? node : node.parentElement;
if (!el) return false;
return !!el.closest('[data-v-embed-gap="true"]');
}

@@ -35,0 +25,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

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