@blocksuite/block-std
Advanced tools
Comparing version 0.0.0-canary-20241212001527 to 0.0.0-canary-20241213001537
104
CHANGELOG.md
# @blocksuite/block-std | ||
## 0.0.0-canary-20241212001527 | ||
## 0.0.0-canary-20241213001537 | ||
@@ -9,6 +9,102 @@ ### Patch Changes | ||
- Updated dependencies | ||
- @blocksuite/global@0.0.0-canary-20241212001527 | ||
- @blocksuite/inline@0.0.0-canary-20241212001527 | ||
- @blocksuite/store@0.0.0-canary-20241212001527 | ||
- @blocksuite/global@0.0.0-canary-20241213001537 | ||
- @blocksuite/inline@0.0.0-canary-20241213001537 | ||
- @blocksuite/store@0.0.0-canary-20241213001537 | ||
## 0.18.7 | ||
### Patch Changes | ||
- 1057773: Blocksuite patch release. | ||
## Feat | ||
- feat(edgeless): rewrite mind map drag indicator (#8805) | ||
- feat: remove data transfer from dnd api (#8955) | ||
## Fix | ||
- fix: dnd from entity api (#8958) | ||
- fix(std): edge case on pointer controller (#8954) | ||
- fix: indent behavior (#8941) | ||
- fix(edgeless): add index reorder buttong for frame block (#8951) | ||
## Chore | ||
- chore: run headless vitest locally by default (#8957) | ||
- chore(blocks): disable image peekview on mobile (#8952) | ||
## Refactor | ||
- refactor(database): refactor addRow functionality in kanban and table views (#8956) | ||
- refactor: notion html adapter (#8947) | ||
- Updated dependencies [1057773] | ||
- @blocksuite/global@0.18.7 | ||
- @blocksuite/inline@0.18.7 | ||
- @blocksuite/store@0.18.7 | ||
## 0.18.6 | ||
### Patch Changes | ||
- d925364: Blocksuite patch release. | ||
## Feat | ||
- feat: add from entity api for dnd (#8946) | ||
- feat: make block to snapshot a sync method (#8943) | ||
- feat(database): enhance filter functionality with default values (#8932) | ||
- feat: bring back the ability to drag blocks from note to edgeless (#8914) | ||
- feat(blocks): responsive ui for embed doc (#8900) | ||
- feat(edgeless): unlock and unlock button (#8826) | ||
- feat(edgeless): impl lock interface for edgeless element and block (#8825) | ||
- feat(edgeless): add lock property to edgeless block and element (#8824) | ||
- feat(blocks): support embed linked doc and synced doc html block adapter (#8907) | ||
- feat(blocks): support database html block adapter (#8898) | ||
## Fix | ||
- fix(blocks): inconsistent language list behavior on hover in Firefox (#8944) | ||
- fix(database): adjust detail panel layout for better responsiveness (#8945) | ||
- fix(database): move cursor in kanban card title by arrow keys (#8893) | ||
- fix(blocks): show keyboard toolbar when focus on title and hide on scrolling (#8939) | ||
- fix(blocks): missing aliases when duplicating linked doc block on edgeless (#8930) | ||
- fix: remove vitest extension from recommendation list (#8936) | ||
- fix(blocks): should prevent default if drop event is handled (#8929) | ||
- fix(blocks): missing aliases when converting from embed to card (#8928) | ||
- fix(blocks): should show original doc title when hovering title button (#8925) | ||
- fix(blocks): hide the thumb for bookmark if its width is less than 375 (#8922) | ||
- fix(blocks): button styling when disabled on embed card edit popup (#8924) | ||
- fix(edgeless): undefined telemetry service (#8918) | ||
- fix(database): add group call frequency is incorrect (#8916) | ||
- fix(database): adjust padding for mobile menu to accommodate safe area insets (#8915) | ||
## Chore | ||
- chore(edgeless): telemetry for edgeless lock feature (#8933) | ||
- chore(blocks): use rest params in parsed result (#8908) | ||
- chore: lock file maintenance (#8919) | ||
- chore: lock file maintenance (#8894) | ||
## Refactor | ||
- refactor: adapter types and utils (#8934) | ||
- refactor: make notion text adapter as an extension (#8926) | ||
## Perf | ||
- perf(std): cache dom rect for pointer controller (#8940) | ||
## Test | ||
- test(database): add sorting functionality tests for multiple rules (#8917) | ||
- test(edgeless): fix lock flaky test by adding waitNextFrame (#8937) | ||
- test(edgeless): edgeless element lock feature tests (#8867) | ||
- Updated dependencies [d925364] | ||
- @blocksuite/global@0.18.6 | ||
- @blocksuite/inline@0.18.6 | ||
- @blocksuite/store@0.18.6 | ||
## 0.18.5 | ||
@@ -15,0 +111,0 @@ |
import type { UIEventDispatcher } from '../dispatcher.js'; | ||
export declare class PointerControl { | ||
private _dispatcher; | ||
private _cachedRect; | ||
private _getRect; | ||
private _pollingInterval; | ||
private controllers; | ||
constructor(dispatcher: UIEventDispatcher); | ||
constructor(_dispatcher: UIEventDispatcher); | ||
private _startPolling; | ||
protected _updateRect(): void; | ||
dispose(): void; | ||
@@ -6,0 +12,0 @@ listen(): void; |
import { IS_IPAD } from '@blocksuite/global/env'; | ||
import { Vec } from '@blocksuite/global/utils'; | ||
import { nextTick, Vec } from '@blocksuite/global/utils'; | ||
import { UIEventState, UIEventStateContext } from '../base.js'; | ||
@@ -13,27 +13,8 @@ import { DndEventState, MultiPointerEventState, PointerEventState, } from '../state/index.js'; | ||
} | ||
const POLL_INTERVAL = 1000; | ||
class PointerControllerBase { | ||
get _rect() { | ||
if (!this._cachedRect) { | ||
this._updateRect(); | ||
} | ||
return this._cachedRect; | ||
} | ||
constructor(_dispatcher) { | ||
constructor(_dispatcher, _getRect) { | ||
this._dispatcher = _dispatcher; | ||
this._cachedRect = null; | ||
this._resizeObserver = null; | ||
this._resizeObserver = new ResizeObserver(() => this._updateRect()); | ||
this._getRect = _getRect; | ||
} | ||
_updateRect() { | ||
if (!this._dispatcher.host) | ||
return; | ||
if (this._resizeObserver && !this._cachedRect) { | ||
this._resizeObserver.observe(this._dispatcher.host); | ||
} | ||
this._cachedRect = this._dispatcher.host.getBoundingClientRect(); | ||
} | ||
dispose() { | ||
this._resizeObserver?.disconnect(); | ||
this._resizeObserver = null; | ||
} | ||
} | ||
@@ -47,3 +28,3 @@ class PointerEventForward extends PointerControllerBase { | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -64,3 +45,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: start?.x ?? -Infinity, | ||
@@ -80,3 +61,3 @@ startY: start?.y ?? -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: start?.x ?? -Infinity, | ||
@@ -117,3 +98,3 @@ startY: start?.y ?? -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -136,3 +117,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -176,3 +157,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -196,3 +177,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: start.x, | ||
@@ -250,3 +231,3 @@ startY: start.y, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: start.x, | ||
@@ -305,3 +286,3 @@ startY: start.y, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -335,3 +316,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: startPrimaryState.x, | ||
@@ -345,3 +326,3 @@ startY: startPrimaryState.y, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: startSecondaryState.x, | ||
@@ -428,15 +409,44 @@ startY: startSecondaryState.y, | ||
export class PointerControl { | ||
constructor(dispatcher) { | ||
constructor(_dispatcher) { | ||
this._dispatcher = _dispatcher; | ||
this._cachedRect = null; | ||
this._getRect = () => { | ||
if (this._cachedRect === null) { | ||
this._updateRect(); | ||
} | ||
return this._cachedRect; | ||
}; | ||
// XXX: polling is used instead of MutationObserver | ||
// due to potential performance issues | ||
this._pollingInterval = null; | ||
this.controllers = [ | ||
new PointerEventForward(dispatcher), | ||
new ClickController(dispatcher), | ||
new DragController(dispatcher), | ||
new PanController(dispatcher), | ||
new PinchController(dispatcher), | ||
new PointerEventForward(_dispatcher, this._getRect), | ||
new ClickController(_dispatcher, this._getRect), | ||
new DragController(_dispatcher, this._getRect), | ||
new PanController(_dispatcher, this._getRect), | ||
new PinchController(_dispatcher, this._getRect), | ||
]; | ||
} | ||
_startPolling() { | ||
const poll = () => { | ||
nextTick() | ||
.then(() => this._updateRect()) | ||
.catch(console.error); | ||
}; | ||
this._pollingInterval = window.setInterval(poll, POLL_INTERVAL); | ||
poll(); | ||
} | ||
_updateRect() { | ||
if (!this._dispatcher.host) | ||
return; | ||
this._cachedRect = this._dispatcher.host.getBoundingClientRect(); | ||
} | ||
dispose() { | ||
this.controllers.forEach(controller => controller.dispose()); | ||
if (this._pollingInterval !== null) { | ||
clearInterval(this._pollingInterval); | ||
this._pollingInterval = null; | ||
} | ||
} | ||
listen() { | ||
this._startPolling(); | ||
this.controllers.forEach(controller => controller.listen()); | ||
@@ -443,0 +453,0 @@ } |
@@ -83,10 +83,12 @@ import { INLINE_ROOT_ATTR } from '@blocksuite/inline'; | ||
const firstElement = this.getClosestBlock(range.startContainer); | ||
if (!firstElement) { | ||
if (!firstElement) | ||
return []; | ||
} | ||
const firstElementIndex = result.indexOf(firstElement); | ||
if (firstElementIndex === -1) | ||
return []; | ||
if (mode === 'flat') { | ||
result = result.filter(el => firstElement.compareDocumentPosition(el) & | ||
Node.DOCUMENT_POSITION_FOLLOWING || el === firstElement); | ||
result = result.slice(firstElementIndex); | ||
} | ||
else if (mode === 'highest') { | ||
result = result.slice(firstElementIndex); | ||
let parent = result[0]; | ||
@@ -93,0 +95,0 @@ result = result.filter((node, index) => { |
{ | ||
"name": "@blocksuite/block-std", | ||
"version": "0.0.0-canary-20241212001527", | ||
"version": "0.0.0-canary-20241213001537", | ||
"description": "Std for blocksuite blocks", | ||
@@ -23,5 +23,5 @@ "type": "module", | ||
"dependencies": { | ||
"@blocksuite/global": "0.0.0-canary-20241212001527", | ||
"@blocksuite/inline": "0.0.0-canary-20241212001527", | ||
"@blocksuite/store": "0.0.0-canary-20241212001527", | ||
"@blocksuite/global": "0.0.0-canary-20241213001537", | ||
"@blocksuite/inline": "0.0.0-canary-20241213001537", | ||
"@blocksuite/store": "0.0.0-canary-20241213001537", | ||
"@lit/context": "^1.1.2", | ||
@@ -28,0 +28,0 @@ "@preact/signals-core": "^1.8.0", |
import { IS_IPAD } from '@blocksuite/global/env'; | ||
import { Vec } from '@blocksuite/global/utils'; | ||
import { nextTick, Vec } from '@blocksuite/global/utils'; | ||
@@ -31,33 +31,10 @@ import type { UIEventDispatcher } from '../dispatcher.js'; | ||
const POLL_INTERVAL = 1000; | ||
abstract class PointerControllerBase { | ||
private _cachedRect: DOMRect | null = null; | ||
constructor( | ||
protected _dispatcher: UIEventDispatcher, | ||
protected _getRect: () => DOMRect | ||
) {} | ||
private _resizeObserver: ResizeObserver | null = null; | ||
protected get _rect() { | ||
if (!this._cachedRect) { | ||
this._updateRect(); | ||
} | ||
return this._cachedRect as DOMRect; | ||
} | ||
constructor(protected _dispatcher: UIEventDispatcher) { | ||
this._resizeObserver = new ResizeObserver(() => this._updateRect()); | ||
} | ||
protected _updateRect() { | ||
if (!this._dispatcher.host) return; | ||
if (this._resizeObserver && !this._cachedRect) { | ||
this._resizeObserver.observe(this._dispatcher.host); | ||
} | ||
this._cachedRect = this._dispatcher.host.getBoundingClientRect(); | ||
} | ||
dispose() { | ||
this._resizeObserver?.disconnect(); | ||
this._resizeObserver = null; | ||
} | ||
abstract listen(): void; | ||
@@ -72,3 +49,3 @@ } | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -93,3 +70,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: start?.x ?? -Infinity, | ||
@@ -114,3 +91,3 @@ startY: start?.y ?? -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: start?.x ?? -Infinity, | ||
@@ -157,3 +134,3 @@ startY: start?.y ?? -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -180,3 +157,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -223,3 +200,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -255,3 +232,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: start.x, | ||
@@ -339,3 +316,3 @@ startY: start.y, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: start.x, | ||
@@ -408,3 +385,3 @@ startY: start.y, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: -Infinity, | ||
@@ -448,3 +425,3 @@ startY: -Infinity, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: startPrimaryState.x, | ||
@@ -457,3 +434,3 @@ startY: startPrimaryState.y, | ||
event, | ||
rect: this._rect, | ||
rect: this._getRect(), | ||
startX: startSecondaryState.x, | ||
@@ -578,21 +555,53 @@ startY: startSecondaryState.y, | ||
export class PointerControl { | ||
private _cachedRect: DOMRect | null = null; | ||
private _getRect = () => { | ||
if (this._cachedRect === null) { | ||
this._updateRect(); | ||
} | ||
return this._cachedRect as DOMRect; | ||
}; | ||
// XXX: polling is used instead of MutationObserver | ||
// due to potential performance issues | ||
private _pollingInterval: number | null = null; | ||
private controllers: PointerControllerBase[]; | ||
constructor(dispatcher: UIEventDispatcher) { | ||
constructor(private _dispatcher: UIEventDispatcher) { | ||
this.controllers = [ | ||
new PointerEventForward(dispatcher), | ||
new ClickController(dispatcher), | ||
new DragController(dispatcher), | ||
new PanController(dispatcher), | ||
new PinchController(dispatcher), | ||
new PointerEventForward(_dispatcher, this._getRect), | ||
new ClickController(_dispatcher, this._getRect), | ||
new DragController(_dispatcher, this._getRect), | ||
new PanController(_dispatcher, this._getRect), | ||
new PinchController(_dispatcher, this._getRect), | ||
]; | ||
} | ||
private _startPolling() { | ||
const poll = () => { | ||
nextTick() | ||
.then(() => this._updateRect()) | ||
.catch(console.error); | ||
}; | ||
this._pollingInterval = window.setInterval(poll, POLL_INTERVAL); | ||
poll(); | ||
} | ||
protected _updateRect() { | ||
if (!this._dispatcher.host) return; | ||
this._cachedRect = this._dispatcher.host.getBoundingClientRect(); | ||
} | ||
dispose() { | ||
this.controllers.forEach(controller => controller.dispose()); | ||
if (this._pollingInterval !== null) { | ||
clearInterval(this._pollingInterval); | ||
this._pollingInterval = null; | ||
} | ||
} | ||
listen() { | ||
this._startPolling(); | ||
this.controllers.forEach(controller => controller.listen()); | ||
} | ||
} |
@@ -102,13 +102,10 @@ import { INLINE_ROOT_ATTR, type InlineRootElement } from '@blocksuite/inline'; | ||
const firstElement = this.getClosestBlock(range.startContainer); | ||
if (!firstElement) { | ||
return []; | ||
} | ||
if (!firstElement) return []; | ||
const firstElementIndex = result.indexOf(firstElement); | ||
if (firstElementIndex === -1) return []; | ||
if (mode === 'flat') { | ||
result = result.filter( | ||
el => | ||
firstElement.compareDocumentPosition(el) & | ||
Node.DOCUMENT_POSITION_FOLLOWING || el === firstElement | ||
); | ||
result = result.slice(firstElementIndex); | ||
} else if (mode === 'highest') { | ||
result = result.slice(firstElementIndex); | ||
let parent = result[0]; | ||
@@ -115,0 +112,0 @@ result = result.filter((node, index) => { |
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
1444800
20736
+ Added@blocksuite/global@0.0.0-canary-20241213001537(transitive)
+ Added@blocksuite/inline@0.0.0-canary-20241213001537(transitive)
+ Added@blocksuite/store@0.0.0-canary-20241213001537(transitive)
+ Added@blocksuite/sync@0.0.0-canary-20241213001537(transitive)
+ Addednanoid@5.1.2(transitive)
- Removed@blocksuite/global@0.0.0-canary-20241212001527(transitive)
- Removed@blocksuite/inline@0.0.0-canary-20241212001527(transitive)
- Removed@blocksuite/store@0.0.0-canary-20241212001527(transitive)
- Removed@blocksuite/sync@0.0.0-canary-20241212001527(transitive)
- Removednanoid@5.1.0(transitive)