@rws-framework/client 2.18.11 → 2.18.13

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.
@@ -22,7 +22,7 @@ function getRWSLoaders(packageDir, executionDir, tsConfigData, appRootDir, entry
22
22
  test: /\.json$/,
23
23
  type: 'javascript/auto',
24
24
  include: [
25
- path.resolve(appRootDir, 'node_modules/entities/lib/maps')
25
+ path.resolve(appRootDir, 'node_modules/entities/lib/maps'),
26
26
  ],
27
27
  },
28
28
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.18.11",
4
+ "version": "2.18.13",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -32,7 +32,6 @@
32
32
  "@types/moment": "^2.13.0",
33
33
  "deepmerge": "^4.3.1",
34
34
  "dragula": "^3.7.3",
35
- "entities": "6.0.0",
36
35
  "he": "^1.2.0",
37
36
  "json5": "^2.2.3",
38
37
  "lodash": "^4.17.21",
@@ -45,10 +44,9 @@
45
44
  "url-router": "^13.0.0",
46
45
  "uuid": "^9.0.1",
47
46
  "v4": "^0.0.1",
48
- "scss-loading-animations": "^1.0.1"
47
+ "scss-loading-animations": "^1.0.1"
49
48
  },
50
- "devDependencies": {
51
- "sanitize-html": "^2.16.0",
49
+ "devDependencies": {
52
50
  "sass": "^1.87.0",
53
51
  "html-webpack-plugin": "^5.6.3",
54
52
  "css-minimizer-webpack-plugin": "^7.0.2",
@@ -5,6 +5,7 @@ import { RWSApiResource } from './rws/rws-api-resource/component';
5
5
  import { ReFormer } from './rws/reformer/component';
6
6
  import { RWSTable } from './rws/rws-table/component';
7
7
  import { RWSModal } from './rws/rws-modal/component';
8
+ import { LineSplitter } from './rws/line-splitter/component';
8
9
 
9
10
 
10
11
  function declareRWSComponents(parted: boolean = false): void
@@ -15,6 +16,7 @@ function declareRWSComponents(parted: boolean = false): void
15
16
  RWSLoader;
16
17
  RWSTable;
17
18
  RWSModal;
19
+ LineSplitter;
18
20
 
19
21
  RWSApiResource;
20
22
  ReFormer;
@@ -0,0 +1,90 @@
1
+ import { RWSViewComponent } from '../../../components/_component';
2
+ import { RWSView } from '../../../components/_decorator';
3
+ import { observable, attr } from '@microsoft/fast-element';
4
+
5
+ import { ViewTemplate } from '@microsoft/fast-element';
6
+
7
+ @RWSView('line-splitter', { debugPackaging: false })
8
+ class LineSplitter extends RWSViewComponent {
9
+ @observable text: string = '';
10
+ @observable content: string | ViewTemplate = '<span class="dots">.</span>';
11
+ @observable query: string = '';
12
+
13
+ @attr allowedTags = '';
14
+ @attr addClass = '';
15
+
16
+ private allowedHTMLTags: string[] = ['dl', 'dt', 'dd', 'br', 'blockquote', 'span', 'p', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'strong', 'i', 'small', 'u'];
17
+
18
+
19
+ parseTags(line: string): string | ViewTemplate
20
+ {
21
+ const componentAllowedTags: string[] = this.allowedHTMLTags.concat(this.allowedTags.split(','));
22
+
23
+ let output = this.domService.sanitizeHTML(line, { ADD_TAGS: [], ALLOWED_TAGS: componentAllowedTags });
24
+
25
+ output = output.replace(/<.*>([\s\S]*?)<\/.*>/g, (match: string) => {
26
+ return match.replace(/\n/g, '');
27
+ });
28
+ output = output.replace(/\n\n/g, '\n');
29
+ output = output.replace(/\n/g, '<br/>');
30
+ output = output.replace(/<\/p><br\/>/g, '</p>');
31
+ output = output
32
+ .replace(/<br\/><h([1-3])>/g, '<h$1>')
33
+ .replace(/<\/h([1-3])><br\/>/g, '</h$1>');
34
+
35
+ if(this.query !== null || this.query !== '') {
36
+ const query: string[] = this.query ? this.query.split(',').map(word => word.trim()) : [];
37
+
38
+ query.forEach(word => {
39
+ // Create a regex for the word, ensuring it's case-insensitive and doesn't affect existing HTML tags
40
+ const regex = new RegExp(`(${word})(?![^<]*>)`, 'gi');
41
+ output = output.replace(regex, '<span class="tagged">$1</span>');
42
+ });
43
+ }
44
+
45
+
46
+ return output;
47
+ }
48
+
49
+ splitLines(): void
50
+ {
51
+ if([". ", ". . ", ". . . "].includes(this.text)){
52
+ this.content = `<span class="dots">${this.text}</span>`
53
+ }else{
54
+ this.content = this.parseTags(this.text);
55
+ }
56
+ }
57
+
58
+ textChanged(oldVal: string, newVal: string)
59
+ {
60
+ if(newVal){
61
+ this.text = newVal;
62
+ this.splitLines();
63
+ }
64
+ }
65
+
66
+ addClassChanged(oldVal: string, newVal: string)
67
+ {
68
+ if(newVal){
69
+ this.addClass = newVal;
70
+ }
71
+ }
72
+
73
+ connectedCallback(): void {
74
+ super.connectedCallback();
75
+
76
+ if(this.text){
77
+ this.splitLines();
78
+ }
79
+ }
80
+
81
+ queryChanged(oldVal: string, newVal: string){
82
+ if(newVal){
83
+ this.splitLines();
84
+ }
85
+ }
86
+ }
87
+
88
+ LineSplitter.defineComponent();
89
+
90
+ export { LineSplitter };
@@ -0,0 +1,104 @@
1
+
2
+
3
+ $bgcolor: var(--line-splitter-bgcolor, #CCC);
4
+ $maincolor: var(--line-splitter-maincolor, #333);;
5
+ $altcolor: #fff;
6
+
7
+ blockquote {
8
+ position: relative;
9
+ font-family: 'Barlow Condensed', sans-serif;
10
+ max-width: 620px;
11
+ margin: 0 auto 80px auto;
12
+ align-self: center;
13
+ display: inline-block;
14
+ width: 100%;
15
+
16
+ .quote-cnt {
17
+ font-family: 'Abril Fatface', cursive;
18
+ position: relative; /* for pseudos */
19
+ color: $maincolor;
20
+ font-size: 1.4rem;
21
+ line-height: 1;
22
+ margin: 0;
23
+ border: 2px solid #fff;
24
+ border: solid 2px;
25
+ border-radius:20px;
26
+ padding: 25px;
27
+ font-weight: bold;
28
+
29
+ .native {
30
+ font-weight: bold;
31
+ }
32
+
33
+ .native + .pronounciation {
34
+ color: $altcolor;
35
+
36
+ font-weight: normal;
37
+ font-size: 0.9rem;
38
+ margin-left: 15px;
39
+ }
40
+
41
+ &:after {
42
+ content:"";
43
+ position: absolute;
44
+ border: 2px solid $maincolor;
45
+ border-radius: 0 50px 0 0;
46
+ width: 60px;
47
+ height: 60px;
48
+ bottom: -62px;
49
+ left: 50px;
50
+ border-bottom: none;
51
+ border-left: none;
52
+ z-index: 3;
53
+ }
54
+
55
+ &:before {
56
+ content:"";
57
+ position: absolute;
58
+ width: 80px;
59
+ border: 6px solid $bgcolor;
60
+ bottom: -3px;
61
+ left: 50px;
62
+ z-index: 2;
63
+ }
64
+ }
65
+ }
66
+
67
+ dl{
68
+
69
+ @include grid-container();
70
+ @include grid-flex-align-items(center, center);
71
+
72
+ dt{
73
+ text-align: right;
74
+ font-weight: bold;
75
+ font-size: 1.2rem;
76
+ padding: 0 15px;
77
+ margin-bottom: 80px;
78
+
79
+ @include grid-column(6);
80
+
81
+ &:after{
82
+ content: ":";
83
+ font-weight: bold;
84
+ font-size: 1.2rem;
85
+ }
86
+ }
87
+
88
+ dd{
89
+ margin-left: 0;
90
+ @include grid-column(6);
91
+ }
92
+ }
93
+
94
+ p{
95
+ margin: 0 0 15px 0;
96
+ }
97
+
98
+ h1, h2, h3 {
99
+ margin: 10px 0 15px 0;
100
+ }
101
+
102
+ ul, ol {
103
+ margin: 0;
104
+ }
@@ -0,0 +1,38 @@
1
+ @import "@rws-mixins";
2
+ @import "_tags";
3
+
4
+ @keyframes blink {
5
+ 0%, 100% { opacity: 1; }
6
+ 50% { opacity: 0; }
7
+ }
8
+
9
+ .spacer {
10
+ margin-right: 10px;
11
+ }
12
+
13
+
14
+ .text-splitter-area {
15
+
16
+ .dots {
17
+ font-weight: 700;
18
+ }
19
+
20
+ &.loading {
21
+
22
+ p:last-child:after{
23
+ content: '';
24
+ display: inline-block;
25
+ width: 5px;
26
+ height: 1rem;
27
+ height: 1.2rem;
28
+ background: rgb(114, 106, 106);
29
+ animation: 0.7s ease 0s infinite normal none running blink;
30
+ transform: translateY(5px);
31
+ margin-left: 5px;
32
+ }
33
+ }
34
+ }
35
+
36
+ .tagged {
37
+ background-color: yellow;
38
+ }
@@ -0,0 +1 @@
1
+ <div class="text-splitter-area ${x => x.addClass}" :innerHTML="${(x) => x.content}"></div>
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Transformer as HTMLTagTransformerType, Tag as HTMLTag, Attributes as HTMLAttributes } from 'sanitize-html';
2
1
  import { observable, attr } from '@microsoft/fast-element';
3
2
 
4
3
  import RWSService from './services/_service';
@@ -84,8 +83,5 @@ export type {
84
83
  IAssetShowOptions as IRWSAssetShowOptions,
85
84
  IRWSConfig,
86
85
  IRWSUser,
87
- TagsProcessorType,
88
- HTMLTagTransformerType,
89
- HTMLTag,
90
- HTMLAttributes
86
+ TagsProcessorType
91
87
  }
@@ -1,6 +1,6 @@
1
1
  import RWSService from './_service';
2
2
  import { DOM } from '@microsoft/fast-element';
3
- // import htmlSanitizer, { Transformer, IOptions } from 'sanitize-html';
3
+ import DOMPurify from 'dompurify';
4
4
 
5
5
  type TagsProcessorType = { [tagName: string]: string | Transformer };
6
6
  type DOMOutputType<T extends Element> = NodeListOf<T> | T | null;
@@ -77,6 +77,15 @@ class DOMService extends RWSService {
77
77
  });
78
78
  });
79
79
  }
80
+
81
+ sanitizeHTML(
82
+ line: string,
83
+ sanitizeOptions: DOMPurify.Config = { })
84
+ {
85
+ const output: string = line.trim();
86
+ const sanitized = DOMPurify.sanitize(output, { USE_PROFILES: { html: true }, ...sanitizeOptions});
87
+ return sanitized;
88
+ }
80
89
  }
81
90
 
82
91