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-20230911110410-f65fc3ab-nightly to 0.0.0-20230912153951-446befe2-nightly

1

dist/components/virgo-line.d.ts

@@ -13,2 +13,3 @@ import { LitElement, type TemplateResult } from 'lit';

}>[];
get vTexts(): import("./virgo-text.js").VText[];
get textLength(): number;

@@ -15,0 +16,0 @@ get textContent(): string;

@@ -21,2 +21,5 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

}
get vTexts() {
return Array.from(this.querySelectorAll('v-text'));
}
get textLength() {

@@ -31,2 +34,3 @@ return this.vElements.reduce((acc, el) => acc + el.delta.insert.length, 0);

await Promise.all(this.vElements.map(el => el.updateComplete));
await Promise.all(this.vTexts.map(el => el.updateComplete));
return result;

@@ -33,0 +37,0 @@ }

1

dist/services/event.d.ts

@@ -16,3 +16,2 @@ import { type BaseTextAttributes } from '../utils/index.js';

private _onBeforeInput;
private _onScroll;
private _onKeyDown;

@@ -19,0 +18,0 @@ private _onClick;

@@ -20,3 +20,2 @@ import { assertExists } from '@blocksuite/global/utils';

this.editor.disposables.addFromEvent(rootElement, 'compositionend', this._onCompositionEnd);
this.editor.disposables.addFromEvent(rootElement, 'scroll', this._onScroll);
this.editor.disposables.addFromEvent(rootElement, 'keydown', this._onKeyDown);

@@ -226,5 +225,2 @@ this.editor.disposables.addFromEvent(rootElement, 'click', this._onClick);

};
this._onScroll = () => {
this.editor.slots.scrollUpdated.emit(this.editor.rootElement.scrollLeft);
};
this._onKeyDown = (event) => {

@@ -231,0 +227,0 @@ if (!event.shiftKey &&

@@ -9,3 +9,2 @@ import type { VRange } from '../types.js';

private _vRange;
private _lastScrollLeft;
constructor(editor: VEditor<TextAttributes>);

@@ -55,7 +54,4 @@ get vRangeProvider(): import("../virgo.js").VRangeProvider | null;

toVRange: (range: Range) => VRange | null;
onScrollUpdated: (scrollLeft: number) => void;
private _applyVRange;
private _scrollLineIntoViewIfNeeded;
private _scrollCursorIntoViewIfNeeded;
}
//# sourceMappingURL=range.d.ts.map

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

import { VirgoLine } from '../components/index.js';
import { findDocumentOrShadowRoot } from '../utils/query.js';

@@ -10,3 +9,2 @@ import { domRangeToVirgoRange, virgoRangeToDomRange, } from '../utils/range-conversion.js';

this._vRange = null;
this._lastScrollLeft = 0;
this.onVRangeUpdated = ([newVRange, sync]) => {

@@ -115,5 +113,2 @@ this._vRange = newVRange;

};
this.onScrollUpdated = (scrollLeft) => {
this._lastScrollLeft = scrollLeft;
};
this._applyVRange = (vRange) => {

@@ -131,30 +126,4 @@ const selectionRoot = findDocumentOrShadowRoot(this.editor);

selection.addRange(newRange);
this._scrollLineIntoViewIfNeeded(newRange);
this._scrollCursorIntoViewIfNeeded(newRange);
this.editor.slots.rangeUpdated.emit(newRange);
};
this._scrollLineIntoViewIfNeeded = (range) => {
if (this.editor.shouldLineScrollIntoView) {
let lineElement = range.endContainer.parentElement;
while (!(lineElement instanceof VirgoLine)) {
lineElement = lineElement?.parentElement ?? null;
}
lineElement?.scrollIntoView({
block: 'nearest',
});
}
};
this._scrollCursorIntoViewIfNeeded = (range) => {
if (this.editor.shouldCursorScrollIntoView) {
const root = this.editor.rootElement;
const rootRect = root.getBoundingClientRect();
const rangeRect = range.getBoundingClientRect();
let moveX = 0;
if (rangeRect.left > rootRect.left) {
moveX = Math.max(this._lastScrollLeft, rangeRect.left - rootRect.right);
}
root.scrollLeft = moveX;
this._lastScrollLeft = moveX;
}
};
}

@@ -161,0 +130,0 @@ get vRangeProvider() {

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

private _mounted;
shouldLineScrollIntoView: boolean;
shouldCursorScrollIntoView: boolean;
readonly isEmbed: (delta: DeltaInsert<TextAttributes>) => boolean;

@@ -43,3 +41,2 @@ readonly vRangeProvider: VRangeProvider | null;

rangeUpdated: Slot<Range>;
scrollUpdated: Slot<number>;
};

@@ -46,0 +43,0 @@ get yText(): Y.Text;

@@ -61,4 +61,2 @@ import { assertExists, DisposableGroup, Slot } from '@blocksuite/global/utils';

this._mounted = false;
this.shouldLineScrollIntoView = true;
this.shouldCursorScrollIntoView = true;
this.setAttributeSchema = this._attributeService.setAttributeSchema;

@@ -106,6 +104,4 @@ this.setAttributeRenderer = this._attributeService.setAttributeRenderer;

rangeUpdated: new Slot(),
scrollUpdated: new Slot(),
};
this.slots.vRangeUpdated.on(this.rangeService.onVRangeUpdated);
this.slots.scrollUpdated.on(this.rangeService.onScrollUpdated);
}

@@ -112,0 +108,0 @@ mount(rootElement) {

{
"name": "@blocksuite/virgo",
"version": "0.0.0-20230911110410-f65fc3ab-nightly",
"version": "0.0.0-20230912153951-446befe2-nightly",
"description": "A micro editor.",

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

"zod": "^3.22.2",
"@blocksuite/global": "0.0.0-20230911110410-f65fc3ab-nightly"
"@blocksuite/global": "0.0.0-20230912153951-446befe2-nightly"
},

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

@@ -20,2 +20,6 @@ import { assertExists } from '@blocksuite/global/utils';

get vTexts() {
return Array.from(this.querySelectorAll('v-text'));
}
get textLength() {

@@ -32,2 +36,3 @@ return this.vElements.reduce((acc, el) => acc + el.delta.insert.length, 0);

await Promise.all(this.vElements.map(el => el.updateComplete));
await Promise.all(this.vTexts.map(el => el.updateComplete));
return result;

@@ -34,0 +39,0 @@ }

@@ -53,3 +53,2 @@ import { assertExists } from '@blocksuite/global/utils';

);
this.editor.disposables.addFromEvent(rootElement, 'scroll', this._onScroll);
this.editor.disposables.addFromEvent(

@@ -313,6 +312,2 @@ rootElement,

private _onScroll = () => {
this.editor.slots.scrollUpdated.emit(this.editor.rootElement.scrollLeft);
};
private _onKeyDown = (event: KeyboardEvent) => {

@@ -319,0 +314,0 @@ if (

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

import { VirgoLine } from '../components/index.js';
import type { VRange } from '../types.js';

@@ -16,3 +15,2 @@ import type { VRangeUpdatedProp } from '../types.js';

private _vRange: VRange | null = null;
private _lastScrollLeft = 0;

@@ -147,6 +145,2 @@ constructor(public readonly editor: VEditor<TextAttributes>) {}

onScrollUpdated = (scrollLeft: number) => {
this._lastScrollLeft = scrollLeft;
};
private _applyVRange = (vRange: VRange): void => {

@@ -166,37 +160,4 @@ const selectionRoot = findDocumentOrShadowRoot(this.editor);

selection.addRange(newRange);
this._scrollLineIntoViewIfNeeded(newRange);
this._scrollCursorIntoViewIfNeeded(newRange);
this.editor.slots.rangeUpdated.emit(newRange);
};
private _scrollLineIntoViewIfNeeded = (range: Range) => {
if (this.editor.shouldLineScrollIntoView) {
let lineElement: HTMLElement | null = range.endContainer.parentElement;
while (!(lineElement instanceof VirgoLine)) {
lineElement = lineElement?.parentElement ?? null;
}
lineElement?.scrollIntoView({
block: 'nearest',
});
}
};
private _scrollCursorIntoViewIfNeeded = (range: Range) => {
if (this.editor.shouldCursorScrollIntoView) {
const root = this.editor.rootElement;
const rootRect = root.getBoundingClientRect();
const rangeRect = range.getBoundingClientRect();
let moveX = 0;
if (rangeRect.left > rootRect.left) {
moveX = Math.max(this._lastScrollLeft, rangeRect.left - rootRect.right);
}
root.scrollLeft = moveX;
this._lastScrollLeft = moveX;
}
};
}

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

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

@@ -86,4 +83,4 @@ readonly vRangeProvider: VRangeProvider | null;

rangeUpdated: Slot<Range>;
scrollUpdated: Slot<number>;
};
get yText() {

@@ -189,7 +186,5 @@ return this._yText;

rangeUpdated: new Slot<Range>(),
scrollUpdated: new Slot<number>(),
};
this.slots.vRangeUpdated.on(this.rangeService.onVRangeUpdated);
this.slots.scrollUpdated.on(this.rangeService.onScrollUpdated);
}

@@ -196,0 +191,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

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