diff --git a/packages/block-std/src/selection/manager.ts b/packages/block-std/src/selection/manager.ts index e25ca9616680..09d3d6f314e4 100644 --- a/packages/block-std/src/selection/manager.ts +++ b/packages/block-std/src/selection/manager.ts @@ -58,7 +58,7 @@ export class SelectionManager { return ctor.fromJSON(json); }; - getInstance( + create( type: T, ...args: ConstructorParameters ): BlockSuite.SelectionInstance[T] { diff --git a/packages/blocks/src/_common/components/rich-text/keymap/container.ts b/packages/blocks/src/_common/components/rich-text/keymap/container.ts index ded7317f4dec..49a77deb75a1 100644 --- a/packages/blocks/src/_common/components/rich-text/keymap/container.ts +++ b/packages/blocks/src/_common/components/rich-text/keymap/container.ts @@ -40,7 +40,7 @@ export const bindContainerHotkey = (blockElement: BlockElement) => { selection.update(selList => { return selList.map(sel => { if (PathFinder.equals(sel.path, blockElement.path)) { - return selection.getInstance('block', { path: blockElement.path }); + return selection.create('block', { path: blockElement.path }); } return sel; }); @@ -55,7 +55,7 @@ export const bindContainerHotkey = (blockElement: BlockElement) => { selection.update(selList => { return selList.map(sel => { if (PathFinder.equals(sel.path, blockElement.path)) { - return selection.getInstance('text', { + return selection.create('text', { from: { path: blockElement.path, index: start ? 0 : blockElement.model.text?.length ?? 0, @@ -102,7 +102,7 @@ export const bindContainerHotkey = (blockElement: BlockElement) => { if (!PathFinder.equals(sel.path, blockElement.path)) { return sel; } - return selection.getInstance('text', { + return selection.create('text', { from: { path: blockElement.path, index: 0, diff --git a/packages/blocks/src/_common/components/rich-text/markdown/utils.ts b/packages/blocks/src/_common/components/rich-text/markdown/utils.ts index b0d23b78a253..3cf9954acf4e 100644 --- a/packages/blocks/src/_common/components/rich-text/markdown/utils.ts +++ b/packages/blocks/src/_common/components/rich-text/markdown/utils.ts @@ -11,7 +11,7 @@ function addSpace(element: BlockElement, index: number) { element.model.text?.insert(' ', index); const currentText = element.selection.find('text'); element.selection.setGroup('note', [ - element.selection.getInstance('text', { + element.selection.create('text', { from: { path: element.path, index: (currentText?.from.index ?? 0) + 1, diff --git a/packages/blocks/src/_common/embed-block-helper/embed-block-element.ts b/packages/blocks/src/_common/embed-block-helper/embed-block-element.ts index b5f84f5f0db5..774536a00653 100644 --- a/packages/blocks/src/_common/embed-block-helper/embed-block-element.ts +++ b/packages/blocks/src/_common/embed-block-helper/embed-block-element.ts @@ -82,7 +82,7 @@ export class EmbedBlockElement< const isInSurface = blockComponent.isInSurface; if (!isInSurface) { this.host.selection.setGroup('note', [ - this.host.selection.getInstance('block', { + this.host.selection.create('block', { path: blockComponent.path, }), ]); diff --git a/packages/blocks/src/attachment-block/attachment-block.ts b/packages/blocks/src/attachment-block/attachment-block.ts index 7469ab98f0a0..43712478170e 100644 --- a/packages/blocks/src/attachment-block/attachment-block.ts +++ b/packages/blocks/src/attachment-block/attachment-block.ts @@ -144,7 +144,7 @@ export class AttachmentBlockComponent extends BlockElement // If start dragging from the attachment element // Set selection and take over dragStart event to start dragging this.host.selection.set([ - this.host.selection.getInstance('block', { + this.host.selection.create('block', { path: attachmentBlock.path, }), ]); @@ -180,7 +180,7 @@ export class AttachmentBlockComponent extends BlockElement private _focusAttachment = () => { const selectionManager = this.host.selection; - const blockSelection = selectionManager.getInstance('block', { + const blockSelection = selectionManager.create('block', { path: this.path, }); selectionManager.setGroup('note', [blockSelection]); diff --git a/packages/blocks/src/bookmark-block/bookmark-block.ts b/packages/blocks/src/bookmark-block/bookmark-block.ts index d7a04267ecd6..d789b90fd4d6 100644 --- a/packages/blocks/src/bookmark-block/bookmark-block.ts +++ b/packages/blocks/src/bookmark-block/bookmark-block.ts @@ -73,7 +73,7 @@ export class BookmarkBlockComponent extends BlockElement< const isInSurface = blockComponent.isInSurface; if (!isInSurface) { this.host.selection.setGroup('note', [ - this.host.selection.getInstance('block', { + this.host.selection.create('block', { path: blockComponent.path, }), ]); diff --git a/packages/blocks/src/bookmark-block/components/bookmark-card.ts b/packages/blocks/src/bookmark-block/components/bookmark-card.ts index 8dc06a1f1a90..9d917810338b 100644 --- a/packages/blocks/src/bookmark-block/components/bookmark-card.ts +++ b/packages/blocks/src/bookmark-block/components/bookmark-card.ts @@ -173,7 +173,7 @@ export class BookmarkCard extends WithDisposable(ShadowlessElement) { private _onCardClick() { const selectionManager = this.bookmark.host.selection; - const blockSelection = selectionManager.getInstance('block', { + const blockSelection = selectionManager.create('block', { path: this.bookmark.path, }); selectionManager.setGroup('note', [blockSelection]); diff --git a/packages/blocks/src/code-block/code-block.ts b/packages/blocks/src/code-block/code-block.ts index 29def510692e..4698a81a3517 100644 --- a/packages/blocks/src/code-block/code-block.ts +++ b/packages/blocks/src/code-block/code-block.ts @@ -324,7 +324,7 @@ export class CodeBlockComponent extends BlockElement { if (from.index === 0 && from.length === 0) { state.raw.preventDefault(); selectionManager.setGroup('note', [ - selectionManager.getInstance('block', { path: this.path }), + selectionManager.create('block', { path: this.path }), ]); return true; } diff --git a/packages/blocks/src/divider-block/divider-block.ts b/packages/blocks/src/divider-block/divider-block.ts index eea1190b7a12..f2d57f9e8da2 100644 --- a/packages/blocks/src/divider-block/divider-block.ts +++ b/packages/blocks/src/divider-block/divider-block.ts @@ -31,7 +31,7 @@ export class DividerBlockComponent extends BlockElement { this.handleEvent('click', () => { this.host.selection.set([ - this.host.selection.getInstance('block', { + this.host.selection.create('block', { path: this.path, }), ]); diff --git a/packages/blocks/src/image-block/doc-image-block.ts b/packages/blocks/src/image-block/doc-image-block.ts index 6afc0f5f5001..79ad115ca174 100644 --- a/packages/blocks/src/image-block/doc-image-block.ts +++ b/packages/blocks/src/image-block/doc-image-block.ts @@ -197,7 +197,7 @@ export class ImageBlockPageComponent extends BlockElement { .filter(sel => { return !['text', 'block', 'image'].includes(sel.type); }) - .concat(selection.getInstance('image', { path: this.path })); + .concat(selection.create('image', { path: this.path })); }); return true; }); @@ -238,7 +238,7 @@ export class ImageBlockPageComponent extends BlockElement { return selList .filter(sel => !sel.is('image')) .concat( - selection.getInstance('text', { + selection.create('text', { from: { path: this.parentPath.concat(blockId), index: 0, @@ -258,7 +258,7 @@ export class ImageBlockPageComponent extends BlockElement { const current = sel.is('image') && PathFinder.equals(sel.path, this.path); if (current) { - return selection.getInstance('block', { path: this.path }); + return selection.create('block', { path: this.path }); } return sel; }); diff --git a/packages/blocks/src/image-block/image-block.ts b/packages/blocks/src/image-block/image-block.ts index 3fa931f966b2..ee96c60d5cd3 100644 --- a/packages/blocks/src/image-block/image-block.ts +++ b/packages/blocks/src/image-block/image-block.ts @@ -107,7 +107,7 @@ export class ImageBlockComponent extends BlockElement { const selection = this.host.selection; selection.setGroup('note', [ - selection.getInstance('block', { path: this.path }), + selection.create('block', { path: this.path }), ]); } @@ -133,7 +133,7 @@ export class ImageBlockComponent extends BlockElement { const isInSurface = blockComponent.isInSurface; if (!isInSurface) { this.std.selection.setGroup('note', [ - this.std.selection.getInstance('block', { + this.std.selection.create('block', { path: blockComponent.path, }), ]); diff --git a/packages/blocks/src/list-block/list-block.ts b/packages/blocks/src/list-block/list-block.ts index 069026dfb044..863546152b8d 100644 --- a/packages/blocks/src/list-block/list-block.ts +++ b/packages/blocks/src/list-block/list-block.ts @@ -34,7 +34,7 @@ export class ListBlockComponent extends BlockElement { selection.update(selList => { return selList .filter(sel => !sel.is('text') && !sel.is('block')) - .concat(selection.getInstance('block', { path: this.path })); + .concat(selection.create('block', { path: this.path })); }); } diff --git a/packages/blocks/src/note-block/commands/select-block-text-by-side.ts b/packages/blocks/src/note-block/commands/select-block-text-by-side.ts index 818f12a999ca..3f77092d13d5 100644 --- a/packages/blocks/src/note-block/commands/select-block-text-by-side.ts +++ b/packages/blocks/src/note-block/commands/select-block-text-by-side.ts @@ -13,7 +13,7 @@ export const selectBlockTextBySide: Command< const { selection } = ctx.std; selection.setGroup('note', [ - selection.getInstance('text', { + selection.create('text', { from: { path, index: tail ? focusBlock.model.text?.length ?? 0 : 0, diff --git a/packages/blocks/src/note-block/commands/select-block.ts b/packages/blocks/src/note-block/commands/select-block.ts index 7dd829c2b6ab..66c5ebdb5700 100644 --- a/packages/blocks/src/note-block/commands/select-block.ts +++ b/packages/blocks/src/note-block/commands/select-block.ts @@ -9,7 +9,7 @@ export const selectBlock: Command<'focusBlock'> = (ctx, next) => { const { selection } = std; selection.setGroup('note', [ - selection.getInstance('block', { path: focusBlock.path }), + selection.create('block', { path: focusBlock.path }), ]); return next(); diff --git a/packages/blocks/src/note-block/commands/select-blocks-between.ts b/packages/blocks/src/note-block/commands/select-blocks-between.ts index d6d417953fb6..73046ba446d1 100644 --- a/packages/blocks/src/note-block/commands/select-blocks-between.ts +++ b/packages/blocks/src/note-block/commands/select-blocks-between.ts @@ -15,7 +15,7 @@ export const selectBlocksBetween: Command< // In same block if (PathFinder.equals(anchorBlock.path, focusBlock.path)) { const path = focusBlock.path; - selection.setGroup('note', [selection.getInstance('block', { path })]); + selection.setGroup('note', [selection.create('block', { path })]); return next(); } @@ -23,13 +23,9 @@ export const selectBlocksBetween: Command< const selections = [...selection.value]; if (selections.every(sel => !PathFinder.equals(sel.path, focusBlock.path))) { if (tail) { - selections.push( - selection.getInstance('block', { path: focusBlock.path }) - ); + selections.push(selection.create('block', { path: focusBlock.path })); } else { - selections.unshift( - selection.getInstance('block', { path: focusBlock.path }) - ); + selections.unshift(selection.create('block', { path: focusBlock.path })); } } diff --git a/packages/blocks/src/note-block/keymap-controller.ts b/packages/blocks/src/note-block/keymap-controller.ts index 42a0d2001fdd..79bdbbc2bbf2 100644 --- a/packages/blocks/src/note-block/keymap-controller.ts +++ b/packages/blocks/src/note-block/keymap-controller.ts @@ -581,7 +581,7 @@ export class KeymapController implements ReactiveController { index + 1 ); - const sel = selection.getInstance('text', { + const sel = selection.create('text', { from: { path: element.parentPath.concat(blockId), index: 0, @@ -619,7 +619,7 @@ export class KeymapController implements ReactiveController { ) ) { blocks.push( - selection.getInstance('block', { + selection.create('block', { path: nodeView.path, }) ); @@ -689,7 +689,7 @@ export class KeymapController implements ReactiveController { ); assertExists(codeElement); this._std.selection.setGroup('note', [ - this._std.selection.getInstance('text', { + this._std.selection.create('text', { from: { path: codeElement.path, index: 0, diff --git a/packages/blocks/src/page-block/clipboard/middlewares/paste.ts b/packages/blocks/src/page-block/clipboard/middlewares/paste.ts index fccde4d4d3f0..afdb6cb30eb2 100644 --- a/packages/blocks/src/page-block/clipboard/middlewares/paste.ts +++ b/packages/blocks/src/page-block/clipboard/middlewares/paste.ts @@ -244,19 +244,19 @@ class PasteTr { assertExists(target); if (!lastModel.text) { if (matchFlavours(lastModel, ['affine:image'])) { - const selection = this.std.selection.getInstance('image', { + const selection = this.std.selection.create('image', { path: target.path, }); this.std.selection.setGroup('note', [selection]); return; } - const selection = this.std.selection.getInstance('block', { + const selection = this.std.selection.create('block', { path: target.path, }); this.std.selection.setGroup('note', [selection]); return; } - const selection = this.std.selection.getInstance('text', { + const selection = this.std.selection.create('text', { from: { path: target.path, index: diff --git a/packages/blocks/src/page-block/commands/text-crud/delete-text.ts b/packages/blocks/src/page-block/commands/text-crud/delete-text.ts index ebada317e4e3..365d6fea875f 100644 --- a/packages/blocks/src/page-block/commands/text-crud/delete-text.ts +++ b/packages/blocks/src/page-block/commands/text-crud/delete-text.ts @@ -51,7 +51,7 @@ export const deleteTextCommand: Command< if (!to) { fromText.delete(from.index, from.length); ctx.std.selection.setGroup('note', [ - ctx.std.selection.getInstance('text', { + ctx.std.selection.create('text', { from: { path: from.path, index: from.index, @@ -81,7 +81,7 @@ export const deleteTextCommand: Command< }); ctx.std.selection.setGroup('note', [ - ctx.std.selection.getInstance('text', { + ctx.std.selection.create('text', { from: { path: to.path, index: to.index, diff --git a/packages/blocks/src/page-block/doc/doc-page-block.ts b/packages/blocks/src/page-block/doc/doc-page-block.ts index 47b7b88e21bd..e824df55bec0 100644 --- a/packages/blocks/src/page-block/doc/doc-page-block.ts +++ b/packages/blocks/src/page-block/doc/doc-page-block.ts @@ -267,7 +267,7 @@ export class DocPageBlockComponent extends BlockElement< .filter(sel => !sel.is('text') && !sel.is('block')) .concat([ sel.is('text') - ? selection.getInstance('text', { + ? selection.create('text', { from: { path: lastNoteChild.path, index: lastNoteChild.model.text?.length ?? 0, @@ -275,7 +275,7 @@ export class DocPageBlockComponent extends BlockElement< }, to: null, }) - : selection.getInstance('block', { + : selection.create('block', { path: lastNoteChild.path, }), ]) @@ -319,7 +319,7 @@ export class DocPageBlockComponent extends BlockElement< .filter(sel => !sel.is('text') && !sel.is('block')) .concat([ sel.is('text') - ? selection.getInstance('text', { + ? selection.create('text', { from: { path: firstNoteChild.path, index: 0, @@ -327,7 +327,7 @@ export class DocPageBlockComponent extends BlockElement< }, to: null, }) - : selection.getInstance('block', { + : selection.create('block', { path: firstNoteChild.path, }), ]) @@ -400,7 +400,7 @@ export class DocPageBlockComponent extends BlockElement< requestAnimationFrame(() => { this.host.selection.setGroup('note', [ - this.host.selection.getInstance('text', { + this.host.selection.create('text', { from: { path: [this.model.id, noteId, paragraphId], index, diff --git a/packages/blocks/src/page-block/edgeless/services/selection-manager.ts b/packages/blocks/src/page-block/edgeless/services/selection-manager.ts index 460d6140ed6c..158164688be2 100644 --- a/packages/blocks/src/page-block/edgeless/services/selection-manager.ts +++ b/packages/blocks/src/page-block/edgeless/services/selection-manager.ts @@ -255,7 +255,7 @@ export class EdgelessSelectionManager { if (elements.length > 0) { instances.push( - this._selection.getInstance( + this._selection.create( 'surface', this.container.surface.path, elements, @@ -267,7 +267,7 @@ export class EdgelessSelectionManager { if (blocks.length > 0) { instances = instances.concat( blocks.map(blockId => - this._selection.getInstance( + this._selection.create( 'surface', [this.container.page.root!.id, blockId], [blockId], @@ -303,7 +303,7 @@ export class EdgelessSelectionManager { } setCursor(cursor: CursorSelection | CursorSelectionState) { - const instance = this._selection.getInstance('cursor', cursor.x, cursor.y); + const instance = this._selection.create('cursor', cursor.x, cursor.y); this._selection.setGroup('edgeless', [...this.selections, instance]); } diff --git a/packages/blocks/src/page-block/keyboard/keyboard-manager.ts b/packages/blocks/src/page-block/keyboard/keyboard-manager.ts index 0da373f42c28..2bc01b7c364a 100644 --- a/packages/blocks/src/page-block/keyboard/keyboard-manager.ts +++ b/packages/blocks/src/page-block/keyboard/keyboard-manager.ts @@ -71,7 +71,7 @@ export class PageKeyboardManager { if (selection) { this._selection.set([ - this._selection.getInstance('text', { + this._selection.create('text', { from: { index: 0, length: 0, diff --git a/packages/blocks/src/page-block/utils/operations/element/block-level.ts b/packages/blocks/src/page-block/utils/operations/element/block-level.ts index 4634a7d5906b..bf3531a777d5 100644 --- a/packages/blocks/src/page-block/utils/operations/element/block-level.ts +++ b/packages/blocks/src/page-block/utils/operations/element/block-level.ts @@ -94,7 +94,7 @@ export function updateBlockElementType( const blockSelections = selectionManager.filter('block'); if (textSelection) { - const newTextSelection = selectionManager.getInstance('text', { + const newTextSelection = selectionManager.create('text', { from: { path: textSelection.from.path.slice(0, -1).concat(firstNewModel.id), index: textSelection.from.index, @@ -120,7 +120,7 @@ export function updateBlockElementType( if (blockSelections.length !== 0) { requestAnimationFrame(() => { const selections = newModels.map(model => { - return selectionManager.getInstance('block', { + return selectionManager.create('block', { path: blockSelections[0].path.slice(0, -1).concat(model.id), }); }); diff --git a/packages/blocks/src/page-block/widgets/doc-dragging-area/doc-dragging-area.ts b/packages/blocks/src/page-block/widgets/doc-dragging-area/doc-dragging-area.ts index 9515c5d9039b..64883af9b733 100644 --- a/packages/blocks/src/page-block/widgets/doc-dragging-area/doc-dragging-area.ts +++ b/packages/blocks/src/page-block/widgets/doc-dragging-area/doc-dragging-area.ts @@ -105,7 +105,7 @@ export class AffineDocDraggingAreaWidget extends WidgetElement { - return this.host.selection.getInstance('block', { + return this.host.selection.create('block', { path: blockPath, }); }); diff --git a/packages/blocks/src/page-block/widgets/drag-handle/drag-handle.ts b/packages/blocks/src/page-block/widgets/drag-handle/drag-handle.ts index 3c63c21e467b..01d821e621a5 100644 --- a/packages/blocks/src/page-block/widgets/drag-handle/drag-handle.ts +++ b/packages/blocks/src/page-block/widgets/drag-handle/drag-handle.ts @@ -779,7 +779,7 @@ export class AffineDragHandleWidget extends WidgetElement< ) => { const { selection } = this.host; const selections = blockElements.map(blockElement => - selection.getInstance('block', { + selection.create('block', { path: blockElement.path, }) ); @@ -788,7 +788,7 @@ export class AffineDragHandleWidget extends WidgetElement< // We need to remain surface selection and set editing as true if (isInsideEdgelessEditor(this.host)) { const surfaceElementId = noteId ? noteId : getNoteId(blockElements[0]); - const surfaceSelection = selection.getInstance( + const surfaceSelection = selection.create( 'surface', blockElements[0]!.path, [surfaceElementId], diff --git a/packages/blocks/src/surface-ref-block/surface-ref-block.ts b/packages/blocks/src/surface-ref-block/surface-ref-block.ts index 0526ab4e86f8..60fd913c0fd2 100644 --- a/packages/blocks/src/surface-ref-block/surface-ref-block.ts +++ b/packages/blocks/src/surface-ref-block/surface-ref-block.ts @@ -323,7 +323,7 @@ export class SurfaceRefBlockComponent extends BlockElement return selList .filter(sel => !sel.is('block')) .concat( - selection.getInstance('text', { + selection.create('text', { from: { path, index: 0, @@ -656,7 +656,7 @@ export class SurfaceRefBlockComponent extends BlockElement private _focusBlock() { this.selection.update(() => { - return [this.selection.getInstance('block', { path: this.path })]; + return [this.selection.create('block', { path: this.path })]; }); } diff --git a/packages/docs/selection-api.md b/packages/docs/selection-api.md index 9b4342281284..0acc9eb88205 100644 --- a/packages/docs/selection-api.md +++ b/packages/docs/selection-api.md @@ -93,12 +93,12 @@ selection.update(current => yourLogic(current)); The `set` method will override all current selections. -You can create a new selection by using `getInstance` method. +You can create a new selection by using `selection.create` method. ```ts const { selection } = std; -const blockSelection = selection.getInstance('block', { path: [0, 1, 2] }); +const blockSelection = selection.create('block', { path: [0, 1, 2] }); ``` What if you want to pick some selections by `type` from the current selection model? We provide `pick` and `find` methods to help you. @@ -214,7 +214,7 @@ std.selection.register(MySelection); Now you can use the `MySelection` in the selection model. ```ts -const mySelection = std.selection.getInstance('mySelection', { +const mySelection = std.selection.create('mySelection', { path: [0, 1, 2], }); ``` diff --git a/packages/lit/src/utils/inline-range-provider.ts b/packages/lit/src/utils/inline-range-provider.ts index 76e5d551df33..e83391a6b3a9 100644 --- a/packages/lit/src/utils/inline-range-provider.ts +++ b/packages/lit/src/utils/inline-range-provider.ts @@ -74,7 +74,7 @@ export const getInlineRangeProvider: ( if (!inlineRange) { selectionManager.clear(['text']); } else { - const textSelection = selectionManager.getInstance('text', { + const textSelection = selectionManager.create('text', { from: { path: element.path, index: inlineRange.index, diff --git a/packages/lit/src/utils/range-manager.ts b/packages/lit/src/utils/range-manager.ts index 0dd33ced2cd7..02e72933ffe0 100644 --- a/packages/lit/src/utils/range-manager.ts +++ b/packages/lit/src/utils/range-manager.ts @@ -99,7 +99,7 @@ export class RangeManager { return null; } - const selection = selectionManager.getInstance('text', { + const selection = selectionManager.create('text', { from, to, isReverse: isRangeReversed, diff --git a/packages/lit/src/utils/range-synchronizer.ts b/packages/lit/src/utils/range-synchronizer.ts index 56bf68cbeefa..fe506aa208e2 100644 --- a/packages/lit/src/utils/range-synchronizer.ts +++ b/packages/lit/src/utils/range-synchronizer.ts @@ -188,7 +188,7 @@ export class RangeSynchronizer { }); }); - const newSelection = this._selectionManager.getInstance('text', { + const newSelection = this._selectionManager.create('text', { from: { path: from.path, index: from.index + (event.data?.length ?? 0), diff --git a/packages/presets/src/fragments/copilot-panel/copilot-panel.ts b/packages/presets/src/fragments/copilot-panel/copilot-panel.ts index 39a961bbacf2..f12329b7a5b2 100644 --- a/packages/presets/src/fragments/copilot-panel/copilot-panel.ts +++ b/packages/presets/src/fragments/copilot-panel/copilot-panel.ts @@ -137,7 +137,7 @@ export class CopilotPanel extends WithDisposable(ShadowlessElement) { const parentPath = firstBlock.parentPath; const selections = models .map(model => [...parentPath, model.id]) - .map(path => this.root.selection.getInstance('block', { path })); + .map(path => this.root.selection.create('block', { path })); this.root.selection.setGroup('note', selections); }, 0); } @@ -167,7 +167,7 @@ export class CopilotPanel extends WithDisposable(ShadowlessElement) { const parentPath = lastBlock.parentPath; const selections = models .map(model => [...parentPath, model.id]) - .map(path => this.root.selection.getInstance('block', { path })); + .map(path => this.root.selection.create('block', { path })); this.root.selection.setGroup('note', selections); }, 0); }