- Issue created by @bkline
- ๐บ๐ธUnited States alison
Apologies if this is an unrelated issue, no scope-creep intended -- and if that's the case, I'll open a new issue -- it just "felt related" --
I'm getting
Uncaught CKEditorError: collection-add-item-invalid-index
any time I try to add a link in CKEditor 5, in a text format with "Limit allowed HTML tags and correct faulty HTML" enabled -- do y'all only have the issue you're seeing in text formats with "limited allowed HTML" enabled, or also in a text format that allows all HTML tags?More about me:
- Drupal core 9.5.10
- Linkit 6.0.0 -- I did try disabling Linkit, the errors still happened
- Editor Advanced Link 2.2.4 -- then I tried disabling Editor Advanced link, errors went away (and linkit worked fine)
More error stuff:
Uncaught CKEditorError: collection-add-item-invalid-index ckeditor5-dll.js?v=35.4.0 Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-collection-add-item-invalid-index at i.addMany (ckeditor5-dll.js?v=35.4.0:5:525625) at i.add (ckeditor5-dll.js?v=35.4.0:5:525522) at editorAdvancedLink.js?v=9.5.10:1:11273 at Array.forEach (<anonymous>) at h._addGroupsToFormView (editorAdvancedLink.js?v=9.5.10:1:11167) at Ke.<anonymous> (editorAdvancedLink.js?v=9.5.10:1:10076) at Ke.fire (ckeditor5-dll.js?v=35.4.0:5:502334) at Ke.set [as visibleView] (ckeditor5-dll.js?v=35.4.0:5:508922) at Ke._showView (ckeditor5-dll.js?v=35.4.0:5:462705) at Ke.add (ckeditor5-dll.js?v=35.4.0:5:460104)
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
CKEditor 5 docs say:
The index passed to Collection#addMany() is invalid. It must be a number between 0 and the collection's length.
โ https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#erro...
And
at editorAdvancedLink.js?v=9.5.10:1:11273
proves it's triggered by this module.
@alison Can you confirm you're on https://www.drupal.org/project/editor_advanced_link/releases/2.2.4 โ ?
- ๐บ๐ธUnited States alison
@Wim Leers Yeppers!
- Drupal core 9.5.10
- Editor Advanced Link 2.2.4
- (Also in the mix: Linkit 6.0.0 -- I did try disabling Linkit, the errors still happened; only thing that cleared the errors is disabling editor_advanced_link functionality on that text format.)
Do you / do y'all think it's noteworthy that the errors only happen on a text format with "limit allow HTML tags" enabled? -- I did try adding stuff to the allowed tags list (by way of "source editing" > "allowed tags" list), but I still got errors. But maybe (hopefully?) I just didn't add everything it needs? (meaning, maybe the EAL module doesn't automagically add all the necessary tags when you enable that button)
(Attached: filter + editor config yml for my filtered_html text format, in case it's useful.)
- Status changed to Needs work
over 1 year ago 2:43pm 25 August 2023 - ๐ณ๐ฑNetherlands arantxio Dordrecht
So we also had the same problem and I found out where the problem lies.
It has to do with the placement of the confirm and cancel buttons. It's in the file: 'editoradvancedlinkui.js' on line 123 and 124.
We place the buttons at the end by using '3 + i', but for some reason this is out of bounds for the index CKEditor expects. You can see that because only the confirm button is showing and not the close button. Replacing it to just 'i' places the buttons all the way at the top of de window so that's unwanted. For us making it '2 + i' fixes the error in the console and makes Linkit work again.I've added a patch which works for us. But a better solution would be to check how many children are currently active and place it after that. I don't have enough experience with this code nor CKEditor to find out how to do so. But I hope what I found helps with finding a proper solution.
- last update
over 1 year ago Composer require-dev failure - ๐ณ๐ฑNetherlands arantxio Dordrecht
Here is also a patch where it is '1 + i'. As on a different server '2 + i' doesn't solve it but making it 1 does.
- ๐ณ๐ฑNetherlands arantxio Dordrecht
We noticed that some users still had issues with this, so I started testing some more. I noticed that when I removed the entire logic for the buttons, they still stay at the bottom and do not give me any errors.
I added a new patch, but it will need plenty of testing it seems.
- Status changed to Needs review
over 1 year ago 3:36pm 31 August 2023 - ๐บ๐ธUnited States smokris Athens, Ohio, USA
On a site running Drupal Core 10.1.2, here's what I see with Arantxio's patches:
If I understand correctly, we want to re-add the "save" and "cancel" buttons to the end of the panel, so they remain in their usual positions. I think we can do that by calling
.add(item)
(without theindex
argument). I've attached a new patch that does that. - Status changed to Needs work
over 1 year ago 3:14pm 12 September 2023 - ๐ณ๐ฑNetherlands gaele
I tried patch #9. It works, mostly. When I click Advanced I get this message, once:
Uncaught CKEditorError: collection-add-item-already-exists
The UI seems to work correctly, though. - First commit to issue fork.
- ๐ฆ๐บAustralia GuillaumeG
Same behavior as @gaele ๐ Exceptions thrown when toggling Advanced section of linking form RTBC
The patch #9 ๐ Exceptions thrown when toggling Advanced section of linking form RTBC helps to fix the layout and when clicking advanced for the first time but this error is still thrown when clicking on Advanced multiple times.
- First commit to issue fork.
- Merge request !14Fix for new window option not rendering under the advanced group on initial dialog open. โ (Open) created by s_leu
- Status changed to Needs review
about 1 year ago 2:43pm 13 December 2023 Testes the patch in #8 and #9 and both of them don't fix all issues here. I pushed a more complete fix based on the patch from #8 for it into an MR. Please review and if you do, continue development inside the MR.
- ๐ฆ๐บAustralia GuillaumeG
Thanks @s_leu.
Patch tested. It is looking good now, no more errors.
- Status changed to RTBC
12 months ago 11:15pm 4 January 2024 - ๐ฌ๐งUnited Kingdom nicrodgers Monmouthshire, UK
Hi @GuillaumeG - just to double check - have you tested the patch or the MR?
Only s_leu said he's continued the work in the MR, but you then say you have tested the patch. Just to be sure. Thanks!
- Status changed to Needs work
11 months ago 5:17pm 16 January 2024 - ๐ฌ๐งUnited Kingdom jonnyhocks
I've moved this back to needs work as I think it still requires some development within the MR.
I tested the MR and was still seeing the issues described in #9 with the layout of the buttons incorrect. And then when testing the patch in #9 I found the buttons to be laid out correctly.
Also, I've done some testing in Firefox and I'm not seeing the behaviour described in #10. I have:
- Added a link
- Saved the node
- Edited the node and clicked on the edit link
I see the 'Advanced' label working as expected.
- ๐ซ๐ทFrance duaelfr Montpellier, France
Hi! FWIW when I first tried to fix that issue, I realized that the buttons behavior was different given the allowed advanced settings selected in the filter. Take that into account when testing your changes because it could work for your specific case but break another oneโฆ I'll be happy to merge a change working for all use cases!
- ๐บ๐ธUnited States DamienMcKenna NH, USA
DuaelFR: do you know which options change the behaviour? We could update the tests to match.
- ๐บ๐ธUnited States jennypanighetti
When I apply the patch from the MR#14, I get the buttons both times I try to add a link and no JS errors (progress!) but the "X" button is now below the "Advanced" toggle.
- Drupal 10.2.2
- CKEditor 5 - ๐ช๐ธSpain juandels3 Seville
Hi! After applying patch #14 the display errors are fixed, but errors are still displayed when opening the "Advanced" spoiler. I have made several tests until I detected that this error is only displayed when enabling the "Open in new window ()" attribute in the settings (Text formats and editors > CKEditor 5 plugin settings > Advanced links). If this attribute is disabled, it is not displayed.
- Status changed to RTBC
10 months ago 4:23am 26 February 2024 - ๐ฆ๐บAustralia jannakha Brisbane!
MR17 works on D10.2.3 php 8.2
no exception, popup displays all buttons and options as expected
before patch: exceptions in console
after patch: all clear
thanks for the patch!
please release! - ๐ฎ๐ณIndia mohit_aghera Rajkot
I can confirm that MR #17 works for me as well.
Drupal core 10.1.x and editor_advanced_link: 2.2.4I noticed the same observations mentionedin #25
- ๐บ๐ธUnited States jennypanighetti
Weird, my output still shows the element in between the two elements on the page. See attached screenshot. I am applying the patch via composer.patches.json using the following link: https://git.drupalcode.org/project/editor_advanced_link/-/merge_requests...
- Status changed to Needs work
9 months ago 12:19am 22 March 2024 - ๐ฆ๐บAustralia jannakha Brisbane!
Neither of the MRs are working on: Drupal 10.2.3/PHP8.2
Editor Advanced Link config: ONLY class attribute enabledMR14 - broken layout, console errors
MR17 - broken layout, console errors
Editor Advanced Link config: ALL attributes are enabled
MR14 - doesn't have full keyboard navigation (can't navigate with keyboard inside details element)
MR17 - console errors, order of fields is invalid
Mark Shi โ changed the visibility of the branch 3371633-exception-collection-item-exists to hidden.
Mark Shi โ changed the visibility of the branch 3371633-exception-collection-item-exists to active.
- ๐ฌ๐งUnited Kingdom altcom_neil
Hi,
Drupal 10.3.5 | Editor Advanced Link 2.2.6 | CKEditor 5
Is this issue now fixed in the contrib module? We were using patch #9 which was causing js errors now. I have tried both MR14 and MR17 and both have the issues.
MR14 - correctly lays everything out but has console errors.
MR17 - leaves the 'Open in a new window' option outside of the Advanced tab.
I removed the patches and the functionality appears to work without any issues.
- ๐ช๐ธSpain juandels3 Seville
Hi. The current status is as follows:
The errors still persists, including in version 2.2.6 with Drupal 10.3.x.- Js error when opening the โAdvancedโ tab when more than one attribute has been enabled from the configuration.
- Js error if a single attribute is enabled from the configuration.
- MR #17 fixes the first point, but takes the โOpen in new windowโ value out of โAdvancedโ.
Hi,
Drupal 10.3.9 and editor advanced link 2.2.6, same behavior described in #33.
- ๐จ๐ฆCanada metasim
Using MR 17 as patch for version 2.2.6
- the console error goes away
- `open in new window` option is still available