From 7568691feb30604371996eb82c959443f420db2b Mon Sep 17 00:00:00 2001 From: Diogo Castro Date: Thu, 7 Apr 2022 15:48:11 +0200 Subject: [PATCH] [full-ci] Improvements to text/md editor (#6667) Rename and improve markdown editor * Support for read-only files * Disable preview for non md files (configurable) * Data integrity checks (prevent exiting with unsaved changes) * Better error information to the user * Keyboard shortcut to save * Rename Markdown Editor to Simple Editor Co-authored-by: Benedikt Kulmann --- .drone.star | 12 +- .github/settings.yml | 2 +- .../unreleased/enhancement-simple-editor | 13 + dev/docker/oc10.web.config.json | 2 +- dev/docker/ocis.web.config.json | 2 +- package.json | 4 +- .../tests/__fixtures__/fileActions.js | 20 +- .../components/AppBar/CreateAndUpload.spec.js | 4 +- .../FilesList/ContextActions.spec.js | 4 +- .../__snapshots__/ContextActions.spec.js.snap | 4 +- .../SideBar/Actions/FileActions.spec.js | 6 +- packages/web-app-markdown-editor/package.json | 6 - packages/web-app-markdown-editor/src/App.vue | 137 ---------- .../l10n/.tx/config | 2 +- .../l10n/translations.json | 0 packages/web-app-simple-editor/package.json | 6 + packages/web-app-simple-editor/src/App.vue | 241 ++++++++++++++++++ .../src/SimpleEditorAppBar.vue} | 16 +- .../src/index.js | 15 +- .../fileFolderActionMenu.feature | 2 +- .../markdownFile.feature | 52 ++-- .../FilesPageElement/fileActionsMenu.js | 12 +- tests/acceptance/pageObjects/personalPage.js | 2 +- ...kdownEditorPage.js => simpleEditorPage.js} | 14 +- ...ditorContext.js => simpleEditorContext.js} | 50 ++-- tests/drone/config-oc10-oauth.json | 2 +- tests/drone/config-oc10-openid.json | 2 +- tests/drone/config-ocis.json | 2 +- yarn.lock | 12 +- 29 files changed, 390 insertions(+), 256 deletions(-) create mode 100644 changelog/unreleased/enhancement-simple-editor delete mode 100644 packages/web-app-markdown-editor/package.json delete mode 100644 packages/web-app-markdown-editor/src/App.vue rename packages/{web-app-markdown-editor => web-app-simple-editor}/l10n/.tx/config (83%) rename packages/{web-app-markdown-editor => web-app-simple-editor}/l10n/translations.json (100%) create mode 100644 packages/web-app-simple-editor/package.json create mode 100644 packages/web-app-simple-editor/src/App.vue rename packages/{web-app-markdown-editor/src/MarkdownEditorAppBar.vue => web-app-simple-editor/src/SimpleEditorAppBar.vue} (68%) rename packages/{web-app-markdown-editor => web-app-simple-editor}/src/index.js (73%) rename tests/acceptance/features/{webUIMarkdownEditor => webUISimpleEditor}/markdownFile.feature (58%) rename tests/acceptance/pageObjects/{markdownEditorPage.js => simpleEditorPage.js} (88%) rename tests/acceptance/stepDefinitions/{markdownEditorContext.js => simpleEditorContext.js} (54%) diff --git a/.drone.star b/.drone.star index 41d6c3f698a..29c6776a570 100644 --- a/.drone.star +++ b/.drone.star @@ -78,7 +78,7 @@ config = { "oC10Files1": [ "webUIFilesCopy", "webUIFavorites", - "webUIMarkdownEditor", + "webUISimpleEditor", ], "oC10Files2": [ "webUIFilesList", @@ -265,7 +265,7 @@ config = { "oC10XGAPortrait2": [ "webUISharingAcceptShares", "webUISharingAcceptSharesToRoot", - "webUIMarkdownEditor", + "webUISimpleEditor", "webUIWebdavLockProtection", "webUIWebdavLocks", "webUIMoveFilesFolders", @@ -358,7 +358,7 @@ config = { "oC10iPhone2": [ "webUISharingAcceptShares", "webUISharingAcceptSharesToRoot", - "webUIMarkdownEditor", + "webUISimpleEditor", "webUISharingInternalUsersBlacklisted", "webUIWebdavLockProtection", "webUIWebdavLocks", @@ -434,7 +434,7 @@ config = { "webUICreateFilesFolders", "webUIDeleteFilesFolders", "webUIFilesCopy", - "webUIMarkdownEditor", + "webUISimpleEditor", ], "oCISFiles2": [ "webUIFilesList", @@ -560,7 +560,7 @@ config = { "webUIRestrictSharing", "webUISharingAcceptShares", "webUISharingAcceptSharesToRoot", - "webUIMarkdownEditor", + "webUISimpleEditor", "webUISharingInternalUsersBlacklisted", "webUIWebdavLockProtection", "webUIWebdavLocks", @@ -666,7 +666,7 @@ basicTestSuites = [ "webUIFilesList", "webUIFilesSearch", "webUILogin", - "webUIMarkdownEditor", + "webUISimpleEditor", "webUIMoveFilesFolders", "webUIOperationsWithFolderShares", "webUIPreview", diff --git a/.github/settings.yml b/.github/settings.yml index f802dc816ae..dc9ca78ba75 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -16,7 +16,7 @@ labels: color: "#ccf4ff" - name: feature:files color: "#d4c5f9" - - name: feature:markdown-editor + - name: feature:simple-editor color: "#d4c5f9" - name: feature:pdf-viewer color: "#d4c5f9" diff --git a/changelog/unreleased/enhancement-simple-editor b/changelog/unreleased/enhancement-simple-editor new file mode 100644 index 00000000000..28ca8522780 --- /dev/null +++ b/changelog/unreleased/enhancement-simple-editor @@ -0,0 +1,13 @@ +Enhancement: Simple Editor + +Replace MarkdownEditor with SimpleEditor and add the following improvements: +* Disable preview for non md files (configurable) +* Data integrity checks (prevent exiting with unsaved changes) +* Better error information to the user +* Keyboard shortcut to save +* Read-only mode +* Fix to open on non-authenticated public links +* Open other extensions (js, json, xml, py, php, yaml) +* UI polish + +https://github.com/owncloud/web/pull/6667 diff --git a/dev/docker/oc10.web.config.json b/dev/docker/oc10.web.config.json index 00f20f3c629..b8a8b4b728a 100644 --- a/dev/docker/oc10.web.config.json +++ b/dev/docker/oc10.web.config.json @@ -8,7 +8,7 @@ "apps": [ "files", "preview", - "markdown-editor", + "simple-editor", "pdf-viewer", "search" ], diff --git a/dev/docker/ocis.web.config.json b/dev/docker/ocis.web.config.json index a4952687ff9..cdf870cf4f9 100644 --- a/dev/docker/ocis.web.config.json +++ b/dev/docker/ocis.web.config.json @@ -16,7 +16,7 @@ }, "apps": [ "files", - "markdown-editor", + "simple-editor", "preview", "pdf-viewer", "search", diff --git a/package.json b/package.json index 96825f7a050..e45e48cf57c 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "packages/web-app-draw-io", "packages/web-app-external", "packages/web-app-files", - "packages/web-app-markdown-editor", + "packages/web-app-simple-editor", "packages/web-app-preview", "packages/web-app-user-management", "packages/web-app-pdf-viewer", @@ -26,7 +26,7 @@ "test:integration": "jest --config ./tests/integration/config/jest.config.js", "test:e2e:cucumber": "NODE_TLS_REJECT_UNAUTHORIZED=0 cucumber-js --profile=e2e -f json:tests/e2e/cucumber/report/cucumber_report.json", "test:unit": "NODE_OPTIONS=--unhandled-rejections=throw jest --coverage --config ./tests/unit/config/jest.config.js", - "licenses:check": "license-checker-rseidelsohn --summary --relativeLicensePath --onlyAllow 'Python-2.0;Apache*;Apache License, Version 2.0;Apache-2.0;Apache 2.0;Artistic-2.0;BSD;BSD-3-Clause;CC-BY-3.0;CC-BY-4.0;CC0-1.0;ISC;MIT;MPL-2.0;Public Domain;Unicode-TOU;Unlicense;WTFPL' --excludePackages 'draw-io;external;files;markdown-editor;preview;owncloud-design-system;pdf-viewer;search;user-management;web-client;web-pkg;web-runtime'", + "licenses:check": "license-checker-rseidelsohn --summary --relativeLicensePath --onlyAllow 'Python-2.0;Apache*;Apache License, Version 2.0;Apache-2.0;Apache 2.0;Artistic-2.0;BSD;BSD-3-Clause;CC-BY-3.0;CC-BY-4.0;CC0-1.0;ISC;MIT;MPL-2.0;Public Domain;Unicode-TOU;Unlicense;WTFPL' --excludePackages 'draw-io;external;files;simple-editor;preview;owncloud-design-system;pdf-viewer;search;user-management;web-client;web-pkg;web-runtime'", "licenses:csv": "license-checker-rseidelsohn --relativeLicensePath --csv --out ./third-party-licenses/third-party-licenses.csv", "licenses:save": "license-checker-rseidelsohn --relativeLicensePath --out /dev/null --files ./third-party-licenses/third-party-licenses" }, diff --git a/packages/web-app-files/tests/__fixtures__/fileActions.js b/packages/web-app-files/tests/__fixtures__/fileActions.js index f94c21fc7c4..5b6b8a9321e 100644 --- a/packages/web-app-files/tests/__fixtures__/fileActions.js +++ b/packages/web-app-files/tests/__fixtures__/fileActions.js @@ -14,9 +14,9 @@ const meta = { id: 'draw-io', icon: 'grid' }, - 'markdown-editor': { - name: 'MarkdownEditor', - id: 'markdown-editor', + 'simple-editor': { + name: 'SimpleEditor', + id: 'simple-editor', icon: 'file-text' } } @@ -49,12 +49,12 @@ const editors = [ routes }, { - app: 'markdown-editor', + app: 'simple-editor', extension: 'md', handler: null, icon: null, newTab: false, - routeName: 'markdown-editor', + routeName: 'simple-editor', routes } ] @@ -131,11 +131,11 @@ const fileActions = { selector: '.oc-files-actions-delete-trigger' }, - 'markdown-editor': { + 'simple-editor': { handler: jest.fn(), - label: () => 'Open in Markdown Editor', - class: 'oc-files-actions-markdown-editor-trigger', - selector: '.oc-files-actions-markdown-editor-trigger', + label: () => 'Open in Simple Editor', + class: 'oc-files-actions-simple-editor-trigger', + selector: '.oc-files-actions-simple-editor-trigger', opensInNewWindow: true }, 'draw-io': { @@ -165,7 +165,7 @@ const fileActions = { exports.fileActions = fileActions exports.getActions = function (actions = []) { - const defaultActions = ['download', 'markdown-editor', 'draw-io', 'preview', 'navigate'] + const defaultActions = ['download', 'simple-editor', 'draw-io', 'preview', 'navigate'] const res = [] for (const key of actions) { diff --git a/packages/web-app-files/tests/unit/components/AppBar/CreateAndUpload.spec.js b/packages/web-app-files/tests/unit/components/AppBar/CreateAndUpload.spec.js index 959bd1a08b0..e312335e78d 100644 --- a/packages/web-app-files/tests/unit/components/AppBar/CreateAndUpload.spec.js +++ b/packages/web-app-files/tests/unit/components/AppBar/CreateAndUpload.spec.js @@ -36,7 +36,7 @@ const newFileHandlers = [ { ext: 'txt', action: { - app: 'markdown-editor', + app: 'simple-editor', newTab: false, extension: 'txt' }, @@ -45,7 +45,7 @@ const newFileHandlers = [ { ext: 'md', action: { - app: 'markdown-editor', + app: 'simple-editor', newTab: false, extension: 'md' }, diff --git a/packages/web-app-files/tests/unit/components/FilesList/ContextActions.spec.js b/packages/web-app-files/tests/unit/components/FilesList/ContextActions.spec.js index 4b67b2aef6f..9eb906dd0f4 100644 --- a/packages/web-app-files/tests/unit/components/FilesList/ContextActions.spec.js +++ b/packages/web-app-files/tests/unit/components/FilesList/ContextActions.spec.js @@ -30,8 +30,8 @@ const mockMenuSections = [ handler: jest.fn(), label: () => 'Open in editor', componentType: 'oc-button', - selector: '.oc-files-actions-markdown-editor-trigger', - class: 'oc-files-actions-markdown-editor-trigger' + selector: '.oc-files-actions-simple-editor-trigger', + class: 'oc-files-actions-simple-editor-trigger' }, ...exampleApps.map((app) => { return { diff --git a/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ContextActions.spec.js.snap b/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ContextActions.spec.js.snap index 9849b9e62b2..b01c0f9fb63 100644 --- a/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ContextActions.spec.js.snap +++ b/packages/web-app-files/tests/unit/components/FilesList/__snapshots__/ContextActions.spec.js.snap @@ -3,7 +3,7 @@ exports[`ContextActions menu items renders a list of actions for a file 1`] = `
-
  • @@ -66,7 +66,7 @@ exports[`ContextActions menu items renders a list of actions for a file 1`] = ` exports[`ContextActions menu items renders a list of actions for a folder 1`] = `
    -
  • diff --git a/packages/web-app-files/tests/unit/components/SideBar/Actions/FileActions.spec.js b/packages/web-app-files/tests/unit/components/SideBar/Actions/FileActions.spec.js index dde47fe3c3b..c8f4d72b09d 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/Actions/FileActions.spec.js +++ b/packages/web-app-files/tests/unit/components/SideBar/Actions/FileActions.spec.js @@ -21,8 +21,8 @@ const filesPersonalRoute = { name: 'files-personal' } const systemDefaultActions = [ [['copy']], [['copy', 'move']], - [['copy', 'markdown-editor']], - [['copy', 'move', 'download', 'markdown-editor']] + [['copy', 'simple-editor']], + [['copy', 'move', 'download', 'simple-editor']] ] describe('FileActions', () => { @@ -32,7 +32,7 @@ describe('FileActions', () => { jest.clearAllMocks() }) it('renders action handlers as clickable elements', async () => { - const actions = ['copy', 'move', 'download', 'markdown-editor'] + const actions = ['copy', 'move', 'download', 'simple-editor'] const wrapper = getWrapper(filesPersonalRoute, actions) for (const button of actions) { diff --git a/packages/web-app-markdown-editor/package.json b/packages/web-app-markdown-editor/package.json deleted file mode 100644 index 03b7cb390f4..00000000000 --- a/packages/web-app-markdown-editor/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "markdown-editor", - "version": "0.0.0", - "description": "ownCloud web markdown-editor", - "license": "AGPL-3.0" -} diff --git a/packages/web-app-markdown-editor/src/App.vue b/packages/web-app-markdown-editor/src/App.vue deleted file mode 100644 index 1c6eee283f5..00000000000 --- a/packages/web-app-markdown-editor/src/App.vue +++ /dev/null @@ -1,137 +0,0 @@ - - - diff --git a/packages/web-app-markdown-editor/l10n/.tx/config b/packages/web-app-simple-editor/l10n/.tx/config similarity index 83% rename from packages/web-app-markdown-editor/l10n/.tx/config rename to packages/web-app-simple-editor/l10n/.tx/config index e43731231aa..b388b1fc915 100644 --- a/packages/web-app-markdown-editor/l10n/.tx/config +++ b/packages/web-app-simple-editor/l10n/.tx/config @@ -1,7 +1,7 @@ [main] host = https://www.transifex.com -[owncloud-web.markdown-editor] +[owncloud-web.simple-editor] file_filter = locale//LC_MESSAGES/app.po minimum_perc = 0 source_file = template.pot diff --git a/packages/web-app-markdown-editor/l10n/translations.json b/packages/web-app-simple-editor/l10n/translations.json similarity index 100% rename from packages/web-app-markdown-editor/l10n/translations.json rename to packages/web-app-simple-editor/l10n/translations.json diff --git a/packages/web-app-simple-editor/package.json b/packages/web-app-simple-editor/package.json new file mode 100644 index 00000000000..83747c692b5 --- /dev/null +++ b/packages/web-app-simple-editor/package.json @@ -0,0 +1,6 @@ +{ + "name": "simple-editor", + "version": "0.0.0", + "description": "ownCloud web simple-editor", + "license": "AGPL-3.0" +} diff --git a/packages/web-app-simple-editor/src/App.vue b/packages/web-app-simple-editor/src/App.vue new file mode 100644 index 00000000000..26741d9db24 --- /dev/null +++ b/packages/web-app-simple-editor/src/App.vue @@ -0,0 +1,241 @@ + + + diff --git a/packages/web-app-markdown-editor/src/MarkdownEditorAppBar.vue b/packages/web-app-simple-editor/src/SimpleEditorAppBar.vue similarity index 68% rename from packages/web-app-markdown-editor/src/MarkdownEditorAppBar.vue rename to packages/web-app-simple-editor/src/SimpleEditorAppBar.vue index d2e0d70aa1b..5f684112d73 100644 --- a/packages/web-app-markdown-editor/src/MarkdownEditorAppBar.vue +++ b/packages/web-app-simple-editor/src/SimpleEditorAppBar.vue @@ -1,17 +1,21 @@