chore(ckeditor5-mermaid): integrate the rest of the files

This commit is contained in:
Elian Doran 2025-05-04 18:19:26 +03:00
parent 89f95f6187
commit 07c2f1805e
No known key found for this signature in database
31 changed files with 44 additions and 540 deletions

View File

@ -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

View File

@ -1,41 +0,0 @@
/* eslint-env node */
'use strict';
module.exports = {
extends: 'ckeditor5',
root: true,
ignorePatterns: [
// Ignore the entire `build/` (the DLL build).
'build/**',
// Ignore the entire `dist/`.
'dist/**'
],
rules: {
// This rule disallows importing core DLL packages directly. Imports should be done using the `ckeditor5` package.
// Also, importing non-DLL packages is not allowed. If the package requires other features to work, they should be
// specified as soft-requirements.
// Read more: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/migration/migration-to-26.html#soft-requirements.
'ckeditor5-rules/ckeditor-imports': 'error',
// 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' ]
}
]
},
overrides: [
{
files: [ 'tests/**/*.js', 'sample/**/*.js' ],
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'
}
}
]
};

View File

@ -1,18 +0,0 @@
* text=auto
*.htaccess eol=lf
*.cgi eol=lf
*.sh eol=lf
*.css text
*.htm text
*.html text
*.js text
*.json text
*.php text
*.txt text
*.md text
*.png -text
*.gif -text
*.jpg -text

View File

@ -1,8 +0,0 @@
.nyc_output/
coverage/
node_modules/
yarn.lock
tmp/
build/
dist
yarn.error

View File

@ -1,6 +0,0 @@
{
"extends": "stylelint-config-ckeditor5",
"ignoreFiles": [
"dist/**/*.css"
]
}

View File

@ -1,22 +0,0 @@
Software License Agreement
==========================
**CKEditor 5 mermaid feature** (https://ckeditor.com/ckeditor-5/)<br>
Copyright (c) 2003-2022, [CKSource](http://cksource.com) Holding sp. z o.o. All rights reserved.
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
Sources of Intellectual Property Included in CKEditor 5 mermaid feature
---------------------------------------------------------------------
Where not otherwise indicated, all CKEditor 5 mermaid feature content is authored by CKSource engineers and consists of CKSource-owned intellectual property.
The following libraries are included in CKEditor 5 mermaid feature under the [MIT license](https://opensource.org/licenses/MIT):
* Lo-Dash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas.
* mermaid - Copyright (c) 2014 - 2021 Knut Sveidqvist. (MIT License)
Trademarks
----------
**CKEditor** is a trademark of [CKSource](http://cksource.com) Holding sp. z o.o. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.

View File

@ -1,24 +0,0 @@
CKEditor 5 Mermaid feature
=================================
Warning: This is an experimental plugin that comes with no support, use it at your own risk.
This package contains a Mermaid feature for CKEditor 5.
## CKEditor 5 Mermaid - Running manual test
You can test all of the features of the `ckeditor5-mermaid` plugin with the manual test sample.
After installing dependencies it's enough to execute the following script at the root of your local clone of the project:
```
yarn start
```
## License
See [LICENSE.md](LICENSE.md) file.
### Trademarks
**CKEditor** is a trademark of [CKSource](https://cksource.com) Holding sp. z o.o. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.

View File

@ -1,76 +0,0 @@
{
"name": "@ckeditor/ckeditor5-mermaid",
"version": "0.0.4",
"description": "Mermaid widget for CKEditor 5.",
"private": true,
"keywords": [
"ckeditor",
"ckeditor5",
"ckeditor 5",
"ckeditor5-feature",
"ckeditor5-plugin",
"ckeditor5-mermaid"
],
"type": "module",
"main": "src/index.js",
"license": "SEE LICENSE IN LICENSE.md",
"author": "CKSource (https://cksource.com/)",
"homepage": "https://github.com/ckeditor/ckeditor5-mermaid",
"bugs": "https://github.com/ckeditor/ckeditor5-mermaid/issues",
"engines": {
"node": ">=18.0.0",
"npm": ">=5.7.1"
},
"files": [
"lang",
"src/**/*.js",
"src/**/*.css",
"theme",
"build",
"ckeditor5-metadata.json"
],
"dependencies": {
"ckeditor5": "43.2.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-dev-build-tools": "^42.0.0",
"@ckeditor/ckeditor5-inspector": "^4.0.0",
"@ckeditor/ckeditor5-package-tools": "^2.1.0",
"ckeditor5": "latest",
"eslint": "^7.32.0",
"eslint-config-ckeditor5": "^6.0.0",
"http-server": "^14.1.1",
"husky": "^4.2.5",
"lint-staged": "^12.0.0",
"stylelint": "^13.13.1",
"stylelint-config-ckeditor5": ">=6.0.0"
},
"peerDependencies": {
"ckeditor5": ">=43.0.0 || ^0.0.0-nightly"
},
"scripts": {
"dll:build": "ckeditor5-package-tools dll:build",
"dll:serve": "http-server ./ -o sample/dll.html",
"lint": "eslint --quiet --ext .ts src/",
"lint:fix": "eslint --quiet --fix --ext .ts src/",
"stylelint": "stylelint --quiet --allow-empty-input 'theme/**/*.css'",
"test": "ckeditor5-package-tools test",
"prepare": "yarn run dll:build",
"prepublishOnly": "ckeditor5-package-tools export-package-as-javascript",
"postpublish": "ckeditor5-package-tools export-package-as-typescript",
"start": "ckeditor5-package-tools start"
},
"lint-staged": {
"**/*.js": [
"eslint --quiet"
],
"**/*.css": [
"stylelint --quiet --allow-empty-input"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}

View File

@ -1,54 +0,0 @@
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/* globals console, window, document */
import { ClassicEditor } from '@ckeditor/ckeditor5-editor-classic';
import { Typing } from '@ckeditor/ckeditor5-typing';
import { Paragraph } from '@ckeditor/ckeditor5-paragraph';
import { Undo } from '@ckeditor/ckeditor5-undo';
import { Enter } from '@ckeditor/ckeditor5-enter';
import { Clipboard } from '@ckeditor/ckeditor5-clipboard';
import { Link } from '@ckeditor/ckeditor5-link';
import { Bold, Italic } from '@ckeditor/ckeditor5-basic-styles';
import { CodeBlock } from '@ckeditor/ckeditor5-code-block';
import CKEditorInspector from '@ckeditor/ckeditor5-inspector';
import Mermaid from '../src/mermaid.js';
ClassicEditor
.create( document.querySelector( '#editor' ), {
plugins: [
Typing,
Paragraph,
Undo,
Enter,
Clipboard,
Link,
Bold,
Italic,
CodeBlock,
Mermaid
],
toolbar: [ 'bold', 'italic', 'link', 'undo', 'redo', 'codeBlock', 'mermaid' ],
codeBlock: {
languages: [
{ language: 'plaintext', label: 'Plain text', class: '' },
{ language: 'javascript', label: 'JavaScript' },
{ language: 'python', label: 'Python' },
{ language: 'mermaid', label: 'Mermaid' }
]
}
} )
.then( editor => {
window.editor = editor;
CKEditorInspector.attach( editor );
window.console.log( 'CKEditor 5 is ready.', editor );
} )
.catch( err => {
console.error( err.stack );
} );

View File

@ -1,119 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CKEditor 5 Mermaid widget Development Sample</title>
<style>
body {
max-width: 800px;
margin: 20px auto;
}
</style>
</head>
<body>
<h1>CKEditor 5 Mermaid widget Development Sample</h1>
<div id="editor">
</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 "@ckeditor/ckeditor5-mermaid" package DLL build is served from the `build/` directory -->
<script src="../build/mermaid.js"></script>
<script>
console.log( 'Objects exported by the DLL build:', CKEditor5[ 'mermaid' ] );
CKEditor5.editorClassic.ClassicEditor
.create( document.querySelector( '#editor' ), {
plugins: [
CKEditor5[ 'mermaid' ].Mermaid,
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: [
'mermaid',
'|',
'undo',
'redo',
'|',
'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;
} )
.catch( error => {
console.error( 'There was a problem initializing the editor.', error );
} );
</script>
</body>
</html>

View File

@ -1,61 +0,0 @@
#!/usr/bin/env node
/**
* @license Copyright (c) 2020-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/
/* eslint-env node */
import { createRequire } from 'module';
import upath from 'upath';
import chalk from 'chalk';
import { build } from '@ckeditor/ckeditor5-dev-build-tools';
function dist( path ) {
return upath.join( 'dist', path );
}
( async () => {
/**
* Step 1
*/
console.log( chalk.cyan( '1/2: Generating NPM build...' ) );
const require = createRequire( import.meta.url );
const pkg = require( upath.resolve( process.cwd(), './package.json' ) );
await build( {
input: 'src/index.js',
output: dist( './index.js' ),
external: [
'ckeditor5',
'ckeditor5-premium-features',
...Object.keys( {
...pkg.dependencies,
...pkg.peerDependencies
} )
],
clean: true,
sourceMap: true,
translations: '**/*.po'
} );
/**
* Step 2
*/
console.log( chalk.cyan( '2/2: Generating browser build...' ) );
await build( {
input: 'src/index.js',
output: dist( 'browser/index.js' ),
sourceMap: true,
minify: true,
browser: true,
name: '@ckeditor/ckeditor5-mermaid',
external: [
'ckeditor5',
'ckeditor5-premium-features'
]
} );
} )();

View File

@ -1,6 +1,22 @@
Software License Agreement Software License Agreement
========================== ==========================
Copyright (c) 2025. All rights reserved. **CKEditor 5 mermaid feature** (https://ckeditor.com/ckeditor-5/)<br>
Copyright (c) 2003-2022, [CKSource](http://cksource.com) Holding sp. z o.o. All rights reserved.
Licensed under the terms of [MIT license](https://opensource.org/licenses/MIT). Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
Sources of Intellectual Property Included in CKEditor 5 mermaid feature
---------------------------------------------------------------------
Where not otherwise indicated, all CKEditor 5 mermaid feature content is authored by CKSource engineers and consists of CKSource-owned intellectual property.
The following libraries are included in CKEditor 5 mermaid feature under the [MIT license](https://opensource.org/licenses/MIT):
* Lo-Dash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas.
* mermaid - Copyright (c) 2014 - 2021 Knut Sveidqvist. (MIT License)
Trademarks
----------
**CKEditor** is a trademark of [CKSource](http://cksource.com) Holding sp. z o.o. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.

View File

@ -1,21 +1,26 @@
@triliumnext/ckeditor5-mermaid @triliumnext/ckeditor5-mermaid
============================== ==============================
This package was created by the [ckeditor5-package-generator](https://www.npmjs.com/package/ckeditor5-package-generator) package. Warning: This is an experimental plugin that comes with no support, use it at your own risk.
This package contains a Mermaid feature for CKEditor 5.
## Table of contents ## Table of contents
* [Developing the package](#developing-the-package) - [@triliumnext/ckeditor5-mermaid](#triliumnextckeditor5-mermaid)
* [Available scripts](#available-scripts) - [Table of contents](#table-of-contents)
* [`start`](#start) - [Developing the package](#developing-the-package)
* [`test`](#test) - [Available scripts](#available-scripts)
* [`lint`](#lint) - [`start`](#start)
* [`stylelint`](#stylelint) - [`test`](#test)
* [`build:dist`](#builddist) - [`lint`](#lint)
* [`translations:synchronize`](#translationssynchronize) - [`stylelint`](#stylelint)
* [`translations:validate`](#translationsvalidate) - [`build:dist`](#builddist)
* [`ts:build` and `ts:clear`](#tsbuild-and-tsclear) - [`translations:synchronize`](#translationssynchronize)
* [License](#license) - [`translations:validate`](#translationsvalidate)
- [`ts:build` and `ts:clear`](#tsbuild-and-tsclear)
- [License](#license)
- [Trademarks](#trademarks)
## Developing the package ## Developing the package
@ -136,6 +141,8 @@ These scripts compile TypeScript and remove the compiled files. They are used in
## License ## License
The `@triliumnext/ckeditor5-mermaid` package is available under [MIT license](https://opensource.org/licenses/MIT). See [LICENSE.md](LICENSE.md) file.
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. ### Trademarks
**CKEditor** is a trademark of [CKSource](https://cksource.com) Holding sp. z o.o. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.

View File

@ -1,7 +1,7 @@
{ {
"name": "@triliumnext/ckeditor5-mermaid", "name": "@triliumnext/ckeditor5-mermaid",
"version": "0.0.1", "version": "0.0.4",
"description": "A plugin for CKEditor 5.", "description": "Mermaid widget for CKEditor 5.",
"keywords": [ "keywords": [
"ckeditor", "ckeditor",
"ckeditor5", "ckeditor5",
@ -23,7 +23,9 @@
"./browser/*": null, "./browser/*": null,
"./package.json": "./package.json" "./package.json": "./package.json"
}, },
"license": "MIT", "license": "SEE LICENSE IN LICENSE.md",
"author": "CKSource (https://cksource.com/)",
"homepage": "https://github.com/ckeditor/ckeditor5-mermaid",
"engines": { "engines": {
"node": ">=18.0.0", "node": ">=18.0.0",
"npm": ">=5.7.1" "npm": ">=5.7.1"

View File

@ -1,17 +0,0 @@
import { describe, expect, it } from 'vitest';
import { Mermaid as MermaidDll, icons } from '../src/index.js';
import Mermaid from '../src/mermaid.js';
import ckeditor from './../theme/icons/ckeditor.svg';
describe( 'CKEditor5 Mermaid DLL', () => {
it( 'exports Mermaid', () => {
expect( MermaidDll ).to.equal( Mermaid );
} );
describe( 'icons', () => {
it( 'exports the "ckeditor" icon', () => {
expect( icons.ckeditor ).to.equal( ckeditor );
} );
} );
} );

View File

@ -1,56 +0,0 @@
import { describe, expect, it, beforeEach, afterEach } from 'vitest';
import { ClassicEditor, Essentials, Paragraph, Heading } from 'ckeditor5';
import Mermaid from '../src/mermaid.js';
describe( 'Mermaid', () => {
it( 'should be named', () => {
expect( Mermaid.pluginName ).to.equal( 'Mermaid' );
} );
describe( 'init()', () => {
let domElement: HTMLElement, editor: ClassicEditor;
beforeEach( async () => {
domElement = document.createElement( 'div' );
document.body.appendChild( domElement );
editor = await ClassicEditor.create( domElement, {
licenseKey: 'GPL',
plugins: [
Paragraph,
Heading,
Essentials,
Mermaid
],
toolbar: [
'mermaid'
]
} );
} );
afterEach( () => {
domElement.remove();
return editor.destroy();
} );
it( 'should load Mermaid', () => {
const myPlugin = editor.plugins.get( 'Mermaid' );
expect( myPlugin ).to.be.an.instanceof( Mermaid );
} );
it( 'should add an icon to the toolbar', () => {
expect( editor.ui.componentFactory.has( 'mermaid' ) ).to.equal( true );
} );
it( 'should add a text into the editor after clicking the icon', () => {
const icon = editor.ui.componentFactory.create( 'mermaid' );
expect( editor.getData() ).to.equal( '' );
icon.fire( 'execute' );
expect( editor.getData() ).to.equal( '<p>Hello CKEditor 5!</p>' );
} );
} );
} );