From 034fe0ebde91d86ae408f688100a79bc069eacd5 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:33:10 +0200 Subject: [PATCH 01/12] WIP: BUGFIX: Dont remove every span tags around content in inline mode --- packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js index 3bbc9429ca..83200d4165 100644 --- a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js +++ b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js @@ -9,7 +9,7 @@ const cleanupContentBeforeCommit = content => { return ''; } - if (content.match(/^/) && content.match(/<\/span>$/)) { + if (content.match(/^[^<]*<\/span>$/)) { return content .replace(/^/, '') .replace(/<\/span>$/, ''); From 3b715e2dee4a1fa8405435ab47afd697c7cd93ac Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Mon, 26 Jun 2023 16:41:09 +0200 Subject: [PATCH 02/12] TASK: Translated using Weblate (Dutch) Currently translated at 94.5% (104 of 110 strings) TASK: Translated using Weblate (Spanish) Currently translated at 94.5% (104 of 110 strings) TASK: Translated using Weblate (German) Currently translated at 94.5% (104 of 110 strings) Co-authored-by: Anonymous Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-1/de/ Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-1/es/ Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-1/nl/ Translation: Neos/Neos.Ui - Main - 8.1 --- Resources/Private/Translations/de/Main.xlf | 24 ++++++++++++++++++++++ Resources/Private/Translations/es/Main.xlf | 24 ++++++++++++++++++++++ Resources/Private/Translations/nl/Main.xlf | 24 ++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/Resources/Private/Translations/de/Main.xlf b/Resources/Private/Translations/de/Main.xlf index 22f47131e7..36484bb3fe 100644 --- a/Resources/Private/Translations/de/Main.xlf +++ b/Resources/Private/Translations/de/Main.xlf @@ -518,6 +518,30 @@ nodes Knoten + + Copy technical details + Technische Details kopieren + + + Technical details copied + Technische Details kopiert + + + Reload Neos UI + Neos UI neu laden + + + Sorry, but the Neos UI could not recover from this error. + Es tut uns leid, aber die Neos UI konnte sich von diesem Fehler nicht wiederherstellen. + + + Please reload the application, or contact your system administrator with the given details. + Bitte laden Sie die Anwendung neu, oder wenden Sie sich mit den angegebenen Details an Ihren Systemadministrator. + + + For more information about the error please refer to the JavaScript console. + Weitere Informationen zu diesem Fehler finden Sie in der JavaScript-Konsole. + diff --git a/Resources/Private/Translations/es/Main.xlf b/Resources/Private/Translations/es/Main.xlf index db3a5b10c7..9d20e83a39 100644 --- a/Resources/Private/Translations/es/Main.xlf +++ b/Resources/Private/Translations/es/Main.xlf @@ -474,6 +474,30 @@ Select a single document in order to be able to edit its properties Seleccionar un solo documento para poder editar sus propiedades + + Copy technical details + Copiar los detalles técnicos + + + Technical details copied + Detalles técnicos copiados + + + Reload Neos UI + Recargar la interfaz de usuario de Neo + + + Sorry, but the Neos UI could not recover from this error. + Lo sentimos, pero la interfaz de usuario de Neos no pudo recuperarse de este error. + + + Please reload the application, or contact your system administrator with the given details. + Por favor, vuelve a cargar la aplicación o ponte en contacto con el administrador del sistema con los detalles proporcionados. + + + For more information about the error please refer to the JavaScript console. + Para obtener más información sobre el error, consulta la consola de JavaScript. + diff --git a/Resources/Private/Translations/nl/Main.xlf b/Resources/Private/Translations/nl/Main.xlf index e824e74e7c..a18336af68 100644 --- a/Resources/Private/Translations/nl/Main.xlf +++ b/Resources/Private/Translations/nl/Main.xlf @@ -435,6 +435,30 @@ Select a single content element in order to be able to edit its properties Selecteer uitsluitend één content element om de eigenschappen aan te passen + + Copy technical details + Kopieer technische details + + + Technical details copied + Technische details gekopieerd + + + Reload Neos UI + Neos UI herladen + + + Sorry, but the Neos UI could not recover from this error. + Sorry, maar de Neos UI kon niet hersteld worden van deze fout. + + + Please reload the application, or contact your system administrator with the given details. + Herlaad u alstublieft de applicatie of geef de verschafte details door aan uw systeembeheerder. + + + For more information about the error please refer to the JavaScript console. + Meer informatie over deze fout kunt u vinden in de JavaScript console. + From 170aaf15b3fb7b2249a0784078be58fb863a684e Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Mon, 26 Jun 2023 16:41:14 +0200 Subject: [PATCH 03/12] TASK: Translated using Weblate (Dutch) Currently translated at 94.5% (104 of 110 strings) TASK: Translated using Weblate (Spanish) Currently translated at 94.5% (104 of 110 strings) TASK: Translated using Weblate (German) Currently translated at 94.5% (104 of 110 strings) Co-authored-by: Anonymous Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-0/de/ Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-0/es/ Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-0/nl/ Translation: Neos/Neos.Ui - Main - 8.0 --- Resources/Private/Translations/de/Main.xlf | 24 ++++++++++++++++++++++ Resources/Private/Translations/es/Main.xlf | 24 ++++++++++++++++++++++ Resources/Private/Translations/nl/Main.xlf | 24 ++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/Resources/Private/Translations/de/Main.xlf b/Resources/Private/Translations/de/Main.xlf index 95ae1100d0..e5abcf98d0 100644 --- a/Resources/Private/Translations/de/Main.xlf +++ b/Resources/Private/Translations/de/Main.xlf @@ -518,6 +518,30 @@ nodes Knoten + + Copy technical details + Technische Details kopieren + + + Technical details copied + Technische Details kopiert + + + Reload Neos UI + Neos UI neu laden + + + Sorry, but the Neos UI could not recover from this error. + Es tut uns leid, aber die Neos UI konnte sich von diesem Fehler nicht wiederherstellen. + + + Please reload the application, or contact your system administrator with the given details. + Bitte laden Sie die Anwendung neu, oder wenden Sie sich mit den angegebenen Details an Ihren Systemadministrator. + + + For more information about the error please refer to the JavaScript console. + Weitere Informationen zu diesem Fehler finden Sie in der JavaScript-Konsole. + diff --git a/Resources/Private/Translations/es/Main.xlf b/Resources/Private/Translations/es/Main.xlf index db3a5b10c7..9d20e83a39 100644 --- a/Resources/Private/Translations/es/Main.xlf +++ b/Resources/Private/Translations/es/Main.xlf @@ -474,6 +474,30 @@ Select a single document in order to be able to edit its properties Seleccionar un solo documento para poder editar sus propiedades + + Copy technical details + Copiar los detalles técnicos + + + Technical details copied + Detalles técnicos copiados + + + Reload Neos UI + Recargar la interfaz de usuario de Neo + + + Sorry, but the Neos UI could not recover from this error. + Lo sentimos, pero la interfaz de usuario de Neos no pudo recuperarse de este error. + + + Please reload the application, or contact your system administrator with the given details. + Por favor, vuelve a cargar la aplicación o ponte en contacto con el administrador del sistema con los detalles proporcionados. + + + For more information about the error please refer to the JavaScript console. + Para obtener más información sobre el error, consulta la consola de JavaScript. + diff --git a/Resources/Private/Translations/nl/Main.xlf b/Resources/Private/Translations/nl/Main.xlf index 901eb90d21..8be85414e1 100644 --- a/Resources/Private/Translations/nl/Main.xlf +++ b/Resources/Private/Translations/nl/Main.xlf @@ -435,6 +435,30 @@ Current value Huidge waarde + + Reload Neos UI + Neos UI herladen + + + Copy technical details + Kopieer technische details + + + Technical details copied + Technische details gekopieerd + + + Sorry, but the Neos UI could not recover from this error. + Sorry, maar de Neos UI kon niet hersteld worden van deze fout. + + + Please reload the application, or contact your system administrator with the given details. + Herlaad u alstublieft de applicatie of geef de verschafte details door aan uw systeembeheerder. + + + For more information about the error please refer to the JavaScript console. + Meer informatie over deze fout kunt u vinden in de JavaScript console. + From 336801d58a4af428319fbb19ef9c3d67a3e950b7 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Mon, 26 Jun 2023 22:35:57 +0200 Subject: [PATCH 04/12] TASK: Translated using Weblate (Dutch) Currently translated at 100.0% (110 of 110 strings) Co-authored-by: Mark Kuiphuis Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-1/nl/ Translation: Neos/Neos.Ui - Main - 8.1 --- Resources/Private/Translations/nl/Main.xlf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Resources/Private/Translations/nl/Main.xlf b/Resources/Private/Translations/nl/Main.xlf index a18336af68..2f47b372db 100644 --- a/Resources/Private/Translations/nl/Main.xlf +++ b/Resources/Private/Translations/nl/Main.xlf @@ -437,27 +437,27 @@ Copy technical details - Kopieer technische details + Kopieer technische details Technical details copied - Technische details gekopieerd + Technische details gekopieerd Reload Neos UI - Neos UI herladen + Neos UI herladen Sorry, but the Neos UI could not recover from this error. - Sorry, maar de Neos UI kon niet hersteld worden van deze fout. + Sorry, maar de Neos UI kon niet hersteld worden van deze fout. Please reload the application, or contact your system administrator with the given details. - Herlaad u alstublieft de applicatie of geef de verschafte details door aan uw systeembeheerder. + Herlaad u alstublieft de applicatie of geef de verschafte details door aan uw systeembeheerder. For more information about the error please refer to the JavaScript console. - Meer informatie over deze fout kunt u vinden in de JavaScript console. + Meer informatie over deze fout kunt u vinden in de JavaScript console. From 04d21bd76dd77afc55869550a8a08cba13c37320 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Mon, 26 Jun 2023 22:36:00 +0200 Subject: [PATCH 05/12] TASK: Translated using Weblate (Dutch) Currently translated at 100.0% (110 of 110 strings) Co-authored-by: Mark Kuiphuis Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-0/nl/ Translation: Neos/Neos.Ui - Main - 8.0 --- Resources/Private/Translations/nl/Main.xlf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Resources/Private/Translations/nl/Main.xlf b/Resources/Private/Translations/nl/Main.xlf index 8be85414e1..6286c7162b 100644 --- a/Resources/Private/Translations/nl/Main.xlf +++ b/Resources/Private/Translations/nl/Main.xlf @@ -437,27 +437,27 @@ Reload Neos UI - Neos UI herladen + Neos UI herladen Copy technical details - Kopieer technische details + Kopieer technische details Technical details copied - Technische details gekopieerd + Technische details gekopieerd Sorry, but the Neos UI could not recover from this error. - Sorry, maar de Neos UI kon niet hersteld worden van deze fout. + Sorry, maar de Neos UI kon niet hersteld worden van deze fout. Please reload the application, or contact your system administrator with the given details. - Herlaad u alstublieft de applicatie of geef de verschafte details door aan uw systeembeheerder. + Herlaad u alstublieft de applicatie of geef de verschafte details door aan uw systeembeheerder. For more information about the error please refer to the JavaScript console. - Meer informatie over deze fout kunt u vinden in de JavaScript console. + Meer informatie over deze fout kunt u vinden in de JavaScript console. From 7c9fc845981d13c7a413efb33094949026071dfa Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 28 Jun 2023 16:02:59 +0200 Subject: [PATCH 06/12] BUGFIX: Fix inline ckeditor mode Since there is still no native support for a inline ckeditor mode. https://github.com/ckeditor/ckeditor5/issues/762 we will continue our hacky road ;) This fixes several issues: - Inserting text with newlines will now correctly insert soft breaks (br) - We use our own pseodo `` tag to avoid the issue of having to parse html with regex and doing it wrong #2918 i also added a test for some inline editing behavior. (Like that there are no outer span or p tags) But writing a tests for #2918 is currently impossible, as our tests currently dont use `https` which means we cant access the `navigator.clipboard` and test that ckeditor works correctly when content is pasted. --- .../Fixtures/1Dimension/createNewNodes.e2e.js | 25 +++++++++++++++++ .../NodeTypes/Content/InlineHeadline.yaml | 28 +++++++++++++++++++ .../InlineHeadline/InlineHeadline.fusion | 9 ++++++ .../src/ckEditorApi.js | 18 +++++++++--- .../src/plugins/inlineMode.js | 26 +++++++++++++++-- 5 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/NodeTypes/Content/InlineHeadline.yaml create mode 100644 Tests/IntegrationTests/SharedNodeTypesPackage/Resources/Private/Fusion/Content/InlineHeadline/InlineHeadline.fusion diff --git a/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js b/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js index 8e243a440e..1adc77dccb 100644 --- a/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js +++ b/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js @@ -207,6 +207,31 @@ test('Can create content node from inside InlineUI', async t => { .switchToMainWindow(); }); +test('Inline CKEditor mode `paragraph: false` works as expected', async t => { + subSection('Create an inline headline node'); + await t + .click(Selector('#neos-ContentTree-ToggleContentTree')) + .click(Page.treeNode.withText('Content Collection (main)')) + .click(Selector('#neos-ContentTree-AddNode')) + .click(ReactSelector('NodeTypeItem').withProps({nodeType: {label: 'Inline_Headline_Test'}})); + await Page.waitForIframeLoading(t); + + subSection('Insert text into the inline text and press enter'); + + await Page.waitForIframeLoading(t); + 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(); + await t.wait(500); // we debounce the change + await t.expect(ReactSelector('Inspector TextAreaEditor').withProps({ value: 'Foo Bar
Bun Buz'}).exists).ok('The TextAreaEditor mirrors the expected value') +}); + test('Supports secondary inspector view for element editors', async t => { const SelectNodeTypeModal = ReactSelector('SelectNodeType'); await t diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/NodeTypes/Content/InlineHeadline.yaml b/Tests/IntegrationTests/SharedNodeTypesPackage/NodeTypes/Content/InlineHeadline.yaml new file mode 100644 index 0000000000..dc8217b52f --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/NodeTypes/Content/InlineHeadline.yaml @@ -0,0 +1,28 @@ +'Neos.TestNodeTypes:Content.InlineHeadline': + superTypes: + 'Neos.Neos:Content': true + ui: + label: Inline_Headline_Test + icon: icon-header + position: 200 + inspector: + groups: + default: + label: 'Default' + position: 5 + icon: 'icon-cogs' + + properties: + title: + type: string + ui: + reloadIfChanged: true + + inlineEditable: true + inline: + editorOptions: + autoparagraph: false + # we show it also in the inspector so we can easily see the raw text content + inspector: + group: 'default' + editor: 'Neos.Neos/Inspector/Editors/TextAreaEditor' diff --git a/Tests/IntegrationTests/SharedNodeTypesPackage/Resources/Private/Fusion/Content/InlineHeadline/InlineHeadline.fusion b/Tests/IntegrationTests/SharedNodeTypesPackage/Resources/Private/Fusion/Content/InlineHeadline/InlineHeadline.fusion new file mode 100644 index 0000000000..19e2ef50c3 --- /dev/null +++ b/Tests/IntegrationTests/SharedNodeTypesPackage/Resources/Private/Fusion/Content/InlineHeadline/InlineHeadline.fusion @@ -0,0 +1,9 @@ +prototype(Neos.TestNodeTypes:Content.InlineHeadline) < prototype(Neos.Neos:ContentComponent) { + title = Neos.Neos:Editable { + property = 'title' + } + + renderer = afx` +

{props.title}

+ ` +} diff --git a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js index 83200d4165..9e9c7ae64a 100644 --- a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js +++ b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js @@ -3,16 +3,26 @@ import DecoupledEditor from '@ckeditor/ckeditor5-editor-decoupled/src/decouplede import {actions} from '@neos-project/neos-ui-redux-store'; // We remove opening and closing span tags that are produced by the inlineMode plugin +/** @param {String} content */ const cleanupContentBeforeCommit = content => { // TODO: remove when this is fixed: https://github.com/ckeditor/ckeditor5/issues/401 if (content.match(/^<([a-z][a-z0-9]*)\b[^>]*> <\/\1>$/)) { return ''; } - if (content.match(/^[^<]*<\/span>$/)) { - return content - .replace(/^/, '') - .replace(/<\/span>$/, ''); + if (content.startsWith('') && content.endsWith('')) { + const contentWithoutOuterInlineWrapper = content + .replace(/^/, '') + .replace(/<\/neos-inline-wrapper>$/, ''); + + if (contentWithoutOuterInlineWrapper.includes('')) { + // in the case, multiple root paragraph elements were inserted into the ckeditor (wich is currently not prevented if the html is modified from outside) + // we have multiple root elements of type . We will convert all of them into spans. + return content + .replace(//g, '') + .replace(/<\/neos-inline-wrapper>/g, ''); + } + return contentWithoutOuterInlineWrapper; } return content; }; diff --git a/packages/neos-ui-ckeditor5-bindings/src/plugins/inlineMode.js b/packages/neos-ui-ckeditor5-bindings/src/plugins/inlineMode.js index b1dc4a5c83..902e805b89 100644 --- a/packages/neos-ui-ckeditor5-bindings/src/plugins/inlineMode.js +++ b/packages/neos-ui-ckeditor5-bindings/src/plugins/inlineMode.js @@ -1,5 +1,9 @@ import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; +/** + * HACK, since there is yet no native support + * see https://github.com/ckeditor/ckeditor5/issues/762 + */ export default class InlineMode extends Plugin { static get pluginName() { return 'InlineMode'; @@ -7,10 +11,26 @@ export default class InlineMode extends Plugin { init() { const editor = this.editor; - // We map paragraph model into plain element - editor.conversion.elementToElement({model: 'paragraph', view: 'span', converterPriority: 'high'}); + // we avoid multiple paragraph's to be created - eg when pasting a text with newlines (this will created soft breaks (
)) + editor.model.schema.extend('paragraph', { isLimit: true }); - // We redefine enter key to great soft breaks instead of paragraphs + + // we map paragraph model into plain element in edit mode + editor.conversion.for('editingDowncast').elementToElement({model: 'paragraph', view: 'span', converterPriority: 'high'}); + + // to avoid having a wrapping "span" tag, we will convert the outmost 'paragraph' and strip the custom tag 'neos-inline-wrapper' + // in a hacky cleanup in cleanupContentBeforeCommit + // see https://neos-project.slack.com/archives/C07QEQ1U2/p1687952441254759 - i could find a better solution + editor.conversion.for('dataDowncast').elementToElement({model: 'paragraph', view: ( modelElement, viewWriter ) => { + const parentIsRoot = modelElement.parent.is('$root'); + const hasAttributes = [...modelElement.getAttributes()].length !== 0; + if (!parentIsRoot || hasAttributes) { + return viewWriter.createContainerElement('span'); + } + return viewWriter.createContainerElement('neos-inline-wrapper'); + }, converterPriority: 'high'}); + + // we redefine enter key to create soft breaks (
) instead of new paragraphs editor.editing.view.document.on('enter', (evt, data) => { editor.execute('shiftEnter'); data.preventDefault(); From ba6e8162b38d62750e5e9569af3dce38192883a8 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 28 Jun 2023 16:50:37 +0200 Subject: [PATCH 07/12] TASK: Translated using Weblate (Spanish) Currently translated at 100.0% (110 of 110 strings) Co-authored-by: gallegonovato Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-1/es/ Translation: Neos/Neos.Ui - Main - 8.1 --- Resources/Private/Translations/es/Main.xlf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Resources/Private/Translations/es/Main.xlf b/Resources/Private/Translations/es/Main.xlf index 9d20e83a39..69d5d8337b 100644 --- a/Resources/Private/Translations/es/Main.xlf +++ b/Resources/Private/Translations/es/Main.xlf @@ -440,7 +440,7 @@ nodes - Nodos + nodos content elements selected @@ -476,27 +476,27 @@ Copy technical details - Copiar los detalles técnicos + Copiar la información técnica Technical details copied - Detalles técnicos copiados + Información técnica copiada Reload Neos UI - Recargar la interfaz de usuario de Neo + Recargar la interfaz del suario de Neos Sorry, but the Neos UI could not recover from this error. - Lo sentimos, pero la interfaz de usuario de Neos no pudo recuperarse de este error. + Lo sentimos, pero la interfaz de usuario de Neos no ha podido recuperarse de este error. Please reload the application, or contact your system administrator with the given details. - Por favor, vuelve a cargar la aplicación o ponte en contacto con el administrador del sistema con los detalles proporcionados. + Por favor, vuelve a cargar la aplicación o pónte en contacto con el administrador del sistema con los datos facilitados. For more information about the error please refer to the JavaScript console. - Para obtener más información sobre el error, consulta la consola de JavaScript. + Para obtener más información sobre el error, consulta la consola JavaScript. From 263c329e514756b28eaf8c03ea5708ecd0ee2e98 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 28 Jun 2023 16:50:38 +0200 Subject: [PATCH 08/12] TASK: Translated using Weblate (Spanish) Currently translated at 100.0% (110 of 110 strings) Co-authored-by: gallegonovato Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-8-0/es/ Translation: Neos/Neos.Ui - Main - 8.0 --- Resources/Private/Translations/es/Main.xlf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Resources/Private/Translations/es/Main.xlf b/Resources/Private/Translations/es/Main.xlf index 9d20e83a39..69d5d8337b 100644 --- a/Resources/Private/Translations/es/Main.xlf +++ b/Resources/Private/Translations/es/Main.xlf @@ -440,7 +440,7 @@ nodes - Nodos + nodos content elements selected @@ -476,27 +476,27 @@ Copy technical details - Copiar los detalles técnicos + Copiar la información técnica Technical details copied - Detalles técnicos copiados + Información técnica copiada Reload Neos UI - Recargar la interfaz de usuario de Neo + Recargar la interfaz del suario de Neos Sorry, but the Neos UI could not recover from this error. - Lo sentimos, pero la interfaz de usuario de Neos no pudo recuperarse de este error. + Lo sentimos, pero la interfaz de usuario de Neos no ha podido recuperarse de este error. Please reload the application, or contact your system administrator with the given details. - Por favor, vuelve a cargar la aplicación o ponte en contacto con el administrador del sistema con los detalles proporcionados. + Por favor, vuelve a cargar la aplicación o pónte en contacto con el administrador del sistema con los datos facilitados. For more information about the error please refer to the JavaScript console. - Para obtener más información sobre el error, consulta la consola de JavaScript. + Para obtener más información sobre el error, consulta la consola JavaScript. From 14e1a0b4fab75c10b437e31880b856b54ff290e4 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 28 Jun 2023 16:52:55 +0200 Subject: [PATCH 09/12] TASK: Translated using Weblate (Spanish) Currently translated at 100.0% (110 of 110 strings) Co-authored-by: gallegonovato Translate-URL: https://hosted.weblate.org/projects/neos/neos-ui-main-7-3/es/ Translation: Neos/Neos.Ui - Main - 7.3 --- Resources/Private/Translations/es/Main.xlf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Resources/Private/Translations/es/Main.xlf b/Resources/Private/Translations/es/Main.xlf index 0607edfbf6..19dae4d8b2 100644 --- a/Resources/Private/Translations/es/Main.xlf +++ b/Resources/Private/Translations/es/Main.xlf @@ -444,7 +444,7 @@ nodes - Nodos + nodos content elements selected @@ -476,27 +476,27 @@ Copy technical details - Copiar los detalles técnicos + Copiar la información técnica Technical details copied - Detalles técnicos copiados + Información técnica copiada Reload Neos UI - Recargar la interfaz de usuario de Neo + Recargar la interfaz del suario de Neos Sorry, but the Neos UI could not recover from this error. - Lo sentimos, pero la interfaz de usuario de Neos no pudo recuperarse de este error. + Lo sentimos, pero la interfaz de usuario de Neos no ha podido recuperarse de este error. For more information about the error please refer to the JavaScript console. - Para obtener más información sobre el error, consulta la consola de JavaScript. + Para obtener más información sobre el error, consulta la consola JavaScript. Please reload the application, or contact your system administrator with the given details. - Por favor, vuelve a cargar la aplicación o ponte en contacto con el administrador del sistema con los detalles proporcionados. + Por favor, vuelve a cargar la aplicación o pónte en contacto con el administrador del sistema con los datos facilitados. From c2d3da1bf901a3e1c35d39120520c2b0a0c22482 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 29 Jun 2023 09:35:51 +0200 Subject: [PATCH 10/12] TASK: Add manual CKEditor Test --- .../neos-ui-ckeditor5-bindings/package.json | 1 + .../src/ckEditorApi.js | 5 +- .../tests/manual/.gitignore | 1 + .../tests/manual/build.js | 56 +++++++++++++++++++ .../tests/manual/index.html | 21 +++++++ .../tests/manual/index.js | 53 ++++++++++++++++++ 6 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 packages/neos-ui-ckeditor5-bindings/tests/manual/.gitignore create mode 100644 packages/neos-ui-ckeditor5-bindings/tests/manual/build.js create mode 100644 packages/neos-ui-ckeditor5-bindings/tests/manual/index.html create mode 100644 packages/neos-ui-ckeditor5-bindings/tests/manual/index.js diff --git a/packages/neos-ui-ckeditor5-bindings/package.json b/packages/neos-ui-ckeditor5-bindings/package.json index 1b29e9f5e2..2419c59349 100644 --- a/packages/neos-ui-ckeditor5-bindings/package.json +++ b/packages/neos-ui-ckeditor5-bindings/package.json @@ -5,6 +5,7 @@ "private": true, "main": "./src/manifest.js", "devDependencies": { + "esbuild": "~0.17.0", "@neos-project/babel-preset-neos-ui": "7.3.17", "@neos-project/build-essentials": "7.3.17", "@neos-project/jest-preset-neos-ui": "7.3.17" diff --git a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js index 9e9c7ae64a..51ddc7dbc5 100644 --- a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js +++ b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js @@ -58,7 +58,7 @@ export const bootstrap = _editorConfig => { editorConfig = _editorConfig; }; -export const createEditor = store => options => { +export const createEditor = store => async options => { const {propertyDomNode, propertyName, editorOptions, globalRegistry, userPreferences, onChange} = options; const ckEditorConfig = editorConfig.configRegistry.getCkeditorConfig({ editorOptions, @@ -67,7 +67,7 @@ export const createEditor = store => options => { propertyDomNode }); - DecoupledEditor + return DecoupledEditor .create(propertyDomNode, ckEditorConfig) .then(editor => { editor.ui.focusTracker.on('change:isFocused', event => { @@ -88,6 +88,7 @@ export const createEditor = store => options => { editor.model.document.on('change', () => handleUserInteractionCallback()); editor.model.document.on('change:data', debounce(() => onChange(cleanupContentBeforeCommit(editor.getData())), 500, {maxWait: 5000})); + return editor; }).catch(e => console.error(e)); }; diff --git a/packages/neos-ui-ckeditor5-bindings/tests/manual/.gitignore b/packages/neos-ui-ckeditor5-bindings/tests/manual/.gitignore new file mode 100644 index 0000000000..1521c8b765 --- /dev/null +++ b/packages/neos-ui-ckeditor5-bindings/tests/manual/.gitignore @@ -0,0 +1 @@ +dist diff --git a/packages/neos-ui-ckeditor5-bindings/tests/manual/build.js b/packages/neos-ui-ckeditor5-bindings/tests/manual/build.js new file mode 100644 index 0000000000..2f9a163375 --- /dev/null +++ b/packages/neos-ui-ckeditor5-bindings/tests/manual/build.js @@ -0,0 +1,56 @@ +const {sep} = require('path') + +const esbuild = require('esbuild'); + +const isWatch = process.argv.includes("--watch"); + +/** @type {import("esbuild").BuildOptions} */ +const options = { + entryPoints: ['./index.js'], + absWorkingDir: __dirname, + outdir: './dist', + sourcemap: true, + minify: false, + logLevel: 'info', + target: 'es2020', + color: true, + bundle: true, + loader: { + '.js': 'tsx', + '.svg': 'dataurl', + '.vanilla-css': 'css', + '.woff2': 'file' + }, + plugins: [ + { + name: 'neos-ui-build', + setup: ({onResolve, onLoad, resolve}) => { + // exclude CKEditor styles + // the filter must match the import statement - and as one usually uses relative paths we cannot look for `@ckeditor` here + // we are currently intercepting all `/\.css/` files, as this is the most accurate way and has nearly no impact on performance + onResolve({filter: /\.css$/, namespace: 'file'}, ({path, ...options}) => { + if (!options.importer.includes(`${sep}@ckeditor${sep}`)) { + return resolve(path, {...options, namespace: 'noRecurse'}) + } + return { + external: true, + sideEffects: false + } + }) + + // load ckeditor icons as plain text and not via `.svg: dataurl` + // (currently neccessary for the table select handle icon) + onLoad({filter: /node_modules\/@ckeditor\/.*\.svg$/}, async ({path}) => ({ + contents: (await require('fs/promises').readFile(path)).toString(), + loader: 'text' + })) + } + } + ], +} + +if (isWatch) { + esbuild.context(options).then((ctx) => ctx.watch()) +} else { + esbuild.build(options) +} diff --git a/packages/neos-ui-ckeditor5-bindings/tests/manual/index.html b/packages/neos-ui-ckeditor5-bindings/tests/manual/index.html new file mode 100644 index 0000000000..2f9831bb83 --- /dev/null +++ b/packages/neos-ui-ckeditor5-bindings/tests/manual/index.html @@ -0,0 +1,21 @@ + + + + + + CKEditor Manual Test + + +

Test Neos + CKEditor Version

+ +

Input

+
Insert text here
+ +

Output

+
...
+ +

Enabled Commands (via editor options)

+

You can run them via editor.execute('bold') or editor.execute('heading', { value: 'heading1' })

+

+
+
diff --git a/packages/neos-ui-ckeditor5-bindings/tests/manual/index.js b/packages/neos-ui-ckeditor5-bindings/tests/manual/index.js
new file mode 100644
index 0000000000..8b1d73e9b4
--- /dev/null
+++ b/packages/neos-ui-ckeditor5-bindings/tests/manual/index.js
@@ -0,0 +1,53 @@
+import initializeConfigRegistry from '../../src/manifest.config';
+import {bootstrap, createEditor} from '../../src/ckEditorApi';
+
+import { SynchronousRegistry, SynchronousMetaRegistry } from '@neos-project/neos-ui-extensibility';
+
+const fakeGlobalRegistry = new SynchronousMetaRegistry();
+
+// I18n Registry
+class FakeI18NRegistry extends SynchronousRegistry {
+    translate(key) {
+        return key;
+    }
+}
+fakeGlobalRegistry.set('i18n', new FakeI18NRegistry());
+
+const configRegistry = initializeConfigRegistry(new SynchronousRegistry());
+
+bootstrap({
+    setFormattingUnderCursor: () => {
+        document.getElementById('enabledCommands').innerText = [...window.editor.commands.names()].join(', ')
+    },
+    setCurrentlyEditedPropertyName: () => {},
+    toolbarItems: [],
+    configRegistry
+})
+
+const fakeStore = {
+    dispatch: () => {}
+}
+
+const createInlineEditor = createEditor(fakeStore);
+
+createInlineEditor({
+    propertyDomNode: document.getElementById('input'),
+    propertyName: 'test',
+    editorOptions: {
+        autoparagraph: false,
+        formatting: {
+            h1: true,
+            h2: true,
+            strong: true
+        }
+    },
+    globalRegistry: fakeGlobalRegistry,
+    userPreferences: {},
+    onChange: (content) => {
+        document.getElementById('output').innerText = content;
+    }
+}).then(editor => {
+    document.getElementById('ckVersion').innerText = CKEDITOR_VERSION;
+
+    window.editor = editor
+})

From edbf0d69add4058d88e0b3233b7164b35f55e1b1 Mon Sep 17 00:00:00 2001
From: mhsdesign <85400359+mhsdesign@users.noreply.github.com>
Date: Thu, 29 Jun 2023 13:48:34 +0200
Subject: [PATCH 11/12] TASK: Revert not `isLimit: true` on paragraph as one
 cannot turn it into headlines

---
 .../src/plugins/inlineMode.js                 |   4 -
 yarn.lock                                     | 138 ++++++++++++++++++
 2 files changed, 138 insertions(+), 4 deletions(-)

diff --git a/packages/neos-ui-ckeditor5-bindings/src/plugins/inlineMode.js b/packages/neos-ui-ckeditor5-bindings/src/plugins/inlineMode.js
index 902e805b89..54540cb393 100644
--- a/packages/neos-ui-ckeditor5-bindings/src/plugins/inlineMode.js
+++ b/packages/neos-ui-ckeditor5-bindings/src/plugins/inlineMode.js
@@ -11,10 +11,6 @@ export default class InlineMode extends Plugin {
     init() {
         const editor = this.editor;
 
-        // we avoid multiple paragraph's to be created - eg when pasting a text with newlines (this will created soft breaks (
)) - editor.model.schema.extend('paragraph', { isLimit: true }); - - // we map paragraph model into plain element in edit mode editor.conversion.for('editingDowncast').elementToElement({model: 'paragraph', view: 'span', converterPriority: 'high'}); diff --git a/yarn.lock b/yarn.lock index bbbb5fc625..ab10383f8e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1508,6 +1508,116 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== +"@esbuild/android-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz#bafb75234a5d3d1b690e7c2956a599345e84a2fd" + integrity sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA== + +"@esbuild/android-arm@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.17.19.tgz#5898f7832c2298bc7d0ab53701c57beb74d78b4d" + integrity sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A== + +"@esbuild/android-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.17.19.tgz#658368ef92067866d95fb268719f98f363d13ae1" + integrity sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww== + +"@esbuild/darwin-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz#584c34c5991b95d4d48d333300b1a4e2ff7be276" + integrity sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg== + +"@esbuild/darwin-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz#7751d236dfe6ce136cce343dce69f52d76b7f6cb" + integrity sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw== + +"@esbuild/freebsd-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz#cacd171665dd1d500f45c167d50c6b7e539d5fd2" + integrity sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ== + +"@esbuild/freebsd-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz#0769456eee2a08b8d925d7c00b79e861cb3162e4" + integrity sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ== + +"@esbuild/linux-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz#38e162ecb723862c6be1c27d6389f48960b68edb" + integrity sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg== + +"@esbuild/linux-arm@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz#1a2cd399c50040184a805174a6d89097d9d1559a" + integrity sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA== + +"@esbuild/linux-ia32@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz#e28c25266b036ce1cabca3c30155222841dc035a" + integrity sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ== + +"@esbuild/linux-loong64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz#0f887b8bb3f90658d1a0117283e55dbd4c9dcf72" + integrity sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ== + +"@esbuild/linux-mips64el@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz#f5d2a0b8047ea9a5d9f592a178ea054053a70289" + integrity sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A== + +"@esbuild/linux-ppc64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz#876590e3acbd9fa7f57a2c7d86f83717dbbac8c7" + integrity sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg== + +"@esbuild/linux-riscv64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz#7f49373df463cd9f41dc34f9b2262d771688bf09" + integrity sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA== + +"@esbuild/linux-s390x@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz#e2afd1afcaf63afe2c7d9ceacd28ec57c77f8829" + integrity sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q== + +"@esbuild/linux-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz#8a0e9738b1635f0c53389e515ae83826dec22aa4" + integrity sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw== + +"@esbuild/netbsd-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz#c29fb2453c6b7ddef9a35e2c18b37bda1ae5c462" + integrity sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q== + +"@esbuild/openbsd-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz#95e75a391403cb10297280d524d66ce04c920691" + integrity sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g== + +"@esbuild/sunos-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz#722eaf057b83c2575937d3ffe5aeb16540da7273" + integrity sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg== + +"@esbuild/win32-arm64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz#9aa9dc074399288bdcdd283443e9aeb6b9552b6f" + integrity sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag== + +"@esbuild/win32-ia32@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz#95ad43c62ad62485e210f6299c7b2571e48d2b03" + integrity sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw== + +"@esbuild/win32-x64@0.17.19": + version "0.17.19" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz#8cfaf2ff603e9aabb910e9c0558c26cf32744061" + integrity sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA== + "@fortawesome/fontawesome-common-types@^0.2.35": version "0.2.35" resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.35.tgz#01dd3d054da07a00b764d78748df20daf2b317e9" @@ -7355,6 +7465,34 @@ es6-weak-map@^2.0.1: es6-iterator "^2.0.3" es6-symbol "^3.1.1" +esbuild@~0.17.0: + version "0.17.19" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.17.19.tgz#087a727e98299f0462a3d0bcdd9cd7ff100bd955" + integrity sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw== + optionalDependencies: + "@esbuild/android-arm" "0.17.19" + "@esbuild/android-arm64" "0.17.19" + "@esbuild/android-x64" "0.17.19" + "@esbuild/darwin-arm64" "0.17.19" + "@esbuild/darwin-x64" "0.17.19" + "@esbuild/freebsd-arm64" "0.17.19" + "@esbuild/freebsd-x64" "0.17.19" + "@esbuild/linux-arm" "0.17.19" + "@esbuild/linux-arm64" "0.17.19" + "@esbuild/linux-ia32" "0.17.19" + "@esbuild/linux-loong64" "0.17.19" + "@esbuild/linux-mips64el" "0.17.19" + "@esbuild/linux-ppc64" "0.17.19" + "@esbuild/linux-riscv64" "0.17.19" + "@esbuild/linux-s390x" "0.17.19" + "@esbuild/linux-x64" "0.17.19" + "@esbuild/netbsd-x64" "0.17.19" + "@esbuild/openbsd-x64" "0.17.19" + "@esbuild/sunos-x64" "0.17.19" + "@esbuild/win32-arm64" "0.17.19" + "@esbuild/win32-ia32" "0.17.19" + "@esbuild/win32-x64" "0.17.19" + escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" From bdd46a54a47d4b3326c3f4c85382831229231dbc Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:01:11 +0200 Subject: [PATCH 12/12] BUGFIX: Fix cleanupContentBeforeCommit and add test Fix bug in the case you had multiple paragraphs and a headline and switched to autoparagrahp: false --- .../neos-ui-ckeditor5-bindings/package.json | 9 ++++- .../src/ckEditorApi.js | 26 +------------- .../src/cleanupContentBeforeCommit.js | 28 +++++++++++++++ .../src/cleanupContentBeforeCommit.spec.js | 36 +++++++++++++++++++ 4 files changed, 73 insertions(+), 26 deletions(-) create mode 100644 packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.js create mode 100644 packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.spec.js diff --git a/packages/neos-ui-ckeditor5-bindings/package.json b/packages/neos-ui-ckeditor5-bindings/package.json index 2419c59349..0a57dbc2e7 100644 --- a/packages/neos-ui-ckeditor5-bindings/package.json +++ b/packages/neos-ui-ckeditor5-bindings/package.json @@ -4,6 +4,10 @@ "description": "Prepare CKEditor5 for the Neos CMS UI", "private": true, "main": "./src/manifest.js", + "scripts": { + "test": "yarn jest -w 2 --coverage", + "test:watch": "yarn jest --watch" + }, "devDependencies": { "esbuild": "~0.17.0", "@neos-project/babel-preset-neos-ui": "7.3.17", @@ -33,5 +37,8 @@ "@neos-project/utils-helpers": "7.3.17", "raw-loader": "^0.5" }, - "license": "GNU GPLv3" + "license": "GNU GPLv3", + "jest": { + "preset": "@neos-project/jest-preset-neos-ui" + } } diff --git a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js index 51ddc7dbc5..6c880347cd 100644 --- a/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js +++ b/packages/neos-ui-ckeditor5-bindings/src/ckEditorApi.js @@ -1,31 +1,7 @@ import debounce from 'lodash.debounce'; import DecoupledEditor from '@ckeditor/ckeditor5-editor-decoupled/src/decouplededitor'; import {actions} from '@neos-project/neos-ui-redux-store'; - -// We remove opening and closing span tags that are produced by the inlineMode plugin -/** @param {String} content */ -const cleanupContentBeforeCommit = content => { - // TODO: remove when this is fixed: https://github.com/ckeditor/ckeditor5/issues/401 - if (content.match(/^<([a-z][a-z0-9]*)\b[^>]*> <\/\1>$/)) { - return ''; - } - - if (content.startsWith('') && content.endsWith('')) { - const contentWithoutOuterInlineWrapper = content - .replace(/^/, '') - .replace(/<\/neos-inline-wrapper>$/, ''); - - if (contentWithoutOuterInlineWrapper.includes('')) { - // in the case, multiple root paragraph elements were inserted into the ckeditor (wich is currently not prevented if the html is modified from outside) - // we have multiple root elements of type . We will convert all of them into spans. - return content - .replace(//g, '') - .replace(/<\/neos-inline-wrapper>/g, ''); - } - return contentWithoutOuterInlineWrapper; - } - return content; -}; +import {cleanupContentBeforeCommit} from './cleanupContentBeforeCommit' let currentEditor = null; let editorConfig = {}; diff --git a/packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.js b/packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.js new file mode 100644 index 0000000000..4efa9cb2f6 --- /dev/null +++ b/packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.js @@ -0,0 +1,28 @@ +// We remove opening and closing span tags that are produced by the inlineMode plugin +/** @param {String} content */ +export const cleanupContentBeforeCommit = content => { + // TODO: remove when this is fixed: https://github.com/ckeditor/ckeditor5/issues/401 + if (content.match(/^<([a-z][a-z0-9]*)\b[^>]*> <\/\1>$/)) { + return ''; + } + + if (content.includes('')) { + let contentWithoutOuterInlineWrapper = content; + + if (content.startsWith('') && content.endsWith('')) { + contentWithoutOuterInlineWrapper = content + .replace(/^/, '') + .replace(/<\/neos-inline-wrapper>$/, ''); + } + + if (contentWithoutOuterInlineWrapper.includes('')) { + // in the case, multiple root paragraph elements were inserted into the ckeditor (wich is currently not prevented if the html is modified from outside) + // we have multiple root elements of type . We will convert all of them into spans. + return content + .replace(//g, '') + .replace(/<\/neos-inline-wrapper>/g, ''); + } + return contentWithoutOuterInlineWrapper; + } + return content; +}; diff --git a/packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.spec.js b/packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.spec.js new file mode 100644 index 0000000000..08ab6aad9e --- /dev/null +++ b/packages/neos-ui-ckeditor5-bindings/src/cleanupContentBeforeCommit.spec.js @@ -0,0 +1,36 @@ +import {cleanupContentBeforeCommit} from './cleanupContentBeforeCommit' + +const assertCleanedUpContent = (input, expected) => { + expect(cleanupContentBeforeCommit(input)).toBe(expected); +} + +test('remove empty nbsp', () => { + assertCleanedUpContent('

 

', ''); + assertCleanedUpContent(' ', ''); +}) + +describe('ckeditor inline mode hack, cleanup ', () => { + test('noop', () => { + assertCleanedUpContent('

', '

'); + + assertCleanedUpContent('', ''); + }) + + test('cleanup single ', () => { + assertCleanedUpContent('', ''); + assertCleanedUpContent('foo', 'foo'); + + assertCleanedUpContent('foo', 'foo'); + }) + + test('cleanup multiple ', () => { + assertCleanedUpContent('foobar', 'foobar'); + + assertCleanedUpContent('foobar', 'foobar'); + }) + + test('cleanup after other root', () => { + // in the case you had multiple paragraphs and a headline and switched to autoparagrahp: false + assertCleanedUpContent('

foo

bar', '

foo

bar'); + }) +})