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

@blocksuite/affine-shared

Package Overview
Dependencies
Maintainers
0
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blocksuite/affine-shared - npm Package Compare versions

Comparing version 0.17.10 to 0.17.11

dist/selection/hightlight.d.ts

20

CHANGELOG.md
# @blocksuite/affine-shared
## 0.17.11
### Patch Changes
- 1052ebd: - Refactor drag handle widget
- Split embed blocks to `@blocksuite/affine-block-embed`
- Fix latex selected state in edgeless mode
- Fix unclear naming
- Fix prototype pollution
- Fix portal interaction in affine modal
- Fix paste linked block on edgeless
- Add scroll anchoring widget
- Add highlight selection
- Updated dependencies [1052ebd]
- @blocksuite/affine-model@0.17.11
- @blocksuite/block-std@0.17.11
- @blocksuite/global@0.17.11
- @blocksuite/inline@0.17.11
- @blocksuite/store@0.17.11
## 0.17.10

@@ -4,0 +24,0 @@

27

dist/commands/block-crud/get-next-block.js
import { assertExists } from '@blocksuite/global/utils';
function getNext(std, block) {
const view = std.view;
const next = std.doc.getNext(block.model);
if (!next)
return null;
return view.getBlock(next.id);
}
import { getNextContentBlock } from '../../utils/index.js';
function getNextBlock(std, path) {
const view = std.view;
const focusBlock = view.getBlock(path);
if (!focusBlock)
const model = std.doc.getBlock(path)?.model;
if (!model)
return null;
let next = null;
if (focusBlock.childBlocks[0]) {
next = focusBlock.childBlocks[0];
}
if (!next) {
next = getNext(std, focusBlock);
}
if (next && !next.contains(focusBlock)) {
return next;
}
return null;
const nextModel = getNextContentBlock(std.host, model);
if (!nextModel)
return null;
return view.getBlock(nextModel.id);
}

@@ -26,0 +13,0 @@ export const getNextBlockCommand = (ctx, next) => {

import { assertExists } from '@blocksuite/global/utils';
function getPrevSibling(std, path) {
const view = std.view;
const block = view.getBlock(path);
if (!block)
return null;
const prev = std.doc.getPrev(block.model);
if (!prev)
return null;
return view.getBlock(prev.id);
}
import { getPrevContentBlock } from '../../utils/index.js';
function getPrevBlock(std, path) {
const view = std.view;
const prev = getPrevSibling(std, path);
if (!prev) {
const model = std.doc.getBlock(path)?.model;
if (!model)
return null;
}
const block = view.getBlock(path);
if (!block)
const prevModel = getPrevContentBlock(std.host, model);
if (!prevModel)
return null;
if (prev && prev.blockId !== path) {
return prev;
}
return null;
return view.getBlock(prevModel.id);
}

@@ -26,0 +13,0 @@ export const getPrevBlockCommand = (ctx, next) => {

@@ -1,5 +0,5 @@

import type { ImageSelection } from '@blocksuite/affine-shared/selection';
import type { BlockSelection, Command, TextSelection } from '@blocksuite/block-std';
import type { RoleType } from '@blocksuite/store';
import { BlockComponent } from '@blocksuite/block-std';
import type { ImageSelection } from '../../selection/index.js';
export declare const getSelectedBlocksCommand: Command<'currentTextSelection' | 'currentBlockSelections' | 'currentImageSelections', 'selectedBlocks', {

@@ -6,0 +6,0 @@ textSelection?: TextSelection;

@@ -1,3 +0,3 @@

import type { ImageSelection } from '@blocksuite/affine-shared/selection';
import type { Command } from '@blocksuite/block-std';
import type { ImageSelection } from '../../selection/index.js';
export declare const getImageSelectionsCommand: Command<never, 'currentImageSelections'>;

@@ -4,0 +4,0 @@ declare global {

@@ -10,6 +10,4 @@ import { BaseSelection } from '@blocksuite/block-std';

static fromJSON(json) {
ImageSelectionSchema.parse(json);
return new ImageSelection({
blockId: json.blockId,
});
const result = ImageSelectionSchema.parse(json);
return new ImageSelection(result);
}

@@ -16,0 +14,0 @@ equals(other) {

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

export { HighlightSelection } from './hightlight.js';
export { ImageSelection } from './image.js';
//# sourceMappingURL=index.d.ts.map

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

export { HighlightSelection } from './hightlight.js';
export { ImageSelection } from './image.js';
//# sourceMappingURL=index.js.map

@@ -60,5 +60,5 @@ import type { DocMode } from '@blocksuite/affine-model';

setPrimaryMode(mode: DocMode, id: string): void;
togglePrimaryMode(id: string): "page" | "edgeless";
togglePrimaryMode(id: string): "edgeless" | "page";
}
export declare function DocModeExtension(service: DocModeProvider): ExtensionType;
//# sourceMappingURL=doc-mode-service.d.ts.map

@@ -94,6 +94,5 @@ import { type BlockStdScope, LifeCycleWatcher } from '@blocksuite/block-std';

applyLastProps(key: LastPropsKey, props: Record<string, unknown>): ({
mode: import("@blocksuite/affine-model").ConnectorMode;
frontEndpointStyle: import("@blocksuite/affine-model").PointStyle;
rearEndpointStyle: import("@blocksuite/affine-model").PointStyle;
stroke: {
stroke: import("@blocksuite/affine-model").LineColor | {
normal: string;

@@ -103,9 +102,9 @@ } | {

dark: string;
} | import("@blocksuite/affine-model").LineColor;
};
strokeStyle: import("@blocksuite/affine-model").StrokeStyle;
strokeWidth: import("@blocksuite/affine-model").LineWidth;
rough: boolean;
mode: import("@blocksuite/affine-model").ConnectorMode;
labelStyle: {
fontSize: number;
color: {
color: import("@blocksuite/affine-model").LineColor | {
normal: string;

@@ -115,10 +114,11 @@ } | {

dark: string;
} | import("@blocksuite/affine-model").LineColor;
};
fontSize: number;
fontFamily: import("@blocksuite/affine-model").FontFamily;
fontWeight: import("@blocksuite/affine-model").FontWeight;
fontStyle: import("@blocksuite/affine-model").FontStyle;
fontWeight: import("@blocksuite/affine-model").FontWeight;
textAlign: import("@blocksuite/affine-model").TextAlign;
};
} | {
color: {
color: import("@blocksuite/affine-model").LineColor | {
normal: string;

@@ -128,7 +128,6 @@ } | {

dark: string;
} | import("@blocksuite/affine-model").LineColor;
};
lineWidth: import("@blocksuite/affine-model").LineWidth;
} | {
fontSize: number;
color: {
color: import("@blocksuite/affine-model").LineColor | {
normal: string;

@@ -138,30 +137,13 @@ } | {

dark: string;
} | import("@blocksuite/affine-model").LineColor;
};
fontSize: number;
fontFamily: import("@blocksuite/affine-model").FontFamily;
fontWeight: import("@blocksuite/affine-model").FontWeight;
fontStyle: import("@blocksuite/affine-model").FontStyle;
fontWeight: import("@blocksuite/affine-model").FontWeight;
textAlign: import("@blocksuite/affine-model").TextAlign;
strokeStyle: import("@blocksuite/affine-model").StrokeStyle;
strokeWidth: number;
fillColor: {
normal: string;
} | {
light: string;
dark: string;
} | import("@blocksuite/affine-model").ShapeFillColor;
strokeColor: {
normal: string;
} | {
light: string;
dark: string;
} | import("@blocksuite/affine-model").LineColor;
shapeStyle: import("@blocksuite/affine-model").ShapeStyle;
filled: boolean;
radius: number;
roughness: number;
textHorizontalAlign?: import("@blocksuite/affine-model").TextAlign | undefined;
textVerticalAlign?: import("@blocksuite/affine-model").TextVerticalAlign | undefined;
} | {
fontSize: number;
color: {
layoutType: import("@blocksuite/affine-model").LayoutType;
style: import("@blocksuite/affine-model").MindmapStyle;
} | {
color: import("@blocksuite/affine-model").LineColor | {
normal: string;

@@ -171,17 +153,6 @@ } | {

dark: string;
} | import("@blocksuite/affine-model").LineColor;
};
fontFamily: import("@blocksuite/affine-model").FontFamily;
fontStyle: import("@blocksuite/affine-model").FontStyle;
fontWeight: import("@blocksuite/affine-model").FontWeight;
textAlign: import("@blocksuite/affine-model").TextAlign;
} | {
color: {
normal: string;
} | {
light: string;
dark: string;
} | import("@blocksuite/affine-model").LineColor;
fontFamily: import("@blocksuite/affine-model").FontFamily;
fontStyle: import("@blocksuite/affine-model").FontStyle;
fontWeight: import("@blocksuite/affine-model").FontWeight;
textAlign: import("@blocksuite/affine-model").TextAlign;

@@ -205,5 +176,2 @@ } | {

} | {
style: import("@blocksuite/affine-model").MindmapStyle;
layoutType: import("@blocksuite/affine-model").LayoutType;
} | {
background?: {

@@ -215,2 +183,34 @@ normal: string;

} | import("@blocksuite/affine-model").FrameBackgroundColor | undefined;
} | {
strokeStyle: import("@blocksuite/affine-model").StrokeStyle;
strokeWidth: number;
color: import("@blocksuite/affine-model").LineColor | {
normal: string;
} | {
light: string;
dark: string;
};
fontSize: number;
fontFamily: import("@blocksuite/affine-model").FontFamily;
fontWeight: import("@blocksuite/affine-model").FontWeight;
fontStyle: import("@blocksuite/affine-model").FontStyle;
textAlign: import("@blocksuite/affine-model").TextAlign;
fillColor: {
normal: string;
} | {
light: string;
dark: string;
} | import("@blocksuite/affine-model").ShapeFillColor;
strokeColor: import("@blocksuite/affine-model").LineColor | {
normal: string;
} | {
light: string;
dark: string;
};
shapeStyle: import("@blocksuite/affine-model").ShapeStyle;
filled: boolean;
radius: number;
roughness: number;
textHorizontalAlign?: import("@blocksuite/affine-model").TextAlign | undefined;
textVerticalAlign?: import("@blocksuite/affine-model").TextVerticalAlign | undefined;
}) & Record<string, unknown>;

@@ -217,0 +217,0 @@ dispose(): void;

import { LifeCycleWatcher } from '@blocksuite/block-std';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { DisposableGroup, Slot, } from '@blocksuite/global/utils';

@@ -95,2 +96,5 @@ import { computed, signal } from '@preact/signals-core';

applyLastProps(key, props) {
if (['__proto__', 'constructor', 'prototype'].includes(key)) {
throw new BlockSuiteError(ErrorCode.DefaultRuntimeError, `Invalid key: ${key}`);
}
const lastProps = this.lastProps$.value[key];

@@ -97,0 +101,0 @@ return mergeWith(clonedeep(lastProps), props, customizer);

export * from './doc-mode-service.js';
export * from './drag-handle-config.js';
export * from './edit-props-store.js';

@@ -3,0 +4,0 @@ export * from './editor-setting-service.js';

export * from './doc-mode-service.js';
export * from './drag-handle-config.js';
export * from './edit-props-store.js';

@@ -3,0 +4,0 @@ export * from './editor-setting-service.js';

@@ -37,2 +37,3 @@ export declare function isTouchPadPinchEvent(e: WheelEvent): boolean;

export declare function requestThrottledConnectedFrame<T extends (...args: unknown[]) => void>(func: T, element?: HTMLElement): T;
export declare const captureEventTarget: (target: EventTarget | null) => Element | null;
//# sourceMappingURL=event.d.ts.map

@@ -94,2 +94,10 @@ import { IS_IOS, IS_MAC } from '@blocksuite/global/env';

}
export const captureEventTarget = (target) => {
const isElementOrNode = target instanceof Element || target instanceof Node;
return isElementOrNode
? target instanceof Element
? target
: target.parentElement
: null;
};
//# sourceMappingURL=event.js.map
export * from './button-popper.js';
export * from './dnd/index.js';
export * from './dom/index.js';

@@ -12,2 +13,3 @@ export * from './event.js';

export * from './signal.js';
export * from './spec/index.js';
export * from './string.js';

@@ -14,0 +16,0 @@ export * from './title.js';

@@ -1,3 +0,3 @@

// Compat with SSR
export * from './button-popper.js';
export * from './dnd/index.js';
export * from './dom/index.js';

@@ -13,2 +13,3 @@ export * from './event.js';

export * from './signal.js';
export * from './spec/index.js';
export * from './string.js';

@@ -15,0 +16,0 @@ export * from './title.js';

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

import { DocModeProvider } from '../../services/doc-mode-service.js';
import { matchFlavours } from './checker.js';

@@ -32,6 +33,3 @@ /**

// in edgeless mode, limit search for the previous block within the same note
if (
// FIXME: this is a workaround to check if the editor is in edgeless mode
// We should use service to check if the editor is in edgeless mode
isInsideEdgelessEditor(editorHost) &&
if (editorHost.std.get(DocModeProvider).getEditorMode() === 'edgeless' &&
parent.role === 'hub') {

@@ -54,9 +52,5 @@ return null;

}
else {
return iterate(prev);
}
return iterate(prev);
}
else {
return null;
}
return null;
};

@@ -95,5 +89,5 @@ return iterate(model);

// Assert nextSibling is not possible to be `affine:page`
if (model.role === 'hub') {
if (nextSibling.role === 'hub') {
// in edgeless mode, limit search for the next block within the same note
if (isInsideEdgelessEditor(editorHost)) {
if (editorHost.std.get(DocModeProvider).getEditorMode() === 'edgeless') {
return null;

@@ -109,5 +103,2 @@ }

}
function isInsideEdgelessEditor(host) {
return Array.from(host.children).some(v => v.tagName.toLowerCase() === 'affine-edgeless-root');
}
//# sourceMappingURL=get-content-block.js.map
{
"name": "@blocksuite/affine-shared",
"version": "0.17.10",
"version": "0.17.11",
"description": "Default BlockSuite editable blocks.",

@@ -18,7 +18,7 @@ "type": "module",

"dependencies": {
"@blocksuite/affine-model": "0.17.10",
"@blocksuite/block-std": "0.17.10",
"@blocksuite/global": "0.17.10",
"@blocksuite/inline": "0.17.10",
"@blocksuite/store": "0.17.10",
"@blocksuite/affine-model": "0.17.11",
"@blocksuite/block-std": "0.17.11",
"@blocksuite/global": "0.17.11",
"@blocksuite/inline": "0.17.11",
"@blocksuite/store": "0.17.11",
"@floating-ui/dom": "^1.6.10",

@@ -25,0 +25,0 @@ "@lit/context": "^1.1.2",

@@ -5,28 +5,11 @@ import type { BlockComponent, Command } from '@blocksuite/block-std';

function getNext(std: BlockSuite.Std, block: BlockComponent) {
const view = std.view;
const next = std.doc.getNext(block.model);
if (!next) return null;
return view.getBlock(next.id);
}
import { getNextContentBlock } from '../../utils/index.js';
function getNextBlock(std: BlockSuite.Std, path: string) {
const view = std.view;
const focusBlock = view.getBlock(path);
if (!focusBlock) return null;
let next: BlockComponent | null = null;
if (focusBlock.childBlocks[0]) {
next = focusBlock.childBlocks[0];
}
if (!next) {
next = getNext(std, focusBlock);
}
if (next && !next.contains(focusBlock)) {
return next;
}
return null;
const model = std.doc.getBlock(path)?.model;
if (!model) return null;
const nextModel = getNextContentBlock(std.host, model);
if (!nextModel) return null;
return view.getBlock(nextModel.id);
}

@@ -33,0 +16,0 @@

@@ -5,10 +5,3 @@ import type { BlockComponent, Command } from '@blocksuite/block-std';

function getPrevSibling(std: BlockSuite.Std, path: string) {
const view = std.view;
const block = view.getBlock(path);
if (!block) return null;
const prev = std.doc.getPrev(block.model);
if (!prev) return null;
return view.getBlock(prev.id);
}
import { getPrevContentBlock } from '../../utils/index.js';

@@ -18,16 +11,7 @@ function getPrevBlock(std: BlockSuite.Std, path: string) {

const prev: BlockComponent | null = getPrevSibling(std, path);
if (!prev) {
return null;
}
const block = view.getBlock(path);
if (!block) return null;
if (prev && prev.blockId !== path) {
return prev;
}
return null;
const model = std.doc.getBlock(path)?.model;
if (!model) return null;
const prevModel = getPrevContentBlock(std.host, model);
if (!prevModel) return null;
return view.getBlock(prevModel.id);
}

@@ -34,0 +18,0 @@

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

import type { ImageSelection } from '@blocksuite/affine-shared/selection';
import type {

@@ -11,2 +10,4 @@ BlockSelection,

import type { ImageSelection } from '../../selection/index.js';
export const getSelectedBlocksCommand: Command<

@@ -13,0 +14,0 @@ 'currentTextSelection' | 'currentBlockSelections' | 'currentImageSelections',

@@ -1,4 +0,5 @@

import type { ImageSelection } from '@blocksuite/affine-shared/selection';
import type { Command } from '@blocksuite/block-std';
import type { ImageSelection } from '../../selection/index.js';
export const getImageSelectionsCommand: Command<

@@ -5,0 +6,0 @@ never,

@@ -14,6 +14,4 @@ import { BaseSelection } from '@blocksuite/block-std';

static override fromJSON(json: Record<string, unknown>): ImageSelection {
ImageSelectionSchema.parse(json);
return new ImageSelection({
blockId: json.blockId as string,
});
const result = ImageSelectionSchema.parse(json);
return new ImageSelection(result);
}

@@ -20,0 +18,0 @@

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

export { HighlightSelection } from './hightlight.js';
export { ImageSelection } from './image.js';
import { type BlockStdScope, LifeCycleWatcher } from '@blocksuite/block-std';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import {

@@ -139,2 +140,8 @@ type DeepPartial,

applyLastProps(key: LastPropsKey, props: Record<string, unknown>) {
if (['__proto__', 'constructor', 'prototype'].includes(key)) {
throw new BlockSuiteError(
ErrorCode.DefaultRuntimeError,
`Invalid key: ${key}`
);
}
const lastProps = this.lastProps$.value[key];

@@ -141,0 +148,0 @@ return mergeWith(clonedeep(lastProps), props, customizer);

export * from './doc-mode-service.js';
export * from './drag-handle-config.js';
export * from './edit-props-store.js';

@@ -3,0 +4,0 @@ export * from './editor-setting-service.js';

@@ -188,1 +188,10 @@ import { IS_IOS, IS_MAC } from '@blocksuite/global/env';

}
export const captureEventTarget = (target: EventTarget | null) => {
const isElementOrNode = target instanceof Element || target instanceof Node;
return isElementOrNode
? target instanceof Element
? target
: target.parentElement
: null;
};

@@ -1,3 +0,3 @@

// Compat with SSR
export * from './button-popper.js';
export * from './dnd/index.js';
export * from './dom/index.js';

@@ -13,2 +13,3 @@ export * from './event.js';

export * from './signal.js';
export * from './spec/index.js';
export * from './string.js';

@@ -15,0 +16,0 @@ export * from './title.js';

import type { EditorHost } from '@blocksuite/block-std';
import type { BlockModel } from '@blocksuite/store';
import { DocModeProvider } from '../../services/doc-mode-service.js';
import { matchFlavours } from './checker.js';

@@ -41,5 +42,3 @@

if (
// FIXME: this is a workaround to check if the editor is in edgeless mode
// We should use service to check if the editor is in edgeless mode
isInsideEdgelessEditor(editorHost) &&
editorHost.std.get(DocModeProvider).getEditorMode() === 'edgeless' &&
parent.role === 'hub'

@@ -69,8 +68,8 @@ ) {

return prev;
} else {
return iterate(prev);
}
} else {
return null;
return iterate(prev);
}
return null;
};

@@ -116,5 +115,7 @@

// Assert nextSibling is not possible to be `affine:page`
if (model.role === 'hub') {
if (nextSibling.role === 'hub') {
// in edgeless mode, limit search for the next block within the same note
if (isInsideEdgelessEditor(editorHost)) {
if (
editorHost.std.get(DocModeProvider).getEditorMode() === 'edgeless'
) {
return null;

@@ -131,7 +132,1 @@ }

}
function isInsideEdgelessEditor(host: EditorHost) {
return Array.from(host.children).some(
v => v.tagName.toLowerCase() === 'affine-edgeless-root'
);
}

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

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 too big to display

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 too big to display

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