Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9dd6f8e
feat(eventbus): create CopyUIEvent entity
ilyamore88 Apr 17, 2026
b53c482
feat(ui-blocks): subscribe for copy event and pass native event objec…
ilyamore88 Apr 17, 2026
0be2ca4
feat(core): init clipboard plugin
ilyamore88 Apr 17, 2026
10c1c22
feat(core): use ClipboardPlugin
ilyamore88 Apr 17, 2026
ad5b441
Merge branch 'main' of github.com:editor-js/document-model into feat/…
ilyamore88 Apr 17, 2026
e1359c8
Merge branch 'main' of github.com:editor-js/document-model into feat/…
ilyamore88 Apr 23, 2026
500178d
Merge branch 'main' of github.com:editor-js/document-model into feat/…
ilyamore88 May 24, 2026
bc3657c
feat: implement clipboard plugin
ilyamore88 May 24, 2026
00d10ac
fix(clipboard-plugin): prevent native event only after checking selec…
ilyamore88 Jun 9, 2026
d426ae4
chore: fix stryker exception description
ilyamore88 Jun 9, 2026
31a5758
Merge branch 'main' of github.com:editor-js/document-model into feat/…
ilyamore88 Jun 9, 2026
9f44277
feat(clipboard-plugin): update docs, add destroy method implementatio…
ilyamore88 Jul 7, 2026
f63d6dd
Merge branch 'main' of github.com:editor-js/document-model into feat/…
ilyamore88 Jul 7, 2026
55b62c8
chore: use currentSelection in selection manager
ilyamore88 Jul 7, 2026
2681e5b
feat(clipboard-plugin): describe clipboard object
ilyamore88 Jul 8, 2026
2b288dc
refactor(selection-api): return empty array instead of null
ilyamore88 Jul 8, 2026
f2a6067
chore: add docs
ilyamore88 Jul 8, 2026
264f721
chore: update docs
ilyamore88 Jul 8, 2026
f4601a6
fix: make removeEventListener js-private
ilyamore88 Jul 8, 2026
ec4aca5
chore(clipboard-plugin): add unit-tests
ilyamore88 Jul 9, 2026
c144d28
Merge branch 'main' of github.com:editor-js/document-model into feat/…
ilyamore88 Jul 15, 2026
b7b617f
fix(clipboard-plugin-tests): proper mock of esm module with mockModule
ilyamore88 Jul 18, 2026
40a9b2b
refactor(clipboard-plugin): create separate package for plugin
ilyamore88 Jul 19, 2026
9de3ad6
ci: add permissions to ci of clipboard plugin
ilyamore88 Jul 19, 2026
158abf6
fix(clipboard-plugin): don't prevent native event if clipboardData is…
ilyamore88 Jul 19, 2026
c163812
chore(index): remove unused isCompositeIndex from scope
ilyamore88 Jul 19, 2026
2cf7dfe
chore: add more unit-tests to improve mutation testing score
ilyamore88 Jul 19, 2026
a4365c3
chore: address review commits
ilyamore88 Jul 20, 2026
4dff6fa
Merge branch 'main' of github.com:editor-js/document-model into feat/…
ilyamore88 Jul 20, 2026
9d0f896
chore: add spec for clipboard plugin
ilyamore88 Jul 20, 2026
18963e9
chore: address review comments
ilyamore88 Jul 20, 2026
0498fab
Initial plan
Copilot Jul 21, 2026
c9591ce
fix(clipboard-plugin): resolve clipboard meta version from core runtime
Copilot Jul 21, 2026
ab2f69d
Merge origin/main into copilot/featclipboard-plugin
Copilot Jul 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion packages/plugins/clipboard-plugin/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ describe('ClipboardPlugin', () => {
new ClipboardPlugin(pluginParamsMock);

const { setData } = dispatchCopyEvent();

expect(setData).toHaveBeenCalledWith('text/plain', 'hello\nworld');
});

Expand All @@ -229,6 +228,28 @@ describe('ClipboardPlugin', () => {
);
});

it('should use core version from api when available', () => {
const api = pluginParamsMock.api as unknown as { version: string };

api.version = '3.2.1';

new ClipboardPlugin(pluginParamsMock);

const { setData } = dispatchCopyEvent();

expect(setData).toHaveBeenCalledWith(
'application/x-editor-js',
JSON.stringify({
blocks: [
{ id: 'b1',
type: 'paragraph' },
{ id: 'b2',
type: 'header' },
],
meta: { version: '3.2.1' },
})
);
});
it('should not prevent native event when clipboardData is unavailable', () => {
new ClipboardPlugin(pluginParamsMock);

Expand Down
38 changes: 36 additions & 2 deletions packages/plugins/clipboard-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ interface Meta {
version: string;
}

/**
* Source that can provide EditorJS core version.
*/
interface CoreVersionSource {
/**
* EditorJS core version.
*/
version?: string;
}

/**
* Custom MIME type used to store EditorJS clipboard data alongside plain text and HTML
*/
Expand All @@ -40,8 +50,11 @@ const EDITOR_JS_CLIPBOARD_MIME_TYPE = 'application/x-editor-js';
export class ClipboardPlugin implements EditorjsPlugin {
public static readonly type = PluginType.Plugin;

static readonly #fallbackCoreVersion = '3.0.0';

readonly #api: EditorAPI;
readonly #eventBus: EventBus;
readonly #coreVersion: string;
#copyEventListener: ((e: CopyUIEvent) => void) | undefined;

/**
Expand All @@ -55,6 +68,7 @@ export class ClipboardPlugin implements EditorjsPlugin {

this.#api = api;
this.#eventBus = eventBus;
this.#coreVersion = this.#getCoreVersion(params);

this.#copyEventListener = (e: CopyUIEvent) => {
const { nativeEvent } = e.detail;
Expand Down Expand Up @@ -146,9 +160,29 @@ export class ClipboardPlugin implements EditorjsPlugin {
return {
blocks,
meta: {
// @todo get version info from Core
version: '3.0.0',
version: this.#coreVersion,
},
};
}

/**
* Resolves EditorJS core version from runtime API/config when available.
* @param params - plugin initialization params
* @returns resolved core version
*/
#getCoreVersion(params: EditorjsPluginParams): string {
const apiVersion = (params.api as CoreVersionSource).version;

if (apiVersion !== undefined && apiVersion.trim() !== '') {
return apiVersion;
}

const configVersion = (params.config as CoreVersionSource).version;

if (configVersion !== undefined && configVersion.trim() !== '') {
return configVersion;
}

return ClipboardPlugin.#fallbackCoreVersion;
}
}