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.5.0-20230314182044-9df30f4 to 0.5.0-20230315153039-983040a

32

dist/tests/editor.unit.spec.js

@@ -331,2 +331,34 @@ import { expect, test } from 'vitest';

});
test('cursor with format', () => {
const yDoc = new Y.Doc();
const yText = yDoc.getText('text');
const virgo = new VEditor(yText);
virgo.insertText({
index: 0,
length: 0,
}, 'aaa', {
bold: true,
});
virgo.setMarks({
italic: true,
});
virgo.insertText({
index: 3,
length: 0,
}, 'bbb');
expect(virgo.yText.toDelta()).toEqual([
{
insert: 'aaa',
attributes: {
bold: true,
},
},
{
insert: 'bbb',
attributes: {
italic: true,
},
},
]);
});
//# sourceMappingURL=editor.unit.spec.js.map

@@ -13,2 +13,3 @@ import { expect, test } from '@playwright/test';

expect(await editorB.innerText()).toBe(ZERO_WIDTH_SPACE);
await page.waitForTimeout(50);
await type(page, 'abcdefg');

@@ -115,2 +116,3 @@ expect(await editorA.innerText()).toBe('abcdefg');

expect(await editorB.innerText()).toBe(ZERO_WIDTH_SPACE);
await page.waitForTimeout(50);
await type(page, 'abcdefg');

@@ -147,2 +149,3 @@ expect(await editorA.innerText()).toBe('abcdefg');

expect(await editorB.innerText()).toBe(ZERO_WIDTH_SPACE);
await page.waitForTimeout(50);
await type(page, 'abcdefg');

@@ -380,2 +383,3 @@ expect(await editorA.innerText()).toBe('abcdefg');

expect(await editorB.innerText()).toBe(ZERO_WIDTH_SPACE);
await page.waitForTimeout(50);
await type(page, 'abcdefghijk');

@@ -537,2 +541,3 @@ expect(await editorA.innerText()).toBe('abcdefghijk');

expect(await editorB.innerText()).toBe(ZERO_WIDTH_SPACE);
await page.waitForTimeout(50);
await type(page, 'abc def');

@@ -558,2 +563,3 @@ expect(await editorA.innerText()).toBe('abc def');

expect(await editorB.innerText()).toBe(ZERO_WIDTH_SPACE);
await page.waitForTimeout(50);
await type(page, 'abc');

@@ -599,2 +605,3 @@ await press(page, 'Enter');

expect(await editorB.innerText()).toBe(ZERO_WIDTH_SPACE);
await page.waitForTimeout(50);
await type(page, 'abc');

@@ -601,0 +608,0 @@ await press(page, 'Enter');

4

dist/virgo.d.ts

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

private _yText;
private _marks;
private _previousAnchor;

@@ -51,2 +52,3 @@ private _previousFocus;

get rootElement(): HTMLElement;
get marks(): TextAttributes | null;
constructor(yText: VEditor['yText']);

@@ -66,2 +68,4 @@ setAttributesSchema: (schema: z.ZodSchema<TextAttributes>) => void;

getFormat(vRange: VRange): TextAttributes;
setMarks(marks: TextAttributes): void;
resetMarks(): void;
setReadonly(isReadonly: boolean): void;

@@ -68,0 +72,0 @@ setVRange(vRange: VRange): void;

@@ -137,2 +137,5 @@ import { assertExists, Slot } from '@blocksuite/global/utils';

}
get marks() {
return this._marks;
}
constructor(yText) {

@@ -145,2 +148,3 @@ this._rootElement = null;

this._isReadonly = false;
this._marks = null;
this._previousAnchor = null;

@@ -581,2 +585,21 @@ this._previousFocus = null;

}
setMarks(marks) {
this._marks = marks;
let vRange = this.getVRange();
const dispose = this.slots.updateVRange.on(([r, t]) => {
if (vRange &&
r &&
((t === 'native' && r.index === vRange.index) ||
(t !== 'native' && r.index === vRange.index + 1))) {
vRange = r;
}
else {
this.resetMarks();
dispose.dispose();
}
});
}
resetMarks() {
this._marks = null;
}
setReadonly(isReadonly) {

@@ -601,5 +624,9 @@ this.rootElement.contentEditable = isReadonly ? 'false' : 'true';

insertText(vRange, text, attributes = {}) {
let attr = attributes;
if (this._marks) {
attr = { ...this._marks, ...attributes };
}
this._transact(() => {
this.yText.delete(vRange.index, vRange.length);
this.yText.insert(vRange.index, text, attributes);
this.yText.insert(vRange.index, text, attr);
});

@@ -606,0 +633,0 @@ }

4

package.json
{
"name": "@blocksuite/virgo",
"version": "0.5.0-20230314182044-9df30f4",
"version": "0.5.0-20230315153039-983040a",
"description": "A micro editor.",

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

"dependencies": {
"@blocksuite/global": "0.5.0-20230314182044-9df30f4",
"@blocksuite/global": "0.5.0-20230315153039-983040a",
"zod": "^3.20.6"

@@ -29,0 +29,0 @@ },

@@ -371,1 +371,45 @@ import { expect, test } from 'vitest';

});
test('cursor with format', () => {
const yDoc = new Y.Doc();
const yText = yDoc.getText('text');
const virgo = new VEditor(yText);
virgo.insertText(
{
index: 0,
length: 0,
},
'aaa',
{
bold: true,
}
);
virgo.setMarks({
italic: true,
});
virgo.insertText(
{
index: 3,
length: 0,
},
'bbb'
);
expect(virgo.yText.toDelta()).toEqual([
{
insert: 'aaa',
attributes: {
bold: true,
},
},
{
insert: 'bbb',
attributes: {
italic: true,
},
},
]);
});

@@ -27,2 +27,4 @@ import { expect, test } from '@playwright/test';

await page.waitForTimeout(50);
await type(page, 'abcdefg');

@@ -171,2 +173,4 @@

await page.waitForTimeout(50);
await type(page, 'abcdefg');

@@ -215,2 +219,4 @@

await page.waitForTimeout(50);
await type(page, 'abcdefg');

@@ -469,2 +475,4 @@

await page.waitForTimeout(50);
await type(page, 'abcdefghijk');

@@ -640,2 +648,4 @@

await page.waitForTimeout(50);
await type(page, 'abc def');

@@ -669,2 +679,4 @@

await page.waitForTimeout(50);
await type(page, 'abc');

@@ -719,2 +731,4 @@ await press(page, 'Enter');

await page.waitForTimeout(50);
await type(page, 'abc');

@@ -721,0 +735,0 @@ await press(page, 'Enter');

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

private _yText: Y.Text;
private _marks: TextAttributes | null = null;

@@ -296,2 +297,6 @@ private _previousAnchor: NativePoint | null = null;

get marks() {
return this._marks;
}
constructor(yText: VEditor['yText']) {

@@ -541,2 +546,25 @@ if (!yText.doc) {

setMarks(marks: TextAttributes): void {
this._marks = marks;
let vRange = this.getVRange();
const dispose = this.slots.updateVRange.on(([r, t]) => {
if (
vRange &&
r &&
((t === 'native' && r.index === vRange.index) ||
(t !== 'native' && r.index === vRange.index + 1))
) {
vRange = r;
} else {
this.resetMarks();
dispose.dispose();
}
});
}
resetMarks(): void {
this._marks = null;
}
setReadonly(isReadonly: boolean): void {

@@ -569,5 +597,10 @@ this.rootElement.contentEditable = isReadonly ? 'false' : 'true';

): void {
let attr = attributes;
if (this._marks) {
attr = { ...this._marks, ...attributes };
}
this._transact(() => {
this.yText.delete(vRange.index, vRange.length);
this.yText.insert(vRange.index, text, attributes);
this.yText.insert(vRange.index, text, attr);
});

@@ -574,0 +607,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

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