Skip to content

Commit

Permalink
Make sure id doesn't start with a digit
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanw authored and pajowu committed Oct 18, 2023
1 parent 5377c5f commit d06c017
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fragdenstaat_de/fds_cms/static/js/cms/ckeditor.wysiwyg.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ CKEDITOR.dtd.$removeEmpty.span = 0;

function addSlugId(el) {
const innerText = el.children.filter(x => x.type == CKEDITOR.NODE_TEXT).map(x => x.value).join(" ")
const slug = innerText.toLowerCase().replace(/[^-_0-9a-zA-Z]/g, '-');
const slug = innerText.toLowerCase().replace(/[^-_0-9a-zA-Z]/g, '-').replace(/^(\d+)/, "-$1");
if ((!el.attributes.id) || (el.attributes.id == el.attributes['data-auto-id'])) {
el.attributes.id = slug;
el.attributes['data-auto-id'] = slug;
Expand Down

0 comments on commit d06c017

Please sign in to comment.