Skip to content

Commit

Permalink
Merge branch 'develop' into sd-cl
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanJelicSF authored Dec 25, 2024
2 parents 419c9f3 + fb3615f commit 854c803
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
46 changes: 46 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,54 @@ setTimeout(() => {
return broadcasting;
}),
},
{
id: 'topbar-publish-date',
load: () => import('./extensions/topbar-publish-date'),
}
],
{},
{
editor3: {
customBlocks: {
getAdditionalWrapperAttributes: (_vocabulary, html) => {
function getHighestHeadingText(el: HTMLElement): string | null {
const headings: Array<keyof HTMLElementTagNameMap> = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];

for (const tag of headings) {
const result = el.querySelector(tag);

if (result != null) {
return result.textContent;
}
}

return null;
}

const tableCellContentElement: HTMLElement =
new DOMParser().parseFromString(html, 'text/html').body;

const replaceSpecialCharacters = (str) =>
str.normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Remove accents
.replace(/([^\w]+|\s+)/g, '-') // Replace space and other characters by hyphen
.replace(/\-\-+/g, '-') // replace multiple hyphens with one hyphen
.replace(/(^-+|-+$)/g, ''); // remove extra hyphens from beginning or end of the string

const heading: string | null = getHighestHeadingText(tableCellContentElement);

const attributes: Array<{name: string; value: string}> = [
{name: 'class', value: 'custom-block'},
];

if (heading != null) {
attributes.push({name: 'data-custom-block-title', value: replaceSpecialCharacters(heading).toLocaleLowerCase()});
}

return attributes;
},
},
},
},
);
});

Expand Down
6 changes: 3 additions & 3 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"superdesk-core": "github:superdesk/superdesk-client-core#develop",
"superdesk-planning": "github:superdesk/superdesk-planning#develop",
"superdesk-publisher": "github:superdesk/superdesk-publisher#release/2.8"
"superdesk-publisher": "github:superdesk/superdesk-publisher#develop"
},
"scripts": {
"build": "npx @superdesk/build-tools build-root-repo ./",
Expand Down
2 changes: 1 addition & 1 deletion server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,4 @@
# 2: reindex slugline
SCHEMA_VERSION = 2

#CORRECTIONS_WORKFLOW = True
CORRECTIONS_WORKFLOW = True

0 comments on commit 854c803

Please sign in to comment.