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.4.0-20230216011811-2776d93 to 0.4.0-20230216093909-90a4996

4

dist/components/base-text.d.ts
import { LitElement } from 'lit';
import { z } from 'zod';
import type { DeltaInsert } from '../types.js';
export declare const baseTextAttributes: z.ZodOptional<z.ZodObject<{
export declare const baseTextAttributes: z.ZodObject<{
bold: z.ZodOptional<z.ZodBoolean>;

@@ -28,3 +28,3 @@ italic: z.ZodOptional<z.ZodBoolean>;

link?: string | undefined;
}>>;
}>;
export type BaseTextAttributes = z.infer<typeof baseTextAttributes>;

@@ -31,0 +31,0 @@ export declare class BaseText extends LitElement {

@@ -13,4 +13,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import { VirgoUnitText } from './virgo-unit-text.js';
export const baseTextAttributes = z
.object({
export const baseTextAttributes = z.object({
bold: z.boolean().optional(),

@@ -23,7 +22,4 @@ italic: z.boolean().optional(),

link: z.string().optional(),
})
.optional();
});
function virgoTextStyles(props) {
if (!props)
return styleMap({});
let textDecorations = '';

@@ -66,7 +62,8 @@ if (props.underline) {

unitText.str = this.delta.insert;
const style = this.delta.attributes
? virgoTextStyles(this.delta.attributes)
: styleMap({});
// we need to avoid \n appearing before and after the span element, which will
// cause the unexpected space
return html `<span
data-virgo-element="true"
style=${virgoTextStyles(this.delta.attributes)}
return html `<span data-virgo-element="true" style=${style}
>${unitText}</span

@@ -73,0 +70,0 @@ >`;

@@ -6,3 +6,3 @@ import { BaseText, baseTextAttributes } from '../components/base-text.js';

export function baseRenderElement(delta) {
const parseResult = baseTextAttributes.parse(delta.attributes);
const parseResult = baseTextAttributes.optional().parse(delta.attributes);
const baseText = new BaseText();

@@ -9,0 +9,0 @@ baseText.delta = {

@@ -40,3 +40,3 @@ import { Signal } from '@blocksuite/global/utils';

insertLineBreak(vRange: VRange): void;
formatText(vRange: VRange, attributes: NonNullable<TextAttributes>, options?: {
formatText(vRange: VRange, attributes: TextAttributes, options?: {
match?: (delta: DeltaInsert, deltaVRange: VRange) => boolean;

@@ -43,0 +43,0 @@ mode?: 'replace' | 'merge';

{
"name": "@blocksuite/virgo",
"version": "0.4.0-20230216011811-2776d93",
"version": "0.4.0-20230216093909-90a4996",
"description": "A micro editor.",

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

"dependencies": {
"@blocksuite/global": "0.4.0-20230216011811-2776d93",
"@blocksuite/global": "0.4.0-20230216093909-90a4996",
"zod": "^3.20.6"

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

@@ -10,13 +10,11 @@ import { html, LitElement } from 'lit';

export const baseTextAttributes = z
.object({
bold: z.boolean().optional(),
italic: z.boolean().optional(),
underline: z.boolean().optional(),
strikethrough: z.boolean().optional(),
inlineCode: z.boolean().optional(),
color: z.string().optional(),
link: z.string().optional(),
})
.optional();
export const baseTextAttributes = z.object({
bold: z.boolean().optional(),
italic: z.boolean().optional(),
underline: z.boolean().optional(),
strikethrough: z.boolean().optional(),
inlineCode: z.boolean().optional(),
color: z.string().optional(),
link: z.string().optional(),
});

@@ -28,4 +26,2 @@ export type BaseTextAttributes = z.infer<typeof baseTextAttributes>;

): ReturnType<typeof styleMap> {
if (!props) return styleMap({});
let textDecorations = '';

@@ -72,8 +68,9 @@ if (props.underline) {

unitText.str = this.delta.insert;
const style = this.delta.attributes
? virgoTextStyles(this.delta.attributes)
: styleMap({});
// we need to avoid \n appearing before and after the span element, which will
// cause the unexpected space
return html`<span
data-virgo-element="true"
style=${virgoTextStyles(this.delta.attributes)}
return html`<span data-virgo-element="true" style=${style}
>${unitText}</span

@@ -80,0 +77,0 @@ >`;

@@ -8,3 +8,3 @@ import { BaseText, baseTextAttributes } from '../components/base-text.js';

export function baseRenderElement(delta: DeltaInsert): TextElement {
const parseResult = baseTextAttributes.parse(delta.attributes);
const parseResult = baseTextAttributes.optional().parse(delta.attributes);

@@ -11,0 +11,0 @@ const baseText = new BaseText();

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

vRange: VRange,
attributes: NonNullable<TextAttributes>,
attributes: TextAttributes,
options: {

@@ -234,0 +234,0 @@ match?: (delta: DeltaInsert, deltaVRange: VRange) => boolean;

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