@blocksuite/store
Advanced tools
Comparing version 0.4.0-20230114163139-bef702b to 0.4.0-20230115125610-fb61886
@@ -60,3 +60,3 @@ import * as Y from 'yjs'; | ||
clone(): Text; | ||
split(index: number): [PrelimText, PrelimText]; | ||
split(index: number, length: number): [PrelimText, PrelimText]; | ||
insert(content: string, index: number, attributes?: Record<string, unknown>): void; | ||
@@ -63,0 +63,0 @@ insertList(insertTexts: DeltaOperation[], index: number): void; |
@@ -100,6 +100,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
} | ||
split(index) { | ||
split(index, length) { | ||
return [ | ||
new PrelimText('splitLeft', index), | ||
new PrelimText('splitRight', index), | ||
new PrelimText('splitRight', index + length), | ||
]; | ||
@@ -106,0 +106,0 @@ } |
@@ -99,3 +99,3 @@ import * as Y from 'yjs'; | ||
const yBase = base._yText; | ||
// attach meta state for identifing split | ||
// attach meta state for identifying split | ||
// otherwise local change from y-side will be ignored by TextAdapter | ||
@@ -110,3 +110,3 @@ // @ts-ignore | ||
// delete the right-half part of `yBase`, making it the new left | ||
yBase.delete(right.index, yBase.length - right.index); | ||
yBase.delete(left.index, yBase.length - left.index); | ||
// cleanup | ||
@@ -113,0 +113,0 @@ splitSet.clear(); |
@@ -51,2 +51,4 @@ /// <reference types="@blocksuite/global" /> | ||
get rootLayer(): BaseBlockModel<unknown> | null; | ||
/** @internal used for getting surface block elements for phasor */ | ||
get ySurfaceContainer(): Y.Map<unknown>; | ||
get isEmpty(): boolean; | ||
@@ -53,0 +55,0 @@ get canUndo(): boolean; |
@@ -9,3 +9,3 @@ import * as Y from 'yjs'; | ||
import { tryMigrate } from './migrations.js'; | ||
import { matchFlavours } from '@blocksuite/global/utils'; | ||
import { assertExists, matchFlavours } from '@blocksuite/global/utils'; | ||
const isWeb = typeof window !== 'undefined'; | ||
@@ -78,2 +78,14 @@ function createChildMap(yChildIds) { | ||
} | ||
/** @internal used for getting surface block elements for phasor */ | ||
get ySurfaceContainer() { | ||
assertExists(this.rootLayer); | ||
const ySurface = this._yBlocks.get(this.rootLayer.id); | ||
if (ySurface?.has('elements')) { | ||
return ySurface.get('elements'); | ||
} | ||
else { | ||
ySurface?.set('elements', new Y.Map()); | ||
return ySurface?.get('elements'); | ||
} | ||
} | ||
get isEmpty() { | ||
@@ -80,0 +92,0 @@ return this._yBlocks.size === 0; |
@@ -161,2 +161,3 @@ import * as Y from 'yjs'; | ||
enable_drag_handle: true, | ||
enable_surface: false, | ||
readonly: {}, | ||
@@ -163,0 +164,0 @@ }; |
{ | ||
"name": "@blocksuite/store", | ||
"version": "0.4.0-20230114163139-bef702b", | ||
"version": "0.4.0-20230115125610-fb61886", | ||
"description": "BlockSuite data store built for general purpose state management.", | ||
@@ -11,3 +11,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@blocksuite/global": "0.4.0-20230114163139-bef702b", | ||
"@blocksuite/global": "0.4.0-20230115125610-fb61886", | ||
"@types/flexsearch": "^0.7.3", | ||
@@ -14,0 +14,0 @@ "buffer": "^6.0.3", |
@@ -155,6 +155,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
split(index: number): [PrelimText, PrelimText] { | ||
split(index: number, length: number): [PrelimText, PrelimText] { | ||
return [ | ||
new PrelimText('splitLeft', index), | ||
new PrelimText('splitRight', index), | ||
new PrelimText('splitRight', index + length), | ||
]; | ||
@@ -161,0 +161,0 @@ } |
@@ -133,3 +133,3 @@ import * as Y from 'yjs'; | ||
// attach meta state for identifing split | ||
// attach meta state for identifying split | ||
// otherwise local change from y-side will be ignored by TextAdapter | ||
@@ -147,3 +147,3 @@ // @ts-ignore | ||
// delete the right-half part of `yBase`, making it the new left | ||
yBase.delete(right.index, yBase.length - right.index); | ||
yBase.delete(left.index, yBase.length - left.index); | ||
@@ -150,0 +150,0 @@ // cleanup |
@@ -25,3 +25,3 @@ import * as Y from 'yjs'; | ||
import { tryMigrate } from './migrations.js'; | ||
import { matchFlavours } from '@blocksuite/global/utils'; | ||
import { assertExists, matchFlavours } from '@blocksuite/global/utils'; | ||
export type YBlock = Y.Map<unknown>; | ||
@@ -110,2 +110,14 @@ export type YBlocks = Y.Map<YBlock>; | ||
/** @internal used for getting surface block elements for phasor */ | ||
get ySurfaceContainer() { | ||
assertExists(this.rootLayer); | ||
const ySurface = this._yBlocks.get(this.rootLayer.id); | ||
if (ySurface?.has('elements')) { | ||
return ySurface.get('elements') as Y.Map<unknown>; | ||
} else { | ||
ySurface?.set('elements', new Y.Map()); | ||
return ySurface?.get('elements') as Y.Map<unknown>; | ||
} | ||
} | ||
get isEmpty() { | ||
@@ -112,0 +124,0 @@ return this._yBlocks.size === 0; |
@@ -222,2 +222,3 @@ import * as Y from 'yjs'; | ||
enable_drag_handle: true, | ||
enable_surface: false, | ||
readonly: {}, | ||
@@ -224,0 +225,0 @@ } satisfies BlockSuiteFlags; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
486140
8026
+ Added@blocksuite/global@0.4.0-20230115125610-fb61886(transitive)
- Removed@blocksuite/global@0.4.0-20230114163139-bef702b(transitive)