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

@blocksuite/virgo

Package Overview
Dependencies
Maintainers
5
Versions
509
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blocksuite/virgo - npm Package Compare versions

Comparing version 0.0.0-20230818053411-bc330b35-nightly to 0.0.0-20230818163111-fc91dac8-nightly

16

dist/services/event.js

@@ -273,9 +273,15 @@ import { assertExists } from '@blocksuite/global/utils';

this._onKeyDown = (event) => {
if (!event.shiftKey) {
if (!event.shiftKey &&
(event.key === 'ArrowLeft' || event.key === 'ArrowRight')) {
const vRange = this._editor.getVRange();
if (!vRange || vRange.length !== 0)
return;
const prevent = () => {
event.preventDefault();
event.stopPropagation();
};
const deltas = this._editor.getDeltasByVRange(vRange);
if (deltas.length === 2) {
if (event.key === 'ArrowLeft' && this._editor.isEmbed(deltas[0][0])) {
prevent();
this._editor.setVRange({

@@ -288,2 +294,3 @@ index: vRange.index - 1,

this._editor.isEmbed(deltas[1][0])) {
prevent();
this._editor.setVRange({

@@ -298,3 +305,4 @@ index: vRange.index,

if (this._editor.isEmbed(delta)) {
if (event.key === 'ArrowLeft') {
if (event.key === 'ArrowLeft' && vRange.index - 1 >= 0) {
prevent();
this._editor.setVRange({

@@ -305,3 +313,5 @@ index: vRange.index - 1,

}
else if (event.key === 'ArrowRight') {
else if (event.key === 'ArrowRight' &&
vRange.index + 1 <= this._editor.yText.length) {
prevent();
this._editor.setVRange({

@@ -308,0 +318,0 @@ index: vRange.index,

8

dist/services/range.js

@@ -53,2 +53,7 @@ import { VirgoLine } from '../components/index.js';

this.setVRange = (vRange, sync = true) => {
if (vRange &&
(vRange.index < 0 ||
vRange.index + vRange.length > this._editor.yText.length)) {
throw new Error('invalid vRange');
}
this._editor.slots.vRangeUpdated.emit([vRange, sync ? 'other' : 'silent']);

@@ -105,5 +110,2 @@ };

this._applyVRange = (vRange) => {
if (!this._editor.isActive()) {
return;
}
const selectionRoot = findDocumentOrShadowRoot(this._editor);

@@ -110,0 +112,0 @@ const selection = selectionRoot.getSelection();

@@ -26,3 +26,2 @@ import type { NullablePartial } from '@blocksuite/global/utils';

shouldCursorScrollIntoView: boolean;
readonly isActive: () => boolean;
readonly isEmbed: (delta: DeltaInsert<TextAttributes>) => boolean;

@@ -66,4 +65,3 @@ slots: {

constructor(yText: VEditor['yText'], ops?: {
active?: VEditor['isActive'];
embed?: (delta: DeltaInsert<TextAttributes>) => boolean;
isEmbed?: (delta: DeltaInsert<TextAttributes>) => boolean;
});

@@ -70,0 +68,0 @@ mount(rootElement: HTMLElement): void;

@@ -78,4 +78,3 @@ import { assertExists, Slot } from '@blocksuite/global/utils';

this._yText = yText;
this.isActive = ops?.active ?? (() => true);
this.isEmbed = ops?.embed ?? (() => false);
this.isEmbed = ops?.isEmbed ?? (() => false);
this.slots = {

@@ -82,0 +81,0 @@ mounted: new Slot(),

{
"name": "@blocksuite/virgo",
"version": "0.0.0-20230818053411-bc330b35-nightly",
"version": "0.0.0-20230818163111-fc91dac8-nightly",
"description": "A micro editor.",

@@ -28,3 +28,3 @@ "main": "dist/index.js",

"zod": "^3.21.4",
"@blocksuite/global": "0.0.0-20230818053411-bc330b35-nightly"
"@blocksuite/global": "0.0.0-20230818163111-fc91dac8-nightly"
},

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

@@ -374,9 +374,18 @@ import { assertExists } from '@blocksuite/global/utils';

private _onKeyDown = (event: KeyboardEvent) => {
if (!event.shiftKey) {
if (
!event.shiftKey &&
(event.key === 'ArrowLeft' || event.key === 'ArrowRight')
) {
const vRange = this._editor.getVRange();
if (!vRange || vRange.length !== 0) return;
const prevent = () => {
event.preventDefault();
event.stopPropagation();
};
const deltas = this._editor.getDeltasByVRange(vRange);
if (deltas.length === 2) {
if (event.key === 'ArrowLeft' && this._editor.isEmbed(deltas[0][0])) {
prevent();
this._editor.setVRange({

@@ -390,2 +399,3 @@ index: vRange.index - 1,

) {
prevent();
this._editor.setVRange({

@@ -399,3 +409,4 @@ index: vRange.index,

if (this._editor.isEmbed(delta)) {
if (event.key === 'ArrowLeft') {
if (event.key === 'ArrowLeft' && vRange.index - 1 >= 0) {
prevent();
this._editor.setVRange({

@@ -405,3 +416,7 @@ index: vRange.index - 1,

});
} else if (event.key === 'ArrowRight') {
} else if (
event.key === 'ArrowRight' &&
vRange.index + 1 <= this._editor.yText.length
) {
prevent();
this._editor.setVRange({

@@ -408,0 +423,0 @@ index: vRange.index,

@@ -76,2 +76,10 @@ import { VirgoLine } from '../components/index.js';

setVRange = (vRange: VRange | null, sync = true): void => {
if (
vRange &&
(vRange.index < 0 ||
vRange.index + vRange.length > this._editor.yText.length)
) {
throw new Error('invalid vRange');
}
this._editor.slots.vRangeUpdated.emit([vRange, sync ? 'other' : 'silent']);

@@ -134,5 +142,2 @@ };

private _applyVRange = (vRange: VRange): void => {
if (!this._editor.isActive()) {
return;
}
const selectionRoot = findDocumentOrShadowRoot(this._editor);

@@ -139,0 +144,0 @@ const selection = selectionRoot.getSelection();

@@ -62,3 +62,2 @@ import type { NullablePartial } from '@blocksuite/global/utils';

readonly isActive: () => boolean;
readonly isEmbed: (delta: DeltaInsert<TextAttributes>) => boolean;

@@ -133,4 +132,3 @@

ops?: {
active?: VEditor['isActive'];
embed?: (delta: DeltaInsert<TextAttributes>) => boolean;
isEmbed?: (delta: DeltaInsert<TextAttributes>) => boolean;
}

@@ -149,4 +147,3 @@ ) {

this._yText = yText;
this.isActive = ops?.active ?? (() => true);
this.isEmbed = ops?.embed ?? (() => false);
this.isEmbed = ops?.isEmbed ?? (() => false);
this.slots = {

@@ -153,0 +150,0 @@ mounted: new Slot(),

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