@rws-framework/client 2.18.10 → 2.18.12
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/builder/webpack/loaders/rws_fast_html_loader.js +2 -5
- package/builder/webpack/loaders/rws_fast_scss_loader.js +2 -5
- package/cfg/build_steps/webpack/_loaders.js +1 -1
- package/package.json +3 -5
- package/src/components/index.ts +2 -0
- package/src/components/rws/line-splitter/component.ts +88 -0
- package/src/components/rws/line-splitter/styles/_tags.scss +104 -0
- package/src/components/rws/line-splitter/styles/layout.scss +38 -0
- package/src/components/rws/line-splitter/template.html +1 -0
- package/src/index.ts +1 -5
- package/src/services/DOMService.ts +11 -1
|
@@ -7,11 +7,8 @@ module.exports = function(content){
|
|
|
7
7
|
const componentPath = path.resolve(componentDir, 'component.ts');
|
|
8
8
|
|
|
9
9
|
if(fs.existsSync(componentPath)){
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
if(fileCnt){
|
|
13
|
-
fs.writeFile(componentPath, fileCnt, () => {})
|
|
14
|
-
}
|
|
10
|
+
const time = new Date();
|
|
11
|
+
fs.utimes(componentPath, time, time, () => {});
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
return '';
|
|
@@ -35,11 +35,8 @@ module.exports = async function(content) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
if(fs.existsSync(componentPath)){
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
if(fileCnt){
|
|
41
|
-
fs.writeFile(componentPath, fileCnt, () => {})
|
|
42
|
-
}
|
|
38
|
+
const time = new Date();
|
|
39
|
+
fs.utimes(componentPath, time, time, () => {});
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
return '';
|
|
@@ -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.
|
|
4
|
+
"version": "2.18.12",
|
|
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",
|
package/src/components/index.ts
CHANGED
|
@@ -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,88 @@
|
|
|
1
|
+
import { RWSView, RWSViewComponent, observable, attr } from '../../../index';
|
|
2
|
+
|
|
3
|
+
import { ViewTemplate } from '@microsoft/fast-element';
|
|
4
|
+
|
|
5
|
+
@RWSView('line-splitter', { debugPackaging: false })
|
|
6
|
+
class LineSplitter extends RWSViewComponent {
|
|
7
|
+
@observable text: string = '';
|
|
8
|
+
@observable content: string | ViewTemplate = '<span class="dots">.</span>';
|
|
9
|
+
@observable query: string = '';
|
|
10
|
+
|
|
11
|
+
@attr allowedTags = '';
|
|
12
|
+
@attr addClass = '';
|
|
13
|
+
|
|
14
|
+
private allowedHTMLTags: string[] = ['dl', 'dt', 'dd', 'br', 'blockquote', 'span', 'p', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'strong', 'i', 'small', 'u'];
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
parseTags(line: string): string | ViewTemplate
|
|
18
|
+
{
|
|
19
|
+
const componentAllowedTags: string[] = this.allowedHTMLTags.concat(this.allowedTags.split(','));
|
|
20
|
+
|
|
21
|
+
let output = this.domService.sanitizeHTML(line, { ADD_TAGS: componentAllowedTags });
|
|
22
|
+
|
|
23
|
+
output = output.replace(/<.*>([\s\S]*?)<\/.*>/g, (match: string) => {
|
|
24
|
+
return match.replace(/\n/g, '');
|
|
25
|
+
});
|
|
26
|
+
output = output.replace(/\n\n/g, '\n');
|
|
27
|
+
output = output.replace(/\n/g, '<br/>');
|
|
28
|
+
output = output.replace(/<\/p><br\/>/g, '</p>');
|
|
29
|
+
output = output
|
|
30
|
+
.replace(/<br\/><h([1-3])>/g, '<h$1>')
|
|
31
|
+
.replace(/<\/h([1-3])><br\/>/g, '</h$1>');
|
|
32
|
+
|
|
33
|
+
if(this.query !== null || this.query !== '') {
|
|
34
|
+
const query: string[] = this.query ? this.query.split(',').map(word => word.trim()) : [];
|
|
35
|
+
|
|
36
|
+
query.forEach(word => {
|
|
37
|
+
// Create a regex for the word, ensuring it's case-insensitive and doesn't affect existing HTML tags
|
|
38
|
+
const regex = new RegExp(`(${word})(?![^<]*>)`, 'gi');
|
|
39
|
+
output = output.replace(regex, '<span class="tagged">$1</span>');
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
splitLines(): void
|
|
48
|
+
{
|
|
49
|
+
if([". ", ". . ", ". . . "].includes(this.text)){
|
|
50
|
+
this.content = `<span class="dots">${this.text}</span>`
|
|
51
|
+
}else{
|
|
52
|
+
this.content = this.parseTags(this.text);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
textChanged(oldVal: string, newVal: string)
|
|
57
|
+
{
|
|
58
|
+
if(newVal){
|
|
59
|
+
this.text = newVal;
|
|
60
|
+
this.splitLines();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
addClassChanged(oldVal: string, newVal: string)
|
|
65
|
+
{
|
|
66
|
+
if(newVal){
|
|
67
|
+
this.addClass = newVal;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
connectedCallback(): void {
|
|
72
|
+
super.connectedCallback();
|
|
73
|
+
|
|
74
|
+
if(this.text){
|
|
75
|
+
this.splitLines();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
queryChanged(oldVal: string, newVal: string){
|
|
80
|
+
if(newVal){
|
|
81
|
+
this.splitLines();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
LineSplitter.defineComponent();
|
|
87
|
+
|
|
88
|
+
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
|
-
|
|
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,16 @@ 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, sanitizeOptions);
|
|
87
|
+
|
|
88
|
+
return sanitized;
|
|
89
|
+
}
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
|