Skip to content

Commit 86bfe63

Browse files
committed
fix(inline-edit): add shared TinyMCE options to avoid rewriting relative URL path
1 parent f2f4a82 commit 86bfe63

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

core-web/libs/portlets/edit-ema/portlet/src/lib/services/inline-edit/inline-edit.service.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest';
22

33
import { ElementRef } from '@angular/core';
44

5-
import { INLINE_CONTENT_STYLES, InlineEditService } from './inline-edit.service';
5+
import {
6+
INLINE_CONTENT_STYLES,
7+
INLINE_EDIT_TINYMCE_BASE_OPTIONS,
8+
InlineEditService
9+
} from './inline-edit.service';
610

711
import { InlineEditingContentletDataset } from '../../edit-ema-editor/components/ema-page-dropzone/types';
812

@@ -12,6 +16,10 @@ describe('InlineEditService', () => {
1216

1317
beforeEach(() => (spectator = createService()));
1418

19+
it('should disable TinyMCE URL conversion so root-relative paths are preserved on serialize', () => {
20+
expect(INLINE_EDIT_TINYMCE_BASE_OPTIONS.convert_urls).toBe(false);
21+
});
22+
1523
it('should inject inline edit', () => {
1624
const iframe = document.createElement('iframe');
1725
document.body.appendChild(iframe);

core-web/libs/portlets/edit-ema/portlet/src/lib/services/inline-edit/inline-edit.service.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ export const INLINE_CONTENT_STYLES = `
3030
}
3131
`;
3232

33+
/**
34+
* Shared TinyMCE options for EMA inline editing (excluding per-instance `setup`).
35+
* Exported so URL-handling defaults (e.g. convert_urls) stay covered by unit tests.
36+
*/
37+
export const INLINE_EDIT_TINYMCE_BASE_OPTIONS = {
38+
menubar: false,
39+
inline: true,
40+
// Avoid rewriting root-relative URLs (e.g. /dA/...) to ../... on serialize; iframe base differs from site root.
41+
convert_urls: false,
42+
valid_styles: {
43+
'*': 'font-size,font-family,color,text-decoration,text-align'
44+
},
45+
powerpaste_word_import: 'clean',
46+
powerpaste_html_import: 'clean'
47+
} as const;
48+
3349
@Injectable({
3450
providedIn: 'root'
3551
})
@@ -39,17 +55,11 @@ export class InlineEditService {
3955
private $inlineEditingTargetDataset = signal<InlineEditingContentletDataset | null>(null);
4056

4157
private readonly DEFAULT_TINYMCE_CONFIG = {
42-
menubar: false,
43-
inline: true,
44-
valid_styles: {
45-
'*': 'font-size,font-family,color,text-decoration,text-align'
46-
},
47-
powerpaste_word_import: 'clean',
48-
powerpaste_html_import: 'clean',
58+
...INLINE_EDIT_TINYMCE_BASE_OPTIONS,
4959
setup: this.#handleInlineEditEvents
5060
};
5161

52-
private readonly TINYCME_CONFIG = {
62+
private readonly TINYMCE_CONFIG = {
5363
minimal: {
5464
plugins: ['link', 'autolink'],
5565
toolbar: 'bold italic underline | link',
@@ -162,7 +172,7 @@ export class InlineEditService {
162172

163173
this.$iframeWindow()
164174
.tinymce.init({
165-
...this.TINYCME_CONFIG[dataset.mode || 'minimal'],
175+
...this.TINYMCE_CONFIG[dataset.mode || 'minimal'],
166176
selector: dataSelector
167177
})
168178
.then(([ed]) => {

0 commit comments

Comments
 (0)