Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 2d1ec36

Browse files
committed
Merge branch 'master' into chore/cancellable-onbeforerowdetail
2 parents b3bc98e + e101b63 commit 2d1ec36

File tree

6 files changed

+117
-4
lines changed

6 files changed

+117
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ One of the best JavasSript datagrid [SlickGrid](https://github.com/mleibman/Slic
1717
[MIT License](LICENSE)
1818

1919
## Documentation
20-
A new [Documentation](https://ghiscoding.gitbook.io/angular-slickgrid/getting-started/quick-start) website is powered by GitBook.
20+
📕 [Documentation](https://ghiscoding.gitbook.io/angular-slickgrid/getting-started/quick-start) website powered by GitBook.
2121

2222
## Installation
2323
A good starting point is the **[Docs - Quick Start](https://ghiscoding.gitbook.io/angular-slickgrid/getting-started/quick-start)** and/or simply clone the [Angular-Slickgrid Demos](https://github.com/ghiscoding/angular-slickgrid-demos) repository. Please review all documentation and closed issues before opening any new issue, also consider asking installation and/or general questions on [Stack Overflow](https://stackoverflow.com/search?tab=newest&q=slickgrid) unless you think there's a bug with the library.

docs/TOC.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
* [Row Detail](grid-functionalities/row-detail.md)
7272
* [Row Selection](grid-functionalities/Row-Selection.md)
7373
* [Tree Data Grid](grid-functionalities/Tree-Data-Grid.md)
74+
* [FAQ](grid-functionalities/FAQ.md)
7475

7576
## Backend Services
7677

@@ -82,6 +83,10 @@
8283
* [Pagination Schema](backend-services/graphql/GraphQL-Pagination.md)
8384
* [Sorting Schema](backend-services/graphql/GraphQL-Sorting.md)
8485

86+
## Developer Guides
87+
88+
* [CSP Compliance](developer-guides/csp-compliance.md)
89+
8590
## Migrations
8691

8792
* [Migration Guide to 2.x](migrations/Migration-to-2.x.md)

docs/column-functionalities/editors/Autocomplete-Editor-(Kraaden-lib).md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
##### _updated for version 2.x_
2-
31
#### Index
42
- [Using fixed `collection` or `collectionAsync`](#using-collection-or-collectionasync)
53
- [Editor Options (`AutocompleterOption` interface)](#editor-options-autocompleteroption-interface)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## CSP Compliance
2+
The library is now, at least mostly, CSP (Content Security Policy) compliant since `v4.0`, however there are some exceptions to be aware of. When using any html string as template (for example with Custom Formatter returning an html string), you will not be fully compliant unless you return `TrustedHTML`. You can achieve this by using the `sanitizer` method in combo with [DOMPurify](https://github.com/cure53/DOMPurify) to return `TrustedHTML` as shown below and with that in place you should be CSP compliant.
3+
4+
> **Note** the default sanitizer in Slickgrid-Universal is actually already configured to return `TrustedHTML` but the CSP safe in the DataView is opt-in via `useCSPSafeFilter`
5+
6+
```typescript
7+
import DOMPurify from 'dompurify';
8+
import { GridOption } from 'angular-slickgrid';
9+
10+
export class Example1 {
11+
gridOptions: GridOption;
12+
13+
prepareGrid() {
14+
// ...
15+
16+
this.gridOptions = {
17+
// NOTE: DOM Purify is already configured in Slickgrid-Universal with the configuration shown below
18+
sanitizer: (html) => DOMPurify.sanitize(html, { RETURN_TRUSTED_TYPE: true }),
19+
// you could also optionally use the sanitizerOptions instead
20+
// sanitizerOptions: { RETURN_TRUSTED_TYPE: true }
21+
}
22+
}
23+
}
24+
```
25+
with this code in place, we can use the following CSP meta tag (which is what we use in the lib demo, ref: [index.html](https://github.com/ghiscoding/slickgrid-universal/blob/master/examples/vite-demo-vanilla-bundle/index.html#L8-L14))
26+
```html
27+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'nonce-random-string'; require-trusted-types-for 'script'; trusted-types dompurify">
28+
```
29+
30+
#### DataView
31+
Since we use the DataView, you will also need to enable a new `useCSPSafeFilter` flag to be CSP safe as the name suggest. This option is opt-in because it has a slight performance impact when enabling this option (it shouldn't be noticeable unless you use a very large dataset).
32+
33+
```typescript
34+
import DOMPurify from 'dompurify';
35+
import { GridOption } from 'angular-slickgrid';
36+
37+
export class Example1 {
38+
gridOptions: GridOption;
39+
40+
prepareGrid() {
41+
// ...
42+
43+
this.gridOptions = {
44+
// you could also optionally use the sanitizerOptions instead
45+
// sanitizerOptions: { RETURN_TRUSTED_TYPE: true }
46+
dataView: {
47+
useCSPSafeFilter: true
48+
},
49+
}
50+
}
51+
}
52+
```
53+
54+
### Custom Formatter using native HTML
55+
We now also allow passing native HTML Element as a Custom Formatter instead of HTML string in order to avoid the use of `innerHTML` and stay CSP safe. We also have a new grid option named `enableHtmlRendering`, which is enabled by default and is allowing the use of `innerHTML` in the library (by Formatters and others), however when disabled it will totally restrict the use of `innerHTML` which will help to stay CSP safe.
56+
57+
You can take a look at the original SlickGrid library with this new [Filtered DataView with HTML Formatter - CSP Header (Content Security Policy)](https://6pac.github.io/SlickGrid/examples/example4-model-html-formatters.html) example which uses this new approach. There was no new Example created in Slickgrid-Universal specifically for this but the approach is the same.

docs/grid-functionalities/FAQ.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#### index
2+
- Frequently asked questions
3+
- [Merging grid options with applied defaults](#merging-grid-options-with-applied-defaults)
4+
5+
### Description
6+
When working with the grid, you might want to Add / Update or Hightlight an item row from the Datagrid.
7+
8+
**Note:** This is strictly a client side event, you still have to implement any backend change yourself.
9+
10+
### Demo
11+
[Demo Page](https://ghiscoding.github.io/Angular-Slickgrid/#/additem) / [Demo Component](https://github.com/ghiscoding/angular-slickgrid/blob/master/src/app/examples/grid-additem.component.ts)
12+
13+
## Frequently asked questions
14+
### Merging grid options with applied defaults
15+
When you pass gridOptions to the `angular-slickgrid` component, keep in mind that they get overloaded with the [Default Grid Options](https://github.com/ghiscoding/angular-slickgrid/blob/master/src/app/modules/angular-slickgrid/global-grid-options.ts). In contrast to what might be expected, this change won't overwrite your provided object.
16+
17+
In cases, where depending on your data you might want to update the options (e.g. make columns readonly based on permissions) make sure to update your reference in the onAngularGridCreated event handler as shown below:
18+
19+
#### View
20+
```html
21+
<angular-slickgrid
22+
gridId="grid1"
23+
[columnDefinitions]="columnDefinitions"
24+
[gridOptions]="gridOptions"
25+
[dataset]="dataset"
26+
(onAngularGridCreated)="angularGridReady($event.detail)">
27+
</angular-slickgrid>
28+
```
29+
30+
#### Component
31+
```typescript
32+
import { Component, OnInit} from '@angular/core';
33+
import { AngularGridInstance } from 'angular-slickgrid';
34+
35+
export class GridBasicComponent implements OnInit {
36+
columnDefinitions: Column[];
37+
gridOptions: GridOption = {
38+
// your initial settings
39+
};
40+
dataset: any[];
41+
42+
ngOnInit(): void {
43+
this.columnDefinitions = [];
44+
}
45+
46+
angularGridReady(angularGrid: AngularGridInstance) {
47+
this.angularGrid = angularGrid;
48+
49+
// update your reference to make use of applied defaults
50+
this.gridOptions = this.angularGrid.slickGrid.getOptions() as GridOption;
51+
}
52+
}
53+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"repository": {
3939
"type": "git",
40-
"url": "git+ssh://git@github.com/ghiscoding/angular-slickgrid.git"
40+
"url": "https://github.com/ghiscoding/angular-slickgrid.git"
4141
},
4242
"main": "src/app/modules/angular-slickgrid/index",
4343
"private": false,

0 commit comments

Comments
 (0)