chore(docs): restructure developer guide for monorepo

This commit is contained in:
Elian Doran
2025-05-02 20:51:13 +03:00
parent 27d1948bb1
commit 81ebbb9390
111 changed files with 2632 additions and 2202 deletions

View File

@@ -0,0 +1,21 @@
# Building the editor
First, make sure <a class="reference-link" href="Environment%20setup.md">Environment setup</a> is set up.
## Trigger the build
```
cd packages/ckeditor5-build-trilium
yarn build
```
This will trigger a change in the `build` directory.
## Copy the build artifact to the main repo
Go to `packages/ckeditor5-build-balloon-trilium/build` and copy `ckeditor.js` and `ckeditor.js.map` to `libraries/ckeditor` in the `Notes` repository.
An example shell command to copy it:
```
cp build/ckeditor.* ~/Projects/TriliumNext/Notes/libraries/ckeditor/
```

View File

@@ -0,0 +1,22 @@
# Differences from upstream
* Embeds [`~~isaul32/ckeditor5-math~~`](https://github.com/isaul32/ckeditor5-math)  <a class="reference-link" href="../ckeditor5-math.md">ckeditor5-math</a>, which is a third-party plugin for adding math support. CKEditor itself also has a [math plugin](https://ckeditor.com/docs/ckeditor5/latest/features/math-equations.html) with MathType and ChemType but it's premium-only.
* Zadam left a TODO in `findandreplaceUI`: `// FIXME: keyboard shortcut doesn't work:` [`https://github.com/ckeditor/ckeditor5/issues/10645`](https://github.com/ckeditor/ckeditor5/issues/10645)
* `packages\ckeditor5-build-balloon-block\src\mention_customization.js` introduces note insertion via `@` character.
<figure class="table" style="width:100%;"><table class="ck-table-resized"><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Affected file</th><th>Affected method</th><th>Changed in</th><th>Reason for change</th></tr></thead><tbody><tr><td><code>packages/ckeditor5-mention/src/mentionui.ts</code></td><td><code>createRegExp()</code></td><td><code>6db05043be24bacf9bd51ea46408232b01a1b232</code> (added back)</td><td>Allows triggering the autocomplete for labels and attributes in the attribute editor.</td></tr><tr><td><code>init()</code></td><td><code>55a63a1934efb9a520fcc2d69f3ce55ac22aca39</code></td><td>Allows dismissing @-mention permanently after pressing ESC, otherwise it would automatically show up as soon as a space was entered.</td></tr></tbody></table></figure>
## Checking the old repo
Use the following command to identify commits from Zadam:
```
git log --oneline --author="adam" --all
```
It's best to run the command from zadam's fork of `trilium-ckeditor5` instead of the TriliumNext once since it might not contain all the unmerged branches.
To show a filtered diff of a commit:
```
git show d42e772783 -- ':!*yarn.lock' ':!*packages/ckeditor5-build-balloon-block/build/*' ':!*package.json'
```

View File

@@ -0,0 +1,26 @@
# Environment setup
## Clone the repository
To set up the repository:
```
git clone https://github.com/TriliumNext/trilium-ckeditor5.git
```
## Install dependencies
First, install root dependencies:
```
cd trilium-ckeditor5
yarn install
```
Secondly, install the Trilium build dependencies:
```
cd packages/ckeditor5-build-trilium
yarn install
```
To trigger the build, see <a class="reference-link" href="Building%20the%20editor.md">Building the editor</a>.

View File

@@ -0,0 +1,65 @@
# Updating to a newer version of CKEditor
## Before updating
Make sure that all the plugins are compatible with this version:  <a class="reference-link" href="Versions%20and%20external%20plugins.md">Versions and external plugins</a>. If not, they will need to be updated to the same version as the one you are updating, by altering their `package.json`.
If the plugin is external to the Trilium organisation, it needs to be forked first.
## Environment setup
The first step is to add the CKEditor source as a remote. This only needs to be done once.
```
git remote add upstream ssh://git@github.com/ckeditor/ckeditor5.git
git fetch upstream
```
## Update steps
Due to how the repository is structured, updates to the CKEditor are a bit difficult.
1. `git fetch upstream`
2. Pick a version and merge with it: `git merge -X theirs v99.2.0`
3. When there are complicated conflicts, sometimes it's easier to take everything from the target version instead, for a given path: `git checkout v99.2.0 -- "packages/ckeditor5-list/**"`.
4. Go in `packages/ckeditor5-build-trilium/package.json` and run `node sync-version.js` to update the `package.json` with the new versions. Review and commit the change.
5. Follow again the dependency setup in <a class="reference-link" href="Environment%20setup.md">Environment setup</a>, as they have changed.
6. [Run the build](Building%20the%20editor.md) and check that it works.
## Final steps
1. Start the TriliumNext server
2. If updated to a newer version of CKEditor, check type `CKEDITOR_VERSION` in the browser/Electron console to ensure that the correct version is used.
3. Do a basic sanity check as well.
4. Commit and push the change on both sides (in the `trilium-ckeditor5` repo and in the `Notes` repo).
## Troubleshooting client side errors
These errors might show up when testing the Trilium app:
```
ReferenceError: CKEditor is not defined
```
Usually this is a side effect of another error, check the logs carefully to see if there is any other related error (perhaps a `CKEditorError`).
* * *
```
Uncaught error: Message: CKEditorError: ckeditor-duplicated-modules
```
Most likely cause is one of the external plugins is incompatible with this version.
For example, to disable the Math plugin, go to `packages/ckeditor5-build-trilium/src/config.ts` and modify:
```diff
-import Math from '@triliumnext/ckeditor5-math/src/math';
-import AutoformatMath from '@triliumnext/ckeditor5-math/src/autoformatmath';
export const COMMON_PLUGINS = [
- Math,
- AutoformatMath,
]
```
In this case, make sure to align the version of all the external plugins with the one you are updating to, usually by forking the external plugin and updating its versions.

View File

@@ -0,0 +1,4 @@
# Versions and external plugins
## External plugins
<figure class="table" style="width:100%;"><table class="ck-table-resized"><colgroup><col> <col> <col></colgroup><tbody><tr><td>trilium-ckeditor5</td><td>43.2.0</td><td>&nbsp;</td></tr><tr><td><code>ckeditor5-math</code></td><td>&nbsp;</td><td>See&nbsp;<a class="reference-link" href="../ckeditor5-math.md">ckeditor5-math</a>.</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table></figure>

View File

@@ -0,0 +1,30 @@
# ckeditor5-math
<figure class="image image-style-align-right"><img src="ckeditor5-math_image.png"><figcaption><code>ckeditor5-math</code> in action.</figcaption></figure>
A fork of [isaul32/ckeditor5-math](https://github.com/isaul32/ckeditor5-math), which is the CKEditor5 plugin which adds the math functionality. The fork was created to handle <a class="reference-link" href="#root/OeKBfN6JbMIq/MF99QFRe1gVy/orRZgNnWETTw/tXFiNo5IYd31/jMHQCKORhZge">#297: Insert Math appears to be broken</a>.
## Development environment
* Tested on Node.js 20.
* The package manager is yarn 1 (v1.22.22 is known to be working fine for it at the time of writing).
* Committing is protected by `husky` which runs `eslint` to ensure that the code is clean.
Important commands:
* To check if the code has any formatting issues: `yarn lint`
* To start a live preview: `yarn start`
* To run the tests: `yarn test`
* Note that this requires Chromium, on NixOS this can be achieved by running a `nix-shell -p chromium`, and running `CHROME_BIN=$(which chromium) yarn test` inside it.
## 📦 Packages
The built artifact of the plugin is released by the CI and available on the [GitHub NPM registry](https://github.com/TriliumNext/ckeditor5-math/pkgs/npm/ckeditor5-math).
Note that due to limitations on GitHub's registry, it is not possible to install this package without setting up a personal access token (even though the package itself is public). See <a class="reference-link" href="#root/ZlxZh8NH5frM/jUH2zJGXM67N">[missing note]</a> for more information.
## ⬆️ Integrating with <a class="reference-link" href="CKEditor">CKEditor</a>
1. Release a new version: <a class="reference-link" href="ckeditor5-math/Release%20management%20%26%20continuou.md">Release management &amp; continuous integration</a>
2. In `trilium-ckeditor5`, go to `packages/ckeditor5-build-trilium/package.json` in the CKEditor repository and change the dependency of `@triliumnext/ckeditor5-math` to the newly released version.
3. Run `yarn install`.
4. Proceed with <a class="reference-link" href="CKEditor/Building%20the%20editor.md">Building the editor</a> to integrate everything into TriliumNext and then commit the change.

View File

@@ -0,0 +1,16 @@
# Release management & continuous integration
To automate the release process, a GitHub workflow has been added which builds the package and releases it over to GitHub NPM registry.
The workflow publishes a release whenever a tag with the correct format is pushed.
The steps are as follows:
1. Ensure that the source code is clean and ready for a release.
2. Go to `package.json` and bump the `version` field.
3. Commit the changes.
4. Tag the commit with `v1.2.3`, with the correct version number.
5. Push the changes.
Then follow the CI and it should indicate success. Afterwards, check the [package](https://github.com/TriliumNext/ckeditor5-math/pkgs/npm/ckeditor5-math)section to ensure that the package is in the “Recent Versions” section.
If the changes could benefit upstream, consider opening a pull request with the changes there as well.

View File

@@ -0,0 +1,21 @@
# Updating with upstream
If there was a change in the upstream repository ([isaul32/ckeditor5-math](https://github.com/isaul32/ckeditor5-math)), it can be integrated as follows:
1. Add the upstream as remote (`git remote add upstream ssh://git@github.com/isaul32/ckeditor5-math.git`).
2. Fetch the changes: `git fetch upstream`
3. Merge with a tag: `git merge v43.1.2`
4. Solve the conflict in `package.json` by:
1. Taking the same version as the upcoming one and appending `-hotfix1`.
2. Keeping the `@triliumnext/ckeditor5-math` name.
5. Install dependencies: `yarn install`
6. Check that the build works via `yarn prepublishOnly`.
7. Commit the changes, push them.
8. Release a version with <a class="reference-link" href="Release%20management%20%26%20continuou.md">Release management &amp; continuous integration</a>.
## CI job not triggered after pushing all the upstream tags
If the CI job was not triggered, you might have accidentally pushed a lot of tags using `git push --tags`. Manually delete the tag and push it again:
```diff
git push -d origin v43.1.2-hotfix1 && git push --tags
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB