@designcrowd/library.brand-page 6.1.1-json-prereq-4 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/{CreatedOnBrandCrowd-de-de-Dk-G3RbI.js → CreatedOnBrandCrowd-de-de-B5B5ThJ6.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-AVAWRjbj.js → CreatedOnBrandCrowd-en-us-a48CaORy.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-C5Xq4Jln.js → CreatedOnBrandCrowd-es-es-xpuZ317-.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-BQXjmcrr.js → CreatedOnBrandCrowd-fr-ca-V-iUMArW.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-BQXjmcrr.js → CreatedOnBrandCrowd-fr-fr-V-iUMArW.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-DRMRc1Zk.js → CreatedOnBrandCrowd-pt-br-DZ0NKSAy.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-DRMRc1Zk.js → CreatedOnBrandCrowd-pt-pt-DZ0NKSAy.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-Dd9-oQ34.js → CreatedOnDcom-de-de-_950cgGp.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-CnDfLzF4.js → CreatedOnDcom-en-us-DogKzH-g.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-bvqvI9gT.js → CreatedOnDcom-es-es-CmGM3IPX.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-BG7UGFe8.js → CreatedOnDcom-fr-ca-BonEDkWZ.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-xdz35O_B.js → CreatedOnDcom-fr-fr-DQHtKrd_.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-CLfHnCkk.js → CreatedOnDcom-pt-br-CtYJSBjs.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-Z7FY0BXt.js → CreatedOnDcom-pt-pt-DoO9r4lA.js} +1 -1
- package/lib/src/brand-page/components/contact-form/ContactForm.mixin.js +7 -8
- package/lib/src/brand-page/components/mailing-list/MailingList.mixin.js +6 -4
- package/lib/src/brand-page/components/page-footer/PageFooter.mixin.d.ts +1 -0
- package/lib/src/brand-page/components/page-footer/PageFooter.mixin.js +4 -1
- package/lib/src/brand-page/components/payment/Payment.mixin.js +4 -3
- package/lib/src/brand-page/components/payment/__fixtures__/request-payment.d.ts +1 -0
- package/lib/src/brand-page/components/payment/__fixtures__/support-me.d.ts +1 -0
- package/lib/src/brand-page/components/payment/request-payment/RequestPayment.mixin.d.ts +1 -0
- package/lib/src/brand-page/components/payment/request-payment/RequestPayment.mixin.js +4 -1
- package/lib/src/brand-page/composables/consent.composable.d.ts +2 -0
- package/lib/src/brand-page/composables/consent.composable.js +9 -3
- package/lib/src/brand-page/models/brand-page-context.model.d.ts +7 -0
- package/lib/src/brand-page/models/index.d.ts +26 -34
- package/lib/src/brand-page/utils/context.util.d.ts +8 -0
- package/lib/src/brand-page/utils/context.util.js +8 -0
- package/lib/src/brand-page/utils/migration.util.js +0 -11
- package/lib/src/brand-page/utils/text.util.d.ts +1 -13
- package/lib/src/brand-page/utils/text.util.js +0 -64
- package/lib/src/brand-page/utils/vcard.util.js +4 -4
- package/lib/src/brand-page/utils/view-model.util.d.ts +0 -1
- package/lib/src/brand-page/utils/view-model.util.js +20 -68
- package/lib/src/brand-page/view-models.d.ts +3 -3
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +1 -1
- package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.js +51 -18
- package/lib/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.d.ts +1 -0
- package/lib/src/brand-page-maker/composables/rich-text-editor/bubbleMenu.d.ts +9 -2
- package/lib/src/brand-page-maker/composables/rich-text-editor/bubbleMenu.js +10 -6
- package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/FontSize.d.ts +20 -0
- package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/FontSize.js +44 -0
- package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/LineHeight.d.ts +27 -0
- package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/LineHeight.js +44 -0
- package/lib/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.d.ts +1 -1
- package/lib/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.js +103 -24
- package/lib/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.js +8 -0
- package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +9 -3
- package/lib/src/brand-page-maker/stores/ui/ui-store.d.ts +1 -1
- package/lib/src/brand-page-maker/utils/index.d.ts +0 -2
- package/lib/src/brand-page-maker/utils/index.js +0 -2
- package/lib/src/brand-page-maker/utils/rich-text-editor.util.d.ts +5 -36
- package/lib/src/brand-page-maker/utils/rich-text-editor.util.js +5 -65
- package/lib/src/brand-page-maker/validators/field.validator.js +2 -10
- package/lib/src/clients/models.d.ts +2 -0
- package/lib/src/css/library.brand-page-brandCrowd.min.css +99 -102
- package/lib/src/css/library.brand-page-brandPage.min.css +99 -102
- package/lib/src/css/library.brand-page-designCom.min.css +99 -102
- package/lib/src/css/library.brand-page-preview.min.css +99 -102
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.mjs +219 -221
- package/lib/src/{lib-uYwxz8qR.js → lib-DtalJKI3.js} +71861 -75344
- package/lib/src/lib.js +1 -2
- package/lib/src/metadata-builder/ai-metadata-executor.d.ts +1 -0
- package/lib/src/metadata-builder/ai-metadata-executor.js +19 -0
- package/lib/src/metadata-builder/builders/section-builders/about-section-builder.js +3 -2
- package/lib/src/metadata-builder/builders/section-builders/banner-section-builder.js +3 -2
- package/lib/src/metadata-builder/builders/section-builders/booking-section-builder.js +3 -2
- package/lib/src/metadata-builder/builders/section-builders/contact-form-builder.js +4 -3
- package/lib/src/metadata-builder/builders/section-builders/images-section-builder.js +3 -2
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-builder.js +2 -1
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-section-builder.js +2 -1
- package/lib/src/metadata-builder/builders/section-builders/profile-section-builder.js +4 -3
- package/lib/src/metadata-builder/builders/section-builders/shapes-section-builder.js +3 -2
- package/lib/src/metadata-builder/builders/section-builders/testimonial-section-builder.js +2 -1
- package/lib/src/metadata-builder/builders/section-builders/text-section-builder.js +11 -15
- package/lib/src/metadata-builder/builders/update-content-text-builder.d.ts +17 -0
- package/lib/src/metadata-builder/builders/update-content-text-builder.js +103 -0
- package/lib/src/metadata-builder/builders/update-content-text-style-builder.d.ts +16 -0
- package/lib/src/metadata-builder/builders/update-content-text-style-builder.js +216 -0
- package/lib/src/metadata-builder/helpers/rte.helpers.d.ts +13 -11
- package/lib/src/metadata-builder/helpers/rte.helpers.js +73 -14
- package/lib/src/metadata-builder/metadata-executor.js +4 -0
- package/lib/src/metadata-builder/models.d.ts +2 -0
- package/lib/src/metadata-builder/models.js +2 -0
- package/lib/src/metadata-builder/parsers/ai-toolcall-parser.d.ts +19 -0
- package/lib/src/metadata-builder/parsers/ai-toolcall-parser.js +4 -0
- package/lib/src/metadata-builder/sanitizers/rte-schema-check.d.ts +8 -7
- package/lib/src/metadata-builder/sanitizers/rte-schema-check.js +52 -21
- package/lib/src/shared/content-settings/components/GenericTextInput.mixin.d.ts +1 -1
- package/lib/src/shared/content-settings/components/GenericTextInput.mixin.js +10 -35
- package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.d.ts +1 -1
- package/lib/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.js +3 -12
- package/lib/src/shared/content-settings/components/email-field/EmailField.mixin.d.ts +1 -1
- package/lib/src/shared/content-settings/components/tel-field/TelField.mixin.d.ts +1 -1
- package/lib/src/shared/content-settings/components/testimonial-items-field/TestimonialItemsField.mixin.d.ts +2 -3
- package/lib/src/shared/content-settings/components/testimonial-items-field/TestimonialItemsField.mixin.js +3 -10
- package/lib/src/shared/content-settings/components/text-field/TextField.mixin.d.ts +1 -1
- package/lib/src/shared/content-settings/components/text-items-field/TextItemsField.mixin.d.ts +1 -2
- package/lib/src/shared/content-settings/components/text-items-field/TextItemsField.mixin.js +1 -4
- package/lib/src/shared/content-settings/components/textarea-field/TextareaField.mixin.d.ts +1 -1
- package/lib/src/shared/content-settings/components/url-field/UrlField.mixin.d.ts +1 -1
- package/lib/src/shared/content-settings/components/youtube-video-field/YoutubeVideoField.mixin.d.ts +1 -1
- package/lib/src/shared/logo-settings/components/EditLogoSettings.mixin.d.ts +1 -1
- package/lib/src/shared/logo-versions/LogoVersions.mixin.d.ts +1 -1
- package/lib/src/shared/my-designs/MyDesigns.mixin.d.ts +1 -1
- package/lib/src/shared/my-uploads/MyMedia.mixin.d.ts +1 -1
- package/lib/src/shared/my-uploads/MyUploads.mixin.d.ts +1 -1
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +1 -1
- package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +1 -1
- package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +1 -1
- package/lib/src/shared/template-settings/components/TemplatesSettings.mixin.d.ts +1 -1
- package/lib/src/shared/template-settings/store/template-settings-store.d.ts +2 -0
- package/lib/src/shared/template-settings/store/template-settings-store.js +72 -24
- package/lib/src/shared/unsplash-library/UnsplashLibrary.mixin.d.ts +1 -1
- package/lib/src/utils/minify-brand-page-metadata.js +1 -4
- package/package.json +15 -17
- package/src/brand-page/components/contact-form/ContactForm.mixin.ts +9 -7
- package/src/brand-page/components/cookie-consent/CookieConsent.vue +1 -0
- package/src/brand-page/components/mailing-list/MailingList.mixin.ts +8 -3
- package/src/brand-page/components/navigation/navigation-carousel/NavigationCarousel.vue +5 -1
- package/src/brand-page/components/page-footer/PageFooter.mixin.ts +4 -1
- package/src/brand-page/components/page-footer/PageFooter.vue +1 -1
- package/src/brand-page/components/payment/Payment.mixin.ts +4 -3
- package/src/brand-page/components/payment/request-payment/RequestPayment.mixin.ts +8 -1
- package/src/brand-page/components/payment/request-payment/RequestPayment.vue +1 -1
- package/src/brand-page/components/save-contact/SaveContactWidget.vue +2 -1
- package/src/brand-page/components/shop/Shop.vue +6 -3
- package/src/brand-page/components/social-links/SocialLinks.vue +5 -2
- package/src/brand-page/components/text-wrapper/TextWrapper.vue +6 -17
- package/src/brand-page/composables/consent.composable.ts +18 -4
- package/src/brand-page/models/brand-page-context.model.ts +7 -0
- package/src/brand-page/models/index.ts +26 -35
- package/src/brand-page/utils/__snapshots__/migration.util.test.ts.snap +3 -3
- package/src/brand-page/utils/context.util.test.ts +43 -0
- package/src/brand-page/utils/context.util.ts +10 -0
- package/src/brand-page/utils/migration.util.ts +0 -12
- package/src/brand-page/utils/style.util.test.ts +0 -51
- package/src/brand-page/utils/text.util.ts +4 -83
- package/src/brand-page/utils/vcard.util.ts +4 -6
- package/src/brand-page/utils/view-model.util.ts +26 -94
- package/src/brand-page/view-models.ts +2 -3
- package/src/brand-page-maker/components/rich-text-editor/RichTextEditor.vue +4 -5
- package/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.test.ts +135 -0
- package/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.ts +62 -21
- package/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.ts +1 -0
- package/src/brand-page-maker/composables/rich-text-editor/bubbleMenu.ts +10 -6
- package/src/brand-page-maker/composables/rich-text-editor/extensions/FontSize.ts +73 -0
- package/src/brand-page-maker/composables/rich-text-editor/extensions/LineHeight.ts +85 -0
- package/src/brand-page-maker/composables/rich-text-editor/useRichTextEditor.ts +111 -27
- package/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.ts +9 -0
- package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +11 -3
- package/src/brand-page-maker/stores/ui/ui-store.ts +1 -1
- package/src/brand-page-maker/utils/index.ts +0 -2
- package/src/brand-page-maker/utils/rich-text-editor.util.test.ts +3 -62
- package/src/brand-page-maker/utils/rich-text-editor.util.ts +11 -86
- package/src/brand-page-maker/validators/field.validator.ts +2 -10
- package/src/clients/models.ts +3 -0
- package/src/lib.ts +1 -9
- package/src/metadata-builder/ai-metadata-executor.ts +26 -0
- package/src/metadata-builder/builders/section-builders/about-section-builder.ts +3 -2
- package/src/metadata-builder/builders/section-builders/banner-section-builder.ts +3 -2
- package/src/metadata-builder/builders/section-builders/booking-section-builder.ts +5 -2
- package/src/metadata-builder/builders/section-builders/contact-form-builder.ts +4 -3
- package/src/metadata-builder/builders/section-builders/images-section-builder.ts +3 -2
- package/src/metadata-builder/builders/section-builders/mailing-list-builder.ts +2 -1
- package/src/metadata-builder/builders/section-builders/mailing-list-section-builder.ts +2 -1
- package/src/metadata-builder/builders/section-builders/profile-section-builder.ts +6 -3
- package/src/metadata-builder/builders/section-builders/shapes-section-builder.ts +3 -2
- package/src/metadata-builder/builders/section-builders/testimonial-section-builder.ts +2 -1
- package/src/metadata-builder/builders/section-builders/text-section-builder.ts +13 -19
- package/src/metadata-builder/builders/update-content-text-builder.ts +148 -0
- package/src/metadata-builder/builders/update-content-text-style-builder.ts +352 -0
- package/src/metadata-builder/helpers/rte.helpers.ts +101 -15
- package/src/metadata-builder/metadata-executor.ts +5 -0
- package/src/metadata-builder/models.ts +3 -0
- package/src/metadata-builder/parsers/ai-toolcall-parser.ts +27 -0
- package/src/metadata-builder/sanitizers/rte-schema-check.ts +53 -24
- package/src/shared/content-settings/components/GenericTextInput.mixin.ts +11 -42
- package/src/shared/content-settings/components/content-settings-item/ContentSettingsItemField.mixin.ts +3 -16
- package/src/shared/content-settings/components/testimonial-items-field/TestimonialItemsField.mixin.ts +4 -13
- package/src/shared/content-settings/components/testimonial-items-field/TestimonialItemsField.vue +4 -6
- package/src/shared/content-settings/components/text-image-field/TextImageField.vue +3 -6
- package/src/shared/content-settings/components/text-items-field/TextItemsField.mixin.ts +1 -6
- package/src/shared/content-settings/components/text-items-field/TextItemsField.vue +1 -1
- package/src/shared/template-settings/store/template-settings-store.ts +93 -27
- package/src/utils/minify-brand-page-metadata.ts +1 -4
- package/lib/src/brand-page/utils/migration/migration-20.d.ts +0 -2
- package/lib/src/brand-page/utils/migration/migration-20.js +0 -66
- package/lib/src/brand-page-maker/__fixtures__/complex-rte.fixture.d.ts +0 -22
- package/lib/src/brand-page-maker/__fixtures__/complex-rte.fixture.js +0 -22
- package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/FontFamily.d.ts +0 -14
- package/lib/src/brand-page-maker/composables/rich-text-editor/extensions/FontFamily.js +0 -39
- package/lib/src/brand-page-maker/composables/rich-text-editor/getRteExtensions.d.ts +0 -28
- package/lib/src/brand-page-maker/composables/rich-text-editor/getRteExtensions.js +0 -117
- package/lib/src/brand-page-maker/utils/rte-render.util.d.ts +0 -63
- package/lib/src/brand-page-maker/utils/rte-render.util.js +0 -95
- package/lib/src/brand-page-maker/utils/rte-sanitize.util.d.ts +0 -6
- package/lib/src/brand-page-maker/utils/rte-sanitize.util.js +0 -156
- package/src/brand-page/utils/migration/migration-20.server.test.ts +0 -125
- package/src/brand-page/utils/migration/migration-20.test.ts +0 -72
- package/src/brand-page/utils/migration/migration-20.ts +0 -87
- package/src/brand-page/utils/text.util.test.ts +0 -106
- package/src/brand-page/utils/view-model.pageid-rte.test.ts +0 -104
- package/src/brand-page-maker/__fixtures__/complex-rte.fixture.ts +0 -23
- package/src/brand-page-maker/composables/rich-text-editor/extensions/FontFamily.test.ts +0 -52
- package/src/brand-page-maker/composables/rich-text-editor/extensions/FontFamily.ts +0 -42
- package/src/brand-page-maker/composables/rich-text-editor/getRteExtensions.ts +0 -162
- package/src/brand-page-maker/utils/__snapshots__/rte-render-parity.test.ts.snap +0 -202
- package/src/brand-page-maker/utils/rte-features.test.ts +0 -378
- package/src/brand-page-maker/utils/rte-render-parity.test.ts +0 -164
- package/src/brand-page-maker/utils/rte-render.util.ts +0 -165
- package/src/brand-page-maker/utils/rte-sanitize-json.test.ts +0 -172
- package/src/brand-page-maker/utils/rte-sanitize.util.ts +0 -192
- package/src/brand-page-maker/validators/field.validator.test.ts +0 -55
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import { Editor } from '@tiptap/vue-3';
|
|
3
|
-
import { getRteExtensions } from '../composables/rich-text-editor/getRteExtensions';
|
|
4
|
-
import { toRteJson, renderRteToHtml } from './rte-render.util';
|
|
5
|
-
import { sanitizeRteJson } from './rte-sanitize.util';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* BP-5787 — feature-by-feature coverage of the whole RTE JSON pipeline.
|
|
9
|
-
*
|
|
10
|
-
* Each case runs a piece of authored HTML through the exact production path:
|
|
11
|
-
* HTML → toRteJson (headless editor parse) → sanitizeRteJson → renderRteToHtml
|
|
12
|
-
* (DOM-less serialiser)
|
|
13
|
-
* and asserts the feature survives end-to-end. One combined golden-master lives
|
|
14
|
-
* in rte-render-parity.test.ts; this file isolates every feature so a
|
|
15
|
-
* regression in any single one (a mark, a textStyle attr, a link, alignment, a
|
|
16
|
-
* block node) fails on its own line instead of inside one opaque snapshot.
|
|
17
|
-
*/
|
|
18
|
-
const pipe = (html: string): string => {
|
|
19
|
-
const json = toRteJson(html);
|
|
20
|
-
|
|
21
|
-
return renderRteToHtml(sanitizeRteJson(json));
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
describe('RTE features — inline marks', () => {
|
|
25
|
-
it('bold → <strong>', () => {
|
|
26
|
-
expect(pipe('<p><strong>x</strong></p>')).toContain('<strong>x</strong>');
|
|
27
|
-
});
|
|
28
|
-
it('italic → <em>', () => {
|
|
29
|
-
expect(pipe('<p><em>x</em></p>')).toContain('<em>x</em>');
|
|
30
|
-
});
|
|
31
|
-
it('underline → <u>', () => {
|
|
32
|
-
expect(pipe('<p><u>x</u></p>')).toContain('<u>x</u>');
|
|
33
|
-
});
|
|
34
|
-
it('strikethrough → <s>', () => {
|
|
35
|
-
expect(pipe('<p><s>x</s></p>')).toContain('<s>x</s>');
|
|
36
|
-
});
|
|
37
|
-
it('inline code → <code>', () => {
|
|
38
|
-
expect(pipe('<p><code>x</code></p>')).toContain('<code>x</code>');
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('RTE features — mark nesting (decoration must inherit font-size)', () => {
|
|
43
|
-
// BP-5787 regression: the textStyle <span> that carries font-size must render
|
|
44
|
-
// OUTSIDE <u>/<s>, so the decoration marks inherit the applied size. Otherwise
|
|
45
|
-
// text-decoration thickness AND vertical position are computed from the base
|
|
46
|
-
// paragraph font, giving thin, mis-centred lines on large text (v3 default
|
|
47
|
-
// priority regression vs v2). Guarded by TextStyle priority: 99.
|
|
48
|
-
it('font-size <span> wraps <u> (not the reverse)', () => {
|
|
49
|
-
const out = pipe('<p><span style="font-size: 40px"><u>x</u></span></p>');
|
|
50
|
-
|
|
51
|
-
expect(out).toContain('<span style="font-size: 40px"><u>x</u></span>');
|
|
52
|
-
expect(out).not.toMatch(/<u><span/);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('font-size <span> wraps <s> (not the reverse)', () => {
|
|
56
|
-
const out = pipe('<p><span style="font-size: 40px"><s>x</s></span></p>');
|
|
57
|
-
|
|
58
|
-
expect(out).toContain('<span style="font-size: 40px"><s>x</s></span>');
|
|
59
|
-
expect(out).not.toMatch(/<s><span/);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('RTE features — textStyle attrs (colour/font/spacing)', () => {
|
|
64
|
-
it('rgb colour is preserved', () => {
|
|
65
|
-
expect(
|
|
66
|
-
pipe('<p><span style="color: rgb(255, 0, 0)">x</span></p>'),
|
|
67
|
-
).toContain('color: rgb(255, 0, 0)');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('hex colour is preserved verbatim (Tiptap v3 no longer normalises to rgb)', () => {
|
|
71
|
-
expect(pipe('<p><span style="color: #00ff00">x</span></p>')).toContain(
|
|
72
|
-
'color: #00ff00',
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('theme token var(--…) colour survives verbatim (NOT flattened to rgb)', () => {
|
|
77
|
-
const out = pipe(
|
|
78
|
-
'<p><span style="color: var(--logo-text-color)">x</span></p>',
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
expect(out).toContain('color: var(--logo-text-color)');
|
|
82
|
-
expect(out).not.toContain('rgb(');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('single-word font-family is preserved', () => {
|
|
86
|
-
expect(
|
|
87
|
-
pipe('<p><span style="font-family: Montserrat">x</span></p>'),
|
|
88
|
-
).toContain('font-family: Montserrat');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('multi-word font-family is preserved UNQUOTED (BP-5787 quote-strip)', () => {
|
|
92
|
-
const out = pipe('<p><span style="font-family: Open Sans">x</span></p>');
|
|
93
|
-
|
|
94
|
-
expect(out).toContain('font-family: Open Sans');
|
|
95
|
-
// must not carry the CSS quotes that the sanitiser would otherwise drop
|
|
96
|
-
expect(out).not.toContain('font-family: "Open Sans"');
|
|
97
|
-
expect(out).not.toContain('"');
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('font-size / letter-spacing / line-height are preserved', () => {
|
|
101
|
-
expect(pipe('<p><span style="font-size: 2em">x</span></p>')).toContain(
|
|
102
|
-
'font-size: 2em',
|
|
103
|
-
);
|
|
104
|
-
expect(
|
|
105
|
-
pipe('<p><span style="letter-spacing: 0.1em">x</span></p>'),
|
|
106
|
-
).toContain('letter-spacing: 0.1em');
|
|
107
|
-
expect(pipe('<p><span style="line-height: 1.5">x</span></p>')).toContain(
|
|
108
|
-
'line-height: 1.5',
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe('RTE features — background colour (highlight)', () => {
|
|
114
|
-
it('highlight → <mark> with data-color + background-color + color:inherit', () => {
|
|
115
|
-
const out = pipe(
|
|
116
|
-
'<p><mark data-color="#ffe08a" style="background-color: #ffe08a">x</mark></p>',
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
expect(out).toContain(
|
|
120
|
-
'<mark data-color="#ffe08a" style="background-color: #ffe08a; color: inherit">x</mark>',
|
|
121
|
-
);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('theme token background colour survives verbatim', () => {
|
|
125
|
-
const out = pipe(
|
|
126
|
-
'<p><mark data-color="var(--logo-primary-color)" style="background-color: var(--logo-primary-color)">x</mark></p>',
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
expect(out).toContain('background-color: var(--logo-primary-color)');
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('RTE features — hyperlinks', () => {
|
|
134
|
-
it('external link keeps href + target + rel', () => {
|
|
135
|
-
const out = pipe(
|
|
136
|
-
'<p><a target="_blank" rel="noopener noreferrer" href="https://example.com">x</a></p>',
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
expect(out).toContain('href="https://example.com"');
|
|
140
|
-
expect(out).toContain('target="_blank"');
|
|
141
|
-
expect(out).toContain('rel="noopener noreferrer"');
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('freshly authored external link (no target/rel in source) still renders target + rel', () => {
|
|
145
|
-
// Regression: target/rel are derived at render time from the href, so a link
|
|
146
|
-
// authored as a bare <a href> — the normal editor case — must still open in a
|
|
147
|
-
// new tab with noopener. Before the render-time policy, these were injected by
|
|
148
|
-
// the HTML DOMPurify sanitiser and were lost when storage moved to JSON.
|
|
149
|
-
const out = pipe('<p><a href="https://example.com">x</a></p>');
|
|
150
|
-
|
|
151
|
-
expect(out).toContain('href="https://example.com"');
|
|
152
|
-
expect(out).toContain('target="_blank"');
|
|
153
|
-
expect(out).toContain('rel="noopener noreferrer"');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('external link with a stale target is normalised to _blank', () => {
|
|
157
|
-
const out = pipe(
|
|
158
|
-
'<p><a target="_self" href="https://example.com">x</a></p>',
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
expect(out).toContain('target="_blank"');
|
|
162
|
-
expect(out).not.toContain('target="_self"');
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('internal relative link keeps its href and gets no target/rel', () => {
|
|
166
|
-
const out = pipe('<p><a href="/about">x</a></p>');
|
|
167
|
-
|
|
168
|
-
expect(out).toContain('href="/about"');
|
|
169
|
-
expect(out).not.toContain('target=');
|
|
170
|
-
expect(out).not.toContain('rel=');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('internal page reference (pageid:) survives the sanitiser with no target/rel', () => {
|
|
174
|
-
// pageid: hrefs are resolved to real routes later in the view-model
|
|
175
|
-
// transform; the sanitiser must not strip them, and they are not external so
|
|
176
|
-
// they get no target/rel.
|
|
177
|
-
const out = pipe('<p><a href="pageid:abc-123">x</a></p>');
|
|
178
|
-
|
|
179
|
-
expect(out).toContain('href="pageid:abc-123"');
|
|
180
|
-
expect(out).not.toContain('target=');
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('javascript: link is dropped (mark removed, text kept)', () => {
|
|
184
|
-
const out = pipe('<p><a href="javascript:alert(1)">x</a></p>');
|
|
185
|
-
|
|
186
|
-
expect(out).not.toContain('<a');
|
|
187
|
-
expect(out).not.toContain('javascript:');
|
|
188
|
-
expect(out).toContain('x');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('data: link is dropped', () => {
|
|
192
|
-
const out = pipe(
|
|
193
|
-
'<p><a href="data:text/html,<script>1</script>">x</a></p>',
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
expect(out).not.toContain('<a');
|
|
197
|
-
expect(out).not.toContain('data:');
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
describe('RTE features — text alignment', () => {
|
|
202
|
-
for (const align of ['center', 'right', 'justify', 'left'] as const) {
|
|
203
|
-
it(`paragraph text-align: ${align}`, () => {
|
|
204
|
-
expect(pipe(`<p style="text-align: ${align}">x</p>`)).toContain(
|
|
205
|
-
`<p style="text-align: ${align}">`,
|
|
206
|
-
);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
it('heading carries its alignment', () => {
|
|
211
|
-
expect(pipe('<h2 style="text-align: center">x</h2>')).toContain(
|
|
212
|
-
'<h2 style="text-align: center">',
|
|
213
|
-
);
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
describe('RTE features — block nodes', () => {
|
|
218
|
-
it('headings h1–h6', () => {
|
|
219
|
-
for (const level of [1, 2, 3, 4, 5, 6]) {
|
|
220
|
-
expect(pipe(`<h${level}>x</h${level}>`)).toContain(`<h${level}`);
|
|
221
|
-
expect(pipe(`<h${level}>x</h${level}>`)).toContain(`</h${level}>`);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('bullet list → <ul><li>', () => {
|
|
226
|
-
const out = pipe('<ul><li>a</li><li>b</li></ul>');
|
|
227
|
-
|
|
228
|
-
expect(out).toContain('<ul>');
|
|
229
|
-
expect(out).toContain('<li>');
|
|
230
|
-
expect(out).toContain('a');
|
|
231
|
-
expect(out).toContain('b');
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('ordered list → <ol><li>', () => {
|
|
235
|
-
expect(pipe('<ol><li>a</li></ol>')).toContain('<ol>');
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it('blockquote → <blockquote>', () => {
|
|
239
|
-
expect(pipe('<blockquote><p>q</p></blockquote>')).toContain('<blockquote>');
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it('code block → <pre><code>', () => {
|
|
243
|
-
expect(pipe('<pre><code>c</code></pre>')).toContain('<pre><code>');
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('hard break → <br/>', () => {
|
|
247
|
-
expect(pipe('<p>a<br>b</p>')).toContain('<br/>');
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it('horizontal rule → <hr/>', () => {
|
|
251
|
-
expect(pipe('<p>a</p><hr><p>b</p>')).toContain('<hr/>');
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
describe('RTE features — combinations & escaping', () => {
|
|
256
|
-
it('nested marks (colour + bold + italic) all survive on the same run', () => {
|
|
257
|
-
const out = pipe(
|
|
258
|
-
'<p><span style="color: rgb(1, 2, 3)"><strong><em>x</em></strong></span></p>',
|
|
259
|
-
);
|
|
260
|
-
|
|
261
|
-
expect(out).toContain('color: rgb(1, 2, 3)');
|
|
262
|
-
expect(out).toContain('<strong>');
|
|
263
|
-
expect(out).toContain('<em>');
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it('a styled hyperlink keeps both the colour and the link', () => {
|
|
267
|
-
const out = pipe(
|
|
268
|
-
'<p><a href="https://x.com"><span style="color: rgb(0, 151, 215)">x</span></a></p>',
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
expect(out).toContain('href="https://x.com"');
|
|
272
|
-
expect(out).toContain('color: rgb(0, 151, 215)');
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('HTML-special characters in text are escaped', () => {
|
|
276
|
-
const out = pipe('<p>a <b> & "c"</p>');
|
|
277
|
-
|
|
278
|
-
expect(out).toContain('<b>');
|
|
279
|
-
expect(out).toContain('&');
|
|
280
|
-
expect(out).not.toContain('<b>');
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
it('serialisation is idempotent (serialize(json) === serialize(reparse))', () => {
|
|
284
|
-
const html =
|
|
285
|
-
'<h2 style="text-align: center"><span style="color: var(--logo-text-color); font-family: Open Sans; font-size: 1.5em">Heading</span></h2>' +
|
|
286
|
-
'<p><strong>bold</strong> <em>italic</em> <u>u</u> <s>s</s> ' +
|
|
287
|
-
'<mark data-color="#ffe08a" style="background-color: #ffe08a">hl</mark> ' +
|
|
288
|
-
'<a target="_blank" rel="noopener noreferrer" href="https://x.com">link</a></p>';
|
|
289
|
-
const once = pipe(html);
|
|
290
|
-
const twice = renderRteToHtml(sanitizeRteJson(toRteJson(once)));
|
|
291
|
-
|
|
292
|
-
expect(twice).toEqual(once);
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
describe('RTE features — maker toolbar commands (emit path)', () => {
|
|
297
|
-
let editors: Editor[] = [];
|
|
298
|
-
|
|
299
|
-
afterEach(() => {
|
|
300
|
-
editors.forEach((e) => e.destroy());
|
|
301
|
-
editors = [];
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
// Apply a real editor command to a full selection (as the toolbar does),
|
|
305
|
-
// then run the emitted JSON through sanitise + serialise.
|
|
306
|
-
const applied = (fn: (e: Editor) => void): string => {
|
|
307
|
-
const editor = new Editor({
|
|
308
|
-
extensions: getRteExtensions({ restrictStarterKit: true }),
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
editors.push(editor);
|
|
312
|
-
editor.commands.setContent('<p>styled text</p>');
|
|
313
|
-
editor.commands.selectAll();
|
|
314
|
-
fn(editor);
|
|
315
|
-
|
|
316
|
-
return renderRteToHtml(sanitizeRteJson(editor.getJSON()));
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
it('setColor', () => {
|
|
320
|
-
expect(applied((e) => e.commands.setColor('rgb(255, 0, 0)'))).toContain(
|
|
321
|
-
'color: rgb(255, 0, 0)',
|
|
322
|
-
);
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
it('setHighlight (background colour)', () => {
|
|
326
|
-
const out = applied((e) => e.commands.setHighlight({ color: '#ffe08a' }));
|
|
327
|
-
|
|
328
|
-
expect(out).toContain('background-color: #ffe08a');
|
|
329
|
-
expect(out).toContain('<mark');
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
it('toggleBold / toggleItalic / toggleUnderline / toggleStrike', () => {
|
|
333
|
-
expect(applied((e) => e.commands.toggleBold())).toContain('<strong>');
|
|
334
|
-
expect(applied((e) => e.commands.toggleItalic())).toContain('<em>');
|
|
335
|
-
expect(applied((e) => e.commands.toggleUnderline())).toContain('<u>');
|
|
336
|
-
expect(applied((e) => e.commands.toggleStrike())).toContain('<s>');
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
it('setFontFamily (multi-word, unquoted)', () => {
|
|
340
|
-
const out = applied((e) =>
|
|
341
|
-
(e.commands as { setFontFamily: (f: string) => boolean }).setFontFamily(
|
|
342
|
-
'Open Sans',
|
|
343
|
-
),
|
|
344
|
-
);
|
|
345
|
-
|
|
346
|
-
expect(out).toContain('font-family: Open Sans');
|
|
347
|
-
expect(out).not.toContain('"');
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('setFontSize / setLetterSpacing', () => {
|
|
351
|
-
expect(
|
|
352
|
-
applied((e) =>
|
|
353
|
-
(e.commands as { setFontSize: (v: string) => boolean }).setFontSize(
|
|
354
|
-
'2em',
|
|
355
|
-
),
|
|
356
|
-
),
|
|
357
|
-
).toContain('font-size: 2em');
|
|
358
|
-
expect(
|
|
359
|
-
applied((e) =>
|
|
360
|
-
(
|
|
361
|
-
e.commands as { setLetterSpacing: (v: string) => boolean }
|
|
362
|
-
).setLetterSpacing('0.1em'),
|
|
363
|
-
),
|
|
364
|
-
).toContain('letter-spacing: 0.1em');
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it('setTextAlign', () => {
|
|
368
|
-
expect(applied((e) => e.commands.setTextAlign('center'))).toContain(
|
|
369
|
-
'text-align: center',
|
|
370
|
-
);
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
it('setLink keeps the href through the pipeline', () => {
|
|
374
|
-
expect(
|
|
375
|
-
applied((e) => e.commands.setLink({ href: 'https://x.com' })),
|
|
376
|
-
).toContain('href="https://x.com"');
|
|
377
|
-
});
|
|
378
|
-
});
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
-
import type { Editor } from '@tiptap/vue-3';
|
|
3
|
-
import { useExternalRichTextEditor } from '../composables/rich-text-editor/useRichTextEditor';
|
|
4
|
-
import {
|
|
5
|
-
renderRteToHtml,
|
|
6
|
-
toRteJson,
|
|
7
|
-
getRteJsonPlainText,
|
|
8
|
-
} from './rte-render.util';
|
|
9
|
-
import {
|
|
10
|
-
COMPLEX_RTE_HTML,
|
|
11
|
-
THEME_TOKEN_REF,
|
|
12
|
-
} from '../__fixtures__/complex-rte.fixture';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* BP-5787 — golden-master render-parity baseline.
|
|
16
|
-
*
|
|
17
|
-
* Captured on the CURRENT (HTML) pipeline. These committed snapshots are the
|
|
18
|
-
* frozen reference for the HTML→JSON migration:
|
|
19
|
-
*
|
|
20
|
-
* - `editor-normalized-html` is what the editor renders the fixture to today.
|
|
21
|
-
* After the migration, `htmlFromJson(getJSON())` MUST equal this snapshot —
|
|
22
|
-
* i.e. the JSON pipeline reproduces identical rendered output (no drift).
|
|
23
|
-
*
|
|
24
|
-
* - `editor-json` freezes the RAW editor output (`getJSON()`), pre-sanitise. It
|
|
25
|
-
* is expected to change exactly once, intentionally, when storage flips to JSON
|
|
26
|
-
* (see "expected vs forbidden drift" in docs/plans/BP-5787-...html). NOTE: this
|
|
27
|
-
* is not the persisted form — the stored doc runs through `sanitizeRteJson`
|
|
28
|
-
* first, which (for links) keeps href only; target/rel are render-derived and
|
|
29
|
-
* stripped from storage. The persisted link shape is pinned in
|
|
30
|
-
* rte-sanitize-json.test.ts, not here.
|
|
31
|
-
*
|
|
32
|
-
* The headless editor uses the SAME extension set as the live editor
|
|
33
|
-
* (useExternalRichTextEditor), so it is a faithful stand-in for the renderer.
|
|
34
|
-
*/
|
|
35
|
-
describe('BP-5787 RTE render parity (golden master)', () => {
|
|
36
|
-
let editor: Editor;
|
|
37
|
-
|
|
38
|
-
const makeEditor = (): Editor => {
|
|
39
|
-
editor = useExternalRichTextEditor().externalEditor;
|
|
40
|
-
|
|
41
|
-
return editor;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
afterEach(() => {
|
|
45
|
-
editor?.destroy();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('T1 — editor renders the complex fixture to the frozen HTML baseline', () => {
|
|
49
|
-
const ed = makeEditor();
|
|
50
|
-
|
|
51
|
-
ed.commands.setContent(COMPLEX_RTE_HTML);
|
|
52
|
-
|
|
53
|
-
// The golden master. The JSON pipeline must reproduce this exactly.
|
|
54
|
-
expect(ed.getHTML()).toMatchSnapshot('editor-normalized-html');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('T1 — round-trip is idempotent (html → json → html === json → html)', () => {
|
|
58
|
-
const ed = makeEditor();
|
|
59
|
-
|
|
60
|
-
ed.commands.setContent(COMPLEX_RTE_HTML);
|
|
61
|
-
const pass1 = ed.getHTML();
|
|
62
|
-
const json = ed.getJSON();
|
|
63
|
-
|
|
64
|
-
// Re-seed from the JSON the migration will store, render again.
|
|
65
|
-
ed.commands.setContent(json);
|
|
66
|
-
const pass2 = ed.getHTML();
|
|
67
|
-
|
|
68
|
-
expect(pass2).toEqual(pass1);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('T6 — freezes the RAW editor JSON (pre-sanitise; not the persisted form)', () => {
|
|
72
|
-
// getJSON() is the editor's raw output: link marks still carry the parsed
|
|
73
|
-
// target/rel/class/title. The persisted form runs through sanitizeRteJson
|
|
74
|
-
// (href-only links) — pinned in rte-sanitize-json.test.ts, not here.
|
|
75
|
-
const ed = makeEditor();
|
|
76
|
-
|
|
77
|
-
ed.commands.setContent(COMPLEX_RTE_HTML);
|
|
78
|
-
|
|
79
|
-
expect(ed.getJSON()).toMatchSnapshot('editor-json');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('T2 — theme token ref survives the round-trip (NOT flattened to rgb)', () => {
|
|
83
|
-
const ed = makeEditor();
|
|
84
|
-
|
|
85
|
-
ed.commands.setContent(COMPLEX_RTE_HTML);
|
|
86
|
-
|
|
87
|
-
// Today the editor preserves var(--…) in marks; the migration must keep it.
|
|
88
|
-
expect(ed.getHTML()).toContain(THEME_TOKEN_REF);
|
|
89
|
-
expect(JSON.stringify(ed.getJSON())).toContain(THEME_TOKEN_REF);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('T1 — render-from-JSON (DOM-less renderer) produces equivalent HTML', () => {
|
|
93
|
-
// renderRteToHtml serialises JSON → HTML via @tiptap/static-renderer from the
|
|
94
|
-
// extension schema (no editor/DOM, so it works on the server). Output is
|
|
95
|
-
// semantically identical to the editor's — the Playwright visual golden-master
|
|
96
|
-
// is the authority on pixel parity; here we freeze the renderer output and
|
|
97
|
-
// assert structure.
|
|
98
|
-
const viaJson = renderRteToHtml(toRteJson(COMPLEX_RTE_HTML));
|
|
99
|
-
|
|
100
|
-
expect(viaJson).toMatchSnapshot('serializer-html');
|
|
101
|
-
|
|
102
|
-
// marks/nodes preserved
|
|
103
|
-
expect(viaJson).toContain('<strong>bold</strong>');
|
|
104
|
-
expect(viaJson).toContain('<em>italic</em>');
|
|
105
|
-
expect(viaJson).toContain('<u>underline</u>');
|
|
106
|
-
expect(viaJson).toContain('<s>strike</s>');
|
|
107
|
-
expect(viaJson).toContain('font-family: Montserrat');
|
|
108
|
-
expect(viaJson).toContain('font-size: 1.5em');
|
|
109
|
-
// theme token ref preserved (the crux of BP-5787)
|
|
110
|
-
expect(viaJson).toContain('color: var(--logo-text-color)');
|
|
111
|
-
// links + alignment
|
|
112
|
-
expect(viaJson).toContain('href="/about"');
|
|
113
|
-
expect(viaJson).toContain('href="https://example.com"');
|
|
114
|
-
expect(viaJson).toContain('text-align: center');
|
|
115
|
-
expect(viaJson).toContain('text-align: right');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('T4 — legacy HTML strings render unchanged (back-compat passthrough)', () => {
|
|
119
|
-
expect(renderRteToHtml(COMPLEX_RTE_HTML)).toEqual(COMPLEX_RTE_HTML);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('T8 — getRteJsonPlainText extracts visible text only (for fraud/translate)', () => {
|
|
123
|
-
const json = toRteJson(COMPLEX_RTE_HTML)!;
|
|
124
|
-
const text = getRteJsonPlainText(json);
|
|
125
|
-
|
|
126
|
-
expect(text).toContain('Themed heading');
|
|
127
|
-
expect(text).toContain('bold');
|
|
128
|
-
expect(text).toContain('external link');
|
|
129
|
-
// no markup or token refs leak into the extracted text
|
|
130
|
-
expect(text).not.toContain('<');
|
|
131
|
-
expect(text).not.toContain('var(--');
|
|
132
|
-
expect(text).not.toContain('font-size');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('T1 — preserves every mark/node in the fixture', () => {
|
|
136
|
-
const ed = makeEditor();
|
|
137
|
-
|
|
138
|
-
ed.commands.setContent(COMPLEX_RTE_HTML);
|
|
139
|
-
const html = ed.getHTML();
|
|
140
|
-
|
|
141
|
-
// bold / italic / underline / strike
|
|
142
|
-
expect(html).toContain('<strong>');
|
|
143
|
-
expect(html).toContain('<em>');
|
|
144
|
-
expect(html).toContain('<u>');
|
|
145
|
-
expect(html).toContain('<s>');
|
|
146
|
-
// textStyle attrs
|
|
147
|
-
expect(html).toContain('font-family: Montserrat');
|
|
148
|
-
expect(html).toContain('font-size: 1.5em');
|
|
149
|
-
expect(html).toContain('letter-spacing: 0.05em');
|
|
150
|
-
expect(html).toContain('line-height: 1.4');
|
|
151
|
-
// highlight: data-color keeps the hex; the rendered style is normalised to rgb()
|
|
152
|
-
expect(html).toContain('data-color="#ffe08a"');
|
|
153
|
-
expect(html).toContain('background-color: rgb(255, 224, 138)');
|
|
154
|
-
// literal hex colour is normalised to rgb() by the editor...
|
|
155
|
-
expect(html).toContain('color: rgb(255, 0, 0)');
|
|
156
|
-
// ...but the THEME TOKEN ref is preserved verbatim (the crux of BP-5787)
|
|
157
|
-
expect(html).toContain('color: var(--logo-text-color)');
|
|
158
|
-
expect(html).toContain('text-align: center');
|
|
159
|
-
expect(html).toContain('text-align: right');
|
|
160
|
-
// links
|
|
161
|
-
expect(html).toContain('href="/about"');
|
|
162
|
-
expect(html).toContain('href="https://example.com"');
|
|
163
|
-
});
|
|
164
|
-
});
|