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

@blocksuite/block-std

Package Overview
Dependencies
Maintainers
5
Versions
909
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blocksuite/block-std - npm Package Compare versions

Comparing version 0.0.0-20230726225156-e7b23c54-nightly to 0.0.0-20230727170546-19a35248-nightly

18

dist/event/dispatcher.js
import { DisposableGroup } from '@blocksuite/global/utils';
import { PathMap } from '../store/index.js';
import { UIEventStateContext } from './base.js';
import { UIEventState } from './base.js';
import { UIEventState, UIEventStateContext } from './base.js';
import { KeyboardControl } from './control/keyboard.js';

@@ -131,12 +130,9 @@ import { PointerControl } from './control/pointer.js';

const globalEvents = handlers.filter(handler => handler.flavour === undefined && handler.path === undefined);
const pathEvents = paths.flatMap(path => {
return handlers.filter(handler => {
if (handler.path === undefined)
return false;
return PathMap.includes(path, handler.path);
});
const pathEvents = handlers.filter(handler => {
const _path = handler.path;
if (_path === undefined)
return false;
return paths.some(path => PathMap.includes(path, _path));
});
const flavourEvents = flavours.flatMap(flavour => {
return handlers.filter(handler => handler.flavour === flavour);
});
const flavourEvents = handlers.filter(handler => handler.flavour && flavours.includes(handler.flavour));
return {

@@ -143,0 +139,0 @@ runners: pathEvents.concat(flavourEvents).concat(globalEvents),

@@ -13,3 +13,2 @@ import { DisposableGroup, Slot } from '@blocksuite/store';

private _selectionConstructors;
private _oldSelections;
slots: {

@@ -16,0 +15,0 @@ changed: Slot<BaseSelection[]>;

@@ -8,3 +8,2 @@ import { DisposableGroup, Slot } from '@blocksuite/store';

this._selectionConstructors = {};
this._oldSelections = [];
this.slots = {

@@ -44,3 +43,2 @@ changed: new Slot(),

set(selections) {
this._oldSelections = this.value;
this._store.setLocalSelection(selections.map(s => s.toJSON()));

@@ -66,3 +64,3 @@ this.slots.changed.emit(selections);

this.blockStore.page.history.on('stack-item-added', (event) => {
event.stackItem.meta.set('selection-state', this._oldSelections);
event.stackItem.meta.set('selection-state', this.value);
});

@@ -69,0 +67,0 @@ this.blockStore.page.history.on('stack-item-popped', (event) => {

@@ -22,2 +22,4 @@ import { BaseSelection } from '../base.js';

static fromJSON(json: Record<string, unknown>): TextSelection;
isCollapsed(): boolean;
isInSameBlock(): boolean;
}

@@ -24,0 +26,0 @@ declare global {

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

import { PathMap } from '../../store/path-map.js';
import { BaseSelection } from '../base.js';

@@ -41,4 +42,10 @@ export class TextSelection extends BaseSelection {

}
isCollapsed() {
return this.to === null;
}
isInSameBlock() {
return this.to === null || PathMap.equals(this.from.path, this.to.path);
}
}
TextSelection.type = 'text';
//# sourceMappingURL=text.js.map
export declare class PathMap<Value = unknown> {
private _map;
constructor();
static pathToKey: (path: string[]) => string;
static pathToKey: (path: readonly string[]) => string;
static keyToPath: (key: string) => string[];
static equals: (path1: string[], path2: string[]) => boolean;
static equals: (path1: readonly string[], path2: readonly string[]) => boolean;
static includes: (path1: string[], path2: string[]) => boolean;

@@ -8,0 +8,0 @@ get(path: string[]): Value | undefined;

{
"name": "@blocksuite/block-std",
"version": "0.0.0-20230726225156-e7b23c54-nightly",
"version": "0.0.0-20230727170546-19a35248-nightly",
"description": "Std for blocksuite blocks",

@@ -12,10 +12,10 @@ "main": "dist/index.js",

"peerDependencies": {
"@blocksuite/store": "0.0.0-20230726225156-e7b23c54-nightly"
"@blocksuite/store": "0.0.0-20230727170546-19a35248-nightly"
},
"dependencies": {
"w3c-keyname": "^2.2.8",
"@blocksuite/global": "0.0.0-20230726225156-e7b23c54-nightly"
"@blocksuite/global": "0.0.0-20230727170546-19a35248-nightly"
},
"devDependencies": {
"@blocksuite/store": "0.0.0-20230726225156-e7b23c54-nightly"
"@blocksuite/store": "0.0.0-20230727170546-19a35248-nightly"
},

@@ -22,0 +22,0 @@ "exports": {

@@ -21,3 +21,2 @@ import { UIEventState, UIEventStateContext } from '../base.js';

});
this._dispatcher.run(

@@ -24,0 +23,0 @@ 'keyDown',

@@ -6,4 +6,3 @@ import { DisposableGroup } from '@blocksuite/global/utils';

import type { UIEventHandler } from './base.js';
import { UIEventStateContext } from './base.js';
import { UIEventState } from './base.js';
import { UIEventState, UIEventStateContext } from './base.js';
import { KeyboardControl } from './control/keyboard.js';

@@ -193,12 +192,11 @@ import { PointerControl } from './control/pointer.js';

const pathEvents = paths.flatMap(path => {
return handlers.filter(handler => {
if (handler.path === undefined) return false;
return PathMap.includes(path, handler.path);
});
const pathEvents = handlers.filter(handler => {
const _path = handler.path;
if (_path === undefined) return false;
return paths.some(path => PathMap.includes(path, _path));
});
const flavourEvents = flavours.flatMap(flavour => {
return handlers.filter(handler => handler.flavour === flavour);
});
const flavourEvents = handlers.filter(
handler => handler.flavour && flavours.includes(handler.flavour)
);

@@ -205,0 +203,0 @@ return {

@@ -78,3 +78,2 @@ import { base, keyName } from 'w3c-keyname';

}
if (name.length !== 1 || name === ' ') {

@@ -81,0 +80,0 @@ return false;

@@ -19,3 +19,2 @@ import type { StackItem } from '@blocksuite/store';

private _selectionConstructors: Record<string, SelectionConstructor> = {};
private _oldSelections: BaseSelection[] = [];

@@ -67,3 +66,2 @@ slots = {

set(selections: BaseSelection[]) {
this._oldSelections = this.value;
this._store.setLocalSelection(selections.map(s => s.toJSON()));

@@ -97,3 +95,3 @@ this.slots.changed.emit(selections);

(event: { stackItem: StackItem }) => {
event.stackItem.meta.set('selection-state', this._oldSelections);
event.stackItem.meta.set('selection-state', this.value);
}

@@ -100,0 +98,0 @@ );

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

import { PathMap } from '../../store/path-map.js';
import { BaseSelection } from '../base.js';

@@ -72,2 +73,10 @@

}
isCollapsed(): boolean {
return this.to === null;
}
isInSameBlock(): boolean {
return this.to === null || PathMap.equals(this.from.path, this.to.path);
}
}

@@ -74,0 +83,0 @@

@@ -8,3 +8,3 @@ export class PathMap<Value = unknown> {

static pathToKey = (path: string[]) => {
static pathToKey = (path: readonly string[]) => {
return path.join('|');

@@ -17,3 +17,3 @@ };

static equals = (path1: string[], path2: string[]) => {
static equals = (path1: readonly string[], path2: readonly string[]) => {
return PathMap.pathToKey(path1) === PathMap.pathToKey(path2);

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

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