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

!!! FEATURE: Upgrade CKEditor 5 from version 16.0.0 to 44.0.0 #3883

Merged
merged 18 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
50 changes: 24 additions & 26 deletions Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Selector, RequestLogger} from 'testcafe';
import {ReactSelector} from 'testcafe-react-selectors';
import {beforeEach, subSection, checkPropTypes} from '../../utils';
import {beforeEach, subSection, checkPropTypes, typeTextInline, clearInlineText} from '../../utils';
import {Page} from '../../pageModel';

/* global fixture:true */
Expand Down Expand Up @@ -170,41 +170,43 @@ test('Can create content node from inside InlineUI', async t => {

subSection('Type something inside of it');
await Page.waitForIframeLoading(t);

await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', headlineTitle, 'heading1');
await t
.switchToIframe(contentIframeSelector)
.typeText(Selector('.test-headline h1'), headlineTitle)
.expect(Selector('.neos-contentcollection').withText(headlineTitle).exists).ok('Typed headline text exists');
// .selectEditableContent(lastEditableElement, lastEditableElement)
// .pressKey(headlineTitle.split('').join(' '))
.expect(Selector('.neos-contentcollection').withText(headlineTitle).exists).ok('Typed headline text exists')
.switchToMainWindow();

subSection('Inline validation');
// We have to wait for ajax requests to be triggered, since they are debounced for 0.5s
await t.wait(1600);
await changeRequestLogger.clear();
await clearInlineText(t, Selector('.test-headline [contenteditable="true"]').nth(-1), true);
await t
.expect(Selector('.test-headline h1').exists).ok('Validation tooltip appeared')
.click('.test-headline h1')
.pressKey('ctrl+a delete')
.switchToMainWindow()
.wait(1600)
.expect(ReactSelector('InlineValidationTooltips').exists).ok('Validation tooltip appeared');
await t
.expect(changeRequestLogger.count(() => true)).eql(0, 'No requests were fired with invalid state');
await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', 'Some text', 'heading1');
await t
.switchToIframe(contentIframeSelector)
.typeText(Selector('.test-headline h1'), 'Some text')
.wait(1600);
.wait(1600)
.switchToMainWindow();
await t.expect(changeRequestLogger.count(() => true)).eql(1, 'Request fired when field became valid');

subSection('Create a link to node');
const linkTargetPage = 'Link target';
await t
.doubleClick('.test-headline h1')
.switchToMainWindow()
.click(ReactSelector('EditorToolbar LinkButton'))
.typeText(ReactSelector('EditorToolbar LinkButton TextInput'), linkTargetPage)
.click(ReactSelector('EditorToolbar ContextDropDownContents NodeOption'))
.switchToIframe(contentIframeSelector)
.expect(Selector('.test-headline h1 a').withAttribute('href').exists).ok('Newly inserted link exists')
.switchToMainWindow();
// 'This test is currently failing due to a bug in testcafe regarding the editable content selection'
subSection('Skipped: Create a link to node');
// const linkTargetPage = 'Link target';
// await t
// .doubleClick('.test-headline h1')
// .switchToMainWindow()
// .click(ReactSelector('EditorToolbar LinkButton'))
// .typeText(ReactSelector('EditorToolbar LinkButton TextInput'), linkTargetPage)
// .click(ReactSelector('EditorToolbar ContextDropDownContents NodeOption'))
// .switchToIframe(contentIframeSelector)
// .expect(Selector('.test-headline h1 a').withAttribute('href').exists).ok('Newly inserted link exists')
// .switchToMainWindow();
});

test('Inline CKEditor mode `paragraph: false` works as expected', async t => {
Expand All @@ -219,12 +221,8 @@ test('Inline CKEditor mode `paragraph: false` works as expected', async t => {
subSection('Insert text into the inline text and press enter');

await Page.waitForIframeLoading(t);
await typeTextInline(t, '.test-inline-headline:last-child [contenteditable="true"]', 'Foo Bar<br>Bun Buz');
await t
.switchToIframe(contentIframeSelector)
.typeText(Selector('.test-inline-headline [contenteditable="true"]'), 'Foo Bar')
.click(Selector('.test-inline-headline [contenteditable="true"]'))
.pressKey('enter')
.typeText(Selector('.test-inline-headline [contenteditable="true"]'), 'Bun Buz')
.expect(Selector('.neos-contentcollection').withText('Foo Bar').exists).ok('Inserted text exists');

await t.switchToMainWindow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ test('Discarding: delete a document node and then discard deletion', async t =>
await Page.goToPage(pageTitleToDelete);
await t
.switchToIframe('[name="neos-content-main"]')
.expect(Selector('.test-headline h1').withText(headlineOnDeletedPage).exists).ok('Navigated to the page and see the headline inline')
.expect(Selector('.neos-contentcollection').withText(headlineOnDeletedPage).exists).ok('Navigated to the page and see the headline inline')
.switchToMainWindow();

subSection('Delete that page');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Selector} from 'testcafe';
import {ReactSelector} from 'testcafe-react-selectors';
import {beforeEach, checkPropTypes} from './../../utils.js';
import {beforeEach, checkPropTypes, typeTextInline} from './../../utils.js';
import {Page} from './../../pageModel';

/* global fixture:true */
Expand All @@ -14,11 +14,11 @@ test('Can crop an image', async t => {
await Page.waitForIframeLoading(t);

const rteInspectorEditor = await ReactSelector('InspectorEditorEnvelope').withProps('id', 'rte');
const ckeContent = await Selector('.ck-content p');
// const ckeContent = await Selector('.ck-content p');
await t
.click(rteInspectorEditor.findReact('Button'));
await typeTextInline(t, '.ck-content p', testContent, '', false);
await t
.typeText(ckeContent, testContent)
.wait(400)
.click(Selector('#neos-Inspector-Apply'));
await Page.waitForIframeLoading(t);
Expand Down
77 changes: 55 additions & 22 deletions Tests/IntegrationTests/Fixtures/1Dimension/syncing.e2e.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import {Selector} from 'testcafe';
import {ReactSelector, waitForReact} from 'testcafe-react-selectors';
import {checkPropTypes, adminUserOnOneDimensionTestSite, editorUserOnOneDimensionTestSite} from './../../utils.js';
import {
checkPropTypes,
adminUserOnOneDimensionTestSite,
editorUserOnOneDimensionTestSite,
typeTextInline,
subSection
} from './../../utils.js';
import {
Page,
PublishDropDown
Expand All @@ -11,8 +17,6 @@ import {
fixture`Syncing`
.afterEach(() => checkPropTypes());

const contentIframeSelector = Selector('[name="neos-content-main"]', {timeout: 2000});

test('Syncing: Create a conflict state between two editors and choose "Discard all" as a resolution strategy during rebase', async t => {
await prepareContentElementConflictBetweenAdminAndEditor(t);
await chooseDiscardAllAsResolutionStrategy(t);
Expand Down Expand Up @@ -137,29 +141,37 @@ async function prepareContentElementConflictBetweenAdminAndEditor(t) {
.ok('[🗋 Sync Demo #3] cannot be found in the document tree of user "editor".');
});


//
// Login as "admin" again
//
await as(t, adminUserOnOneDimensionTestSite, async () => {
//
// Create a headline node in [🗋 Sync Demo #3]
//
subSection('Create a headline node in the document');
await Page.goToPage('Sync Demo #3');
await t
.switchToIframe(contentIframeSelector)
.click(Selector('.neos-contentcollection'))
.click(Selector('#neos-InlineToolbar-AddNode'))
.switchToMainWindow()
.switchToMainWindow();

await openContentTree(t);

await t
.wait(1000)
.click(Page.treeNode.withText('Content Collection (main)'))
.click(Page.treeNode.withText('Content Collection (main)'))
.wait(1000)
.click(Selector('#neos-ContentTree-AddNode'))
.click(Selector('button#into'))
.click(ReactSelector('NodeTypeItem').withProps({nodeType: {label: 'Headline_Test'}}))
.switchToIframe(contentIframeSelector)
.typeText(Selector('.test-headline h1'), 'Hello from Page "Sync Demo #3"!')
.wait(2000)
.click(ReactSelector('NodeTypeItem').find('button>span>span').withText('Headline_Test'))
await Page.waitForIframeLoading(t);

subSection('Type something inside of it');
await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', 'Hello from Page "Sync Demo #3"!');
await t
.expect(Selector('.neos-contentcollection').withText('Hello from Page "Sync Demo #3"!').exists).ok('Typed headline text exists')
.switchToMainWindow();
});


//
// Login as "editor" again
//
Expand All @@ -175,7 +187,6 @@ async function prepareContentElementConflictBetweenAdminAndEditor(t) {
await PublishDropDown.publishAll();
});


//
// Login as "admin" again and visit [🗋 Sync Demo #3]
//
Expand All @@ -198,16 +209,27 @@ async function prepareDocumentConflictBetweenAdminAndEditor(t) {
await createDocumentNode(t, 'Home', 'into', 'This page will be deleted during sync');
await PublishDropDown.publishAll();

subSection('Create a headline node in the document');
await Page.waitForIframeLoading(t);

await t
.switchToMainWindow();

await openContentTree(t);

await t
.switchToIframe(contentIframeSelector)
.click(Selector('.neos-contentcollection'))
.click(Selector('#neos-InlineToolbar-AddNode'))
.switchToMainWindow()
.wait(1000)
.click(Page.treeNode.withText('Content Collection (main)'))
.click(Page.treeNode.withText('Content Collection (main)'))
.wait(1000)
.click(Selector('#neos-ContentTree-AddNode'))
.click(Selector('button#into'))
.click(ReactSelector('NodeTypeItem').withProps({nodeType: {label: 'Headline_Test'}}))
.switchToIframe(contentIframeSelector)
.doubleClick(Selector('.test-headline h1'))
.typeText(Selector('.test-headline h1'), 'This change will not be published.')
.click(ReactSelector('NodeTypeItem').find('button>span>span').withText('Headline_Test'));
await Page.waitForIframeLoading(t);

subSection('Type something inside of it');
await typeTextInline(t, '.test-headline:last-child', 'This change will not be published.');
await t
.wait(2000)
.switchToMainWindow();
});
Expand Down Expand Up @@ -380,3 +402,14 @@ async function assertThatWeCannotSeePageInTree(t, pageTitle) {
await t.expect(Page.treeNode.withExactText(pageTitle).exists)
.notOk(`[🗋 ${pageTitle}] can still be found in the document tree of user "admin".`);
}

async function openContentTree(t) {
const contentTree = ReactSelector('ToggleContentTree');
const isPanelOpen = await contentTree.getReact(({props}) => props.isPanelOpen);

if (!isPanelOpen) {
await t
.pressKey('t')
.pressKey('c');
}
}
59 changes: 59 additions & 0 deletions Tests/IntegrationTests/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {t, Role, ClientFunction, Selector} from 'testcafe';
import {waitForReact} from 'testcafe-react-selectors';
import {PublishDropDown, Page} from './pageModel';
import {forEach} from "../../.yarn/releases/yarn-3.2.0";

export const subSection = name => console.log('\x1b[33m%s\x1b[0m', ' - ' + name);

Expand Down Expand Up @@ -68,3 +69,61 @@ export async function beforeEach(t) {
}
await Page.goToPage('Home');
}

// This is a workaround for the fact that the contenteditable element is not directly selectable
// for more information see https://testcafe.io/documentation/402688/reference/test-api/testcontroller/selecteditablecontent
export async function typeTextInline(t, selector, text, textType, switchToIframe = true) {
await waitForReact(30000);
await Page.waitForIframeLoading();

const textTypeToTagMap = {
paragraph: 'p',
heading1: 'h1',
heading2: 'h2',
heading3: 'h3',
heading4: 'h4'
};

if (!Object.keys(textTypeToTagMap).includes(textType)) {
textType = 'paragraph';
}

const tagName = textTypeToTagMap[textType] || '';
try {
const contentIframeSelector = Selector('[name="neos-content-main"]', {timeout: 2000});

if (switchToIframe) {
await t.switchToIframe(contentIframeSelector);
}

await t.eval(() => {
const element = window.document.querySelector(selector);
const editor = element.closest('.ck-editor__editable');
const content = tagName !== '' ? `<${tagName}>${text}</${tagName}>` : text;
editor.ckeditorInstance.data.set(content);
},
{dependencies: {selector, text, tagName}}
);
} catch (e) {
// console.log(e);
}
}

export async function clearInlineText(t, selector, switchToIframe = true) {
await waitForReact(30000);
await Page.waitForIframeLoading();

try {
const contentIframeSelector = Selector('[name="neos-content-main"]', {timeout: 2000});
const lastEditableElement = selector;
if (switchToIframe) {
await t.switchToIframe(contentIframeSelector);
}

await t
.selectEditableContent(lastEditableElement, lastEditableElement)
.pressKey('ctrl+a delete');
} catch (e) {
// console.log(e);
}
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"moment": "^2.20.1",
"vfile-message": "^2.0.2",
"isemail@3.2.0": "patch:isemail@npm:3.2.0#./patches/isemail-npm-3.2.0-browserified.patch",
"react-codemirror2@7.2.1": "patch:react-codemirror2@npm:7.2.1#./patches/react-codemirror2-npm-7.2.1-browserified.patch",
"@ckeditor/ckeditor5-engine@^16.0.0": "patch:@ckeditor/ckeditor5-engine@npm:16.0.0#./patches/@ckeditor-ckeditor5-engine-npm-16.0.0-placeholder.patch"
"react-codemirror2@7.2.1": "patch:react-codemirror2@npm:7.2.1#./patches/react-codemirror2-npm-7.2.1-browserified.patch"
},
"scripts": {
"lint": "tsc --noemit && stylelint 'packages/*/src/**/*.css' && yarn eslint 'packages/*/src/**/*.{js,jsx,ts,tsx}'",
Expand Down
28 changes: 14 additions & 14 deletions packages/neos-ui-ckeditor5-bindings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
"private": true,
"main": "./src/manifest.js",
"dependencies": {
"@ckeditor/ckeditor5-alignment": "^16.0.0",
"@ckeditor/ckeditor5-basic-styles": "^16.0.0",
"@ckeditor/ckeditor5-core": "^16.0.0",
"@ckeditor/ckeditor5-editor-decoupled": "^16.0.0",
"@ckeditor/ckeditor5-engine": "^16.0.0",
"@ckeditor/ckeditor5-essentials": "^16.0.0",
"@ckeditor/ckeditor5-heading": "^16.0.0",
"@ckeditor/ckeditor5-link": "^16.0.0",
"@ckeditor/ckeditor5-list": "^16.0.0",
"@ckeditor/ckeditor5-paragraph": "^16.0.0",
"@ckeditor/ckeditor5-remove-format": "^16.0.0",
"@ckeditor/ckeditor5-table": "^16.0.0",
"@ckeditor/ckeditor5-utils": "^16.0.0",
"@ckeditor/ckeditor5-widget": "^16.0.0",
"@ckeditor/ckeditor5-alignment": "^44.0.0",
"@ckeditor/ckeditor5-basic-styles": "^44.0.0",
"@ckeditor/ckeditor5-core": "^44.0.0",
"@ckeditor/ckeditor5-editor-decoupled": "^44.0.0",
"@ckeditor/ckeditor5-engine": "^44.0.0",
"@ckeditor/ckeditor5-essentials": "^44.0.0",
"@ckeditor/ckeditor5-heading": "^44.0.0",
"@ckeditor/ckeditor5-link": "^44.0.0",
"@ckeditor/ckeditor5-list": "^44.0.0",
"@ckeditor/ckeditor5-paragraph": "^44.0.0",
"@ckeditor/ckeditor5-remove-format": "^44.0.0",
"@ckeditor/ckeditor5-table": "^44.0.0",
"@ckeditor/ckeditor5-utils": "^44.0.0",
"@ckeditor/ckeditor5-widget": "^44.0.0",
"@neos-project/neos-ui-decorators": "workspace:*",
"@neos-project/neos-ui-editors": "workspace:*",
"@neos-project/neos-ui-extensibility": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';

import {neos} from '@neos-project/neos-ui-decorators';
import {svgToDataUri} from '@neos-project/utils-helpers';
import ckeIcons from './icons';

import style from './TableDropDown.module.css';
Expand Down Expand Up @@ -39,12 +40,14 @@ export default class TableDropDownButton extends PureComponent {
}

render() {
const iconDataUri = svgToDataUri(ckeIcons[this.props.icon]);
console.log({iconDataUri});
return (
<DropDown
padded={false}
>
<DropDown.Header title={this.props.i18nRegistry.translate(this.props.tooltip)}>
<img style={{verticalAlign: 'text-top'}} src={ckeIcons[this.props.icon]} alt={this.props.i18nRegistry.translate(this.props.tooltip)} />
<img style={{verticalAlign: 'text-top'}} src={iconDataUri} alt={this.props.i18nRegistry.translate(this.props.tooltip)} />
</DropDown.Header>
<DropDown.Contents className={style.contents} scrollable={false}>
{this.props.options.map(item => item.type === 'checkBox' ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,10 @@
font-weight:700;
background:#fafafa
}

/* The type around buttons has been added in CKEditor and has been not implemented yet in
the neos-ui. We maybe also don't need it at the moment.
*/
.ck .ck-widget .ck-widget__type-around__button {
display: none;
}
Loading
Loading