@sitecore-feaas/clientside 0.1.17 → 0.1.19

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/test/extras.ts ADDED
@@ -0,0 +1,714 @@
1
+ import { describe, it, assert, beforeAll, expect } from 'vitest'
2
+ import { CH1Node, serializeCH1RichText } from '../src/dom.js'
3
+ describe('Extras', function () {
4
+ it('should serialize content hub', function () {
5
+ const data: CH1Node = {
6
+ type: 'doc',
7
+ content: [
8
+ {
9
+ type: 'paragraph',
10
+ content: [
11
+ {
12
+ type: 'text',
13
+ text: 'Customers want to experience uninterrupted interactions with brands —whether shopping, surfing, or asking questions —from wherever they are and on whichever device they happen to be using. If they put one device down and pick up another, they want the brand to recognize where they were previously so their journey can continue. '
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ type: 'paragraph',
19
+ content: [
20
+ {
21
+ type: 'text',
22
+ text: 'This is the '
23
+ },
24
+ {
25
+ type: 'text',
26
+ marks: [
27
+ {
28
+ type: 'link',
29
+ attrs: {
30
+ href: 'https://www.sitecore.com/knowledge-center/digital-marketing-resources/omnichannel-marketing',
31
+ target: '_blank',
32
+ class: null
33
+ }
34
+ }
35
+ ],
36
+ text: 'seamless omnichannel experience'
37
+ },
38
+ {
39
+ type: 'text',
40
+ text: ' that customers crave today. But it can be a struggle for marketers to keep up with customers as they swap from one device to another and expand to new devices. One way that marketers can keep pace with the ever-growing number of customer touchpoints is to use a headless content management system (CMS), which enables content to flow to where customers interact. A headless CMS opens up the possibility of serving content and experiences to the latest, or most popular customer touchpoint.'
41
+ }
42
+ ]
43
+ },
44
+ {
45
+ type: 'paragraph',
46
+ content: [
47
+ {
48
+ type: 'text',
49
+ text: 'Unfortunately, with legacy content management systems still dominating the global CMS market, many marketers struggle to meet today’s customer expectations. As expectations and digital behaviors continue to evolve, there’s never been a better time to investigate the flexibility of a headless CMS and the benefits it provides to digital marketers today.'
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ type: 'heading',
55
+ attrs: {
56
+ level: 2
57
+ },
58
+ content: [
59
+ {
60
+ type: 'text',
61
+ text: 'Headless CMS vs. traditional CMS: What’s the difference?'
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ type: 'paragraph',
67
+ content: [
68
+ {
69
+ type: 'text',
70
+ text: 'Traditional CMS platforms are built with desktop web browsers in mind. They help you construct web pages and e-commerce experiences that can be served through templates built for popular internet browsers like Google Chrome, Firefox, and Internet Explorer.'
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ type: 'paragraph',
76
+ content: [
77
+ {
78
+ type: 'text',
79
+ text: 'Which is fine, if that’s all you need to do. But consumers today expect personalized and consistent omnichannel experiences through various channels such as smart speakers, kiosks, event screens, and smart watches. This is where the “headless” element comes in.'
80
+ }
81
+ ]
82
+ },
83
+ {
84
+ type: 'paragraph',
85
+ content: [
86
+ {
87
+ type: 'text',
88
+ text: 'The presentation of your content is not dictated by a headless CMS. The front-end display —also known as the “head” —isn’t connected to your backend. Your content can be created once, stored centrally, and distributed to any device or touchpoint, without restrictions. This means marketers can be far more flexible while still maintaining data and analytics tracking —and personalization.'
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ type: 'heading',
94
+ attrs: {
95
+ level: 2
96
+ },
97
+ content: [
98
+ {
99
+ type: 'text',
100
+ text: 'Six benefits of going headless'
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ type: 'heading',
106
+ attrs: {
107
+ level: 3
108
+ },
109
+ content: [
110
+ {
111
+ type: 'text',
112
+ text: '1. Beat competitors to new channels'
113
+ }
114
+ ]
115
+ },
116
+ {
117
+ type: 'paragraph',
118
+ content: [
119
+ {
120
+ type: 'text',
121
+ text: 'Did you know that every second '
122
+ },
123
+ {
124
+ type: 'text',
125
+ marks: [
126
+ {
127
+ type: 'link',
128
+ attrs: {
129
+ href: 'https://www.mckinsey.com/business-functions/mckinsey-digital/our-insights/the-internet-of-things-the-value-of-digitizing-the-physical-world',
130
+ target: '_blank',
131
+ class: null
132
+ }
133
+ }
134
+ ],
135
+ text: '127 new devices'
136
+ },
137
+ {
138
+ type: 'text',
139
+ text: ' get connected to the internet? That’s a lot of places a customer might be hanging out. The explosion of '
140
+ },
141
+ {
142
+ type: 'text',
143
+ marks: [
144
+ {
145
+ type: 'link',
146
+ attrs: {
147
+ href: 'https://www.sitecore.com/resources/index/ebooks/headless-key-to-iot',
148
+ target: '_blank',
149
+ class: null
150
+ }
151
+ }
152
+ ],
153
+ text: 'IoT devices'
154
+ },
155
+ {
156
+ type: 'text',
157
+ text: ' has dramatically changed consumer behavior. A headless CMS enables marketers to push their content beyond web and mobile applications, to reach consumers on whichever exciting touchpoints come into existence.'
158
+ }
159
+ ]
160
+ },
161
+ {
162
+ type: 'heading',
163
+ attrs: {
164
+ level: 3
165
+ },
166
+ content: [
167
+ {
168
+ type: 'text',
169
+ text: '2. Prepare for the future —without trying'
170
+ }
171
+ ]
172
+ },
173
+ {
174
+ type: 'paragraph',
175
+ content: [
176
+ {
177
+ type: 'text',
178
+ text: 'By using the same technology to connect with any device or touchpoint on the market today and tomorrow, a headless CMS removes concerns about the future. You’re always prepared to meet your customers on the new frontier of interaction, wherever that may be.'
179
+ }
180
+ ]
181
+ },
182
+ {
183
+ type: 'heading',
184
+ attrs: {
185
+ level: 3
186
+ },
187
+ content: [
188
+ {
189
+ type: 'text',
190
+ text: '3. Be consistent and avoid duplication'
191
+ }
192
+ ]
193
+ },
194
+ {
195
+ type: 'paragraph',
196
+ content: [
197
+ {
198
+ type: 'text',
199
+ text: 'A headless CMS provides an environment where content can be repurposed and reused for any channel, or device. This removes the unnecessary duplication of content as well as helping to keep branding and messaging consistent across channels by breaking down channel silos that can disconnect marketing teams.'
200
+ }
201
+ ]
202
+ },
203
+ {
204
+ type: 'heading',
205
+ attrs: {
206
+ level: 3
207
+ },
208
+ content: [
209
+ {
210
+ type: 'text',
211
+ text: '4. Be faster to market'
212
+ }
213
+ ]
214
+ },
215
+ {
216
+ type: 'paragraph',
217
+ content: [
218
+ {
219
+ type: 'text',
220
+ text: 'With a headless CMS, your content is created, edited, stored, previewed, and published in the same place. Content can be re-published across channels, in varying presentation styles, without the need to re-create any of it. This '
221
+ },
222
+ {
223
+ type: 'text',
224
+ marks: [
225
+ {
226
+ type: 'link',
227
+ attrs: {
228
+ href: 'https://www.sitecore.com/resources/index/ebooks/why-cms-architecture-matters',
229
+ target: '_blank',
230
+ class: null
231
+ }
232
+ }
233
+ ],
234
+ text: 'unified architecture'
235
+ },
236
+ {
237
+ type: 'text',
238
+ text: ' helps you evolve and iterate on campaigns at greater speed. The faster you are to market, the more time you put between you and your competitors, who are forced to catch up.'
239
+ }
240
+ ]
241
+ },
242
+ {
243
+ type: 'heading',
244
+ attrs: {
245
+ level: 3
246
+ },
247
+ content: [
248
+ {
249
+ type: 'text',
250
+ text: '5. Decrease barriers to innovation'
251
+ }
252
+ ]
253
+ },
254
+ {
255
+ type: 'paragraph',
256
+ content: [
257
+ {
258
+ type: 'text',
259
+ text: 'With the eruption of new IoT devices and sensors, a headless content management system enables marketers to experimentand explore different initiatives. For example, energy firm '
260
+ },
261
+ {
262
+ type: 'text',
263
+ marks: [
264
+ {
265
+ type: 'link',
266
+ attrs: {
267
+ href: 'https://www.sitecore.com/customers/service/innogy',
268
+ target: '_blank',
269
+ class: null
270
+ }
271
+ },
272
+ {
273
+ type: 'unknown'
274
+ }
275
+ ],
276
+ text: 'Innogy used Sitecore’s headless CMS'
277
+ },
278
+ {
279
+ type: 'text',
280
+ text: ' to connect IoT sensors to internal analytics systems and to customer-facing mobile apps to give their customers real-time gas meter readings, and personalized messaging.'
281
+ }
282
+ ]
283
+ },
284
+ {
285
+ type: 'heading',
286
+ attrs: {
287
+ level: 3
288
+ },
289
+ content: [
290
+ {
291
+ type: 'text',
292
+ text: '6. Embrace martech freedom'
293
+ }
294
+ ]
295
+ },
296
+ {
297
+ type: 'paragraph',
298
+ content: [
299
+ {
300
+ type: 'text',
301
+ text: 'A headless CMS doesn’t just seamlessly connect with any device, it can also easily connect with any third-party tool or software on the market. Marketers can connect their favorite tools, from marketing automation tools to CRMs to conversion optimization technologies. Vendor lock-in becomes a thing of the past as you are free to explore best-of-breed technologies for each dimension of your marketing campaign.'
302
+ }
303
+ ]
304
+ },
305
+ {
306
+ type: 'heading',
307
+ attrs: {
308
+ level: 2
309
+ },
310
+ content: [
311
+ {
312
+ type: 'text',
313
+ text: 'Lose your head or risk losing customers'
314
+ }
315
+ ]
316
+ },
317
+ {
318
+ type: 'paragraph',
319
+ content: [
320
+ {
321
+ type: 'text',
322
+ text: 'Consumers seem to have an endless thirst for new ways to interact online. As a result, their time is divided up into smaller chunks, meaning that brands who are putting all their efforts into desktop and mobile applications are at risk of missing out.'
323
+ }
324
+ ]
325
+ },
326
+ {
327
+ type: 'paragraph',
328
+ content: [
329
+ {
330
+ type: 'text',
331
+ text: 'Investing in multiple technologies is one option, but now that the headless CMS secret is out, it’s fair to say that creating, storing, and publishing content in this flexible way is the best solution.'
332
+ }
333
+ ]
334
+ }
335
+ ]
336
+ }
337
+
338
+ expect(serializeCH1RichText(data)).toEqual(
339
+ `<p>Customers want to experience uninterrupted interactions with brands —whether shopping, surfing, or asking questions —from wherever they are and on whichever device they happen to be using. If they put one device down and pick up another, they want the brand to recognize where they were previously so their journey can continue.</p>
340
+ <p>This is the
341
+ <a href="https://www.sitecore.com/knowledge-center/digital-marketing-resources/omnichannel-marketing" target="_blank">seamless omnichannel experience</a>
342
+ that customers crave today. But it can be a struggle for marketers to keep up with customers as they swap from one device to another and expand to new devices. One way that marketers can keep pace with the ever-growing number of customer touchpoints is to use a headless content management system (CMS), which enables content to flow to where customers interact. A headless CMS opens up the possibility of serving content and experiences to the latest, or most popular customer touchpoint.</p>
343
+ <p>Unfortunately, with legacy content management systems still dominating the global CMS market, many marketers struggle to meet today’s customer expectations. As expectations and digital behaviors continue to evolve, there’s never been a better time to investigate the flexibility of a headless CMS and the benefits it provides to digital marketers today.</p>
344
+ <h2>Headless CMS vs. traditional CMS: What’s the difference?</h2>
345
+ <p>Traditional CMS platforms are built with desktop web browsers in mind. They help you construct web pages and e-commerce experiences that can be served through templates built for popular internet browsers like Google Chrome, Firefox, and Internet Explorer.</p>
346
+ <p>Which is fine, if that’s all you need to do. But consumers today expect personalized and consistent omnichannel experiences through various channels such as smart speakers, kiosks, event screens, and smart watches. This is where the “headless” element comes in.</p>
347
+ <p>The presentation of your content is not dictated by a headless CMS. The front-end display —also known as the “head” —isn’t connected to your backend. Your content can be created once, stored centrally, and distributed to any device or touchpoint, without restrictions. This means marketers can be far more flexible while still maintaining data and analytics tracking —and personalization.</p>
348
+ <h2>Six benefits of going headless</h2>
349
+ <h3>1. Beat competitors to new channels</h3>
350
+ <p>Did you know that every second
351
+ <a href="https://www.mckinsey.com/business-functions/mckinsey-digital/our-insights/the-internet-of-things-the-value-of-digitizing-the-physical-world" target="_blank">127 new devices</a>
352
+ get connected to the internet? That’s a lot of places a customer might be hanging out. The explosion of
353
+ <a href="https://www.sitecore.com/resources/index/ebooks/headless-key-to-iot" target="_blank">IoT devices</a>
354
+ has dramatically changed consumer behavior. A headless CMS enables marketers to push their content beyond web and mobile applications, to reach consumers on whichever exciting touchpoints come into existence.</p>
355
+ <h3>2. Prepare for the future —without trying</h3>
356
+ <p>By using the same technology to connect with any device or touchpoint on the market today and tomorrow, a headless CMS removes concerns about the future. You’re always prepared to meet your customers on the new frontier of interaction, wherever that may be.</p>
357
+ <h3>3. Be consistent and avoid duplication</h3>
358
+ <p>A headless CMS provides an environment where content can be repurposed and reused for any channel, or device. This removes the unnecessary duplication of content as well as helping to keep branding and messaging consistent across channels by breaking down channel silos that can disconnect marketing teams.</p>
359
+ <h3>4. Be faster to market</h3>
360
+ <p>With a headless CMS, your content is created, edited, stored, previewed, and published in the same place. Content can be re-published across channels, in varying presentation styles, without the need to re-create any of it. This
361
+ <a href="https://www.sitecore.com/resources/index/ebooks/why-cms-architecture-matters" target="_blank">unified architecture</a>
362
+ helps you evolve and iterate on campaigns at greater speed. The faster you are to market, the more time you put between you and your competitors, who are forced to catch up.</p>
363
+ <h3>5. Decrease barriers to innovation</h3>
364
+ <p>With the eruption of new IoT devices and sensors, a headless content management system enables marketers to experimentand explore different initiatives. For example, energy firm
365
+ <a href="https://www.sitecore.com/customers/service/innogy" target="_blank">Innogy used Sitecore’s headless CMS</a>
366
+ to connect IoT sensors to internal analytics systems and to customer-facing mobile apps to give their customers real-time gas meter readings, and personalized messaging.</p>
367
+ <h3>6. Embrace martech freedom</h3>
368
+ <p>A headless CMS doesn’t just seamlessly connect with any device, it can also easily connect with any third-party tool or software on the market. Marketers can connect their favorite tools, from marketing automation tools to CRMs to conversion optimization technologies. Vendor lock-in becomes a thing of the past as you are free to explore best-of-breed technologies for each dimension of your marketing campaign.</p>
369
+ <h2>Lose your head or risk losing customers</h2>
370
+ <p>Consumers seem to have an endless thirst for new ways to interact online. As a result, their time is divided up into smaller chunks, meaning that brands who are putting all their efforts into desktop and mobile applications are at risk of missing out.</p>
371
+ <p>Investing in multiple technologies is one option, but now that the headless CMS secret is out, it’s fair to say that creating, storing, and publishing content in this flexible way is the best solution.</p>`
372
+ )
373
+ })
374
+ it('should support all content hub rich text nodes', function () {
375
+ const data: CH1Node = {
376
+ type: 'doc',
377
+ content: [
378
+ {
379
+ type: 'heading',
380
+ attrs: {
381
+ level: 1
382
+ },
383
+ content: [
384
+ {
385
+ type: 'text',
386
+ text: 'This is headline 1'
387
+ }
388
+ ]
389
+ },
390
+ {
391
+ type: 'heading',
392
+ attrs: {
393
+ level: 2
394
+ },
395
+ content: [
396
+ {
397
+ type: 'text',
398
+ text: 'This is headline 2'
399
+ }
400
+ ]
401
+ },
402
+ {
403
+ type: 'heading',
404
+ attrs: {
405
+ level: 3
406
+ },
407
+ content: [
408
+ {
409
+ type: 'text',
410
+ text: 'This is headline 3'
411
+ }
412
+ ]
413
+ },
414
+ {
415
+ type: 'heading',
416
+ attrs: {
417
+ level: 4
418
+ },
419
+ content: [
420
+ {
421
+ type: 'text',
422
+ text: 'This is headline 4'
423
+ }
424
+ ]
425
+ },
426
+ {
427
+ type: 'heading',
428
+ attrs: {
429
+ level: 5
430
+ },
431
+ content: [
432
+ {
433
+ type: 'text',
434
+ text: 'This is headline 5'
435
+ }
436
+ ]
437
+ },
438
+ {
439
+ type: 'heading',
440
+ attrs: {
441
+ level: 6
442
+ },
443
+ content: [
444
+ {
445
+ type: 'text',
446
+ text: 'This is headline 6'
447
+ }
448
+ ]
449
+ },
450
+ {
451
+ type: 'paragraph',
452
+ content: [
453
+ {
454
+ type: 'text',
455
+ text: 'This is paragraph with '
456
+ },
457
+ {
458
+ type: 'text',
459
+ marks: [
460
+ {
461
+ type: 'bold'
462
+ }
463
+ ],
464
+ text: 'bold'
465
+ },
466
+ {
467
+ type: 'text',
468
+ text: ' and '
469
+ },
470
+ {
471
+ type: 'text',
472
+ marks: [
473
+ {
474
+ type: 'italic'
475
+ }
476
+ ],
477
+ text: 'italic'
478
+ },
479
+ {
480
+ type: 'text',
481
+ text: ' and '
482
+ },
483
+ {
484
+ type: 'text',
485
+ marks: [
486
+ {
487
+ type: 'underline'
488
+ }
489
+ ],
490
+ text: 'underline'
491
+ },
492
+ {
493
+ type: 'text',
494
+ text: ' and '
495
+ },
496
+ {
497
+ type: 'text',
498
+ marks: [
499
+ {
500
+ type: 'strike'
501
+ }
502
+ ],
503
+ text: 'strikethrough'
504
+ }
505
+ ]
506
+ },
507
+ {
508
+ type: 'paragraph',
509
+ content: [
510
+ {
511
+ type: 'text',
512
+ text: 'This is bulleted list'
513
+ }
514
+ ]
515
+ },
516
+ {
517
+ type: 'bulletList',
518
+ content: [
519
+ {
520
+ type: 'listItem',
521
+ content: [
522
+ {
523
+ type: 'paragraph',
524
+ content: [
525
+ {
526
+ type: 'text',
527
+ text: 'bullet 1'
528
+ }
529
+ ]
530
+ }
531
+ ]
532
+ },
533
+ {
534
+ type: 'listItem',
535
+ content: [
536
+ {
537
+ type: 'paragraph',
538
+ content: [
539
+ {
540
+ type: 'text',
541
+ text: 'bullet 2'
542
+ }
543
+ ]
544
+ }
545
+ ]
546
+ }
547
+ ]
548
+ },
549
+ {
550
+ type: 'paragraph',
551
+ content: [
552
+ {
553
+ type: 'text',
554
+ text: 'This is numbered list'
555
+ }
556
+ ]
557
+ },
558
+ {
559
+ type: 'orderedList',
560
+ attrs: {
561
+ start: 1
562
+ },
563
+ content: [
564
+ {
565
+ type: 'listItem',
566
+ content: [
567
+ {
568
+ type: 'paragraph',
569
+ content: [
570
+ {
571
+ type: 'text',
572
+ text: 'number 1'
573
+ }
574
+ ]
575
+ }
576
+ ]
577
+ },
578
+ {
579
+ type: 'listItem',
580
+ content: [
581
+ {
582
+ type: 'paragraph',
583
+ content: [
584
+ {
585
+ type: 'text',
586
+ text: 'number 2'
587
+ }
588
+ ]
589
+ }
590
+ ]
591
+ }
592
+ ]
593
+ },
594
+ {
595
+ type: 'paragraph',
596
+ content: [
597
+ {
598
+ type: 'text',
599
+ text: 'This is a '
600
+ },
601
+ {
602
+ type: 'text',
603
+ marks: [
604
+ {
605
+ type: 'link',
606
+ attrs: {
607
+ href: 'www.test.com',
608
+ target: '_blank',
609
+ class: null
610
+ }
611
+ }
612
+ ],
613
+ text: 'link'
614
+ },
615
+ {
616
+ type: 'text',
617
+ text: ' example'
618
+ }
619
+ ]
620
+ },
621
+ {
622
+ type: 'paragraph',
623
+ content: [
624
+ {
625
+ type: 'text',
626
+ marks: [
627
+ {
628
+ type: 'code'
629
+ }
630
+ ],
631
+ text: 'This is code example'
632
+ }
633
+ ]
634
+ },
635
+ {
636
+ type: 'codeBlock',
637
+ attrs: {
638
+ language: null
639
+ },
640
+ content: [
641
+ {
642
+ type: 'text',
643
+ text: 'This is code block example '
644
+ }
645
+ ]
646
+ },
647
+ {
648
+ type: 'blockquote',
649
+ content: [
650
+ {
651
+ type: 'paragraph',
652
+ content: [
653
+ {
654
+ type: 'text',
655
+ text: 'This is quote example'
656
+ }
657
+ ]
658
+ }
659
+ ]
660
+ },
661
+ {
662
+ type: 'horizontalRule'
663
+ },
664
+ {
665
+ type: 'paragraph',
666
+ content: [
667
+ {
668
+ type: 'text',
669
+ text: 'Above there is a line brake'
670
+ }
671
+ ]
672
+ },
673
+ {
674
+ type: 'paragraph'
675
+ },
676
+ {
677
+ type: 'unknown'
678
+ }
679
+ ]
680
+ }
681
+
682
+ expect(serializeCH1RichText(data)).toEqual(
683
+ `<h1>This is headline 1</h1>
684
+ <h2>This is headline 2</h2>
685
+ <h3>This is headline 3</h3>
686
+ <h4>This is headline 4</h4>
687
+ <h5>This is headline 5</h5>
688
+ <h6>This is headline 6</h6>
689
+ <p>This is paragraph with
690
+ <strong>bold</strong>
691
+ and
692
+ <em>italic</em>
693
+ and
694
+ <u>underline</u>
695
+ and
696
+ <s>strikethrough</s></p>
697
+ <p>This is bulleted list</p>
698
+ <ul><li><p>bullet 1</p></li>
699
+ <li><p>bullet 2</p></li></ul>
700
+ <p>This is numbered list</p>
701
+ <ol start="1"><li><p>number 1</p></li>
702
+ <li><p>number 2</p></li></ol>
703
+ <p>This is a
704
+ <a href="www.test.com" target="_blank">link</a>
705
+ example</p>
706
+ <p>This is code example</p>
707
+ <code>This is code block example</code>
708
+ <blockquote><p>This is quote example</p></blockquote>
709
+ <hr />
710
+ <p>Above there is a line brake</p>
711
+ <p />`
712
+ )
713
+ })
714
+ })