From 51123284579332511dc56bbae11b33a60b179b71 Mon Sep 17 00:00:00 2001 From: JannikStreek Date: Tue, 17 Sep 2024 10:25:28 +0200 Subject: [PATCH] Merge upstream 2.2.4 (#25) --- .github/workflows/release.yml | 2 +- CHANGELOG.md | 19 + admin/package.json | 18 +- bin/migrateDB.ts | 83 ++ bin/package.json | 13 +- bin/push-after-release.sh | 1 - doc/api/editbar.adoc | 18 +- doc/api/embed_parameters.adoc | 44 +- doc/api/hooks_client-side.adoc | 22 +- doc/api/hooks_server-side.adoc | 306 +++++-- doc/api/http_api.adoc | 710 +++++++-------- doc/api/http_api.md | 728 +++++++++++++++ doc/api/toolbar.adoc | 34 +- doc/api/toolbar.md | 46 + doc/cli.md | 29 + doc/documentation.adoc | 2 +- doc/package.json | 2 +- doc/stats.adoc | 18 +- doc/stats.md | 18 + docker-compose.dev.yml | 20 +- docker-compose.prod.yml | 75 ++ package.json | 5 +- pnpm-lock.yaml | 1154 +++++++++++------------- src/locales/be-tarask.json | 8 + src/node/hooks/express/specialpages.ts | 6 +- src/node/utils/Settings.ts | 10 +- src/package.json | 25 +- src/static/js/vendors/html10n.ts | 6 + src/templates/pad.html | 14 +- ui/package.json | 2 +- var/.gitignore | 4 +- 31 files changed, 2218 insertions(+), 1224 deletions(-) create mode 100644 bin/migrateDB.ts create mode 100644 doc/api/http_api.md create mode 100644 doc/api/toolbar.md create mode 100644 doc/cli.md create mode 100644 doc/stats.md create mode 100644 docker-compose.prod.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 694d7747ce6..4153f6a4ee6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ on: types: [published] push: branches: - - 'merge-upstream-2.2.2-dev' + - 'merge-upstream-2.2.4' env: REGISTRY: ghcr.io diff --git a/CHANGELOG.md b/CHANGELOG.md index 7772d044752..bd572bcbe7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +# 2.2.4 + +### Notable enhancements and fixes + +- Switched to new SQLite backend +- Fixed rusty-store-kv module not found + + +# 2.2.3 + +### Notable enhancements and fixes + +- Introduced a new in process database `rustydb` that represents a fast key value store written in Rust. +- Readded window._ as a shortcut for getting text +- Added support for migrating any ueberdb database to another. You can now switch as you please. See here: https://docs.etherpad.org/cli.html +- Further Typescript movements +- A lot of security issues fixed and reviewed in this release. Please update. + + # 2.2.2 ### Notable enhancements and fixes diff --git a/admin/package.json b/admin/package.json index 527d725d5cf..aea97c9fd51 100644 --- a/admin/package.json +++ b/admin/package.json @@ -1,7 +1,7 @@ { "name": "admin", "private": true, - "version": "2.2.2", + "version": "2.2.4", "type": "module", "scripts": { "dev": "vite", @@ -16,25 +16,25 @@ "devDependencies": { "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-toast": "^1.2.1", - "@types/react": "^18.3.4", + "@types/react": "^18.3.5", "@types/react-dom": "^18.2.25", - "@typescript-eslint/eslint-plugin": "^8.2.0", - "@typescript-eslint/parser": "^8.2.0", + "@typescript-eslint/eslint-plugin": "^8.4.0", + "@typescript-eslint/parser": "^8.4.0", "@vitejs/plugin-react-swc": "^3.5.0", - "eslint": "^9.9.0", + "eslint": "^9.9.1", "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-react-refresh": "^0.4.10", + "eslint-plugin-react-refresh": "^0.4.11", "i18next": "^23.14.0", "i18next-browser-languagedetector": "^8.0.0", - "lucide-react": "^0.429.0", + "lucide-react": "^0.439.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-hook-form": "^7.52.2", + "react-hook-form": "^7.53.0", "react-i18next": "^15.0.1", "react-router-dom": "^6.26.1", "socket.io-client": "^4.7.5", "typescript": "^5.5.4", - "vite": "^5.4.2", + "vite": "^5.4.3", "vite-plugin-static-copy": "^1.0.6", "vite-plugin-svgr": "^4.2.0", "zustand": "^4.5.5" diff --git a/bin/migrateDB.ts b/bin/migrateDB.ts new file mode 100644 index 00000000000..37f1cda230d --- /dev/null +++ b/bin/migrateDB.ts @@ -0,0 +1,83 @@ +// DB migration +import {readFileSync} from 'node:fs' +import {Database, DatabaseType} from "ueberdb2"; +import path from "node:path"; +const settings = require('ep_etherpad-lite/node/utils/Settings'); + + +// file1 = source, file2 = target +// pnpm run migrateDB --file1 --file2 +const arg = process.argv.slice(2); + +if (arg.length != 4) { + console.error('Wrong number of arguments!. Call with pnpm run migrateDB --file1 source.json target.json') + process.exit(1) +} + +type SettingsConfig = { + dbType: string, + dbSettings: any +} + +/* + { + "dbType": "", + "dbSettings": { + + } + } + */ + +let firstDBSettingsFile: string +let secondDBSettingsFile: string + + +if (arg[0] == "--file1") { + firstDBSettingsFile = arg[1] +} else if (arg[0] === "--file2") { + secondDBSettingsFile = arg[1] +} + +if (arg[2] == "--file1") { + firstDBSettingsFile = arg[3] +} else if (arg[2] === "--file2") { + secondDBSettingsFile = arg[3] +} + + + +const settingsfile = JSON.parse(readFileSync(path.join(settings.root,firstDBSettingsFile!)).toString()) as SettingsConfig +const settingsfile2 = JSON.parse(readFileSync(path.join(settings.root,secondDBSettingsFile!)).toString()) as SettingsConfig + +console.log(settingsfile2) +if ("filename" in settingsfile.dbSettings) { + settingsfile.dbSettings.filename = path.join(settings.root, settingsfile.dbSettings.filename) + console.log(settingsfile.dbType + " location is "+ settingsfile.dbSettings.filename) +} + +if ("filename" in settingsfile2.dbSettings) { + settingsfile2.dbSettings.filename = path.join(settings.root, settingsfile2.dbSettings.filename) + console.log(settingsfile2.dbType + " location is "+ settingsfile2.dbSettings.filename) +} + +const ueberdb1 = new Database(settingsfile.dbType as DatabaseType, settingsfile.dbSettings) +const ueberdb2 = new Database(settingsfile2.dbType as DatabaseType, settingsfile2.dbSettings) + +const handleSync = async ()=>{ + await ueberdb1.init() + await ueberdb2.init() + + const allKeys = await ueberdb1.findKeys('*','') + for (const key of allKeys) { + const foundVal = await ueberdb1.get(key)! + await ueberdb2.set(key, foundVal) + } +} + +handleSync().then(()=>{ + console.log("Done syncing dbs") +}).catch(e=>{ + console.log(`Error syncing db ${e}`) +}) + + diff --git a/bin/package.json b/bin/package.json index 4298f938796..acea680ffea 100644 --- a/bin/package.json +++ b/bin/package.json @@ -1,21 +1,21 @@ { "name": "bin", - "version": "2.2.2", + "version": "2.2.4", "description": "", "main": "checkAllPads.js", "directories": { "doc": "doc" }, "dependencies": { - "axios": "^1.7.5", + "axios": "^1.7.7", "ep_etherpad-lite": "workspace:../src", "log4js": "^6.9.1", "semver": "^7.6.3", - "tsx": "^4.17.0", - "ueberdb2": "^4.2.93" + "tsx": "^4.19.0", + "ueberdb2": "^4.2.103" }, "devDependencies": { - "@types/node": "^22.4.2", + "@types/node": "^22.5.4", "@types/semver": "^7.5.8", "typescript": "^5.5.4" }, @@ -34,7 +34,8 @@ "stalePlugins": "node --import tsx ./plugins/stalePlugins.ts", "checkPlugin": "node --import tsx ./plugins/checkPlugin.ts", "plugins": "node --import tsx ./plugins.ts", - "generateChangelog": "node --import tsx generateReleaseNotes.ts" + "generateChangelog": "node --import tsx generateReleaseNotes.ts", + "migrateDB": "node --import tsx migrateDB.ts" }, "author": "", "license": "ISC" diff --git a/bin/push-after-release.sh b/bin/push-after-release.sh index 326f8a7f7c6..b1963d282bf 100644 --- a/bin/push-after-release.sh +++ b/bin/push-after-release.sh @@ -1,4 +1,3 @@ - #!/bin/bash # Specify the path to your package.json file diff --git a/doc/api/editbar.adoc b/doc/api/editbar.adoc index 9135d8d4f5d..8dc865f861c 100644 --- a/doc/api/editbar.adoc +++ b/doc/api/editbar.adoc @@ -1,22 +1,14 @@ -# Editbar - -Located in `src/static/js/pad_editbar.js` +== Editbar +src/static/js/pad_editbar.js === isEnabled() -If the editorbar contains the class `enabledtoolbar`, it is enabled. - - -## disable() - -Disables the editorbar. This is done by adding the class `disabledtoolbar` and removing the enabledtoolbar - -## toggleDropDown(dropdown) +=== disable() +=== toggleDropDown(dropdown) Shows the dropdown `div.popup` whose `id` equals `dropdown`. -## registerCommand(cmd, callback) - +=== registerCommand(cmd, callback) Register a handler for a specific command. Commands are fired if the corresponding button is clicked or the corresponding select is changed. === registerAceCommand(cmd, callback) diff --git a/doc/api/embed_parameters.adoc b/doc/api/embed_parameters.adoc index 2185e7ffab9..51130771f7c 100644 --- a/doc/api/embed_parameters.adoc +++ b/doc/api/embed_parameters.adoc @@ -10,65 +10,65 @@ Cut and paste the following code into any webpage to embed a pad. The parameters ---- -## showLineNumbers -* Boolean +=== showLineNumbers + * Boolean Default: true -## showControls -* Boolean +=== showControls + * Boolean Default: true -## showChat -* Boolean +=== showChat + * Boolean Default: true -## useMonospaceFont -* Boolean +=== useMonospaceFont + * Boolean Default: false -## userName -* String +=== userName + * String Default: "unnamed" Example: `userName=Etherpad%20User` -## userColor -* String (css hex color value) +=== userColor + * String (css hex color value) Default: randomly chosen by pad server Example: `userColor=%23ff9900` -## noColors -* Boolean +=== noColors + * Boolean Default: false -## alwaysShowChat -* Boolean +=== alwaysShowChat + * Boolean Default: false -## lang -* String +=== lang + * String Default: en Example: `lang=ar` (translates the interface into Arabic) -## rtl -* Boolean +=== rtl + * Boolean Default: true Displays pad text from right to left. -## #L -* Int +=== #L + * Int Default: 0 Focuses pad at specific line number and places caret at beginning of this line diff --git a/doc/api/hooks_client-side.adoc b/doc/api/hooks_client-side.adoc index 9b0e0d18c56..f12f120e94f 100644 --- a/doc/api/hooks_client-side.adoc +++ b/doc/api/hooks_client-side.adoc @@ -3,7 +3,11 @@ Most of these hooks are called during or in order to set up the formatting process. +<<<<<<<< HEAD:doc/api/hooks_client-side.adoc === documentReady +======== +## documentReady +>>>>>>>> 2.2.4:doc/api/hooks_client-side.md Called from: `src/templates/pad.html` Things in context: @@ -333,7 +337,7 @@ Context properties: === collectContentPre -Called from: src/static/js/contentcollector.js +Called from: `src/static/js/contentcollector.js` Things in context: @@ -357,7 +361,7 @@ If you want to specify also a value, call cc.doAttrib(state, === collectContentImage -Called from: src/static/js/contentcollector.js +Called from: `src/static/js/contentcollector.js` Things in context: @@ -384,7 +388,7 @@ exports.collectContentImage = function(name, context){ === collectContentPost -Called from: src/static/js/contentcollector.js +Called from: `src/static/js/contentcollector.js` Things in context: @@ -433,7 +437,7 @@ This hook is provided to allow a plugin to turn DOM node selection into === aceKeyEvent -Called from: src/static/js/ace2_inner.js +Called from: `src/static/js/ace2_inner.js` Things in context: @@ -448,7 +452,7 @@ The return value should be true if you have handled the event. === collectContentLineText -Called from: src/static/js/contentcollector.js +Called from: `src/static/js/contentcollector.js` Things in context: @@ -476,7 +480,7 @@ exports.collectContentLineText = (hookName, context) => { === collectContentLineBreak -Called from: src/static/js/contentcollector.js +Called from: `src/static/js/contentcollector.js` Things in context: @@ -489,7 +493,7 @@ domline or not. The return value should be either true(break the line) or false. === disableAuthorColorsForThisLine -Called from: src/static/js/linestylefilter.js +Called from: `src/static/js/linestylefilter.js` Things in context: @@ -505,7 +509,7 @@ deliniation. The return value should be either true(disable) or false. === aceSetAuthorStyle -Called from: src/static/js/ace2_inner.js +Called from: `src/static/js/ace2_inner.js` Things in context: @@ -522,7 +526,7 @@ hooks should return 1 if the plugin handles highlighting. If no plugin returns === aceSelectionChanged -Called from: src/static/js/ace2_inner.js +Called from: `src/static/js/ace2_inner.js` Things in context: diff --git a/doc/api/hooks_server-side.adoc b/doc/api/hooks_server-side.adoc index 25a696b432b..4d656c27cfc 100644 --- a/doc/api/hooks_server-side.adoc +++ b/doc/api/hooks_server-side.adoc @@ -1,8 +1,17 @@ +<<<<<<<< HEAD:doc/api/hooks_server-side.adoc == Server-side hooks These hooks are called on server-side. === loadSettings Called from: `src/node/server.ts` +======== +# Server-side hooks + +These hooks are called on server-side. + +## loadSettings +Called from: `src/node/server.js` +>>>>>>>> 2.2.4:doc/api/hooks_server-side.md Things in context: @@ -10,8 +19,13 @@ Things in context: Use this hook to receive the global settings in your plugin. +<<<<<<<< HEAD:doc/api/hooks_server-side.adoc === shutdown Called from: `src/node/server.ts` +======== +## shutdown +Called from: `src/node/server.js` +>>>>>>>> 2.2.4:doc/api/hooks_server-side.md Things in context: None @@ -33,7 +47,11 @@ exports.shutdown = async (hookName, context) => { }; ---- +<<<<<<<< HEAD:doc/api/hooks_server-side.adoc === pluginUninstall +======== +## pluginUninstall +>>>>>>>> 2.2.4:doc/api/hooks_server-side.md Called from: `src/static/js/pluginfw/installer.js` Things in context: @@ -42,7 +60,11 @@ Things in context: If this hook returns an error, the callback to the uninstall function gets an error as well. This mostly seems useful for handling additional features added in based on the installation of other plugins, which is pretty cool! +<<<<<<<< HEAD:doc/api/hooks_server-side.adoc === pluginInstall +======== +## pluginInstall +>>>>>>>> 2.2.4:doc/api/hooks_server-side.md Called from: `src/static/js/pluginfw/installer.js` Things in context: @@ -59,8 +81,8 @@ Run during startup after the named plugin is initialized. Context properties: - * `logger`: An object with the following `console`-like methods: `debug`, - `info`, `log`, `warn`, `error`. +* `logger`: An object with the following `console`-like methods: `debug`, + `info`, `log`, `warn`, `error`. === expressPreSession @@ -141,7 +163,11 @@ exports.expressCloseServer = async () => { }; ---- +<<<<<<<< HEAD:doc/api/hooks_server-side.adoc === eejsBlock_`` +======== +## eejsBlock_`` +>>>>>>>> 2.2.4:doc/api/hooks_server-side.md Called from: `src/node/eejs/index.js` Things in context: @@ -152,40 +178,45 @@ This hook gets called upon the rendering of an ejs template block. For any speci Available blocks in `pad.html` are: - * `htmlHead` - after `` and immediately before the title tag - * `styles` - the style ``s - * `body` - the contents of the body tag - * `editbarMenuLeft` - the left tool bar (consider using the toolbar controller instead of manually adding html here) - * `editbarMenuRight` - right tool bar - * `afterEditbar` - allows you to add stuff immediately after the toolbar - * `userlist` - the contents of the userlist dropdown - * `loading` - the initial loading message - * `mySettings` - the left column of the settings dropdown ("My view"); intended for adding checkboxes only - * `mySettings.dropdowns` - add your dropdown settings here - * `globalSettings` - the right column of the settings dropdown ("Global view") - * `importColumn` - import form - * `exportColumn` - export form - * `modals` - Contains all connectivity messages - * `embedPopup` - the embed dropdown - * `scripts` - Add your script tags here, if you really have to (consider use client-side hooks instead) +* `htmlHead` - after `` and immediately before the title tag +* `styles` - the style ``s +* `body` - the contents of the body tag +* `editbarMenuLeft` - the left tool bar (consider using the toolbar controller instead of manually adding html here) +* `editbarMenuRight` - right tool bar +* `afterEditbar` - allows you to add stuff immediately after the toolbar +* `userlist` - the contents of the userlist dropdown +* `loading` - the initial loading message +* `mySettings` - the left column of the settings dropdown ("My view"); intended for adding checkboxes only +* `mySettings.dropdowns` - add your dropdown settings here +* `globalSettings` - the right column of the settings dropdown ("Global view") +* `importColumn` - import form +* `exportColumn` - export form +* `modals` - Contains all connectivity messages +* `embedPopup` - the embed dropdown +* `scripts` - Add your script tags here, if you really have to (consider use client-side hooks instead) `timeslider.html` blocks: - * `timesliderStyles` - * `timesliderScripts` - * `timesliderBody` - * `timesliderTop` - * `timesliderEditbarRight` - * `modals` +* `timesliderStyles` +* `timesliderScripts` +* `timesliderBody` +* `timesliderTop` +* `timesliderEditbarRight` +* `modals` `index.html` blocks: - * `indexCustomStyles` - contains the `index.css` `` tag, allows you to add your own or to customize the one provided by the active skin - * `indexWrapper` - contains the form for creating new pads - * `indexCustomScripts` - contains the `index.js` `