Skip to content

JGLWEB-1832 cke5 plugin - #7

Open
amalija-ramljak wants to merge 21 commits into
masterfrom
JGLWEB-1832-cke5-plugin
Open

amalija-ramljak wants to merge 21 commits into
masterfrom
JGLWEB-1832-cke5-plugin

Conversation

@amalija-ramljak

Copy link
Copy Markdown
Member
  • reading some data from ngrm bundle with a webpack alias
  • configuration for rich text goes through siteaccess aware params
  • config provider
  • custom tag config
  • docs updated

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Ibexa OSS 4.6 (Media Site 3.7, Symfony 5.4) with NGRM 3.1.0 and this branch at f2ac2df. I rebuilt the admin assets with the richtext config.

What works in the browser:

  • toolbar button, browse, select, alt/caption override, CSS class and variation
  • publish: stored as <eztemplate name="ngremotemedia"> with locationId, variationName and cssClass
  • front render with the variation, the overrides and the class
  • re-edit restores the element with its data
  • two RichText fields on one page get separate field ids and locations
  • the alignment command stores alignment

Requesting changes for two blockers, see the inline comments:

  1. One remote resource location is shared by all versions, translations and copies of the content, and the editor changes or deletes it over AJAX right away, not on publish. Reproduced: in an unsaved draft v2 I removed the element, location 13 was deleted at once, and the published v1 now renders <div class="ngremotemedia-error">Invalid data</div>. Deleting the draft does not bring it back. Crop and override edits in a draft also go live immediately. The field type does not have this problem, because its storage creates a new location per version.
  2. netgen/remote-media-bundle: ^3.0 allows 3.0.x. The 3.0.x CKEditor plugin is an arrow function, so CKEditor's new fails and every RichText field in the admin breaks. This needs ^3.1.

NGRM side, not this PR, but it affects it:

  • update.js does not send source, and RemoteResourceService::handleLocationUpdate() sets $data['source'] ?? null. After the first override or variation change, the location loses ibexa_richtext. Confirmed in the DB. As a result, location_source only holds until the first edit.
  • operation-handlers/remove.js deletes the location on every remove that is not a detach. Drag and drop, cut/paste and undo of the widget probably delete the location while the element still references it. From the code, not run.
  • cssClass and variationName are restored only from the async getSelectedImage response. If the editor saves before it returns, or if it fails, both are dropped from the XML. From the code, not run.
  • createLocation has no error handling. If the POST fails, the element has no locationId and is silently dropped on save.

Merge conflicts with master:

  • composer.json: resolve to ^3.1 and keep the two new requires.
  • INSTALL.md: keep master's migrations section and drop the doctrine:schema:update note.
  • README.md: keep both sections.
  • CHANGELOG.md 1.0.0 says the rich text integration is not part of 1.0.0. This needs a new release section and an UPGRADE note: new netgen_remote_media_ibexa semantic config, NGRM 3.1 requirement, richtext encore build.

There are no tests for Configuration, ConfigurationProvider or the custom tag format.

Comment thread composer.json Resolved
Comment thread lib/RichText/ConfigurationProvider.php Resolved
Comment thread RICHTEXT.md Resolved
Comment thread INSTALL.md Resolved
Comment thread lib/FieldType/SearchFields.php Resolved
…ugin

# Conflicts:
#	INSTALL.md
#	README.md
#	composer.json
…nfig only with the RichText bundle

- variation_group, location_source, folder and parent_folder must be strings (or null), e.g. folder: 2024 failed at runtime
- the custom tag and the toolbar button are prepended only when IbexaFieldTypeRichTextBundle is enabled
…address review

- the editor copies every loaded location (copyLocationsOnLoad), drafts, translations and copies no longer change locations of other versions
- the form waits for pending location requests before submitting, failed requests show an error notification
- require netgen/remote-media-bundle 3.1.1 (CKEditor 5 plugin with copyLocationsOnLoad and onError)
- expose the editor configuration with an admin UI component instead of a RichText configuration provider, which ran on every Twig rendering
- check ngrm/upload and ngrm/read_protected with Ibexa authorization attributes instead of ibexa:module:function strings
- custom tag template: render protected resources only with ngrm/read_protected and authenticated, render alignment, use the configured view_resource template
- tests for the configuration, the editor configuration template and the custom tag format
…0 changelog and upgrade notes

- ibexa:encore:compile has only --config-name on 4.6, the plugin is in the richtext config
- run JavaScript tests with the Node.js test runner on CI
@amalija-ramljak

Copy link
Copy Markdown
Member Author

@RandyCupic everything should be fixed, could you please check if it's okay?

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retested at 4d3599f with NGRM #134 on Ibexa 4.6. The shared location is fixed: removing an element or changing an override in a draft doesn't reach the published version anymore, and after publish each version points to its own locations. The other points from my first review are fixed too. Thanks.

Must fix

  • NGRM #134 goes out as 3.2.0, it adds new plugin options. Please require ^3.2, see inline. CI stays red until it's tagged.
  • No orphan locations, see inline on RICHTEXT.md.
  • CS Fixer fails on tests/bundle/Templating/EditorConfigurationTemplateTest.php.

Comment thread composer.json Resolved
Comment thread RICHTEXT.md Resolved

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One smaller thing I found after the review, see inline.

…cation requests and require NGRM 3.2

- the RichText external storage is decorated to collect the locations of deleted RichText fields (discarded drafts, deleted versions, translations, content and field definitions), they are deleted at the end of the request or console command when no RichText field of any version or content and no field type field references them
- autosave the draft again once pending location requests have settled, Ibexa autosave posts FormData past the submit listener
- require netgen/remote-media-bundle ^3.2
- keep mb_trim with symfony/polyfill-mbstring and use mb_substr_count, required by mb_str_functions
- RICHTEXT.md, CHANGELOG.md and UPGRADE.md updated
…used locations on submit

- copyLocationsOnChange replaces copyLocationsOnLoad (netgen/remote-media-bundle 3.2), opening the editor no longer copies locations
- expose the deleteLocation endpoint, the plugin deletes the locations it created or copied which are no longer in the editor data when the form is submitted
…s once the content is saved

- the content edit form sends the stored locations no editor on the page references anymore (getUnusedStoredLocations of netgen/remote-media-bundle 3.2) as ngremotemedia_unused_locations, only on submit, never with the autosave
- on BeforeUpdateContentEvent they are collected and deleted at the end of the request when no field references them anymore, also when an earlier autosave already removed them from the draft

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retested at a2772fb with NGRM #134 on Ibexa 4.6. Copy on the first change, deleting on submit, discarded drafts, deleted versions, the archive limit, deleted and copied content and the autosave rerun all work. Nice work.

Must fix

  • FieldStorage takes down the whole admin, see inline.
  • Cancel leaves the copies behind, see inline.

CI goes green once I tag #134 as 3.2.0.

Comment thread lib/RichText/FieldStorage.php Resolved
…ld storage decorator

- RichTextStorage redeclares its protected $gateway property, so reading it from the decorator is a fatal error on PHP < 8.4 on every request building the storage registry.
- Test the decorator built from the bundle service configuration around the real RichText storage and gateway services, and use the real RichText storage in the location cleaner test.
… edit is cancelled

- Cancel deletes the draft, or stores nothing for new content, so all locations the editor created or copied are deleted with deleteOwnLocations() of NGRM 3.2.1, also those still in the editor data.
- Require netgen/remote-media-bundle ^3.2.1.
@amalija-ramljak

Copy link
Copy Markdown
Member Author

These things should be fixed this time. There is additional work made in netgen/NetgenRemoteMediaBundle#135 thats required for this code as well

@amalija-ramljak

Copy link
Copy Markdown
Member Author

do note that in 4b06475#diff-d2ab9925cad7eac58e0ff4cc0d251a937ecf49e4b6bf57f8b95aab76648a9d34 file (should link to composer json) - its been set to 3.2.1 so let me know if it shouold be 3.2.0 anyway, im not sure if youll release the related #135 as 3.2.1

@RandyCupic RandyCupic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retested at 4b06475 with NGRM 3.3.0. The admin works again, and Cancel deletes the copies, also when the create is still pending. Publish, discarded drafts and deleted versions still clean up. Nice work.

I pushed two small fixes myself, to get this merged today:

  • ^3.3 instead of ^3.2.1 in composer.json, CHANGELOG.md and UPGRADE.md. #135 went out as 3.3.0, since it adds the deleteOwnLocations() export.
  • RichTextFieldStorageTest registers DOMDocumentLoaderInterface. fieldtype-richtext 4.6.33 injects it into RichTextStorage, so the test failed with non-existent service "Ibexa\Contracts\FieldTypeRichText\RichText\DOMDocumentLoaderInterface". On older versions nothing uses it.

CI is green, including prefer-lowest. Good to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants