mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
* chore: rename module-local variables to not conflict * feat: make ICopyable generic and update clipboard APIs * chore: switch over more things to use generic ICopyables * chore: fix shortcut items using copy paste * chore: add test for interface between clipboard and pasters * chore: export isCopyable * chore: format * chore: fixup PR comments * chore: add deprecation tags
32 lines
849 B
TypeScript
32 lines
849 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {ICopyable, ICopyData} from '../interfaces/i_copyable.js';
|
|
import type {IPaster} from '../interfaces/i_paster.js';
|
|
import * as registry from '../registry.js';
|
|
|
|
/**
|
|
* Registers the given paster so that it cna be used for pasting.
|
|
*
|
|
* @param type The type of the paster to register, e.g. 'block', 'comment', etc.
|
|
* @param paster The paster to register.
|
|
*/
|
|
export function register<U extends ICopyData, T extends ICopyable<U>>(
|
|
type: string,
|
|
paster: IPaster<U, T>,
|
|
) {
|
|
registry.register(registry.Type.PASTER, type, paster);
|
|
}
|
|
|
|
/**
|
|
* Unregisters the paster associated with the given type.
|
|
*
|
|
* @param type The type of the paster to unregister.
|
|
*/
|
|
export function unregister(type: string) {
|
|
registry.unregister(registry.Type.PASTER, type);
|
|
}
|