@blocksuite/inline
Advanced tools
Comparing version 0.11.0-nightly-202312211032-84fe6bb to 0.11.0-nightly-202312212326-e2b48df
@@ -24,2 +24,3 @@ import { DisposableGroup, Slot } from '@blocksuite/global/utils'; | ||
private _rootElement; | ||
private _eventSource; | ||
private _isReadonly; | ||
@@ -49,2 +50,3 @@ private _eventService; | ||
get rootElement(): InlineRootElement<TextAttributes>; | ||
get eventSource(): HTMLElement; | ||
get eventService(): EventService<TextAttributes>; | ||
@@ -99,3 +101,3 @@ get rangeService(): RangeService<TextAttributes>; | ||
}); | ||
mount(rootElement: HTMLElement): void; | ||
mount(rootElement: HTMLElement, eventSource?: HTMLElement): void; | ||
unmount(): void; | ||
@@ -102,0 +104,0 @@ requestUpdate(syncInlineRange?: boolean): void; |
@@ -29,2 +29,6 @@ import { assertExists, DisposableGroup, Slot } from '@blocksuite/global/utils'; | ||
} | ||
get eventSource() { | ||
assertExists(this._eventSource); | ||
return this._eventSource; | ||
} | ||
get eventService() { | ||
@@ -56,2 +60,3 @@ return this._eventService; | ||
this._rootElement = null; | ||
this._eventSource = null; | ||
this._isReadonly = false; | ||
@@ -134,8 +139,10 @@ this._eventService = new EventService(this); | ||
} | ||
mount(rootElement) { | ||
mount(rootElement, eventSource = rootElement) { | ||
const inlineRoot = rootElement; | ||
inlineRoot.inlineEditor = this; | ||
this._rootElement = inlineRoot; | ||
this._eventSource = eventSource; | ||
render(nothing, this._rootElement); | ||
this._rootElement.contentEditable = 'true'; | ||
this._eventSource.contentEditable = 'true'; | ||
this._rootElement.dataset.vRoot = 'true'; | ||
@@ -142,0 +149,0 @@ this._bindYTextObserver(); |
@@ -13,2 +13,3 @@ import { assertExists } from '@blocksuite/global/utils'; | ||
this.mount = () => { | ||
const eventSource = this.editor.eventSource; | ||
const rootElement = this.editor.rootElement; | ||
@@ -18,8 +19,8 @@ if (!this.inlineRangeProvider) { | ||
} | ||
this.editor.disposables.addFromEvent(rootElement, 'beforeinput', this._onBeforeInput); | ||
this.editor.disposables.addFromEvent(rootElement, 'compositionstart', this._onCompositionStart); | ||
this.editor.disposables.addFromEvent(rootElement, 'compositionend', (event) => { | ||
this.editor.disposables.addFromEvent(eventSource, 'beforeinput', this._onBeforeInput); | ||
this.editor.disposables.addFromEvent(eventSource, 'compositionstart', this._onCompositionStart); | ||
this.editor.disposables.addFromEvent(eventSource, 'compositionend', (event) => { | ||
this._onCompositionEnd(event).catch(console.error); | ||
}); | ||
this.editor.disposables.addFromEvent(rootElement, 'keydown', this._onKeyDown); | ||
this.editor.disposables.addFromEvent(eventSource, 'keydown', this._onKeyDown); | ||
this.editor.disposables.addFromEvent(rootElement, 'click', this._onClick); | ||
@@ -26,0 +27,0 @@ }; |
{ | ||
"name": "@blocksuite/inline", | ||
"version": "0.11.0-nightly-202312211032-84fe6bb", | ||
"version": "0.11.0-nightly-202312212326-e2b48df", | ||
"description": "A micro editor.", | ||
@@ -27,3 +27,3 @@ "type": "module", | ||
"zod": "^3.22.4", | ||
"@blocksuite/global": "0.11.0-nightly-202312211032-84fe6bb" | ||
"@blocksuite/global": "0.11.0-nightly-202312212326-e2b48df" | ||
}, | ||
@@ -30,0 +30,0 @@ "scripts": { |
@@ -52,2 +52,3 @@ import { assertExists, DisposableGroup, Slot } from '@blocksuite/global/utils'; | ||
private _rootElement: InlineRootElement<TextAttributes> | null = null; | ||
private _eventSource: HTMLElement | null = null; | ||
private _isReadonly = false; | ||
@@ -108,2 +109,7 @@ | ||
get eventSource() { | ||
assertExists(this._eventSource); | ||
return this._eventSource; | ||
} | ||
get eventService() { | ||
@@ -213,8 +219,10 @@ return this._eventService; | ||
mount(rootElement: HTMLElement) { | ||
mount(rootElement: HTMLElement, eventSource: HTMLElement = rootElement) { | ||
const inlineRoot = rootElement as InlineRootElement<TextAttributes>; | ||
inlineRoot.inlineEditor = this; | ||
this._rootElement = inlineRoot; | ||
this._eventSource = eventSource; | ||
render(nothing, this._rootElement); | ||
this._rootElement.contentEditable = 'true'; | ||
this._eventSource.contentEditable = 'true'; | ||
this._rootElement.dataset.vRoot = 'true'; | ||
@@ -221,0 +229,0 @@ |
@@ -28,2 +28,3 @@ import { assertExists } from '@blocksuite/global/utils'; | ||
mount = () => { | ||
const eventSource = this.editor.eventSource; | ||
const rootElement = this.editor.rootElement; | ||
@@ -40,3 +41,3 @@ | ||
this.editor.disposables.addFromEvent( | ||
rootElement, | ||
eventSource, | ||
'beforeinput', | ||
@@ -46,3 +47,3 @@ this._onBeforeInput | ||
this.editor.disposables.addFromEvent( | ||
rootElement, | ||
eventSource, | ||
'compositionstart', | ||
@@ -52,3 +53,3 @@ this._onCompositionStart | ||
this.editor.disposables.addFromEvent( | ||
rootElement, | ||
eventSource, | ||
'compositionend', | ||
@@ -60,3 +61,3 @@ (event: CompositionEvent) => { | ||
this.editor.disposables.addFromEvent( | ||
rootElement, | ||
eventSource, | ||
'keydown', | ||
@@ -63,0 +64,0 @@ this._onKeyDown |
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
545647
8692
+ Added@blocksuite/global@0.11.0-nightly-202312212326-e2b48df(transitive)
- Removed@blocksuite/global@0.11.0-nightly-202312211032-84fe6bb(transitive)
Updated@blocksuite/global@0.11.0-nightly-202312212326-e2b48df