Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cms 25371 unified ckeditor5 package #198

Merged
merged 45 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3ee2a0c
update dependencies to new unified ckeditor5 package
jens-meisner Aug 5, 2024
77ac3a0
translated imports by script
jens-meisner Aug 5, 2024
dfa98b1
manual type fixes + adding "addTranslations" and "openLink"
jens-meisner Aug 5, 2024
33c3860
fix position of //@ts-expect-error after different formatting
jens-meisner Aug 5, 2024
5321740
first iteration to get jest running with esm
jens-meisner Aug 22, 2024
3cec951
next iteration to get jest tests run
jens-meisner Oct 23, 2024
a901be4
patch ckeditor5 version 42.0.2 + fix build outputDir + revert shared-…
jens-meisner Oct 24, 2024
78a612e
all jest tests functional again
jens-meisner Oct 28, 2024
2792f6d
fix filename + fix lint + remove old dep + remove useFakeTimers
jens-meisner Oct 29, 2024
d0ac0e6
remove all useFakeTimers
jens-meisner Oct 29, 2024
f54fb6e
update pnpm-lockk
jens-meisner Oct 29, 2024
3817e83
fix playwright tests by avoiding imports which assume to be in a browser
jens-meisner Nov 14, 2024
7daf023
Merge branch 'main' into CMS-25371-unified-ckeditor5-package
jens-meisner Nov 14, 2024
f9804db
Merge branch 'main' into CMS-25371-unified-ckeditor5-package
jens-meisner Nov 14, 2024
75c84cc
reset versions from rc and update pnpm-lock
jens-meisner Nov 14, 2024
321da4b
reset versions from rc and update pnpm-lock
jens-meisner Nov 14, 2024
6bae950
change exports.types in package.json to "src/index.ts" to get correct…
jens-meisner Nov 14, 2024
7540abb
fix drag and drop tests except "Should render dropped content-link wi…
jens-meisner Nov 14, 2024
4b3d5c6
adding also "en" translations; otherwise german text was used + fixes…
jens-meisner Nov 15, 2024
03c4057
undo some changes and instead change getOptionalPlugin + revert addin…
jens-meisner Nov 15, 2024
f337317
adding (again) also "en" translations (confusing); otherwise german t…
jens-meisner Nov 15, 2024
10dc5fa
upgrade ckeditor5 to 43.3.1 (including pnpm patch)
jens-meisner Nov 15, 2024
f27d322
fix lint errors
jens-meisner Nov 15, 2024
cd35e2a
restore service-agent peerDependency to "^1.1.5 || ^2.01"
jens-meisner Nov 15, 2024
f5bb687
skip test temporarily; test fails, but doing dnd manually works
jens-meisner Nov 18, 2024
cee1972
fix bad peerDependency
jens-meisner Nov 18, 2024
3410acf
fix lint errors
jens-meisner Nov 18, 2024
dffbe45
fix bad jest config
jens-meisner Nov 18, 2024
03c27df
fix doc errors
jens-meisner Nov 18, 2024
9af7e0a
copy package.json and README into dist folder + update pnpm-lock
jens-meisner Nov 18, 2024
0a673bd
remove temporarily used deps for script
jens-meisner Nov 18, 2024
2c4f6ca
update pnpm-lock
jens-meisner Nov 18, 2024
8be31d3
fix exports in publishConfig
jens-meisner Nov 18, 2024
6e445ab
update pnpm-lock
jens-meisner Nov 18, 2024
de94ba5
remove all main entries in package.json + change import type
jens-meisner Nov 19, 2024
388ca3c
added missing exports in package.json + fixed circular dependency in …
jens-meisner Nov 19, 2024
9f966a1
fix publishConfig
jens-meisner Nov 19, 2024
9025a3a
restore main and publishConfig for example-data
jens-meisner Nov 19, 2024
c47a0d9
create type Pluginterface locally as it is not exposed anymore from c…
jens-meisner Nov 20, 2024
3c455e1
remove TODO
jens-meisner Nov 20, 2024
55503ab
import ckeditor5.css explicitely
jens-meisner Nov 20, 2024
9e7992f
fix drop issue on ballon panel, if drag over editor was missing + ena…
jens-meisner Nov 20, 2024
e7bcd6e
use publishConfig for published package.json + publish *.ts files too
jens-meisner Nov 21, 2024
a0d2e51
fix lint error, rename prepare-package.js to .cjs - require undefined…
jens-meisner Nov 21, 2024
5d12412
omit sources and source-maps in published package
jens-meisner Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module.exports = {
* ESLint Plugin: Import
* =====================================================================
*/
"import/no-extraneous-dependencies": ["error", { optionalDependencies: false }],
"import/no-extraneous-dependencies": ["error", { optionalDependencies: false, devDependencies: true }],
/*
* =====================================================================
* ESLint Plugin: JSDoc
Expand Down
75 changes: 25 additions & 50 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@coremedia/ckeditor5-app",
"description": "A custom CKEditor 5 build made by the CKEditor 5 online builder.",
"version": "21.0.0",
"version": "20.1.0",
"author": {
"name": "CoreMedia GmbH",
"email": "info@coremedia.com",
Expand All @@ -15,60 +15,35 @@
"license": "Apache-2.0",
"private": true,
"dependencies": {
"@ckeditor/ckeditor5-alignment": "43.2.0",
"@ckeditor/ckeditor5-autoformat": "43.2.0",
"@ckeditor/ckeditor5-autosave": "43.2.0",
"@ckeditor/ckeditor5-basic-styles": "43.2.0",
"@ckeditor/ckeditor5-block-quote": "43.2.0",
"@ckeditor/ckeditor5-clipboard": "43.2.0",
"@ckeditor/ckeditor5-code-block": "43.2.0",
"@ckeditor/ckeditor5-core": "43.2.0",
"@ckeditor/ckeditor5-editor-classic": "43.2.0",
"@ckeditor/ckeditor5-engine": "43.2.0",
"@ckeditor/ckeditor5-essentials": "43.2.0",
"@ckeditor/ckeditor5-find-and-replace": "43.2.0",
"@ckeditor/ckeditor5-font": "43.2.0",
"@ckeditor/ckeditor5-heading": "43.2.0",
"@ckeditor/ckeditor5-highlight": "43.2.0",
"@ckeditor/ckeditor5-image": "43.2.0",
"@ckeditor/ckeditor5-indent": "43.2.0",
"@ckeditor/ckeditor5-language": "43.2.0",
"@ckeditor/ckeditor5-link": "43.2.0",
"@ckeditor/ckeditor5-list": "43.2.0",
"@ckeditor/ckeditor5-paragraph": "43.2.0",
"@ckeditor/ckeditor5-paste-from-office": "43.2.0",
"@ckeditor/ckeditor5-remove-format": "43.2.0",
"@ckeditor/ckeditor5-source-editing": "43.2.0",
"@ckeditor/ckeditor5-table": "43.2.0",
"@ckeditor/ckeditor5-typing": "43.2.0",
"@ckeditor/ckeditor5-ui": "43.2.0",
"@ckeditor/ckeditor5-upload": "43.2.0",
"@ckeditor/ckeditor5-utils": "43.2.0",
"ckeditor5": "43.3.1",
"@coremedia-internal/ckeditor5-coremedia-example-data": "^1.0.0",
"@coremedia/ckeditor5-bbcode": "^21.0.0",
"@coremedia/ckeditor5-coremedia-blocklist": "^21.0.0",
"@coremedia/ckeditor5-coremedia-content-clipboard": "^21.0.0",
"@coremedia/ckeditor5-coremedia-differencing": "^21.0.0",
"@coremedia/ckeditor5-coremedia-images": "^21.0.0",
"@coremedia/ckeditor5-coremedia-link": "^21.0.0",
"@coremedia/ckeditor5-coremedia-richtext": "^21.0.0",
"@coremedia/ckeditor5-coremedia-studio-essentials": "^21.0.0",
"@coremedia/ckeditor5-coremedia-studio-integration-mock": "^21.0.0",
"@coremedia/ckeditor5-data-facade": "^21.0.0",
"@coremedia/ckeditor5-dataprocessor-support": "^21.0.0",
"@coremedia/ckeditor5-dialog-visibility": "^21.0.0",
"@coremedia/ckeditor5-dom-converter": "^21.0.0",
"@coremedia/ckeditor5-font-mapper": "^21.0.0",
"@coremedia/ckeditor5-link-common": "^21.0.0",
"@coremedia/service-agent": "^2.0.1",
"@coremedia/ckeditor5-bbcode": "^20.1.0",
"@coremedia/ckeditor5-coremedia-blocklist": "^20.1.0",
"@coremedia/ckeditor5-coremedia-content-clipboard": "^20.1.0",
"@coremedia/ckeditor5-coremedia-differencing": "^20.1.0",
"@coremedia/ckeditor5-coremedia-images": "^20.1.0",
"@coremedia/ckeditor5-coremedia-link": "^20.1.0",
"@coremedia/ckeditor5-coremedia-richtext": "^20.1.0",
"@coremedia/ckeditor5-coremedia-studio-essentials": "^20.1.0",
"@coremedia/ckeditor5-coremedia-studio-integration-mock": "workspace:*",
"@coremedia/ckeditor5-data-facade": "^20.1.0",
"@coremedia/ckeditor5-dataprocessor-support": "^20.1.0",
"@coremedia/ckeditor5-dialog-visibility": "^20.1.0",
"@coremedia/ckeditor5-dom-converter": "^20.1.0",
"@coremedia/ckeditor5-font-mapper": "^20.1.0",
"@coremedia/ckeditor5-link-common": "^20.1.0",
"@coremedia/service-agent": "^1.1.5",
"xml-formatter": "^3.6.2"
},
"devDependencies": {
"@ckeditor/ckeditor5-dev-translations": "^40.3.1",
"@ckeditor/ckeditor5-dev-utils": "^40.3.1",
"@babel/core": "^7.25.2",
"@babel/plugin-transform-runtime": "^7.25.4",
"@ckeditor/ckeditor5-dev-translations": "^43.0.1",
"@ckeditor/ckeditor5-dev-utils": "^43.0.1",
"@ckeditor/ckeditor5-inspector": "^4.1.0",
"@ckeditor/ckeditor5-theme-lark": "43.2.0",
"@ckeditor/ckeditor5-theme-lark": "43.3.1",
"@types/node": "^20.14.10",
"babel-loader": "^8.3.0",
"circular-dependency-plugin": "^5.2.2",
"css-loader": "^7.1.2",
"esbuild-loader": "^3.2.0",
Expand All @@ -79,7 +54,7 @@
"rimraf": "^6.0.1",
"style-loader": "^4.0.0",
"terser-webpack-plugin": "^5.3.10",
"typescript": "^5.4.5",
"typescript": "5.4.5",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4"
},
Expand Down
3 changes: 1 addition & 2 deletions app/src/CKEditorInstanceFactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ApplicationState } from "./ApplicationState";
import { ClassicEditor } from "@ckeditor/ckeditor5-editor-classic";

import { ClassicEditor } from "ckeditor5";
export type CKEditorInstanceFactory = (sourceElement: HTMLElement, state: ApplicationState) => Promise<ClassicEditor>;
4 changes: 2 additions & 2 deletions app/src/DataFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export const dataFormatter: {
collapseContent: false,
whiteSpaceAtEndOfSelfclosingTag: true,
})
: empty ?? "",
text: (data, empty) => (data ? data : empty ?? ""),
: (empty ?? ""),
text: (data, empty) => (data ? data : (empty ?? "")),
};
28 changes: 7 additions & 21 deletions app/src/createCKEditorInstance.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApplicationState } from "./ApplicationState";
import { ClassicEditor } from "@ckeditor/ckeditor5-editor-classic";
import { Command, Editor } from "@ckeditor/ckeditor5-core";
import { ClassicEditor, Command, Editor } from "ckeditor5";
import { CKEditorInstanceFactory } from "./CKEditorInstanceFactory";
import { Differencing } from "@coremedia/ckeditor5-coremedia-differencing";
import { initReadOnlyToggle } from "./ReadOnlySwitch";
Expand All @@ -17,21 +16,22 @@ import { initExamplesAndBindTo } from "./example-data";
// See https://github.com/ckeditor/ckeditor5-inspector/issues/173
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
declare class CKEditorInspector {
static attach(editorOrConfig: Editor | Record<string, Editor>, options?: { isCollapsed?: boolean }): string[];
static attach(
editorOrConfig: Editor | Record<string, Editor>,
options?: {
isCollapsed?: boolean;
},
): string[];
}

export const editorElementId = "editor";

export interface CKEditorInstanceFactories {
bbcode: CKEditorInstanceFactory;
richtext: CKEditorInstanceFactory;
}

export const ckEditorInstanceFactories: CKEditorInstanceFactories = {
bbcode: createBBCodeEditor,
richtext: createRichTextEditor,
};

const attachInspector = (editor: Editor, { dataType, inspector }: ApplicationState): string[] =>
CKEditorInspector.attach(
{
Expand All @@ -43,7 +43,6 @@ const attachInspector = (editor: Editor, { dataType, inspector }: ApplicationSta
isCollapsed: inspector === "collapsed",
},
);

const optionallyActivateDifferencing = (editor: Editor): void => {
if (editor.plugins.has(Differencing)) {
editor.plugins.get(Differencing).activateDifferencing();
Expand All @@ -57,7 +56,6 @@ const optionallyActivateDifferencing = (editor: Editor): void => {
*/
const registerResetUndo = (editor: Editor): void => {
const undoCommand: Command | undefined = editor.commands.get("undo");

if (undoCommand) {
//@ts-expect-error Editor extension, no typing available.
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
Expand Down Expand Up @@ -98,14 +96,11 @@ const initializePreviewData = (editor: ClassicEditor, { dataType }: ApplicationS
updatePreview(editor.getData(), "text");
}
};

export const createCKEditorInstance = async (state: ApplicationState): Promise<ClassicEditor> => {
const sourceElement = document.getElementById(editorElementId);

if (!sourceElement) {
throw new Error(`Required element with id ${editorElementId} not defined in HTML.`);
}

const { dataType, uiLanguage, readOnlyMode } = state;
let factory: CKEditorInstanceFactory;
switch (dataType) {
Expand All @@ -118,29 +113,22 @@ export const createCKEditorInstance = async (state: ApplicationState): Promise<C
default:
throw new Error(`Unknown data type: ${dataType}`);
}

const editor = await factory(sourceElement, state);

initExamplesAndBindTo(editor, dataType);

initDataTypeSwitch({
default: dataType,
onSwitch(mode): void {
state.dataType = mode;
},
});

initUiLanguageSwitch({
default: uiLanguage,
onSwitch(lang): void {
state.uiLanguage = lang;
},
});

attachInspector(editor, state);

optionallyActivateDifferencing(editor);

initReadOnlyToggle({
default: readOnlyMode,
onSwitch: (mode) => {
Expand All @@ -152,9 +140,7 @@ export const createCKEditorInstance = async (state: ApplicationState): Promise<C
state.readOnlyMode = mode;
},
});

initPreview(state);

registerResetUndo(editor);
initializePreviewData(editor, state);
registerGlobalEditor(editor);
Expand Down
Loading
Loading