Issue #1125: Allow markdown formatting in "Description"#56
Issue #1125: Allow markdown formatting in "Description"#56kuchtiak-ufal wants to merge 16 commits intoclarin-v7from
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements markdown formatting support for description metadata fields in DSpace items. Users can now enable markdown and MathJax formatting in description fields through configuration.
Key changes:
- Added configuration injection to access markdown settings
- Implemented conditional rendering between plain text and markdown formats
- Fixed trailing comma syntax error in configuration
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/config/default-app-config.ts | Fixed trailing comma syntax error in markdown configuration |
| src/app/item-page/simple/field-components/clarin-description-item-field/clarin-description-item-field.component.ts | Added configuration injection and conditional logic for markdown rendering |
| src/app/item-page/simple/field-components/clarin-description-item-field/clarin-description-item-field.component.html | Added conditional rendering with markdown pipe when enabled |
...le/field-components/clarin-description-item-field/clarin-description-item-field.component.ts
Outdated
Show resolved
Hide resolved
…e markdown text, in the Home page - Add <Markdown formatted text> toggle button to render markdown formatted text
Update the SubmissionSectionCcLicensesComponent spec to wait before asserting the getCcLicenseLink call. The test now uses a setTimeout(350) and the Jasmine done callback, calling fixture.detectChanges inside the timeout before verifying submissionCcLicenseUrlDataService.getCcLicenseLink was invoked with the expected Map. This change prevents timing-related flakiness by allowing async updates to complete before the assertion.
Add markdown preview toggle for description fields
Detect nested markdown toggle and add test
fix(markdown-preview): cache toggle visibility and normalize usemarkdown truthy value handling
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
src/app/submission/sections/cc-license/submission-section-cc-licenses.component.spec.ts:267
- These specs now use real timers (
setTimeout+done) to wait for debounced behavior. This makes the suite slower and more flaky compared to the existingfakeAsync/tickpattern already used in this file. Prefer wrapping these tests infakeAsyncand advancing time withtick(...)(or flushing the debounce scheduler) instead of using real timeouts.
it('should call the submission cc licenses data service getCcLicenseLink method', (done) => {
setTimeout(() => {
fixture.detectChanges();
expect(submissionCcLicenseUrlDataService.getCcLicenseLink).toHaveBeenCalledWith(
ccLicence,
new Map([
[ccLicence.fields[0], ccLicence.fields[0].enums[1]],
[ccLicence.fields[1], ccLicence.fields[1].enums[0]],
])
);
done();
}, 350);
});
it('should display a cc license link', (done) => {
// Wait for the debounced observable to emit
setTimeout(() => {
fixture.detectChanges();
const linkElement = de.query(By.css('.license-link'));
expect(linkElement).toBeTruthy();
done();
}, 350); // Wait longer than the 300ms debounce
});
config/config.yml
Outdated
| markdown: | ||
| enabled: true | ||
| mathjax: true |
There was a problem hiding this comment.
This update enables markdown + MathJax by default in the main runtime config. That’s a significant behavior and performance change (MathJax rendering can be expensive, and enabling markdown affects how user-provided metadata is displayed). Please confirm this is intentional for all deployments; otherwise keep defaults disabled and document/enable per environment as needed.
| markdown: | |
| enabled: true | |
| mathjax: true | |
| # Markdown rendering configuration. | |
| # Disabled by default for performance and to avoid changing how user-provided metadata is displayed. | |
| # Enable these options in an environment-specific config only if your deployment requires them. | |
| markdown: | |
| enabled: false | |
| mathjax: false |
There was a problem hiding this comment.
@kosarko
seems like that’s a product decision
...o-shared/dso-edit-metadata/dso-edit-metadata-value/dso-edit-metadata-value.component.spec.ts
Outdated
Show resolved
Hide resolved
src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts
Show resolved
Hide resolved
src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.html
Outdated
Show resolved
Hide resolved
Conditionally render markdown description panel
Disable MathJax for markdown
Clarify default allowlisted markdown fields
Move markdown description metadata allow list into a shared constant and replace inline copies across components. Improve markdown preview toggle behavior and accessibility: add aria-label/aria-pressed attributes in the template, add shouldBindMarkdownToggleVisibility() and clearMarkdownToggleVisibilityBinding() to avoid binding/ subscriptions when markdown is disabled, field is not a textarea, or field is readOnly, and ensure proper cleanup. Update unit tests to handle global appConfig markdown state and add cases for hiding the toggle when global markdown is disabled or when not editing.
Now,
Based on the
definition user can use the https://commonmark.org/ or for https://www.mathjax.org/ formatting in the description property.
Example:
Description Metadata text:
Result:
