diff --git a/Makefile b/Makefile index 9cc04f8f..5ea38c49 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ source_dir=$(build_dir)/source sign_dir=$(build_dir)/sign package_name=$(app_name) cert_dir=$(HOME)/.nextcloud/certificates -version+=0.1.4-beta.1 +version+=0.2.0-beta.1 all: build-front appstore diff --git a/appinfo/info.xml b/appinfo/info.xml index 7e6b6944..7db5d2e2 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -10,7 +10,7 @@ Mind Map A mind map editor - 0.1.4-beta.1 + 0.2.0-beta.1 AGPL-3.0-or-later Jingtao Yan, Nextcloud community Files_MindMap @@ -23,6 +23,6 @@ https://raw.githubusercontent.com/nextcloud/files_mindmap/master/screenshots/2.png https://raw.githubusercontent.com/nextcloud/files_mindmap/master/screenshots/3.png - + diff --git a/package-lock.json b/package-lock.json index a61e4afe..0b70947a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,14 @@ { "name": "files_mindmap", - "version": "0.1.4-beta.1", + "version": "0.2.0-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "files_mindmap", - "version": "0.1.4-beta.1", + "version": "0.2.0-beta.1", "license": "AGPL-3.0-or-later", "dependencies": { - "@mdi/svg": "^7.3.67", "@nextcloud/auth": "^2.5.0", "@nextcloud/axios": "^2.4.0", "@nextcloud/dialogs": "^7.5.0", diff --git a/package.json b/package.json index f4a9fd25..c235c96e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "files_mindmap", - "version": "0.1.4-beta.1", + "version": "0.2.0-beta.1", "description": "A Mind map editor", "author": "Jingtao Yan, Nextcloud community", "license": "AGPL-3.0-or-later", @@ -29,7 +29,6 @@ "test:watch": "vitest" }, "dependencies": { - "@mdi/svg": "^7.3.67", "@nextcloud/auth": "^2.5.0", "@nextcloud/axios": "^2.4.0", "@nextcloud/dialogs": "^7.5.0", diff --git a/src/__tests__/legacyFileAction.spec.js b/src/__tests__/legacyFileAction.spec.js deleted file mode 100644 index f50d8003..00000000 --- a/src/__tests__/legacyFileAction.spec.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { afterEach, describe, expect, it, vi } from 'vitest' -import { registerLegacyFileAction } from '../legacyFileAction.js' - -vi.mock('@nextcloud/viewer', () => ({ getViewer: vi.fn() })) - -describe('registerLegacyFileAction', () => { - afterEach(() => { - delete window._nc_fileactions - }) - - it('registers one hidden default action in the files 3 registry', () => { - registerLegacyFileAction() - registerLegacyFileAction() - - expect(window._nc_fileactions).toHaveLength(1) - expect(window._nc_fileactions[0]).toMatchObject({ id: 'file_mindmap', default: 'hidden' }) - }) - - it('keeps actions registered before it', () => { - window._nc_fileactions = [{ id: 'other' }] - registerLegacyFileAction() - - expect(window._nc_fileactions.map((action) => action.id)).toEqual(['other', 'file_mindmap']) - }) - - it('is enabled for a single readable mind map only', () => { - registerLegacyFileAction() - const { enabled } = window._nc_fileactions[0] - const km = { mime: 'application/km', permissions: 1 } - - expect(enabled([km])).toBe(true) - expect(enabled([{ ...km, permissions: 0 }])).toBe(false) - expect(enabled([{ ...km, mime: 'text/plain' }])).toBe(false) - expect(enabled([km, km])).toBe(false) - }) -}) diff --git a/src/legacyFileAction.js b/src/legacyFileAction.js deleted file mode 100644 index cc3fe218..00000000 --- a/src/legacyFileAction.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import SvgPencil from '@mdi/svg/svg/pencil.svg?raw' -import { translate as t } from '@nextcloud/l10n' -import { getViewer } from '@nextcloud/viewer' -import { HANDLER_ID, MIMES } from './constants.js' -import logger from './logger.js' - -const ACTION_ID = 'file_mindmap' -const PERMISSION_READ = 1 - -/** - * Register the hidden default action that opens mind maps from the Files app of Nextcloud 32. - * - * Files 32 looks up the default action once when it opens a file from the URL, as on a public - * file share, so this has to run synchronously in the init script. The action is a plain object - * in the `window._nc_fileactions` registry of `@nextcloud/files` 3, whose `FileAction` only - * wraps these properties, so that library does not load on every page. - */ -export function registerLegacyFileAction() { - window._nc_fileactions ??= [] - if (window._nc_fileactions.some((action) => action.id === ACTION_ID)) { - return - } - - window._nc_fileactions.push({ - id: ACTION_ID, - displayName: () => t('files_mindmap', 'Edit'), - iconSvgInline: () => SvgPencil, - enabled: (nodes) => nodes.length === 1 && MIMES.includes(nodes[0].mime) && (nodes[0].permissions & PERMISSION_READ) !== 0, - async exec(node) { - try { - await getViewer().open([node], node, {}, HANDLER_ID) - return true - } catch (error) { - logger.error('Could not open the mind map', { error }) - const { showError } = await import('@nextcloud/dialogs') - showError(error.message) - return false - } - }, - default: 'hidden', - }) -} diff --git a/src/mindmapviewer.js b/src/mindmapviewer.js index b999c82a..872669e7 100644 --- a/src/mindmapviewer.js +++ b/src/mindmapviewer.js @@ -7,11 +7,8 @@ import { translate as t } from '@nextcloud/l10n' import { registerHandler } from '@nextcloud/viewer' import { HANDLER_ID, MIMES, TAG_NAME } from './constants.js' -import { registerLegacyFileAction } from './legacyFileAction.js' import MindMap from './views/MindMap.js' -const version = Number.parseInt((window.OC?.config?.version ?? '0').split('.')[0]) - if (!window.customElements.get(TAG_NAME)) { window.customElements.define(TAG_NAME, MindMap) } @@ -23,8 +20,3 @@ registerHandler({ enabled: (nodes) => nodes.every((node) => MIMES.includes(node.mime)), theme: 'dark', }) - -// From 33 on the viewer registers the actions for its handlers itself -if (version < 33) { - registerLegacyFileAction() -}