@blocksuite/global
Advanced tools
Comparing version 0.4.0-20230210031655-264744e to 0.4.0-20230210193543-bf10cf9
@@ -27,2 +27,3 @@ export declare const TextIcon: import("lit-html").TemplateResult<1>; | ||
export declare const LinkIcon: import("lit-html").TemplateResult<1>; | ||
export declare const FontLinkIcon: import("lit-html").TemplateResult<1>; | ||
export declare const CopyIcon: import("lit-html").TemplateResult<1>; | ||
@@ -38,2 +39,15 @@ export declare const PasteIcon: import("lit-html").TemplateResult<1>; | ||
export declare const BlockHubIcon: import("lit-html").TemplateResult<1>; | ||
export declare const SearchIcon: import("lit-html").TemplateResult<1>; | ||
/** | ||
* ✅ | ||
*/ | ||
export declare const ConfirmIcon: import("lit-html").TemplateResult<1>; | ||
/** | ||
* 🖊️ | ||
*/ | ||
export declare const EditIcon: import("lit-html").TemplateResult<1>; | ||
export declare const UnlinkIcon: import("lit-html").TemplateResult<1>; | ||
export declare const CaptionIcon: import("lit-html").TemplateResult<1>; | ||
export declare const DownloadIcon: import("lit-html").TemplateResult<1>; | ||
export declare const LineWrapIcon: import("lit-html").TemplateResult<1>; | ||
export declare const RectIcon: import("lit-html").TemplateResult<1>; | ||
@@ -40,0 +54,0 @@ export declare const ArrowDownIcon: import("lit-html").TemplateResult<1>; |
@@ -6,4 +6,8 @@ import { Disposable } from './disposable.js'; | ||
private _disposables; | ||
static fromEvent<N extends keyof WindowEventMap>(element: Window, eventName: N, options?: boolean | AddEventListenerOptions): Signal<WindowEventMap[N]>; | ||
static fromEvent<N extends keyof HTMLElementEventMap>(element: HTMLElement, eventName: N, eventOptions?: boolean | AddEventListenerOptions): Signal<HTMLElementEventMap[N]>; | ||
/** | ||
* This is method will return a disposable that will remove the listener | ||
*/ | ||
static disposableListener<N extends keyof WindowEventMap>(element: Window, eventName: N, handler: (e: WindowEventMap[N]) => void, options?: boolean | AddEventListenerOptions): Disposable; | ||
static disposableListener<N extends keyof DocumentEventMap>(element: Document, eventName: N, handler: (e: DocumentEventMap[N]) => void, eventOptions?: boolean | AddEventListenerOptions): Disposable; | ||
static disposableListener<N extends keyof HTMLElementEventMap>(element: HTMLElement, eventName: N, handler: (e: HTMLElementEventMap[N]) => void, eventOptions?: boolean | AddEventListenerOptions): Disposable; | ||
filter(testFun: (v: T) => boolean): Signal<T>; | ||
@@ -10,0 +14,0 @@ on(callback: (v: T) => unknown): Disposable; |
@@ -24,14 +24,9 @@ import { flattenDisposable } from './disposable.js'; | ||
} | ||
static fromEvent(element, eventName, eventOptions) { | ||
const signal = new Signal(); | ||
const handler = (ev) => { | ||
signal.emit(ev); | ||
}; | ||
static disposableListener(element, eventName, handler, eventOptions) { | ||
element.addEventListener(eventName, handler, eventOptions); | ||
signal._disposables.push({ | ||
return { | ||
dispose: () => { | ||
element.removeEventListener(eventName, handler, eventOptions); | ||
}, | ||
}); | ||
return signal; | ||
}; | ||
} | ||
@@ -38,0 +33,0 @@ filter(testFun) { |
{ | ||
"name": "@blocksuite/global", | ||
"version": "0.4.0-20230210031655-264744e", | ||
"version": "0.4.0-20230210193543-bf10cf9", | ||
"types": "./index.d.ts", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -9,32 +9,36 @@ import { Disposable, flattenDisposable } from './disposable.js'; | ||
private _disposables: Disposable[] = []; | ||
static fromEvent<N extends keyof WindowEventMap>( | ||
/** | ||
* This is method will return a disposable that will remove the listener | ||
*/ | ||
static disposableListener<N extends keyof WindowEventMap>( | ||
element: Window, | ||
eventName: N, | ||
handler: (e: WindowEventMap[N]) => void, | ||
options?: boolean | AddEventListenerOptions | ||
): Signal<WindowEventMap[N]>; | ||
static fromEvent<N extends keyof HTMLElementEventMap>( | ||
element: HTMLElement, | ||
): Disposable; | ||
static disposableListener<N extends keyof DocumentEventMap>( | ||
element: Document, | ||
eventName: N, | ||
handler: (e: DocumentEventMap[N]) => void, | ||
eventOptions?: boolean | AddEventListenerOptions | ||
): Signal<HTMLElementEventMap[N]>; | ||
static fromEvent<N extends keyof HTMLElementEventMap>( | ||
element: HTMLElement | Window, | ||
): Disposable; | ||
static disposableListener<N extends keyof HTMLElementEventMap>( | ||
element: HTMLElement, | ||
eventName: N, | ||
handler: (e: HTMLElementEventMap[N]) => void, | ||
eventOptions?: boolean | AddEventListenerOptions | ||
): Signal<HTMLElementEventMap[N]> { | ||
const signal = new Signal<HTMLElementEventMap[N]>(); | ||
const handler = (ev: HTMLElementEventMap[N]) => { | ||
signal.emit(ev); | ||
}; | ||
(element as HTMLElement).addEventListener(eventName, handler, eventOptions); | ||
signal._disposables.push({ | ||
): Disposable; | ||
static disposableListener( | ||
element: HTMLElement | Window | Document, | ||
eventName: string, | ||
handler: (e: Event) => void, | ||
eventOptions?: boolean | AddEventListenerOptions | ||
): Disposable { | ||
element.addEventListener(eventName, handler, eventOptions); | ||
return { | ||
dispose: () => { | ||
(element as HTMLElement).removeEventListener( | ||
eventName, | ||
handler, | ||
eventOptions | ||
); | ||
element.removeEventListener(eventName, handler, eventOptions); | ||
}, | ||
}); | ||
return signal; | ||
}; | ||
} | ||
@@ -41,0 +45,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
329425
4159