Skip to content

Build your personal knowledge base with Trilium Notes

refactor(ckeditor5): fold admonition into the aggregate package

Elian Dorane295d36ae880
diff --git a/CLAUDE.md b/CLAUDE.md
index eef701a6dc..3105e4e752 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -75,7 +75,7 @@ packages/
codemirror/ # Code editor integration
highlightjs/ # Syntax highlighting
share-theme/ # Theme for shared/published notes
- ckeditor5-admonition/, ckeditor5-footnotes/, ckeditor5-math/, ckeditor5-mermaid/
+ ckeditor5-footnotes/, ckeditor5-math/, ckeditor5-mermaid/
express-partial-content/, pdfjs-viewer/, splitjs/
turndown-plugin-gfm/
```
diff --git a/docs/Developer Guide/Developer Guide/Architecture.md b/docs/Developer Guide/Developer Guide/Architecture.md
index 9f39138d73..f64bfe365b 100644
--- a/docs/Developer Guide/Developer Guide/Architecture.md
+++ b/docs/Developer Guide/Developer Guide/Architecture.md
@@ -94,7 +94,6 @@ trilium/
│ ├── ckeditor5/ # Custom rich text editor
│ ├── codemirror/ # Code editor customizations
│ ├── highlightjs/ # Syntax highlighting
-│ ├── ckeditor5-admonition/ # CKEditor plugin: admonitions
│ ├── ckeditor5-footnotes/ # CKEditor plugin: footnotes
│ ├── ckeditor5-math/ # CKEditor plugin: math equations
│ ├── ckeditor5-mermaid/ # CKEditor plugin: diagrams
diff --git a/flake.nix b/flake.nix
index e2996fc4c9..793b79c5e9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -238,7 +238,6 @@ nodejs.python
components = [
"packages/ckeditor5"
- "packages/ckeditor5-admonition"
"packages/ckeditor5-footnotes"
"packages/ckeditor5-math"
"packages/ckeditor5-mermaid"
diff --git a/packages/ckeditor5-admonition/.editorconfig b/packages/ckeditor5-admonition/.editorconfig
deleted file mode 100644
index 37ea8ff914..0000000000
--- a/packages/ckeditor5-admonition/.editorconfig
+++ /dev/null
@@ -1,19 +0,0 @@
-# Configurations to normalize the IDE behavior.
-# http://editorconfig.org/
-
-root = true
-
-[*]
-indent_style = tab
-tab_width = 4
-charset = utf-8
-end_of_line = lf
-trim_trailing_whitespace = true
-insert_final_newline = true
-
-[*.{js,jsx,ts}]
-quote_type = single
-
-[package.json]
-indent_style = space
-tab_width = 2
diff --git a/packages/ckeditor5-admonition/.gitattributes b/packages/ckeditor5-admonition/.gitattributes
deleted file mode 100644
index 41be6fafe7..0000000000
--- a/packages/ckeditor5-admonition/.gitattributes
+++ /dev/null
@@ -1,19 +0,0 @@
-* text=auto
-
-*.htaccess eol=lf
-*.cgi eol=lf
-*.sh eol=lf
-
-*.css text
-*.htm text
-*.html text
-*.js text
-*.ts text
-*.json text
-*.php text
-*.txt text
-*.md text
-
-*.png -text
-*.gif -text
-*.jpg -text
diff --git a/packages/ckeditor5-admonition/.gitignore b/packages/ckeditor5-admonition/.gitignore
deleted file mode 100644
index 437dda1d0a..0000000000
--- a/packages/ckeditor5-admonition/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-build/
-coverage/
-dist/
-node_modules/
-tmp/
-sample/ckeditor.dist.js
-
-# Ignore compiled TypeScript files.
-src/**/*.js
-src/**/*.d.ts
diff --git a/packages/ckeditor5-admonition/.stylelintrc b/packages/ckeditor5-admonition/.stylelintrc
deleted file mode 100644
index 1d86a41f98..0000000000
--- a/packages/ckeditor5-admonition/.stylelintrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": "stylelint-config-ckeditor5"
-}
diff --git a/packages/ckeditor5-admonition/LICENSE.md b/packages/ckeditor5-admonition/LICENSE.md
deleted file mode 100644
index b60c76711a..0000000000
--- a/packages/ckeditor5-admonition/LICENSE.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Software License Agreement
-==========================
-
-Copyright (c) 2025. All rights reserved.
-
-Licensed under the terms of [MIT license](https://opensource.org/licenses/MIT).
diff --git a/packages/ckeditor5-admonition/README.md b/packages/ckeditor5-admonition/README.md
deleted file mode 100644
index f38e132f94..0000000000
--- a/packages/ckeditor5-admonition/README.md
+++ /dev/null
@@ -1,141 +0,0 @@
-@triliumnext/ckeditor5-admonition
-=================================
-
-This package was created by the [ckeditor5-package-generator](https://www.npmjs.com/package/ckeditor5-package-generator) package.
-
-## Table of contents
-
-* [Developing the package](#developing-the-package)
-* [Available scripts](#available-scripts)
- * [`start`](#start)
- * [`test`](#test)
- * [`lint`](#lint)
- * [`stylelint`](#stylelint)
- * [`build:dist`](#builddist)
- * [`translations:synchronize`](#translationssynchronize)
- * [`translations:validate`](#translationsvalidate)
- * [`ts:build` and `ts:clear`](#tsbuild-and-tsclear)
-* [License](#license)
-
-## Developing the package
-
-To read about the CKEditor 5 Framework, visit the [CKEditor 5 Framework documentation](https://ckeditor.com/docs/ckeditor5/latest/framework/index.html).
-
-## Available scripts
-
-NPM scripts are a convenient way to provide commands in a project. They are defined in the `package.json` file and shared with people contributing to the project. It ensures developers use the same command with the same options (flags).
-
-All the scripts can be executed by running `npm run <script>`. Pre and post commands with matching names will be run for those as well.
-
-The following scripts are available in the package.
-
-### `start`
-
-Starts an HTTP server with the live-reload mechanism that allows previewing and testing of plugins available in the package.
-
-When the server starts, the default browser will open the developer sample. This can be disabled by passing the `--no-open` option to that command.
-
-You can also define the language that will translate the created editor by specifying the `--language [LANG]` option. It defaults to `'en'`.
-
-Examples:
-
-```bash
-# Starts the server and open the browser.
-npm run start
-
-# Disable auto-opening the browser.
-npm run start -- --no-open
-
-# Create the editor with the interface in German.
-npm run start -- --language=de
-```
-
-### `test`
-
-Allows executing unit tests for the package specified in the `tests/` directory. To check the code coverage, add the `--coverage` modifier. See other [CLI flags](https://vitest.dev/guide/cli.html) in Vitest.
-
-Examples:
-
-```bash
-# Execute tests.
-npm run test
-
-# Generate code coverage report after each change in the sources.
-npm run test -- --coverage
-```
-
-### `lint`
-
-Runs ESLint, which analyzes the code (all `*.ts` files) to quickly find problems.
-
-Examples:
-
-```bash
-# Execute eslint.
-npm run lint
-```
-
-### `stylelint`
-
-Similar to the `lint` task, stylelint analyzes the CSS code (`*.css` files in the `theme/` directory) in the package.
-
-Examples:
-
-```bash
-# Execute stylelint.
-npm run stylelint
-```
-
-### `build:dist`
-
-Creates npm and browser builds of your plugin. These builds can be added to the editor by following the [Configuring CKEditor 5 features](https://ckeditor.com/docs/ckeditor5/latest/getting-started/setup/configuration.html) guide.
-
-Examples:
-
-```bash
-# Builds the `npm` and browser files thats are ready to publish.
-npm run build:dist
-```
-
-### `translations:synchronize`
-
-Synchronizes translation messages (arguments of the `t()` function) by performing the following steps:
-
- * Collect all translation messages from the package by finding `t()` calls in source files.
- * Detect if translation context is valid, i.e. whether the provided values do not interfere with the values specified in the `@ckeditor/ckeditor5-core` package.
- * If there are no validation errors, update all translation files (`*.po` files) to be in sync with the context file:
- * unused translation entries are removed,
- * missing translation entries are added with empty string as the message translation,
- * missing translation files are created for languages that do not have own `*.po` file yet.
-
-The task may end with an error if one of the following conditions is met:
-
-* Found the `Unused context` error &ndash; entries specified in the `lang/contexts.json` file are not used in source files. They should be removed.
-* Found the `Duplicated contex` error &ndash; some of the entries are duplicated. Consider removing them from the `lang/contexts.json` file, or rewriting them.
-* Found the `Missing context` error &ndash; entries specified in source files are not described in the `lang/contexts.json` file. They should be added.
-
-Examples:
-
-```bash
-npm run translations:synchronize
-```
-
-### `translations:validate`
-
-Peforms only validation steps as described in [`translations:synchronize`](#translationssynchronize) script, but without modifying any files. It only checks the correctness of the context file against the `t()` function calls.
-
-Examples:
-
-```bash
-npm run translations:validate
-```
-
-### `ts:build` and `ts:clear`
-
-These scripts compile TypeScript and remove the compiled files. They are used in the aforementioned life cycle scripts, and there is no need to call them manually.
-
-## License
-
-The `@triliumnext/ckeditor5-admonition` package is available under [MIT license](https://opensource.org/licenses/MIT).
-
-However, it is the default license of packages created by the [ckeditor5-package-generator](https://www.npmjs.com/package/ckeditor5-package-generator) package and can be changed.
diff --git a/packages/ckeditor5-admonition/ckeditor5-metadata.json b/packages/ckeditor5-admonition/ckeditor5-metadata.json
deleted file mode 100644
index 20505eac3b..0000000000
--- a/packages/ckeditor5-admonition/ckeditor5-metadata.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "plugins": [
- {
- "name": "Admonition",
- "className": "Admonition",
- "description": "Implements admonitions (warning, info boxes) in a similar fashion to blockquotes",
- "path": "src/admonition.ts",
- "uiComponents": [
- {
- "name": "admonition",
- "type": "Button",
- "iconPath": "theme/icons/admonition.svg"
- }
- ],
- "htmlOutput": [
- {
- "elements": "aside"
- }
- ]
- }
- ]
-}
diff --git a/packages/ckeditor5-admonition/eslint.config.js b/packages/ckeditor5-admonition/eslint.config.js
deleted file mode 100644
index 8e49f74ea6..0000000000
--- a/packages/ckeditor5-admonition/eslint.config.js
+++ /dev/null
@@ -1,83 +0,0 @@
-import globals from 'globals';
-import { defineConfig } from 'eslint/config';
-import eslintConfigCKEditor5 from 'eslint-config-ckeditor5';
-import eslintPluginCKEditor5Rules from 'eslint-plugin-ckeditor5-rules';
-
-export default defineConfig( [
- eslintConfigCKEditor5,
- {
- name: 'Ignored files config',
- ignores: [
- // Ignore compiled JavaScript files, as they are generated automatically.
- 'src/**/*.js',
- // Also, do not check typing declarations, too.
- 'src/**/*.d.ts',
- // Ignore the entire `dist/` (the NIM build).
- 'dist/**'
- ]
- },
- {
- name: 'Base config',
- languageOptions: {
- ecmaVersion: 'latest',
- sourceType: 'module'
- },
- linterOptions: {
- reportUnusedInlineConfigs: 'error',
- reportUnusedDisableDirectives: 'error'
- },
- plugins: {
- 'ckeditor5-rules': eslintPluginCKEditor5Rules
- },
- rules: {
- // This rule disallows importing from any path other than the package main entrypoint.
- 'ckeditor5-rules/allow-imports-only-from-main-package-entry-point': 'error',
- // As required by the ECMAScript (ESM) standard, all imports must include a file extension.
- // If the import does not include it, this rule will try to automatically detect the correct file extension.
- 'ckeditor5-rules/require-file-extensions-in-imports': [ 'error', {
- extensions: [ '.ts', '.js', '.json' ]
- } ],
- // This rule ensures that all imports from `@ckeditor/*` packages are done through the main package entry points.
- // This is required for the editor types to work properly and to ease migration to the installation methods
- // introduced in CKEditor 5 version 42.0.0.
- 'ckeditor5-rules/no-legacy-imports': 'error'
- }
- },
- {
- name: 'NodeJS environment config',
- files: [
- './scripts/**/*.{js,mjs,cjs}'
- ],
- languageOptions: {
- globals: {
- ...globals.node
- }
- }
- },
- {
- name: 'Browser environment config',
- files: [
- './sample/**/*.{ts,mts,cts}',
- './src/**/*.{ts,mts,cts}',
- './tests/**/*.{ts,mts,cts}',
- './typings/**/*.d.ts'
- ],
- languageOptions: {
- globals: {
- ...globals.browser
- }
- }
- },
- {
- name: 'Sample and tests config',
- files: [
- 'sample/**/*.{ts,mts,cts}',
- 'tests/**/*.{ts,mts,cts}'
- ],
- rules: {
- // To write complex tests, you may need to import files that are not exported in DLL files by default.
- // Hence, imports CKEditor 5 packages in test files are not checked.
- 'ckeditor5-rules/ckeditor-imports': 'off'
- }
- }
-] );
diff --git a/packages/ckeditor5-admonition/lang/contexts.json b/packages/ckeditor5-admonition/lang/contexts.json
deleted file mode 100644
index 421249ff62..0000000000
--- a/packages/ckeditor5-admonition/lang/contexts.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Admonition": "Toolbar button tooltip for the Admonition feature."
-}
diff --git a/packages/ckeditor5-admonition/lang/en.po b/packages/ckeditor5-admonition/lang/en.po
deleted file mode 100644
index b5032283ad..0000000000
--- a/packages/ckeditor5-admonition/lang/en.po
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
-#
-# !!! IMPORTANT !!!
-#
-# Before you edit this file, please keep in mind that contributing to the project
-# translations is possible ONLY via the Transifex online service.
-#
-# To submit your translations, visit https://www.transifex.com/ckeditor/ckeditor5.
-#
-# To learn more, check out the official contributor's guide:
-# https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html
-#
-msgid ""
-msgstr ""
-"Language: \n"
-"Language-Team: \n"
-"Plural-Forms: \n"
-"Content-Type: text/plain; charset=UTF-8\n"
-
-msgctxt "Toolbar button tooltip for the Admoniton feature."
-msgid "Admonition"
-msgstr "Admonition"
diff --git a/packages/ckeditor5-admonition/package.json b/packages/ckeditor5-admonition/package.json
deleted file mode 100644
index bc1c347443..0000000000
--- a/packages/ckeditor5-admonition/package.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "name": "@triliumnext/ckeditor5-admonition",
- "version": "1.0.0",
- "description": "Admonition (info box, warning box) feature for CKEditor 5.",
- "keywords": [
- "ckeditor",
- "ckeditor5",
- "ckeditor 5",
- "ckeditor5-feature",
- "ckeditor5-plugin",
- "ckeditor5-package-generator"
- ],
- "type": "module",
- "main": "src/index.ts",
- "engines": {
- "node": ">=18.0.0",
- "npm": ">=5.7.1"
- },
- "devDependencies": {
- "@ckeditor/ckeditor5-inspector": ">=4.1.0",
- "@vitest/browser": "4.1.10",
- "ckeditor5": "48.3.1",
- "eslint": "10.8.0",
- "eslint-config-ckeditor5": ">=9.1.0",
- "stylelint": "17.14.1",
- "stylelint-config-ckeditor5": ">=9.1.0",
- "typescript": "6.0.3",
- "vite-plugin-svgo": "2.0.0",
- "vitest": "4.1.10",
- "webdriverio": "9.30.0"
- },
- "peerDependencies": {
- "ckeditor5": "48.3.1"
- },
- "author": "Elian Doran <[email protected]>",
- "license": "GPL-2.0-or-later",
- "scripts": {
- "lint": "eslint \"**/*.{js,ts}\" --quiet",
- "stylelint": "stylelint --quiet --allow-empty-input 'theme/**/*.css'",
- "test": "vitest",
- "test:debug": "vitest --inspect-brk --no-file-parallelism --browser.headless=false"
- }
-}
diff --git a/packages/ckeditor5-admonition/sample/ckeditor.ts b/packages/ckeditor5-admonition/sample/ckeditor.ts
deleted file mode 100644
index 146af2a413..0000000000
--- a/packages/ckeditor5-admonition/sample/ckeditor.ts
+++ /dev/null
@@ -1,113 +0,0 @@
-declare global {
- interface Window {
- editor: ClassicEditor;
- }
-}
-
-import {
- ClassicEditor,
- Autoformat,
- Base64UploadAdapter,
- BlockQuote,
- Bold,
- Code,
- CodeBlock,
- Essentials,
- Heading,
- Image,
- ImageCaption,
- ImageStyle,
- ImageToolbar,
- ImageUpload,
- Indent,
- Italic,
- Link,
- List,
- MediaEmbed,
- Paragraph,
- Table,
- TableToolbar
-} from 'ckeditor5';
-
-import CKEditorInspector from '@ckeditor/ckeditor5-inspector';
-
-import Admonition from '../src/admonition.js';
-
-import 'ckeditor5/ckeditor5.css';
-
-ClassicEditor
- .create( document.getElementById( 'editor' )!, {
- licenseKey: 'GPL',
- plugins: [
- Admonition,
- Essentials,
- Autoformat,
- BlockQuote,
- Bold,
- Heading,
- Image,
- ImageCaption,
- ImageStyle,
- ImageToolbar,
- ImageUpload,
- Indent,
- Italic,
- Link,
- List,
- MediaEmbed,
- Paragraph,
- Table,
- TableToolbar,
- CodeBlock,
- Code,
- Base64UploadAdapter
- ],
- toolbar: [
- 'undo',
- 'redo',
- '|',
- 'admonition',
- '|',
- 'heading',
- '|',
- 'bold',
- 'italic',
- 'link',
- 'code',
- 'bulletedList',
- 'numberedList',
- '|',
- 'outdent',
- 'indent',
- '|',
- 'uploadImage',
- 'blockQuote',
- 'insertTable',
- 'mediaEmbed',
- 'codeBlock'
- ],
- image: {
- toolbar: [
- 'imageStyle:inline',
- 'imageStyle:block',
- 'imageStyle:side',
- '|',
- 'imageTextAlternative'
- ]
- },
- table: {
- contentToolbar: [
- 'tableColumn',
- 'tableRow',
- 'mergeTableCells'
- ]
- }
- } )
- .then( editor => {
- window.editor = editor;
- CKEditorInspector.attach( editor );
- window.console.log( 'CKEditor 5 is ready.', editor );
- } )
- .catch( err => {
- window.console.error( err.stack );
- } );
diff --git a/packages/ckeditor5-admonition/sample/dll.html b/packages/ckeditor5-admonition/sample/dll.html
deleted file mode 100644
index 7956bfc929..0000000000
--- a/packages/ckeditor5-admonition/sample/dll.html
+++ /dev/null
@@ -1,172 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <link rel="icon" type="image/png" href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/favicons/32x32.png" sizes="32x32">
- <meta charset="utf-8">
- <title>CKEditor 5 – DLL Sample</title>
- <style>
- body {
- max-width: 800px;
- margin: 20px auto;
- }
- </style>
-</head>
-<body>
-
-<h1>CKEditor 5 – DLL Sample</h1>
-
-<div id="editor">
- <h2>Production sample</h2>
- <p>
- This is a demo of the <a href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/overview.html#classic-editor">classic editor
- build</a>, initialized using the <a href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/development/dll-builds.html">DLL builds</a>.
- </p>
- <p>
- Your plugin (Admonition) generated by the tool is already loaded into the editor. By default, it has an example button that adds some text to the editor. Whenever you change the plugin's name or toolbar items, make sure to update the editor configuration in the <code>sample/dll.html</code> file.
- </p>
-
- <h3>Uncaught TypeError</h3>
- <p>If the editor is not initialized correctly and the browser console displays an error such as the following:</p>
- <pre><code>Uncaught TypeError: Cannot read properties of undefined (reading 'Admonition') at dll.html:85</code></pre>
- <p>it means that the DLL build of the <code>@triliumnext/ckeditor5-admonition</code> package has not been created.</p>
- <p>Please call the <code>npm run dll:build</code> command in the CLI, and after it finishes, refresh the page.</p>
-
- <h3>Anatomy of the DLL build</h3>
- <p>The source of the DLL build is located in the <code>src/index.ts</code> file. It may export as many things as the package offers.</p>
-
- <h4>Maintaining the sample</h4>
- <p>Whenever you change objects exported by the DLL build, please review the content of the sample. Things to keep in mind:</p>
- <ul>
- <li>Review the list of loaded plugins in the configuration.</li>
- <li>Review names of items registered in toolbars.</li>
- </ul>
-
- <h3>The goal</h3>
- <p>The primary purpose of the sample is to verify whether the plugins in the package will work together with CKEditor 5 created with the DLL approach.</p>
-
- <h3>Publishing the package</h3>
- <p>
- While releasing TypeScript package on npm, few things have to be taken care of:
- </p>
- <ul>
- <li>Building DLL</li>
- <li>Building TypeScript</li>
- <li>Changing the <code>main</code> filed in <code>package.json</code> to <code>.js</code> extension</li>
- </ul>
- <p>
- Likewise, after the release, there are few steps:
- </p>
- <ul>
- <li>Deleting compiled TypeScript files (they are generated in the <code>src</code> directory, and create needless clutter)</li>
- <li>Changing the <code>main</code> filed in <code>package.json</code> back to <code>.ts</code> extension</li>
- </ul>
- <p>
- When calling <code>npm publish</code>, those steps are handled automatically by predefined <code>prepublishOnly</code> and <code>postpublish</code> scripts. To learn more, see <a href="https://docs.npmjs.com/cli/v7/using-npm/scripts#pre--post-scripts">NPM docs</a>.
- </p>
-
- <h3>Reporting issues</h3>
- <p>If you found a problem with CKEditor 5 or the package generator, please, report an issue:</p>
- <ul>
- <li><a href="https://github.com/ckeditor/ckeditor5/issues/new/choose">CKEditor 5</a></li>
- <li><a href="https://github.com/ckeditor/create-ckeditor5-plugin/issues/new">The package generator</a></li>
- </ul>
-</div>
-
-<!-- DLL builds are served from the `node_modules/` directory -->
-<script src="../node_modules/ckeditor5/build/ckeditor5-dll.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-editor-classic/build/editor-classic.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-code-block/build/code-block.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-essentials/build/essentials.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-basic-styles/build/basic-styles.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-heading/build/heading.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-autoformat/build/autoformat.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-block-quote/build/block-quote.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-image/build/image.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-link/build/link.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-indent/build/indent.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-media-embed/build/media-embed.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-list/build/list.js"></script>
-<script src="../node_modules/@ckeditor/ckeditor5-table/build/table.js"></script>
-
-<!-- The "@triliumnext/ckeditor5-admonition" package DLL build is served from the `build/` directory -->
-<script src="../build/admonition.js"></script>
-
-<script>
- console.log( 'Objects exported by the DLL build:', CKEditor5[ 'admonition' ] );
-
- CKEditor5.editorClassic.ClassicEditor
- .create( document.querySelector( '#editor' ), {
- plugins: [
- CKEditor5[ 'admonition' ].Admonition,
- CKEditor5.essentials.Essentials,
- CKEditor5.autoformat.Autoformat,
- CKEditor5.blockQuote.BlockQuote,
- CKEditor5.basicStyles.Bold,
- CKEditor5.heading.Heading,
- CKEditor5.image.Image,
- CKEditor5.image.ImageCaption,
- CKEditor5.image.ImageStyle,
- CKEditor5.image.ImageToolbar,
- CKEditor5.image.ImageUpload,
- CKEditor5.indent.Indent,
- CKEditor5.basicStyles.Italic,
- CKEditor5.link.Link,
- CKEditor5.list.List,
- CKEditor5.mediaEmbed.MediaEmbed,
- CKEditor5.paragraph.Paragraph,
- CKEditor5.table.Table,
- CKEditor5.table.TableToolbar,
- CKEditor5.codeBlock.CodeBlock,
- CKEditor5.basicStyles.Code,
- CKEditor5.upload.Base64UploadAdapter
- ],
- toolbar: [
- 'admonition',
- '|',
- 'heading',
- '|',
- 'bold',
- 'italic',
- 'link',
- 'code',
- 'bulletedList',
- 'numberedList',
- '|',
- 'outdent',
- 'indent',
- '|',
- 'uploadImage',
- 'blockQuote',
- 'insertTable',
- 'mediaEmbed',
- 'codeBlock',
- '|',
- 'undo',
- 'redo'
- ],
- image: {
- toolbar: [
- 'imageStyle:inline',
- 'imageStyle:block',
- 'imageStyle:side',
- '|',
- 'imageTextAlternative'
- ]
- },
- table: {
- contentToolbar: [
- 'tableColumn',
- 'tableRow',
- 'mergeTableCells'
- ]
- }
- } )
- .then( editor => {
- window.editor = editor;
- } )
- .catch( error => {
- console.error( 'There was a problem initializing the editor.', error );
- } );
-</script>
-</body>
-</html>
diff --git a/packages/ckeditor5-admonition/sample/index.html b/packages/ckeditor5-admonition/sample/index.html
deleted file mode 100644
index 090ab66ac2..0000000000
--- a/packages/ckeditor5-admonition/sample/index.html
+++ /dev/null
@@ -1,123 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
- <link rel="icon" type="image/png" href="https://ckeditor.com/docs/ckeditor5/latest/assets/img/favicons/32x32.png"
- sizes="32x32">
- <meta charset="utf-8">
- <title>CKEditor 5 – Development Sample</title>
- <style>
- body {
- max-width: 800px;
- margin: 20px auto;
- }
- </style>
-</head>
-
-<body>
-
- <h1>CKEditor 5 – Development Sample</h1>
-
- <div id="editor">
- <h2>Development environment</h2>
- <p>
- This is a demo of the <a
- href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/overview.html#classic-editor">classic
- editor
- build</a> that loads your plugin (<code>Admonition</code>) generated by the
- tool. You can modify this
- sample and use it to validate whether a plugin or a set of plugins work fine.
- </p>
- <p>
- <code>Admonition</code> inserts text into the editor. You can click the
- CKEditor 5 icon in the toolbar and see the results.
- </p>
-
- <h3>Helpful resources</h3>
- <ul>
- <li>Architecture
- <ul>
- <li>
- <a
- href="https://ckeditor.com/docs/ckeditor5/latest/framework/guides/architecture/core-editor-architecture.html">Core
- editor architecture</a>
- </li>
- </ul>
- <ul>
- <li>
- <a
- href="https://ckeditor.com/docs/ckeditor5/latest/framework/guides/architecture/editing-engine.html">The
- editing engine</a>
- </li>
- </ul>
- <ul>
- <li>
- <a
- href="https://ckeditor.com/docs/ckeditor5/latest/framework/guides/architecture/ui-library.html">The
- UI library</a>
- </li>
- </ul>
- </li>
-
- <li>
- <a
- href="https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/browser-compatibility.html">Browser
- compatibility</a>
- </li>
-
- <li>
- <a href="https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html">The error
- codes</a>
- </li>
-
- <li><a href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/development/dll-builds.html">The DLL
- builds</a></li>
- </ul>
-
- <h3>The directory structure</h3>
-
- <p>
- The code snippet below presents the directory structure.
- </p>
-
- <pre><code class="language-plaintext">.
-├─ lang
-│ └─ contexts.json # Entries used for creating translations.
-├─ sample
-│ ├─ dll.html # The editor initialized using the DLL builds. Check README for details.
-│ ├─ index.html # The currently displayed file.
-│ └─ ckeditor.ts # The editor initialization script.
-├─ src
-│ ├─ admonition.ts
-│ ├─ augmentation.ts # Type augmentations for the `@ckeditor/ckeditor5-core` module. Read more in <a href="https://ckeditor.com/docs/ckeditor5/latest/api/module_core_plugincollection-PluginsMap.html">PluginsMap</a> and <a href="https://ckeditor.com/docs/ckeditor5/latest/api/module_core_commandcollection-CommandsMap.html">CommandsMap</a>.
-│ ├─ index.ts # The modules exported by the package when using the DLL builds.
-│ └─ **/*.ts # All TypeScript source files should be saved here.
-├─ tests
-│ ├─ admonition.ts
-│ ├─ index.ts # Tests for the plugin.
-│ └─ **/*.ts # All tests should be saved here.
-├─ theme
-│ ├─ icons
-│ │ ├─ ckeditor.svg # The CKEditor 5 icon displayed in the toolbar.
-│ │ └─ **/*.svg # All icon files should be saved here.
-│ └─ **/*.css # All CSS files should be saved here.
-├─ typings
-│ └─ **/*.d.ts # Files containing type definitions.
-├─ .editorconfig
-├─ ...
-├─ README.md
-└─ tsconfig.json # TypeScript configuration file.</code></pre>
-
- <h3>Reporting issues</h3>
- <p>If you found a problem with CKEditor 5 or the package generator, please, report an issue:</p>
- <ul>
- <li><a href="https://github.com/ckeditor/ckeditor5/issues/new/choose">CKEditor 5</a></li>
- <li><a href="https://github.com/ckeditor/ckeditor5-package-generator/issues/new">The package generator</a>
- </li>
- </ul>
- </div>
-
- <script src="./ckeditor.dist.js"></script>
-</body>
-
-</html>
diff --git a/packages/ckeditor5-admonition/src/admonition.ts b/packages/ckeditor5-admonition/src/admonition.ts
deleted file mode 100644
index 33cbf25286..0000000000
--- a/packages/ckeditor5-admonition/src/admonition.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Plugin } from 'ckeditor5';
-
-import AdmonitionEditing from './admonitionediting.js';
-import AdmonitionUI from './admonitionui.js';
-import AdmonitionAutoformat from './admonitionautoformat.js';
-
-export default class Admonition extends Plugin {
-
- public static get requires() {
- return [ AdmonitionEditing, AdmonitionUI, AdmonitionAutoformat ] as const;
- }
-
- public static get pluginName() {
- return 'Admonition' as const;
- }
-
-}
diff --git a/packages/ckeditor5-admonition/src/admonitionautoformat.ts b/packages/ckeditor5-admonition/src/admonitionautoformat.ts
deleted file mode 100644
index 9179aabaa0..0000000000
--- a/packages/ckeditor5-admonition/src/admonitionautoformat.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Autoformat, blockAutoformatEditing, Plugin } from "ckeditor5";
-import { AdmonitionType, ADMONITION_TYPES } from "./admonitioncommand.js";
-
-function tryParseAdmonitionType(match: RegExpMatchArray) {
- if (match.length !== 2) {
- return;
- }
-
- if ((ADMONITION_TYPES as readonly string[]).includes(match[1])) {
- return match[1] as AdmonitionType;
- }
-}
-
-export default class AdmonitionAutoformat extends Plugin {
-
- static get requires() {
- return [ Autoformat ];
- }
-
- afterInit() {
- if (!this.editor.commands.get("admonition")) {
- return;
- }
-
- const instance = (this as any);
- blockAutoformatEditing(this.editor, instance, /^\!\!\[*\! (.+) $/, ({ match }) => {
- const type = tryParseAdmonitionType(match);
-
- if (type) {
- // User has entered the admonition type, so we insert as-is.
- this.editor.execute("admonition", { forceValue: type });
- } else {
- // User has not entered a valid type, assume it's part of the text of the admonition.
- this.editor.execute("admonition");
- if (match.length > 1) {
- this.editor.execute("insertText", { text: (match[1] ?? "") + " " });
- }
- }
- });
- }
-}
diff --git a/packages/ckeditor5-admonition/src/admonitioncommand.ts b/packages/ckeditor5-admonition/src/admonitioncommand.ts
deleted file mode 100644
index 35456efbc5..0000000000
--- a/packages/ckeditor5-admonition/src/admonitioncommand.ts
+++ /dev/null
@@ -1,275 +0,0 @@
-/**
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
-
-/**
- * @module admonition/admonitioncommand
- */
-
-import { Command, first } from 'ckeditor5';
-import type { ModelElement, ModelPosition, ModelRange, ModelSchema, ModelWriter, ModelDocumentFragment } from 'ckeditor5';
-
-/**
- * The block quote command plugin.
- *
- * @extends module:core/command~Command
- */
-
-export const ADMONITION_TYPES = [ "note", "tip", "important", "caution", "warning" ] as const;
-export const ADMONITION_TYPE_ATTRIBUTE = "admonitionType";
-export const DEFAULT_ADMONITION_TYPE = ADMONITION_TYPES[0];
-export type AdmonitionType = typeof ADMONITION_TYPES[number];
-
-interface ExecuteOpts {
- /**
- * If set, it will force the command behavior. If `true`, the command will apply a block quote,
- * otherwise the command will remove the block quote. If not set, the command will act basing on its current value.
- */
- forceValue?: AdmonitionType;
- /**
- * If set to true and `forceValue` is not specified, the command will apply the previous admonition type (if the command was already executed).
- */
- usePreviousChoice?: boolean
-}
-
-export default class AdmonitionCommand extends Command {
- /**
- * Whether the selection starts in a block quote.
- *
- * @observable
- * @readonly
- */
- declare public value: AdmonitionType | false;
-
- private _lastType?: AdmonitionType;
-
- /**
- * @inheritDoc
- */
- public override refresh(): void {
- this.value = this._getValue();
- this.isEnabled = this._checkEnabled();
- }
-
- /**
- * Executes the command. When the command {@link #value is on}, all top-most block quotes within
- * the selection will be removed. If it is off, all selected blocks will be wrapped with
- * a block quote.
- *
- * @fires execute
- * @param options Command options.
- */
- public override execute( options: ExecuteOpts = {} ): void {
- const model = this.editor.model;
- const schema = model.schema;
- const selection = model.document.selection;
-
- const blocks = Array.from( selection.getSelectedBlocks() );
-
- const value = this._getType(options);
-
- model.change( writer => {
- if ( !value ) {
- this._removeQuote( writer, blocks.filter( findQuote ) );
- } else {
- const blocksToQuote = blocks.filter( block => {
- // Already quoted blocks needs to be considered while quoting too
- // in order to reuse their <bQ> elements.
- return findQuote( block ) || checkCanBeQuoted( schema, block );
- } );
-
- this._applyQuote( writer, blocksToQuote, value);
- }
- } );
- }
-
- private _getType(options: ExecuteOpts): AdmonitionType | false {
- const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
-
- // Allow removing the admonition.
- if (!value) {
- return false;
- }
-
- // Prefer the type from the command, if any.
- if (typeof value === "string") {
- return value;
- }
-
- // See if we can restore the previous language.
- if (options.usePreviousChoice && this._lastType) {
- return this._lastType;
- }
-
- // Otherwise return a default.
- return "note";
- }
-
- /**
- * Checks the command's {@link #value}.
- */
- private _getValue(): AdmonitionType | false {
- const selection = this.editor.model.document.selection;
- const firstBlock = first( selection.getSelectedBlocks() );
- if (!firstBlock) {
- return false;
- }
-
- // In the current implementation, the admonition must be an immediate parent of a block element.
- const firstQuote = findQuote( firstBlock );
- if (firstQuote?.is("element")) {
- return firstQuote.getAttribute(ADMONITION_TYPE_ATTRIBUTE) as AdmonitionType;
- }
-
- return false;
- }
-
- /**
- * Checks whether the command can be enabled in the current context.
- *
- * @returns Whether the command should be enabled.
- */
- private _checkEnabled(): boolean {
- if ( this.value ) {
- return true;
- }
-
- const selection = this.editor.model.document.selection;
- const schema = this.editor.model.schema;
-
- const firstBlock = first( selection.getSelectedBlocks() );
-
- if ( !firstBlock ) {
- return false;
- }
-
- return checkCanBeQuoted( schema, firstBlock );
- }
-
- /**
- * Removes the quote from given blocks.
- *
- * If blocks which are supposed to be "unquoted" are in the middle of a quote,
- * start it or end it, then the quote will be split (if needed) and the blocks
- * will be moved out of it, so other quoted blocks remained quoted.
- */
- private _removeQuote( writer: ModelWriter, blocks: Array<ModelElement> ): void {
- // Unquote all groups of block. Iterate in the reverse order to not break following ranges.
- getRangesOfBlockGroups( writer, blocks ).reverse().forEach( groupRange => {
- if ( groupRange.start.isAtStart && groupRange.end.isAtEnd ) {
- writer.unwrap( groupRange.start.parent as ModelElement );
-
- return;
- }
-
- // The group of blocks are at the beginning of an <bQ> so let's move them left (out of the <bQ>).
- if ( groupRange.start.isAtStart ) {
- const positionBefore = writer.createPositionBefore( groupRange.start.parent as ModelElement );
-
- writer.move( groupRange, positionBefore );
-
- return;
- }
-
- // The blocks are in the middle of an <bQ> so we need to split the <bQ> after the last block
- // so we move the items there.
- if ( !groupRange.end.isAtEnd ) {
- writer.split( groupRange.end );
- }
-
- // Now we are sure that groupRange.end.isAtEnd is true, so let's move the blocks right.
-
- const positionAfter = writer.createPositionAfter( groupRange.end.parent as ModelElement );
-
- writer.move( groupRange, positionAfter );
- } );
- }
-
- /**
- * Applies the quote to given blocks.
- */
- private _applyQuote( writer: ModelWriter, blocks: Array<ModelElement>, type?: AdmonitionType): void {
- this._lastType = type;
- const quotesToMerge: Array<ModelElement | ModelDocumentFragment> = [];
-
- // Quote all groups of block. Iterate in the reverse order to not break following ranges.
- getRangesOfBlockGroups( writer, blocks ).reverse().forEach( groupRange => {
- let quote = findQuote( groupRange.start );
-
- if ( !quote ) {
- const attributes: Record<string, unknown> = {};
- attributes[ADMONITION_TYPE_ATTRIBUTE] = type;
- quote = writer.createElement( 'aside', attributes);
-
- writer.wrap( groupRange, quote );
- } else if (quote.is("element")) {
- this.editor.model.change((writer) => {
- writer.setAttribute(ADMONITION_TYPE_ATTRIBUTE, type, quote as ModelElement);
- });
- }
-
- quotesToMerge.push( quote );
- } );
-
- // Merge subsequent <bQ> elements. Reverse the order again because this time we want to go through
- // the <bQ> elements in the source order (due to how merge works – it moves the right element's content
- // to the first element and removes the right one. Since we may need to merge a couple of subsequent `<bQ>` elements
- // we want to keep the reference to the first (furthest left) one.
- quotesToMerge.reverse().reduce( ( currentQuote, nextQuote ) => {
- if ( currentQuote.nextSibling == nextQuote ) {
- writer.merge( writer.createPositionAfter( currentQuote ) );
-
- return currentQuote;
- }
-
- return nextQuote;
- } );
- }
-}
-
-function findQuote( elementOrPosition: ModelElement | ModelPosition ): ModelElement | ModelDocumentFragment | null {
- return elementOrPosition.parent!.name == 'aside' ? elementOrPosition.parent : null;
-}
-
-/**
- * Returns a minimal array of ranges containing groups of subsequent blocks.
- *
- * content: abcdefgh
- * blocks: [ a, b, d, f, g, h ]
- * output ranges: [ab]c[d]e[fgh]
- */
-function getRangesOfBlockGroups( writer: ModelWriter, blocks: Array<ModelElement> ): Array<ModelRange> {
- let startPosition;
- let i = 0;
- const ranges = [];
-
- while ( i < blocks.length ) {
- const block = blocks[ i ];
- const nextBlock = blocks[ i + 1 ];
-
- if ( !startPosition ) {
- startPosition = writer.createPositionBefore( block );
- }
-
- if ( !nextBlock || block.nextSibling != nextBlock ) {
- ranges.push( writer.createRange( startPosition, writer.createPositionAfter( block ) ) );
- startPosition = null;
- }
-
- i++;
- }
-
- return ranges;
-}
-
-/**
- * Checks whether <bQ> can wrap the block.
- */
-function checkCanBeQuoted( schema: ModelSchema, block: ModelElement ): boolean {
- // TMP will be replaced with schema.checkWrap().
- const isBQAllowed = schema.checkChild( block.parent as ModelElement, 'aside' );
- const isBlockAllowedInBQ = schema.checkChild( [ '$root', 'aside' ], block );
-
- return isBQAllowed && isBlockAllowedInBQ;
-}
diff --git a/packages/ckeditor5-admonition/src/admonitionediting.ts b/packages/ckeditor5-admonition/src/admonitionediting.ts
deleted file mode 100644
index 30fa260290..0000000000
--- a/packages/ckeditor5-admonition/src/admonitionediting.ts
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
-
-/**
- * @module admonition/admonitionediting
- */
-
-import { Delete, Enter, Plugin, ViewDocumentDeleteEvent, ViewDocumentEnterEvent } from 'ckeditor5';
-import AdmonitionCommand, { AdmonitionType, ADMONITION_TYPES, DEFAULT_ADMONITION_TYPE, ADMONITION_TYPE_ATTRIBUTE } from './admonitioncommand.js';
-
-/**
- * The block quote editing.
- *
- * Introduces the `'admonition'` command and the `'aside'` model element.
- *
- * @extends module:core/plugin~Plugin
- */
-export default class AdmonitionEditing extends Plugin {
- /**
- * @inheritDoc
- */
- public static get pluginName() {
- return 'AdmonitionEditing' as const;
- }
-
- /**
- * @inheritDoc
- */
- public static get requires() {
- return [ Enter, Delete ] as const;
- }
-
- /**
- * @inheritDoc
- */
- public init(): void {
- const editor = this.editor;
- const schema = editor.model.schema;
-
- editor.commands.add( 'admonition', new AdmonitionCommand( editor ) );
-
- schema.register( 'aside', {
- inheritAllFrom: '$container',
- allowAttributes: ADMONITION_TYPE_ATTRIBUTE
- } );
-
- editor.conversion.for("upcast").elementToElement({
- view: {
- name: "aside",
- classes: "admonition",
- },
- model: (viewElement, { writer }) => {
- let type: AdmonitionType = DEFAULT_ADMONITION_TYPE;
- for (const className of viewElement.getClassNames()) {
- if (className !== "admonition" && (ADMONITION_TYPES as readonly string[]).includes(className)) {
- type = className as AdmonitionType;
- }
- }
-
- const attributes: Record<string, unknown> = {};
- attributes[ADMONITION_TYPE_ATTRIBUTE] = type;
- return writer.createElement("aside", attributes);
- }
- });
-
- editor.conversion.for("downcast")
- .elementToElement( {
- model: 'aside',
- view: "aside"
- })
- .attributeToAttribute({
- model: ADMONITION_TYPE_ATTRIBUTE,
- view: (value) => ({
- key: "class",
- value: [ "admonition", value as string ]
- })
- });
-
- // Postfixer which cleans incorrect model states connected with block quotes.
- editor.model.document.registerPostFixer( writer => {
- const changes = editor.model.document.differ.getChanges();
-
- for ( const entry of changes ) {
- if ( entry.type == 'insert' ) {
- const element = entry.position.nodeAfter;
-
- if ( !element ) {
- // We are inside a text node.
- continue;
- }
-
- if ( element.is( 'element', 'aside' ) && element.isEmpty ) {
- // Added an empty aside - remove it.
- writer.remove( element );
-
- return true;
- } else if ( element.is( 'element', 'aside' ) && !schema.checkChild( entry.position, element ) ) {
- // Added a aside in incorrect place. Unwrap it so the content inside is not lost.
- writer.unwrap( element );
-
- return true;
- } else if ( element.is( 'element' ) ) {
- // Just added an element. Check that all children meet the scheme rules.
- const range = writer.createRangeIn( element );
-
- for ( const child of range.getItems() ) {
- if (
- child.is( 'element', 'aside' ) &&
- !schema.checkChild( writer.createPositionBefore( child ), child )
- ) {
- writer.unwrap( child );
-
- return true;
- }
- }
- }
- } else if ( entry.type == 'remove' ) {
- const parent = entry.position.parent;
-
- if ( parent.is( 'element', 'aside' ) && parent.isEmpty ) {
- // Something got removed and now aside is empty. Remove the aside as well.
- writer.remove( parent );
-
- return true;
- }
- }
- }
-
- return false;
- } );
-
- const viewDocument = this.editor.editing.view.document;
- const selection = editor.model.document.selection;
- const admonitionCommand = editor.commands.get( 'admonition' );
- if (!admonitionCommand) {
- return;
- }
-
- // Overwrite default Enter key behavior.
- // If Enter key is pressed with selection collapsed in empty block inside a quote, break the quote.
- this.listenTo<ViewDocumentEnterEvent>( viewDocument, 'enter', ( evt, data ) => {
- if ( !selection.isCollapsed || !admonitionCommand.value ) {
- return;
- }
-
- const positionParent = selection.getLastPosition()!.parent;
-
- if ( positionParent.isEmpty ) {
- editor.execute( 'admonition' );
- editor.editing.view.scrollToTheSelection();
-
- data.preventDefault();
- evt.stop();
- }
- }, { context: 'aside' } );
-
- // Overwrite default Backspace key behavior.
- // If Backspace key is pressed with selection collapsed in first empty block inside a quote, break the quote.
- this.listenTo<ViewDocumentDeleteEvent>( viewDocument, 'delete', ( evt, data ) => {
- if ( data.direction != 'backward' || !selection.isCollapsed || !admonitionCommand!.value ) {
- return;
- }
-
- const positionParent = selection.getLastPosition()!.parent;
-
- if ( positionParent.isEmpty && !positionParent.previousSibling ) {
- editor.execute( 'admonition' );
- editor.editing.view.scrollToTheSelection();
-
- data.preventDefault();
- evt.stop();
- }
- }, { context: 'aside' } );
- }
-}
diff --git a/packages/ckeditor5-admonition/src/admonitionui.ts b/packages/ckeditor5-admonition/src/admonitionui.ts
deleted file mode 100644
index ec765ecced..0000000000
--- a/packages/ckeditor5-admonition/src/admonitionui.ts
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
-
-/**
- * @module admonition/admonitionui
- */
-
-import { Plugin, addListToDropdown, createDropdown, ListDropdownItemDefinition, SplitButtonView, ViewModel } from 'ckeditor5';
-
-import '../theme/blockquote.css';
-import admonitionIcon from '../theme/icons/admonition.svg?raw';
-import { AdmonitionType } from './admonitioncommand.js';
-import { Collection } from 'ckeditor5';
-
-interface AdmonitionDefinition {
- title: string;
-}
-
-export const ADMONITION_TYPES: Record<AdmonitionType, AdmonitionDefinition> = {
- note: {
- title: "Note"
- },
- tip: {
- title: "Tip"
- },
- important: {
- title: "Important"
- },
- caution: {
- title: "Caution"
- },
- warning: {
- title: "Warning"
- }
-};
-
-/**
- * The block quote UI plugin.
- *
- * It introduces the `'admonition'` button.
- *
- * @extends module:core/plugin~Plugin
- */
-export default class AdmonitionUI extends Plugin {
- /**
- * @inheritDoc
- */
- public static get pluginName() {
- return 'AdmonitionUI' as const;
- }
-
- /**
- * @inheritDoc
- */
- public init(): void {
- const editor = this.editor;
-
- editor.ui.componentFactory.add( 'admonition', () => {
- const buttonView = this._createButton();
-
- return buttonView;
- } );
- }
-
- /**
- * Creates a button for admonition command to use either in toolbar or in menu bar.
- */
- private _createButton() {
- const editor = this.editor;
- const locale = editor.locale;
- const command = editor.commands.get( 'admonition' )!;
- const dropdownView = createDropdown(locale, SplitButtonView);
- const splitButtonView = dropdownView.buttonView;
- const t = locale.t;
-
- addListToDropdown(dropdownView, this._getDropdownItems())
-
- // Button configuration.
- splitButtonView.set( {
- label: t( 'Admonition' ),
- icon: admonitionIcon,
- isToggleable: true,
- tooltip: true
- } );
- splitButtonView.on("execute", () => {
- editor.execute("admonition", { usePreviousChoice: true });
- editor.editing.view.focus();
- });
- splitButtonView.bind( 'isOn' ).to( command, 'value', value => (!!value) as boolean);
-
- // Dropdown configuration
- dropdownView.bind( 'isEnabled' ).to( command, 'isEnabled' );
- dropdownView.on("execute", evt => {
- editor.execute("admonition", { forceValue: ( evt.source as any ).commandParam } );
- editor.editing.view.focus();
- });
-
- return dropdownView;
- }
-
- private _getDropdownItems() {
- const itemDefinitions = new Collection<ListDropdownItemDefinition>();
- const command = this.editor.commands.get("admonition");
- if (!command) {
- return itemDefinitions;
- }
-
- for (const [ type, admonition ] of Object.entries(ADMONITION_TYPES)) {
- const definition: ListDropdownItemDefinition = {
- type: "button",
- model: new ViewModel({
- commandParam: type,
- label: admonition.title,
- class: `ck-tn-admonition-option ck-tn-admonition-${type}`,
- role: 'menuitemradio',
- withText: true
- })
- }
-
- definition.model.bind("isOn").to(command, "value", currentType => currentType === type);
- itemDefinitions.add(definition);
- }
-
- return itemDefinitions;
- }
-}
diff --git a/packages/ckeditor5-admonition/src/augmentation.ts b/packages/ckeditor5-admonition/src/augmentation.ts
deleted file mode 100644
index 200ee650be..0000000000
--- a/packages/ckeditor5-admonition/src/augmentation.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import AdmonitionCommand from './admonitioncommand.js';
-import AdmonitionEditing from './admonitionediting.js';
-import AdmonitionUI from './admonitionui.js';
-import type { Admonition } from './index.js';
-
-declare module 'ckeditor5' {
- interface PluginsMap {
- [ Admonition.pluginName ]: Admonition;
- [ AdmonitionEditing.pluginName ]: AdmonitionEditing;
- [ AdmonitionUI.pluginName ]: AdmonitionUI;
- }
-
- interface CommandsMap {
- admonition: AdmonitionCommand;
- }
-
-}
diff --git a/packages/ckeditor5-admonition/src/index.ts b/packages/ckeditor5-admonition/src/index.ts
deleted file mode 100644
index 23716647d3..0000000000
--- a/packages/ckeditor5-admonition/src/index.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import admonitionIcon from '../theme/icons/admonition.svg?raw';
-import './augmentation.js';
-import "../theme/blockquote.css";
-
-export { default as Admonition } from './admonition.js';
-export { default as AdmonitionEditing } from './admonitionediting.js';
-export { default as AdmonitionUI, ADMONITION_TYPES } from './admonitionui.js';
-export { default as AdmonitionAutoformat } from './admonitionautoformat.js';
-export type { default as AdmonitionCommand, AdmonitionType } from './admonitioncommand.js';
-
-export const icons = {
- admonitionIcon
-};
diff --git a/packages/ckeditor5-admonition/tsconfig.json b/packages/ckeditor5-admonition/tsconfig.json
deleted file mode 100644
index 303791fc66..0000000000
--- a/packages/ckeditor5-admonition/tsconfig.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "compilerOptions": {
- /**
- * TypeScript automagically loads typings from all "@types/*" packages if the "compilerOptions.types" array is not defined in
- * this file. However, if some dependencies have "@types/*" packages as their dependencies, they'll also be loaded as well.
- * As a result, TypeScript loaded "@types/node" which we don't want to use, because it allows using Node.js specific APIs that
- * are not available in the browsers.
- *
- * To avoid such issues, we defined this empty "types" to disable automatic inclusion of the "@types/*" packages.
- */
- "types": [],
- "lib": [
- "ES2019", // Must match the "target".
- "ES2020.String",
- "DOM",
- "DOM.Iterable"
- ],
- "noImplicitAny": true,
- "noImplicitOverride": true,
- "composite": true,
- "strict": true,
- "target": "es2019",
- "sourceMap": true,
- "allowJs": true,
- "moduleDetection": "force",
- "moduleResolution": "NodeNext",
- "module": "NodeNext",
- "skipLibCheck": true,
- "noUncheckedSideEffectImports": false,
- "outDir": "out-tsc",
- "typeRoots": [
- "typings",
- "node_modules/@types"
- ]
- },
- "include": [
- "./sample",
- "./src",
- "./typings"
- ]
-}
diff --git a/packages/ckeditor5-admonition/tsconfig.test.json b/packages/ckeditor5-admonition/tsconfig.test.json
deleted file mode 100644
index 065d98e49b..0000000000
--- a/packages/ckeditor5-admonition/tsconfig.test.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "extends": "./tsconfig.json",
- "compilerOptions": {
- "types": [
- "@types/mocha"
- ],
- "sourceMap": true
- },
- "include": [
- "./sample",
- "./src",
- "./tests",
- "./typings"
- ]
-}
diff --git a/packages/ckeditor5-admonition/typings/ckeditor5-inspector.d.ts b/packages/ckeditor5-admonition/typings/ckeditor5-inspector.d.ts
deleted file mode 100644
index d50ee49c45..0000000000
--- a/packages/ckeditor5-admonition/typings/ckeditor5-inspector.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-declare module '@ckeditor/ckeditor5-inspector' {
- const inspector: {
- attach( editor: any ): void;
- };
-
- export default inspector;
-}
diff --git a/packages/ckeditor5-admonition/typings/types.d.ts b/packages/ckeditor5-admonition/typings/types.d.ts
deleted file mode 100644
index 09be57e1c9..0000000000
--- a/packages/ckeditor5-admonition/typings/types.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare module '*.svg?raw' {
- const content: string;
- export default content;
-}
diff --git a/packages/ckeditor5-admonition/vitest.config.ts b/packages/ckeditor5-admonition/vitest.config.ts
deleted file mode 100644
index 38ec41e75b..0000000000
--- a/packages/ckeditor5-admonition/vitest.config.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * @license Copyright (c) 2023-2024, CKSource Holding sp. z o.o. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-import { defineConfig } from 'vitest/config';
-import svg from 'vite-plugin-svgo';
-
-export default defineConfig( {
- plugins: [
- svg()
- ],
- test: {
- environment: "happy-dom",
- include: [
- 'tests/**/*.[jt]s'
- ],
- globals: true,
- watch: false,
- passWithNoTests: true,
- coverage: {
- provider: "v8",
- include: ["src/**/*.{ts,tsx}"],
- exclude: ["**/*.{test,spec}.{ts,mts,cts,tsx,js,jsx}", "**/*.d.ts"],
- reporter: ["text", "lcov"],
- reportsDirectory: "./test-output/vitest/coverage"
- }
- }
-} );
diff --git a/packages/ckeditor5/package.json b/packages/ckeditor5/package.json
index 78389f9530..d3327016e9 100644
--- a/packages/ckeditor5/package.json
+++ b/packages/ckeditor5/package.json
@@ -15,7 +15,6 @@
},
"dependencies": {
"@triliumnext/commons": "workspace:*",
- "@triliumnext/ckeditor5-admonition": "workspace:*",
"@triliumnext/ckeditor5-collapsible": "workspace:*",
"@triliumnext/ckeditor5-utils": "workspace:*",
"@triliumnext/ckeditor5-footnotes": "workspace:*",
diff --git a/packages/ckeditor5/src/extra_slash_commands.spec.ts b/packages/ckeditor5/src/extra_slash_commands.spec.ts
index 0ed65ad2b7..21b4bf7a91 100644
--- a/packages/ckeditor5/src/extra_slash_commands.spec.ts
+++ b/packages/ckeditor5/src/extra_slash_commands.spec.ts
@@ -250,7 +250,7 @@ describe("buildExtraCommands", () => {
describe("admonition commands", () => {
it("includes one command per ADMONITION_TYPE with execute function", async () => {
- const { ADMONITION_TYPES } = await import("@triliumnext/ckeditor5-admonition");
+ const { ADMONITION_TYPES } = await import("./plugins/admonition/admonition_ui.js");
const commands = buildExtraCommands(t);
for (const keyword of Object.keys(ADMONITION_TYPES)) {
const cmd = commands.find((c) => c.id === keyword);
@@ -263,7 +263,7 @@ describe("buildExtraCommands", () => {
});
it("admonition execute calls editor.execute('admonition') with the keyword", async () => {
- const { ADMONITION_TYPES } = await import("@triliumnext/ckeditor5-admonition");
+ const { ADMONITION_TYPES } = await import("./plugins/admonition/admonition_ui.js");
const commands = buildExtraCommands(t);
for (const keyword of Object.keys(ADMONITION_TYPES)) {
diff --git a/packages/ckeditor5/src/extra_slash_commands.ts b/packages/ckeditor5/src/extra_slash_commands.ts
index e90280ea57..53a47591d8 100644
--- a/packages/ckeditor5/src/extra_slash_commands.ts
+++ b/packages/ckeditor5/src/extra_slash_commands.ts
@@ -10,7 +10,8 @@ import { COMMAND_NAME as INSERT_DATE_TIME_COMMAND } from './plugins/insert_date_
import { COMMAND_NAME as INTERNAL_LINK_COMMAND } from './plugins/internallink.js';
import { COMMAND_NAME as INCLUDE_NOTE_COMMAND } from './plugins/includenote.js';
import { COMMAND_NAME as MARKDOWN_IMPORT_COMMAND } from './plugins/markdownimport.js';
-import { ADMONITION_TYPES, type AdmonitionType } from '@triliumnext/ckeditor5-admonition';
+import { ADMONITION_TYPES } from "./plugins/admonition/admonition_ui.js";
+import type { AdmonitionType } from "./plugins/admonition/admonition_command.js";
import { icons as collapsibleIcons } from '@triliumnext/ckeditor5-collapsible';
import dateTimeIcon from './icons/date-time.svg?raw';
import internalLinkIcon from './icons/trilium.svg?raw';
diff --git a/packages/ckeditor5-admonition/theme/icons/admonition.svg b/packages/ckeditor5/src/icons/admonition.svg
similarity index 100%
rename from packages/ckeditor5-admonition/theme/icons/admonition.svg
rename to packages/ckeditor5/src/icons/admonition.svg
diff --git a/packages/ckeditor5/src/index.ts b/packages/ckeditor5/src/index.ts
index 7bab9403bc..d9663dff89 100644
--- a/packages/ckeditor5/src/index.ts
+++ b/packages/ckeditor5/src/index.ts
@@ -1,4 +1,8 @@
import "ckeditor5/ckeditor5.css";
+// Baseline block-quote styling from CKEditor's block-quote feature. It arrived here with the
+// admonition plugin (which was forked from block-quote) but styles `blockquote`, not admonitions —
+// the client's theme-next stylesheet overrides parts of it with `!important`.
+import "./theme/blockquote.css";
import "./theme/code_block_toolbar.css";
import "./theme/link_embed_form.css";
import { COMMON_PLUGINS, CORE_PLUGINS, POPUP_EDITOR_PLUGINS } from "./plugins.js";
diff --git a/packages/ckeditor5/src/plugins.spec.ts b/packages/ckeditor5/src/plugins.spec.ts
index 2e724679a3..49d2e2c417 100644
--- a/packages/ckeditor5/src/plugins.spec.ts
+++ b/packages/ckeditor5/src/plugins.spec.ts
@@ -1,7 +1,7 @@
import { BlockToolbar } from "ckeditor5";
import { describe, expect, it } from "vitest";
-import { Admonition } from "@triliumnext/ckeditor5-admonition";
+import Admonition from "./plugins/admonition/admonition.js";
import { COMMON_PLUGINS, CORE_PLUGINS, POPUP_EDITOR_PLUGINS } from "./plugins.js";
import CutToNotePlugin from "./plugins/cuttonote.js";
import Uploadfileplugin from "./plugins/file_upload/uploadfileplugin.js";
diff --git a/packages/ckeditor5/src/plugins.ts b/packages/ckeditor5/src/plugins.ts
index eb1e23443b..56e9f0f238 100644
--- a/packages/ckeditor5/src/plugins.ts
+++ b/packages/ckeditor5/src/plugins.ts
@@ -25,7 +25,7 @@ import Uploadfileplugin from "./plugins/file_upload/uploadfileplugin.js";
import SyntaxHighlighting from "./plugins/syntax_highlighting/index.js";
import Kbd from "./plugins/keyboard_marker/keyboard_marker.js";
import { Mermaid } from "@triliumnext/ckeditor5-mermaid";
-import { Admonition } from "@triliumnext/ckeditor5-admonition";
+import Admonition from "./plugins/admonition/admonition.js";
import { Collapsible } from "@triliumnext/ckeditor5-collapsible";
import { Footnotes } from "@triliumnext/ckeditor5-footnotes";
import { Math, AutoformatMath } from "@triliumnext/ckeditor5-math";
@@ -35,7 +35,6 @@ import ImageActions from "./plugins/image_actions.js";
import TriliumSnippets from "./plugins/snippets/snippets.js";
// import "@triliumnext/ckeditor5-mermaid/index.css";
-// import "@triliumnext/ckeditor5-admonition/index.css";
// import "@triliumnext/ckeditor5-footnotes/index.css";
// import "@triliumnext/ckeditor5-math/index.css";
import CodeBlockToolbar from "./plugins/code_block_toolbar.js";
@@ -46,8 +45,8 @@ import MoveBlockUpDownPlugin from "./plugins/move_block_updown.js";
import ScrollOnUndoRedoPlugin from "./plugins/scroll_on_undo_redo.js"
import InlineCodeNoSpellcheck from "./plugins/inline_code_no_spellcheck.js";
import InlineCodeToolbar from "./plugins/inline_code_toolbar.js";
-import AdmonitionTypeDropdown from "./plugins/admonition_type_dropdown.js";
-import AdmonitionToolbar from "./plugins/admonition_toolbar.js";
+import AdmonitionTypeDropdown from "./plugins/admonition/admonition_type_dropdown.js";
+import AdmonitionToolbar from "./plugins/admonition/admonition_toolbar.js";
import IncludeNoteBoxSizeDropdown from "./plugins/include_note_box_size_dropdown.js";
import IncludeNoteToolbar from "./plugins/include_note_toolbar.js";
import LinkEmbedToolbar from "./plugins/link_embed/link_embed_toolbar.js";
diff --git a/packages/ckeditor5/src/plugins/admonition/README.md b/packages/ckeditor5/src/plugins/admonition/README.md
new file mode 100644
index 0000000000..219a183731
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/README.md
@@ -0,0 +1,39 @@
+# Admonition
+
+Info boxes / warning boxes: an `<aside class="admonition <type>">` container holding block content,
+with five types (`note`, `tip`, `important`, `caution`, `warning`).
+
+The feature is split the usual CKEditor way:
+
+| File | Role |
+|---|---|
+| `admonition.ts` | Glue plugin; also declares the `ckeditor5` module augmentation |
+| `admonition_command.ts` | The `admonition` command — wraps/unwraps blocks, owns the type names |
+| `admonition_editing.ts` | Schema, upcast/downcast, post-fixer, Enter/Backspace break-out |
+| `admonition_ui.ts` | The split button + type dropdown, and the user-facing type titles |
+| `admonition_autoformat.ts` | `!!! <type> ` at the start of a block |
+| `admonition_toolbar.ts` | Balloon toolbar shown when the selection is inside an admonition |
+| `admonition_type_dropdown.ts` | Toolbar dropdown for switching an existing admonition's type |
+
+## Provenance
+
+Adapted from CKEditor 5's **block-quote** feature (`@ckeditor/ckeditor5-block-quote`), copyright
+CKSource Holding sp. z o.o., which Trilium forked to build admonitions on: the command, editing
+plugin and UI plugin still carry the CKSource license header, and the command's internals still
+speak in terms of "quotes". The autoformat, toolbar and type-dropdown parts are Trilium's own.
+
+It lived at `packages/ckeditor5-admonition` until it was folded into this package — it had no
+consumers outside `@triliumnext/ckeditor5`, was never published, and shipped a
+`ckeditor5-package-generator` scaffold (sample pages, its own ESLint/Stylelint/vitest configs) that
+nothing invoked. Half the feature already lived here: `admonition_toolbar.ts` and
+`admonition_type_dropdown.ts` were in the aggregate while the plugin they drive was in the package.
+
+Two things were straightened out during the move:
+
+- The package exported **two different** `ADMONITION_TYPES` — a tuple of names from the command
+ module and a `Record<type, {title}>` from the UI module — and the barrel re-exported the UI one,
+ shadowing the other. The tuple is now `ADMONITION_TYPE_NAMES`; `ADMONITION_TYPES` remains the
+ record consumers already used.
+- `theme/blockquote.css` did not belong to this feature at all — it is CKEditor's baseline
+ `blockquote` styling, inherited from the fork. It moved to `src/theme/blockquote.css` and is
+ imported from `src/index.ts` with the other global stylesheets.
diff --git a/packages/ckeditor5/src/plugins/admonition/admonition.ts b/packages/ckeditor5/src/plugins/admonition/admonition.ts
new file mode 100644
index 0000000000..9d3a5b716e
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/admonition.ts
@@ -0,0 +1,39 @@
+import { Plugin } from "ckeditor5";
+
+import type AdmonitionCommand from "./admonition_command.js";
+import AdmonitionAutoformat from "./admonition_autoformat.js";
+import AdmonitionEditing from "./admonition_editing.js";
+import AdmonitionUI from "./admonition_ui.js";
+
+/**
+ * The admonition (info box / warning box) feature: an `<aside class="admonition <type>">`
+ * container holding block content.
+ *
+ * This is a "glue" plugin which loads {@link AdmonitionEditing}, {@link AdmonitionUI} and
+ * {@link AdmonitionAutoformat}.
+ *
+ * Adapted from CKEditor 5's block-quote feature; see the `README.md` next to this file.
+ */
+export default class Admonition extends Plugin {
+
+ public static get requires() {
+ return [AdmonitionEditing, AdmonitionUI, AdmonitionAutoformat] as const;
+ }
+
+ public static get pluginName() {
+ return "Admonition" as const;
+ }
+
+}
+
+declare module "ckeditor5" {
+ interface PluginsMap {
+ [Admonition.pluginName]: Admonition;
+ [AdmonitionEditing.pluginName]: AdmonitionEditing;
+ [AdmonitionUI.pluginName]: AdmonitionUI;
+ }
+
+ interface CommandsMap {
+ admonition: AdmonitionCommand;
+ }
+}
diff --git a/packages/ckeditor5/src/plugins/admonition/admonition_autoformat.spec.ts b/packages/ckeditor5/src/plugins/admonition/admonition_autoformat.spec.ts
new file mode 100644
index 0000000000..84bd746e1c
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_autoformat.spec.ts
@@ -0,0 +1,59 @@
+import { _getModelData as getModelData, _setModelData as setModelData, Autoformat, ClassicEditor, Essentials, Paragraph } from "ckeditor5";
+import { beforeEach, describe, expect, it } from "vitest";
+
+import { createTestEditor } from "../../../test/editor-kit.js";
+import Admonition from "./admonition.js";
+import AdmonitionAutoformat from "./admonition_autoformat.js";
+
+/**
+ * Type `text` at the current (collapsed) selection one character at a time, the way the autoformat
+ * feature expects to observe it — it reacts to the `insertText` that completes the pattern.
+ */
+function type(editor: ClassicEditor, text: string): void {
+ for (const character of text) {
+ editor.execute("insertText", { text: character });
+ }
+}
+
+describe("AdmonitionAutoformat", () => {
+ let editor: ClassicEditor;
+
+ beforeEach(async () => {
+ editor = await createTestEditor([Essentials, Paragraph, Admonition]);
+ });
+
+ it("declares Autoformat as a requirement", () => {
+ expect(AdmonitionAutoformat.requires).toContain(Autoformat);
+ });
+
+ it("turns `!!! tip ` into a tip admonition", () => {
+ setModelData(editor.model, "<paragraph>[]</paragraph>");
+
+ type(editor, "!!! tip ");
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe(
+ `<aside admonitionType="tip"><paragraph></paragraph></aside>`
+ );
+ });
+
+ it("keeps an unknown type as the admonition's text", () => {
+ setModelData(editor.model, "<paragraph>[]</paragraph>");
+
+ type(editor, "!!! nonsense ");
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe(
+ `<aside admonitionType="note"><paragraph>nonsense </paragraph></aside>`
+ );
+ });
+
+ it("does nothing without the admonition command", async () => {
+ const plain = await createTestEditor([Essentials, Paragraph, Autoformat, AdmonitionAutoformat]);
+
+ expect(plain.commands.get("admonition")).toBeUndefined();
+
+ setModelData(plain.model, "<paragraph>[]</paragraph>");
+ type(plain, "!!! tip ");
+
+ expect(getModelData(plain.model, { withoutSelection: true })).toBe("<paragraph>!!! tip </paragraph>");
+ });
+});
diff --git a/packages/ckeditor5/src/plugins/admonition/admonition_autoformat.ts b/packages/ckeditor5/src/plugins/admonition/admonition_autoformat.ts
new file mode 100644
index 0000000000..a664c169cc
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_autoformat.ts
@@ -0,0 +1,45 @@
+import { Autoformat, blockAutoformatEditing, Plugin } from "ckeditor5";
+
+import { ADMONITION_TYPE_NAMES, AdmonitionType } from "./admonition_command.js";
+
+/**
+ * Turns `!!! <type> ` at the start of a block into an admonition of that type. When the word after
+ * the marker is not a known type it is kept as the admonition's text instead.
+ */
+export default class AdmonitionAutoformat extends Plugin {
+
+ static get requires() {
+ return [Autoformat] as const;
+ }
+
+ afterInit() {
+ if (!this.editor.commands.get("admonition")) {
+ return;
+ }
+
+ // `blockAutoformatEditing` only uses the plugin to own the `change:data` listener, and is
+ // typed against `Autoformat` — pass the real instance rather than casting `this`.
+ const autoformat = this.editor.plugins.get(Autoformat);
+
+ blockAutoformatEditing(this.editor, autoformat, /^\!\!\[*\! (.+) $/, ({ match }) => {
+ const type = tryParseAdmonitionType(match);
+
+ if (type) {
+ // User has entered the admonition type, so we insert as-is.
+ this.editor.execute("admonition", { forceValue: type });
+ } else {
+ // User has not entered a valid type, assume it's part of the text of the admonition.
+ // The pattern has exactly one capture group, so `match[1]` is always present.
+ this.editor.execute("admonition");
+ this.editor.execute("insertText", { text: `${match[1]} ` });
+ }
+ });
+ }
+
+}
+
+function tryParseAdmonitionType(match: RegExpMatchArray): AdmonitionType | undefined {
+ if ((ADMONITION_TYPE_NAMES as readonly string[]).includes(match[1])) {
+ return match[1] as AdmonitionType;
+ }
+}
diff --git a/packages/ckeditor5/src/plugins/admonition/admonition_command.spec.ts b/packages/ckeditor5/src/plugins/admonition/admonition_command.spec.ts
new file mode 100644
index 0000000000..92fd6187e0
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_command.spec.ts
@@ -0,0 +1,200 @@
+import { _getModelData as getModelData, _setModelData as setModelData, ClassicEditor, Essentials, Heading, Paragraph } from "ckeditor5";
+import { beforeEach, describe, expect, it } from "vitest";
+
+import { createTestEditor } from "../../../test/editor-kit.js";
+import Admonition from "./admonition.js";
+import type AdmonitionCommand from "./admonition_command.js";
+import AdmonitionEditing from "./admonition_editing.js";
+
+describe("AdmonitionCommand", () => {
+ let editor: ClassicEditor;
+ let command: AdmonitionCommand;
+
+ beforeEach(async () => {
+ editor = await createTestEditor([Essentials, Paragraph, Heading, Admonition]);
+ command = editor.commands.get("admonition") as AdmonitionCommand;
+ });
+
+ describe("value and isEnabled", () => {
+ it("is off and enabled in a plain paragraph", () => {
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+
+ expect(command.value).toBe(false);
+ expect(command.isEnabled).toBe(true);
+ });
+
+ it("reports the type of the admonition the selection sits in", () => {
+ setModelData(editor.model, `<aside admonitionType="warning"><paragraph>foo[]</paragraph></aside>`);
+
+ expect(command.value).toBe("warning");
+ expect(command.isEnabled).toBe(true);
+ });
+
+ it("is off and disabled when the selection contains no block at all", async () => {
+ // No Paragraph plugin, so the root stays empty and `getSelectedBlocks()` yields nothing.
+ const blockless = await createTestEditor([Essentials, AdmonitionEditing]);
+ const blocklessCommand = blockless.commands.get("admonition") as AdmonitionCommand;
+
+ expect(blocklessCommand.value).toBe(false);
+ expect(blocklessCommand.isEnabled).toBe(false);
+ });
+ });
+
+ describe("applying", () => {
+ it("wraps the selected block in a note by default", () => {
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+
+ editor.execute("admonition");
+
+ expect(getModelData(editor.model)).toBe(
+ `<aside admonitionType="note"><paragraph>foo[]</paragraph></aside>`
+ );
+ });
+
+ it("applies the type given via forceValue", () => {
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+
+ editor.execute("admonition", { forceValue: "caution" });
+
+ expect(command.value).toBe("caution");
+ });
+
+ it("reuses the previous choice when usePreviousChoice is set", () => {
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+ editor.execute("admonition", { forceValue: "tip" });
+ editor.execute("admonition");
+
+ expect(command.value).toBe(false);
+
+ editor.execute("admonition", { usePreviousChoice: true });
+
+ expect(command.value).toBe("tip");
+ });
+
+ it("falls back to the default type when usePreviousChoice is set but nothing was chosen yet", () => {
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+
+ editor.execute("admonition", { usePreviousChoice: true });
+
+ expect(command.value).toBe("note");
+ });
+
+ it("changes the type of an admonition the selection already sits in", () => {
+ setModelData(editor.model, `<aside admonitionType="note"><paragraph>foo[]</paragraph></aside>`);
+
+ editor.execute("admonition", { forceValue: "important" });
+
+ expect(getModelData(editor.model)).toBe(
+ `<aside admonitionType="important"><paragraph>foo[]</paragraph></aside>`
+ );
+ });
+
+ it("wraps several selected blocks in a single admonition", () => {
+ setModelData(editor.model, "<paragraph>[foo</paragraph><paragraph>bar]</paragraph>");
+
+ editor.execute("admonition");
+
+ expect(getModelData(editor.model)).toBe(
+ `<aside admonitionType="note"><paragraph>[foo</paragraph><paragraph>bar]</paragraph></aside>`
+ );
+ });
+
+ it("merges a newly wrapped block into the admonition it now sits next to", () => {
+ // The selection spans the block already inside an admonition and the one after it, so
+ // the command reuses the existing <aside> for the first and creates one for the second
+ // — the two then get merged.
+ setModelData(
+ editor.model,
+ `<aside admonitionType="note"><paragraph>[foo</paragraph></aside><paragraph>bar]</paragraph>`
+ );
+
+ editor.execute("admonition", { forceValue: "note" });
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe(
+ `<aside admonitionType="note"><paragraph>foo</paragraph><paragraph>bar</paragraph></aside>`
+ );
+ });
+
+ it("keeps non-adjacent block groups in separate admonitions", () => {
+ setModelData(
+ editor.model,
+ "<paragraph>[foo</paragraph><heading1>skipped</heading1><paragraph>bar]</paragraph>"
+ );
+ // Restrict the selection to the two paragraphs only by re-selecting them individually.
+ editor.model.change((writer) => {
+ const root = editor.model.document.getRoot();
+ const first = root?.getChild(0);
+ const last = root?.getChild(2);
+ if (!first?.is("element") || !last?.is("element")) {
+ return;
+ }
+ writer.setSelection([
+ writer.createRangeIn(first),
+ writer.createRangeIn(last)
+ ]);
+ });
+
+ editor.execute("admonition");
+
+ const data = getModelData(editor.model, { withoutSelection: true });
+ expect(data).toBe(
+ `<aside admonitionType="note"><paragraph>foo</paragraph></aside>` +
+ `<heading1>skipped</heading1>` +
+ `<aside admonitionType="note"><paragraph>bar</paragraph></aside>`
+ );
+ });
+ });
+
+ describe("removing", () => {
+ it("unwraps the admonition when every block inside is selected", () => {
+ setModelData(editor.model, `<aside admonitionType="note"><paragraph>foo[]</paragraph></aside>`);
+
+ editor.execute("admonition");
+
+ expect(getModelData(editor.model)).toBe("<paragraph>foo[]</paragraph>");
+ });
+
+ it("moves the block out to the left when it starts the admonition", () => {
+ setModelData(
+ editor.model,
+ `<aside admonitionType="note"><paragraph>foo[]</paragraph><paragraph>bar</paragraph></aside>`
+ );
+
+ editor.execute("admonition");
+
+ expect(getModelData(editor.model)).toBe(
+ `<paragraph>foo[]</paragraph><aside admonitionType="note"><paragraph>bar</paragraph></aside>`
+ );
+ });
+
+ it("moves the block out to the right when it ends the admonition", () => {
+ setModelData(
+ editor.model,
+ `<aside admonitionType="note"><paragraph>foo</paragraph><paragraph>bar[]</paragraph></aside>`
+ );
+
+ editor.execute("admonition");
+
+ expect(getModelData(editor.model)).toBe(
+ `<aside admonitionType="note"><paragraph>foo</paragraph></aside><paragraph>bar[]</paragraph>`
+ );
+ });
+
+ it("splits the admonition when the block is in the middle", () => {
+ setModelData(
+ editor.model,
+ `<aside admonitionType="note">` +
+ `<paragraph>foo</paragraph><paragraph>bar[]</paragraph><paragraph>baz</paragraph>` +
+ `</aside>`
+ );
+
+ editor.execute("admonition");
+
+ expect(getModelData(editor.model)).toBe(
+ `<aside admonitionType="note"><paragraph>foo</paragraph></aside>` +
+ `<paragraph>bar[]</paragraph>` +
+ `<aside admonitionType="note"><paragraph>baz</paragraph></aside>`
+ );
+ });
+ });
+});
diff --git a/packages/ckeditor5/src/plugins/admonition/admonition_command.ts b/packages/ckeditor5/src/plugins/admonition/admonition_command.ts
new file mode 100644
index 0000000000..f4c4ef41a6
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_command.ts
@@ -0,0 +1,282 @@
+/**
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
+ * For licensing, see the `README.md` next to this file or
+ * https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import { Command, first } from "ckeditor5";
+import type { ModelElement, ModelPosition, ModelRange, ModelSchema, ModelWriter } from "ckeditor5";
+
+/**
+ * The admonition type names, in the order they are offered in the UI.
+ *
+ * The user-facing titles live in `ADMONITION_TYPES` in `admonition_ui.ts`; this is the bare list
+ * of names, used where only the names matter (autoformat, upcast).
+ */
+export const ADMONITION_TYPE_NAMES = ["note", "tip", "important", "caution", "warning"] as const;
+export const ADMONITION_TYPE_ATTRIBUTE = "admonitionType";
+export const DEFAULT_ADMONITION_TYPE = ADMONITION_TYPE_NAMES[0];
+export type AdmonitionType = typeof ADMONITION_TYPE_NAMES[number];
+
+interface ExecuteOpts {
+ /**
+ * If set, it will force the command behavior: the given type is applied. If not set, the
+ * command toggles — it removes the admonition when the selection already sits in one, and
+ * otherwise applies {@link DEFAULT_ADMONITION_TYPE} (or the previous choice, see
+ * {@link ExecuteOpts.usePreviousChoice}).
+ */
+ forceValue?: AdmonitionType;
+ /**
+ * If set to true and `forceValue` is not specified, the command will apply the previous
+ * admonition type (if the command was already executed).
+ */
+ usePreviousChoice?: boolean;
+}
+
+/**
+ * Wraps the selected blocks in an `<aside>` admonition, or unwraps them when the selection already
+ * sits inside one.
+ *
+ * Adapted from CKEditor 5's `BlockQuoteCommand`, with the admonition type carried on the element as
+ * the `admonitionType` attribute.
+ */
+export default class AdmonitionCommand extends Command {
+
+ /**
+ * The type of the admonition the selection sits in, or `false` when it sits in none.
+ *
+ * @observable
+ * @readonly
+ */
+ declare public value: AdmonitionType | false;
+
+ private _lastType?: AdmonitionType;
+
+ /**
+ * @inheritDoc
+ */
+ public override refresh(): void {
+ this.value = this._getValue();
+ this.isEnabled = this._checkEnabled();
+ }
+
+ /**
+ * Executes the command. When the command {@link #value is on}, all top-most admonitions within
+ * the selection will be removed. If it is off, all selected blocks will be wrapped with an
+ * admonition.
+ *
+ * @fires execute
+ * @param options Command options.
+ */
+ public override execute(options: ExecuteOpts = {}): void {
+ const model = this.editor.model;
+ const schema = model.schema;
+ const selection = model.document.selection;
+
+ const blocks = Array.from(selection.getSelectedBlocks());
+
+ const value = this._getType(options);
+
+ model.change((writer) => {
+ if (!value) {
+ this._removeQuote(writer, blocks.filter(findQuote));
+ } else {
+ const blocksToQuote = blocks.filter((block) => {
+ // Already quoted blocks needs to be considered while quoting too
+ // in order to reuse their <aside> elements.
+ return findQuote(block) || checkCanBeQuoted(schema, block);
+ });
+
+ this._applyQuote(writer, blocksToQuote, value);
+ }
+ });
+ }
+
+ private _getType(options: ExecuteOpts): AdmonitionType | false {
+ const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
+
+ // Allow removing the admonition.
+ if (!value) {
+ return false;
+ }
+
+ // Prefer the type from the command, if any.
+ if (typeof value === "string") {
+ return value;
+ }
+
+ // See if we can restore the previous choice.
+ if (options.usePreviousChoice && this._lastType) {
+ return this._lastType;
+ }
+
+ // Otherwise return a default.
+ return DEFAULT_ADMONITION_TYPE;
+ }
+
+ /**
+ * Checks the command's {@link #value}.
+ */
+ private _getValue(): AdmonitionType | false {
+ const selection = this.editor.model.document.selection;
+ const firstBlock = first(selection.getSelectedBlocks());
+ if (!firstBlock) {
+ return false;
+ }
+
+ // In the current implementation, the admonition must be an immediate parent of a block element.
+ const firstQuote = findQuote(firstBlock);
+ if (firstQuote) {
+ return firstQuote.getAttribute(ADMONITION_TYPE_ATTRIBUTE) as AdmonitionType;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks whether the command can be enabled in the current context.
+ *
+ * @returns Whether the command should be enabled.
+ */
+ private _checkEnabled(): boolean {
+ if (this.value) {
+ return true;
+ }
+
+ const selection = this.editor.model.document.selection;
+ const schema = this.editor.model.schema;
+
+ const firstBlock = first(selection.getSelectedBlocks());
+
+ if (!firstBlock) {
+ return false;
+ }
+
+ return checkCanBeQuoted(schema, firstBlock);
+ }
+
+ /**
+ * Removes the admonition from given blocks.
+ *
+ * If blocks which are supposed to be "unquoted" are in the middle of an admonition, start it or
+ * end it, then the admonition will be split (if needed) and the blocks will be moved out of it,
+ * so other quoted blocks remained quoted.
+ */
+ private _removeQuote(writer: ModelWriter, blocks: Array<ModelElement>): void {
+ // Unquote all groups of block. Iterate in the reverse order to not break following ranges.
+ getRangesOfBlockGroups(writer, blocks).reverse().forEach((groupRange) => {
+ if (groupRange.start.isAtStart && groupRange.end.isAtEnd) {
+ writer.unwrap(groupRange.start.parent as ModelElement);
+
+ return;
+ }
+
+ // The group of blocks are at the beginning of an <aside> so let's move them left (out of it).
+ if (groupRange.start.isAtStart) {
+ const positionBefore = writer.createPositionBefore(groupRange.start.parent as ModelElement);
+
+ writer.move(groupRange, positionBefore);
+
+ return;
+ }
+
+ // The blocks are in the middle of an <aside> so we need to split it after the last block
+ // so we move the items there.
+ if (!groupRange.end.isAtEnd) {
+ writer.split(groupRange.end);
+ }
+
+ // Now we are sure that groupRange.end.isAtEnd is true, so let's move the blocks right.
+
+ const positionAfter = writer.createPositionAfter(groupRange.end.parent as ModelElement);
+
+ writer.move(groupRange, positionAfter);
+ });
+ }
+
+ /**
+ * Applies the admonition to given blocks.
+ */
+ private _applyQuote(writer: ModelWriter, blocks: Array<ModelElement>, type?: AdmonitionType): void {
+ this._lastType = type;
+ const quotesToMerge: Array<ModelElement> = [];
+
+ // Quote all groups of block. Iterate in the reverse order to not break following ranges.
+ getRangesOfBlockGroups(writer, blocks).reverse().forEach((groupRange) => {
+ let quote = findQuote(groupRange.start);
+
+ if (!quote) {
+ const attributes: Record<string, unknown> = {};
+ attributes[ADMONITION_TYPE_ATTRIBUTE] = type;
+ quote = writer.createElement("aside", attributes);
+
+ writer.wrap(groupRange, quote);
+ } else {
+ writer.setAttribute(ADMONITION_TYPE_ATTRIBUTE, type, quote);
+ }
+
+ quotesToMerge.push(quote);
+ });
+
+ // Merge subsequent <aside> elements. Reverse the order again because this time we want to go
+ // through them in the source order (due to how merge works – it moves the right element's
+ // content to the first element and removes the right one. Since we may need to merge a couple
+ // of subsequent `<aside>` elements we want to keep the reference to the first (furthest left) one.
+ quotesToMerge.reverse().reduce((currentQuote, nextQuote) => {
+ if (currentQuote.nextSibling == nextQuote) {
+ writer.merge(writer.createPositionAfter(currentQuote));
+
+ return currentQuote;
+ }
+
+ return nextQuote;
+ });
+ }
+
+}
+
+function findQuote(elementOrPosition: ModelElement | ModelPosition): ModelElement | null {
+ const parent = elementOrPosition.parent;
+ return parent?.is("element", "aside") ? parent : null;
+}
+
+/**
+ * Returns a minimal array of ranges containing groups of subsequent blocks.
+ *
+ * content: abcdefgh
+ * blocks: [ a, b, d, f, g, h ]
+ * output ranges: [ab]c[d]e[fgh]
+ */
+function getRangesOfBlockGroups(writer: ModelWriter, blocks: Array<ModelElement>): Array<ModelRange> {
+ let startPosition: ModelPosition | null = null;
+ let i = 0;
+ const ranges: Array<ModelRange> = [];
+
+ while (i < blocks.length) {
+ const block = blocks[i];
+ const nextBlock = blocks[i + 1];
+
+ if (!startPosition) {
+ startPosition = writer.createPositionBefore(block);
+ }
+
+ if (!nextBlock || block.nextSibling != nextBlock) {
+ ranges.push(writer.createRange(startPosition, writer.createPositionAfter(block)));
+ startPosition = null;
+ }
+
+ i++;
+ }
+
+ return ranges;
+}
+
+/**
+ * Checks whether an `<aside>` can wrap the block.
+ */
+function checkCanBeQuoted(schema: ModelSchema, block: ModelElement): boolean {
+ const isAsideAllowed = schema.checkChild(block.parent as ModelElement, "aside");
+ const isBlockAllowedInAside = schema.checkChild(["$root", "aside"], block);
+
+ return isAsideAllowed && isBlockAllowedInAside;
+}
diff --git a/packages/ckeditor5/src/plugins/admonition/admonition_editing.spec.ts b/packages/ckeditor5/src/plugins/admonition/admonition_editing.spec.ts
new file mode 100644
index 0000000000..b1f9f38f7f
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_editing.spec.ts
@@ -0,0 +1,202 @@
+import { _getModelData as getModelData, _setModelData as setModelData, ClassicEditor, Enter, Essentials, Paragraph, Delete as WidgetDelete } from "ckeditor5";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+import { createTestEditor } from "../../../test/editor-kit.js";
+import Admonition from "./admonition.js";
+import AdmonitionEditing from "./admonition_editing.js";
+
+describe("AdmonitionEditing", () => {
+ let editor: ClassicEditor;
+
+ beforeEach(async () => {
+ editor = await createTestEditor([Essentials, Paragraph, Admonition]);
+ });
+
+ it("declares its required plugins", () => {
+ expect(AdmonitionEditing.requires).toContain(Enter);
+ expect(AdmonitionEditing.requires).toContain(WidgetDelete);
+ expect(AdmonitionEditing.pluginName).toBe("AdmonitionEditing");
+ });
+
+ it("registers the aside element and its type attribute in the schema", () => {
+ const schema = editor.model.schema;
+
+ expect(schema.isRegistered("aside")).toBe(true);
+ expect(schema.checkChild(["$root", "aside"], "paragraph")).toBe(true);
+ expect(schema.checkAttribute("aside", "admonitionType")).toBe(true);
+ });
+
+ describe("upcast", () => {
+ it("reads the type from the element's class list", () => {
+ editor.setData(`<aside class="admonition warning"><p>foo</p></aside>`);
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe(
+ `<aside admonitionType="warning"><paragraph>foo</paragraph></aside>`
+ );
+ });
+
+ it("falls back to the default type when no known type class is present", () => {
+ editor.setData(`<aside class="admonition"><p>foo</p></aside>`);
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe(
+ `<aside admonitionType="note"><paragraph>foo</paragraph></aside>`
+ );
+ });
+
+ it("ignores unrelated classes", () => {
+ editor.setData(`<aside class="admonition something-else"><p>foo</p></aside>`);
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe(
+ `<aside admonitionType="note"><paragraph>foo</paragraph></aside>`
+ );
+ });
+
+ it("leaves an aside without the admonition class alone", () => {
+ editor.setData(`<aside><p>foo</p></aside>`);
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe("<paragraph>foo</paragraph>");
+ });
+ });
+
+ describe("downcast", () => {
+ it("writes the admonition class alongside the type", () => {
+ setModelData(editor.model, `<aside admonitionType="caution"><paragraph>foo</paragraph></aside>`);
+
+ expect(editor.getData()).toBe(`<aside class="admonition caution"><p>foo</p></aside>`);
+ });
+ });
+
+ describe("post-fixer", () => {
+ it("removes an admonition inserted with no content at all", () => {
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+
+ editor.model.change((writer) => {
+ const root = editor.model.document.getRoot();
+ const aside = writer.createElement("aside", { admonitionType: "tip" });
+ writer.insert(aside, writer.createPositionAt(root ?? aside, "end"));
+ });
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe("<paragraph>foo</paragraph>");
+ });
+
+ it("removes an admonition that ends up empty", () => {
+ setModelData(editor.model, `<aside admonitionType="note"><paragraph>foo[]</paragraph></aside>`);
+
+ editor.model.change((writer) => {
+ const root = editor.model.document.getRoot();
+ const aside = root?.getChild(0);
+ if (aside?.is("element")) {
+ writer.remove(writer.createRangeIn(aside));
+ }
+ });
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toBe("<paragraph></paragraph>");
+ });
+
+ it("unwraps a misplaced admonition nested inside an inserted element", () => {
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+
+ editor.model.change((writer) => {
+ const root = editor.model.document.getRoot();
+ // The inserted element is the paragraph, so the post-fixer only finds the illegal
+ // <aside> by scanning the inserted element's descendants.
+ const paragraph = writer.createElement("paragraph");
+ const aside = writer.createElement("aside", { admonitionType: "tip" });
+ writer.insertElement("paragraph", aside, 0);
+ writer.insert(aside, writer.createPositionAt(paragraph, 0));
+ writer.insert(paragraph, writer.createPositionAt(root ?? paragraph, "end"));
+ });
+
+ expect(getModelData(editor.model, { withoutSelection: true })).not.toContain("<aside");
+ });
+ });
+
+ describe("breaking out of an admonition", () => {
+ it("leaves the admonition when Enter is pressed in an empty trailing block", () => {
+ setModelData(
+ editor.model,
+ `<aside admonitionType="note"><paragraph>foo</paragraph><paragraph>[]</paragraph></aside>`
+ );
+
+ editor.editing.view.document.fire("enter", {
+ preventDefault: vi.fn(),
+ isSoft: false
+ });
+
+ expect(getModelData(editor.model)).toBe(
+ `<aside admonitionType="note"><paragraph>foo</paragraph></aside><paragraph>[]</paragraph>`
+ );
+ });
+
+ it("keeps the admonition when Enter is pressed in a non-empty block", () => {
+ setModelData(editor.model, `<aside admonitionType="note"><paragraph>foo[]</paragraph></aside>`);
+
+ editor.editing.view.document.fire("enter", {
+ preventDefault: vi.fn(),
+ isSoft: false
+ });
+
+ expect(getModelData(editor.model, { withoutSelection: true })).toContain(`<aside admonitionType="note">`);
+ });
+
+ it("ignores Enter outside an admonition", () => {
+ setModelData(editor.model, "<paragraph>[]</paragraph>");
+ const executeSpy = vi.spyOn(editor, "execute");
+
+ editor.editing.view.document.fire("enter", { preventDefault: vi.fn(), isSoft: false });
+
+ // The default behaviour runs instead — the plugin never breaks out of an admonition.
+ expect(executeSpy).not.toHaveBeenCalledWith("admonition");
+ });
+
+ it("leaves the admonition when Backspace is pressed in the first empty block", () => {
+ setModelData(
+ editor.model,
+ `<aside admonitionType="note"><paragraph>[]</paragraph><paragraph>foo</paragraph></aside>`
+ );
+
+ editor.editing.view.document.fire("delete", {
+ direction: "backward",
+ preventDefault: vi.fn(),
+ unit: "character"
+ });
+
+ expect(getModelData(editor.model)).toBe(
+ `<paragraph>[]</paragraph><aside admonitionType="note"><paragraph>foo</paragraph></aside>`
+ );
+ });
+
+ it("ignores a forward delete", () => {
+ setModelData(editor.model, `<aside admonitionType="note"><paragraph>[]</paragraph></aside>`);
+ const executeSpy = vi.spyOn(editor, "execute");
+
+ editor.editing.view.document.fire("delete", { direction: "forward", preventDefault: vi.fn(), unit: "character" });
+
+ expect(executeSpy).not.toHaveBeenCalledWith("admonition");
+ });
+
+ it("ignores Backspace in a block that is not the first one", () => {
+ setModelData(
+ editor.model,
+ `<aside admonitionType="note"><paragraph>foo</paragraph><paragraph>[]</paragraph></aside>`
+ );
+ const executeSpy = vi.spyOn(editor, "execute");
+
+ editor.editing.view.document.fire("delete", { direction: "backward", preventDefault: vi.fn(), unit: "character" });
+
+ expect(executeSpy).not.toHaveBeenCalledWith("admonition");
+ });
+
+ it("ignores Enter when the selection is not collapsed", () => {
+ setModelData(
+ editor.model,
+ `<aside admonitionType="note"><paragraph>[foo]</paragraph></aside>`
+ );
+ const executeSpy = vi.spyOn(editor, "execute");
+
+ editor.editing.view.document.fire("enter", { preventDefault: vi.fn(), isSoft: false });
+
+ expect(executeSpy).not.toHaveBeenCalledWith("admonition");
+ });
+ });
+});
diff --git a/packages/ckeditor5/src/plugins/admonition/admonition_editing.ts b/packages/ckeditor5/src/plugins/admonition/admonition_editing.ts
new file mode 100644
index 0000000000..e868e14f95
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_editing.ts
@@ -0,0 +1,176 @@
+/**
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
+ * For licensing, see the `README.md` next to this file or
+ * https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import { Delete, Enter, Plugin, ViewDocumentDeleteEvent, ViewDocumentEnterEvent } from "ckeditor5";
+
+import AdmonitionCommand, { ADMONITION_TYPE_ATTRIBUTE, ADMONITION_TYPE_NAMES, AdmonitionType, DEFAULT_ADMONITION_TYPE } from "./admonition_command.js";
+
+/**
+ * The admonition editing feature.
+ *
+ * Introduces the `'admonition'` command and the `'aside'` model element.
+ */
+export default class AdmonitionEditing extends Plugin {
+
+ /**
+ * @inheritDoc
+ */
+ public static get pluginName() {
+ return "AdmonitionEditing" as const;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static get requires() {
+ return [Enter, Delete] as const;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public init(): void {
+ const editor = this.editor;
+ const schema = editor.model.schema;
+
+ const admonitionCommand = new AdmonitionCommand(editor);
+ editor.commands.add("admonition", admonitionCommand);
+
+ schema.register("aside", {
+ inheritAllFrom: "$container",
+ allowAttributes: ADMONITION_TYPE_ATTRIBUTE
+ });
+
+ editor.conversion.for("upcast").elementToElement({
+ view: {
+ name: "aside",
+ classes: "admonition"
+ },
+ model: (viewElement, { writer }) => {
+ let type: AdmonitionType = DEFAULT_ADMONITION_TYPE;
+ for (const className of viewElement.getClassNames()) {
+ if (className !== "admonition" && (ADMONITION_TYPE_NAMES as readonly string[]).includes(className)) {
+ type = className as AdmonitionType;
+ }
+ }
+
+ const attributes: Record<string, unknown> = {};
+ attributes[ADMONITION_TYPE_ATTRIBUTE] = type;
+ return writer.createElement("aside", attributes);
+ }
+ });
+
+ editor.conversion.for("downcast")
+ .elementToElement({
+ model: "aside",
+ view: "aside"
+ })
+ .attributeToAttribute({
+ model: ADMONITION_TYPE_ATTRIBUTE,
+ view: (value) => ({
+ key: "class",
+ value: ["admonition", value as string]
+ })
+ });
+
+ // Postfixer which cleans incorrect model states connected with admonitions.
+ editor.model.document.registerPostFixer((writer) => {
+ const changes = editor.model.document.differ.getChanges();
+
+ for (const entry of changes) {
+ if (entry.type == "insert") {
+ const element = entry.position.nodeAfter;
+
+ if (!element) {
+ // We are inside a text node.
+ continue;
+ }
+
+ if (element.is("element", "aside") && element.isEmpty) {
+ // Added an empty aside - remove it.
+ writer.remove(element);
+
+ return true;
+ } else if (element.is("element")) {
+ // Just added an element. Check that all children meet the scheme rules.
+ //
+ // Upstream's block-quote post-fixer also checks the inserted element itself
+ // against the schema here. That case is unreachable: `writer.insert()` and
+ // `writer.move()` both normalise an <aside> out of a parent that does not
+ // allow it, so the differ never reports one at an illegal position. A
+ // misplaced <aside> only ever arrives nested inside some other inserted
+ // element, which the scan below handles.
+ const range = writer.createRangeIn(element);
+
+ for (const child of range.getItems()) {
+ if (
+ child.is("element", "aside") &&
+ !schema.checkChild(writer.createPositionBefore(child), child)
+ ) {
+ writer.unwrap(child);
+
+ return true;
+ }
+ }
+ }
+ } else if (entry.type == "remove") {
+ const parent = entry.position.parent;
+
+ if (parent.is("element", "aside") && parent.isEmpty) {
+ // Something got removed and now aside is empty. Remove the aside as well.
+ writer.remove(parent);
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+ });
+
+ const viewDocument = this.editor.editing.view.document;
+ const selection = editor.model.document.selection;
+
+ // Overwrite default Enter key behavior.
+ // If Enter key is pressed with selection collapsed in an empty block inside an admonition,
+ // break out of the admonition.
+ this.listenTo<ViewDocumentEnterEvent>(viewDocument, "enter", (evt, data) => {
+ if (!selection.isCollapsed || !admonitionCommand.value) {
+ return;
+ }
+
+ const positionParent = selection.getLastPosition()?.parent;
+
+ if (positionParent?.isEmpty) {
+ editor.execute("admonition");
+ editor.editing.view.scrollToTheSelection();
+
+ data.preventDefault();
+ evt.stop();
+ }
+ }, { context: "aside" });
+
+ // Overwrite default Backspace key behavior.
+ // If Backspace key is pressed with selection collapsed in the first empty block inside an
+ // admonition, break out of the admonition.
+ this.listenTo<ViewDocumentDeleteEvent>(viewDocument, "delete", (evt, data) => {
+ if (data.direction != "backward" || !selection.isCollapsed || !admonitionCommand.value) {
+ return;
+ }
+
+ const positionParent = selection.getLastPosition()?.parent;
+
+ if (positionParent?.isEmpty && !positionParent.previousSibling) {
+ editor.execute("admonition");
+ editor.editing.view.scrollToTheSelection();
+
+ data.preventDefault();
+ evt.stop();
+ }
+ }, { context: "aside" });
+ }
+
+}
diff --git a/packages/ckeditor5/src/plugins/admonition_toolbar.spec.ts b/packages/ckeditor5/src/plugins/admonition/admonition_toolbar.spec.ts
similarity index 98%
rename from packages/ckeditor5/src/plugins/admonition_toolbar.spec.ts
rename to packages/ckeditor5/src/plugins/admonition/admonition_toolbar.spec.ts
index 394a662201..d4dbd8b6cb 100644
--- a/packages/ckeditor5/src/plugins/admonition_toolbar.spec.ts
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_toolbar.spec.ts
@@ -1,8 +1,8 @@
import { ClassicEditor, Essentials, Paragraph, _setModelData as setModelData, WidgetToolbarRepository } from "ckeditor5";
-import { Admonition } from "@triliumnext/ckeditor5-admonition";
+import Admonition from "./admonition.js";
import { beforeEach, describe, expect, it } from "vitest";
-import { createTestEditor } from "../../test/editor-kit.js";
+import { createTestEditor } from "../../../test/editor-kit.js";
import AdmonitionToolbar from "./admonition_toolbar.js";
import AdmonitionTypeDropdown from "./admonition_type_dropdown.js";
diff --git a/packages/ckeditor5/src/plugins/admonition_toolbar.ts b/packages/ckeditor5/src/plugins/admonition/admonition_toolbar.ts
similarity index 96%
rename from packages/ckeditor5/src/plugins/admonition_toolbar.ts
rename to packages/ckeditor5/src/plugins/admonition/admonition_toolbar.ts
index 6aa7bbb696..6ceeab2ff7 100644
--- a/packages/ckeditor5/src/plugins/admonition_toolbar.ts
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_toolbar.ts
@@ -1,5 +1,5 @@
import { Plugin, ViewDocumentFragment, WidgetToolbarRepository, type ViewNode } from "ckeditor5";
-import { Admonition } from "@triliumnext/ckeditor5-admonition";
+import Admonition from "./admonition.js";
import AdmonitionTypeDropdown from "./admonition_type_dropdown";
export default class AdmonitionToolbar extends Plugin {
diff --git a/packages/ckeditor5/src/plugins/admonition_type_dropdown.spec.ts b/packages/ckeditor5/src/plugins/admonition/admonition_type_dropdown.spec.ts
similarity index 98%
rename from packages/ckeditor5/src/plugins/admonition_type_dropdown.spec.ts
rename to packages/ckeditor5/src/plugins/admonition/admonition_type_dropdown.spec.ts
index 227e3d1cda..4dde61ac00 100644
--- a/packages/ckeditor5/src/plugins/admonition_type_dropdown.spec.ts
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_type_dropdown.spec.ts
@@ -1,8 +1,9 @@
import { ClassicEditor, Essentials, Paragraph, _setModelData as setModelData } from "ckeditor5";
-import { Admonition, ADMONITION_TYPES } from "@triliumnext/ckeditor5-admonition";
+import Admonition from "./admonition.js";
+import { ADMONITION_TYPES } from "./admonition_ui.js";
import { beforeEach, describe, expect, it, vi } from "vitest";
-import { createTestEditor } from "../../test/editor-kit.js";
+import { createTestEditor } from "../../../test/editor-kit.js";
import AdmonitionTypeDropdown from "./admonition_type_dropdown.js";
// ---- Typed interfaces for the dropdown internals ----
diff --git a/packages/ckeditor5/src/plugins/admonition_type_dropdown.ts b/packages/ckeditor5/src/plugins/admonition/admonition_type_dropdown.ts
similarity index 92%
rename from packages/ckeditor5/src/plugins/admonition_type_dropdown.ts
rename to packages/ckeditor5/src/plugins/admonition/admonition_type_dropdown.ts
index f2d641c87a..d4d5ad54f2 100644
--- a/packages/ckeditor5/src/plugins/admonition_type_dropdown.ts
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_type_dropdown.ts
@@ -1,5 +1,8 @@
import { Plugin, type ListDropdownButtonDefinition, Collection, ViewModel, createDropdown, addListToDropdown, DropdownButtonView } from "ckeditor5";
-import { Admonition, ADMONITION_TYPES, type AdmonitionCommand, type AdmonitionType } from "@triliumnext/ckeditor5-admonition";
+import Admonition from "./admonition.js";
+import type AdmonitionCommand from "./admonition_command.js";
+import type { AdmonitionType } from "./admonition_command.js";
+import { ADMONITION_TYPES } from "./admonition_ui.js";
/**
* Toolbar item which displays the list of admonition types in a dropdown.
diff --git a/packages/ckeditor5/src/plugins/admonition/admonition_ui.spec.ts b/packages/ckeditor5/src/plugins/admonition/admonition_ui.spec.ts
new file mode 100644
index 0000000000..91a7a6b77d
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_ui.spec.ts
@@ -0,0 +1,162 @@
+import { _setModelData as setModelData, ClassicEditor, Essentials, Paragraph, SplitButtonView } from "ckeditor5";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+import { createTestEditor } from "../../../test/editor-kit.js";
+import Admonition from "./admonition.js";
+import type AdmonitionCommand from "./admonition_command.js";
+import AdmonitionUI, { ADMONITION_TYPES } from "./admonition_ui.js";
+
+// ---- Typed interfaces for the dropdown internals ----
+
+interface ListButtonView {
+ commandParam?: string;
+ label?: string;
+ isOn?: boolean;
+ fire(event: string): void;
+}
+
+interface ListItemView {
+ children: {
+ get(idx: number): ListButtonView;
+ };
+}
+
+interface ListView {
+ items: {
+ length: number;
+ get(idx: number): ListItemView;
+ };
+}
+
+interface SplitDropdownView {
+ isOpen: boolean;
+ isEnabled: boolean;
+ buttonView: SplitButtonView;
+ panelView: { children: { get(idx: number): ListView | null } };
+ fire(event: string, data?: unknown): void;
+}
+
+/**
+ * Opens the dropdown to trigger the lazy panel population, then returns the ListView.
+ * CKEditor's addListToDropdown defers adding the list until the panel is first opened.
+ */
+function openDropdown(dropdown: SplitDropdownView): ListView {
+ dropdown.isOpen = true;
+ const listView = dropdown.panelView.children.get(0);
+ if (!listView) {
+ throw new Error("Dropdown panel did not render a list view after opening.");
+ }
+ return listView;
+}
+
+function createButton(editor: ClassicEditor): SplitDropdownView {
+ return editor.ui.componentFactory.create("admonition") as unknown as SplitDropdownView;
+}
+
+describe("AdmonitionUI", () => {
+ describe("with the editing plugin loaded", () => {
+ let editor: ClassicEditor;
+ let command: AdmonitionCommand;
+
+ beforeEach(async () => {
+ editor = await createTestEditor([Essentials, Paragraph, Admonition]);
+ command = editor.commands.get("admonition") as AdmonitionCommand;
+ });
+
+ it("registers the admonition split button", () => {
+ const dropdown = createButton(editor);
+ const button = dropdown.buttonView;
+
+ expect(button).toBeInstanceOf(SplitButtonView);
+ expect(button.label).toBe("Admonition");
+ expect(button.icon).toContain("<svg");
+ expect(button.isToggleable).toBe(true);
+ expect(button.tooltip).toBe(true);
+ });
+
+ it("applies the previous choice when the split button itself is executed", () => {
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+ editor.execute("admonition", { forceValue: "tip" });
+ editor.execute("admonition");
+
+ const dropdown = createButton(editor);
+ const focusSpy = vi.spyOn(editor.editing.view, "focus");
+
+ dropdown.buttonView.fire("execute");
+
+ expect(command.value).toBe("tip");
+ expect(focusSpy).toHaveBeenCalled();
+ });
+
+ it("binds the split button isOn and the dropdown isEnabled to the command", () => {
+ const dropdown = createButton(editor);
+
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+ expect(dropdown.buttonView.isOn).toBe(false);
+ expect(dropdown.isEnabled).toBe(true);
+
+ editor.execute("admonition", { forceValue: "note" });
+
+ expect(dropdown.buttonView.isOn).toBe(true);
+ });
+
+ it("offers every admonition type in the dropdown", () => {
+ const dropdown = createButton(editor);
+ const listView = openDropdown(dropdown);
+ const types = Object.keys(ADMONITION_TYPES);
+
+ expect(listView.items.length).toBe(types.length);
+
+ for (let i = 0; i < listView.items.length; i++) {
+ const button = listView.items.get(i).children.get(0);
+ const type = button.commandParam as keyof typeof ADMONITION_TYPES | undefined;
+
+ expect(types).toContain(button.commandParam);
+ if (type) {
+ expect(button.label).toBe(ADMONITION_TYPES[type].title);
+ }
+ }
+ });
+
+ it("applies the picked type when a dropdown item is executed", () => {
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+
+ const dropdown = createButton(editor);
+ const listView = openDropdown(dropdown);
+ const focusSpy = vi.spyOn(editor.editing.view, "focus");
+ const tipButton = listView.items.get(1).children.get(0);
+
+ expect(tipButton.commandParam).toBe("tip");
+
+ // List items delegate `execute` to the dropdown, which reads `evt.source.commandParam`.
+ tipButton.fire("execute");
+
+ expect(command.value).toBe("tip");
+ expect(focusSpy).toHaveBeenCalled();
+ });
+
+ it("marks the dropdown item matching the current admonition type", () => {
+ const dropdown = createButton(editor);
+ const listView = openDropdown(dropdown);
+
+ setModelData(editor.model, "<paragraph>foo[]</paragraph>");
+ editor.execute("admonition", { forceValue: "tip" });
+
+ expect(listView.items.get(1).children.get(0).isOn).toBe(true);
+ expect(listView.items.get(0).children.get(0).isOn).toBe(false);
+ });
+ });
+
+ describe("without the editing plugin", () => {
+ it("still builds a button, with no command bindings and an empty dropdown", async () => {
+ const editor = await createTestEditor([Essentials, Paragraph, AdmonitionUI]);
+
+ expect(editor.commands.get("admonition")).toBeUndefined();
+
+ const dropdown = createButton(editor);
+
+ expect(dropdown.buttonView.label).toBe("Admonition");
+ expect(openDropdown(dropdown).items.length).toBe(0);
+ });
+ });
+});
diff --git a/packages/ckeditor5/src/plugins/admonition/admonition_ui.ts b/packages/ckeditor5/src/plugins/admonition/admonition_ui.ts
new file mode 100644
index 0000000000..c9fa163bb7
--- /dev/null
+++ b/packages/ckeditor5/src/plugins/admonition/admonition_ui.ts
@@ -0,0 +1,127 @@
+/**
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
+ * For licensing, see the `README.md` next to this file or
+ * https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import { addListToDropdown, Collection, createDropdown, ListDropdownItemDefinition, Plugin, SplitButtonView, ViewModel } from "ckeditor5";
+
+import admonitionIcon from "../../icons/admonition.svg?raw";
+import { AdmonitionType } from "./admonition_command.js";
+
+interface AdmonitionDefinition {
+ title: string;
+}
+
+/**
+ * The user-facing definition of each admonition type. Keyed by the type names in
+ * `ADMONITION_TYPE_NAMES` (see `admonition_command.ts`).
+ */
+export const ADMONITION_TYPES: Record<AdmonitionType, AdmonitionDefinition> = {
+ note: {
+ title: "Note"
+ },
+ tip: {
+ title: "Tip"
+ },
+ important: {
+ title: "Important"
+ },
+ caution: {
+ title: "Caution"
+ },
+ warning: {
+ title: "Warning"
+ }
+};
+
+/**
+ * The admonition UI plugin.
+ *
+ * It introduces the `'admonition'` split button: clicking the button applies the previously chosen
+ * type, while the dropdown offers every type.
+ */
+export default class AdmonitionUI extends Plugin {
+
+ /**
+ * @inheritDoc
+ */
+ public static get pluginName() {
+ return "AdmonitionUI" as const;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public init(): void {
+ const editor = this.editor;
+
+ editor.ui.componentFactory.add("admonition", () => this._createButton());
+ }
+
+ /**
+ * Creates a button for the admonition command to use either in toolbar or in menu bar.
+ */
+ private _createButton() {
+ const editor = this.editor;
+ const locale = editor.locale;
+ const command = editor.commands.get("admonition");
+ const dropdownView = createDropdown(locale, SplitButtonView);
+ const splitButtonView = dropdownView.buttonView;
+ const t = locale.t;
+
+ addListToDropdown(dropdownView, this._getDropdownItems());
+
+ // Button configuration.
+ splitButtonView.set({
+ label: t("Admonition"),
+ icon: admonitionIcon,
+ isToggleable: true,
+ tooltip: true
+ });
+ splitButtonView.on("execute", () => {
+ editor.execute("admonition", { usePreviousChoice: true });
+ editor.editing.view.focus();
+ });
+
+ if (command) {
+ splitButtonView.bind("isOn").to(command, "value", (value) => !!value);
+ dropdownView.bind("isEnabled").to(command, "isEnabled");
+ }
+
+ dropdownView.on("execute", (evt) => {
+ const commandParam = (evt.source as { commandParam?: AdmonitionType }).commandParam;
+ editor.execute("admonition", { forceValue: commandParam });
+ editor.editing.view.focus();
+ });
+
+ return dropdownView;
+ }
+
+ private _getDropdownItems() {
+ const itemDefinitions = new Collection<ListDropdownItemDefinition>();
+ const command = this.editor.commands.get("admonition");
+ if (!command) {
+ return itemDefinitions;
+ }
+
+ for (const [type, admonition] of Object.entries(ADMONITION_TYPES)) {
+ const definition: ListDropdownItemDefinition = {
+ type: "button",
+ model: new ViewModel({
+ commandParam: type,
+ label: admonition.title,
+ class: `ck-tn-admonition-option ck-tn-admonition-${type}`,
+ role: "menuitemradio",
+ withText: true
+ })
+ };
+
+ definition.model.bind("isOn").to(command, "value", (currentType) => currentType === type);
+ itemDefinitions.add(definition);
+ }
+
+ return itemDefinitions;
+ }
+
+}
diff --git a/packages/ckeditor5-admonition/theme/blockquote.css b/packages/ckeditor5/src/theme/blockquote.css
similarity index 100%
rename from packages/ckeditor5-admonition/theme/blockquote.css
rename to packages/ckeditor5/src/theme/blockquote.css
diff --git a/packages/ckeditor5/tsconfig.json b/packages/ckeditor5/tsconfig.json
index 75f71ff710..bd97c9669e 100644
--- a/packages/ckeditor5/tsconfig.json
+++ b/packages/ckeditor5/tsconfig.json
@@ -9,9 +9,6 @@
{
"path": "../ckeditor5-math"
},
- {
- "path": "../ckeditor5-admonition"
- },
{
"path": "../ckeditor5-mermaid"
},
diff --git a/packages/ckeditor5/tsconfig.lib.json b/packages/ckeditor5/tsconfig.lib.json
index addb47c0f5..0e74666220 100644
--- a/packages/ckeditor5/tsconfig.lib.json
+++ b/packages/ckeditor5/tsconfig.lib.json
@@ -27,9 +27,6 @@
{
"path": "../ckeditor5-math"
},
- {
- "path": "../ckeditor5-admonition"
- },
{
"path": "../ckeditor5-collapsible"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6fa8590971..cd3b7c9dd1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1094,9 +1094,6 @@ importers:
packages/ckeditor5:
dependencies:
- '@triliumnext/ckeditor5-admonition':
- specifier: workspace:*
- version: link:../ckeditor5-admonition
'@triliumnext/ckeditor5-collapsible':
specifier: workspace:*
version: link:../ckeditor5-collapsible
@@ -1129,42 +1126,6 @@ importers:
specifier: 9.30.0
version: 9.30.0([email protected])
- packages/ckeditor5-admonition:
- devDependencies:
- '@ckeditor/ckeditor5-inspector':
- specifier: '>=4.1.0'
- version: 5.0.3
- '@vitest/browser':
- specifier: 4.1.10
- ckeditor5:
- specifier: 48.3.1
- version: 48.3.1([email protected])
- eslint:
- specifier: 10.8.0
- eslint-config-ckeditor5:
- specifier: '>=9.1.0'
- stylelint:
- specifier: 17.14.1
- stylelint-config-ckeditor5:
- specifier: '>=9.1.0'
- typescript:
- specifier: 6.0.3
- version: 6.0.3
- vite-plugin-svgo:
- specifier: 2.0.0
- vitest:
- specifier: 4.1.10
- webdriverio:
- specifier: 9.30.0
- version: 9.30.0([email protected])
-
packages/ckeditor5-collapsible:
dependencies:
'@triliumnext/ckeditor5-utils':
diff --git a/tsconfig.json b/tsconfig.json
index 7b02a802c9..b14538090a 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -48,9 +48,6 @@
{
"path": "./packages/ckeditor5-mermaid"
},
- {
- "path": "./packages/ckeditor5-admonition"
- },
{
"path": "./packages/ckeditor5-footnotes"
},