Skip to content

Commit 3e6d483

Browse files
committed
undo v1.0.0
1 parent 0956b3f commit 3e6d483

37 files changed

+4281
-390
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
### This is a...
11+
12+
* [ ] feature request
13+
* [ ] bug report
14+
* [ ] usage question
15+
16+
### Environment
17+
18+
NodeJS Version:
19+
Typescript Version:
20+
Angular Version:
21+
@angular-redux2/store version:
22+
@angular/cli version: (if applicable)
23+
OS:
24+
25+
### Link to repo showing the issue
26+
(optional, but helps _a lot_)
27+
28+
### Expected Behaviour:
29+
30+
### Actual Behaviour:
31+
32+
### Stack Trace/Error Message:
33+
34+
### Additional Notes:
35+
(optional)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ main ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ main ]
20+
schedule:
21+
- cron: '26 4 * * 4'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'javascript' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v2
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v1
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
52+
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v1
57+
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 https://git.io/JvXDl
60+
61+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62+
# and modify them (or add more) to build your code if your project
63+
# uses a compiled language
64+
65+
#- run: |
66+
# make bootstrap
67+
# make release
68+
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v1

.github/workflows/node.js.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
types:
11+
- opened
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node: [ 16, 18 ]
20+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
22+
name: Node ${{ matrix.node }}
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Use Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: ${{ matrix.node }}
29+
30+
- name: Install Dependencies
31+
run: npm ci
32+
33+
- name: Run Unit Tests
34+
run: npm run ci:test
35+
36+
- name: Clean Distribution Directory
37+
run: npm run ci:clean

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# angular-redux2/undo
2+
3+
`@angular-redux2/undo` is an @angular-redux2/store package that provides undo and redo functionality for state
4+
management using Redux.
5+
6+
[![Discord](https://img.shields.io/discord/1050521693795405874?logo=Angular-redux2)](https://discord.com/invite/7BnsAqst6W)
7+
[![npm version](https://img.shields.io/npm/v/@angular-redux2/undo.svg)](https://www.npmjs.com/package/@angular-redux2/undo)
8+
[![downloads per month](https://img.shields.io/npm/dm/@angular-redux2/undo.svg)](https://www.npmjs.com/package/@angular-redux2/undo)
9+
10+
## Installation
11+
You can install angular-redux2/sync using npm:
12+
13+
```bash
14+
npm install @angular-redux2/undo
15+
```
16+
17+
## Usage
18+
- Take me to the [API docs](https://angular-redux2.github.io/undo).
19+
20+
To use `@angular-redux2/undo` in your Angular application, follow these steps:
21+
Define a StateWatchMap object that maps the properties you want to track for undo/redo operations to their corresponding
22+
state paths and configure the undo middleware in your Angular-Redux2/store setup by including it in the list of middleware:
23+
24+
```typescript
25+
const middleware: Array<Middleware> = [
26+
ngUndoMiddleware({
27+
propertyName1: {
28+
path: 'path.to.property1'
29+
},
30+
propertyName2: {
31+
path: 'path.to.property2'
32+
},
33+
}),
34+
];
35+
36+
ngRedux.configureStore(rootReducer, {}, middleware, enhancer);
37+
```
38+
Implement the undo/redo functionality in your Angular component or service.
39+
You can use the `undo`, `redo`, `jump`, and `clear_history` methods provided by `NgUndoStateActions` to perform the corresponding actions:
40+
41+
```typescript
42+
// Example component
43+
import { Component } from '@angular/core';
44+
import { undo, redo, jump, clear_history } from '@angular-redux2/undo';
45+
46+
@Component({
47+
selector: 'app-example',
48+
template: `
49+
<button (click)="onUndo()">Undo</button>
50+
<button (click)="onRedo()">Redo</button>
51+
<button (click)="onJump(-2)">Jump Backward</button>
52+
<button (click)="onJump(2)">Jump Forward</button>
53+
<button (click)="onClearHistory()">Clear History</button>
54+
`
55+
})
56+
export class ExampleComponent {
57+
constructor(private undoStateActions: NgUndoStateActions) {}
58+
59+
@Dispatch
60+
onUndo() {
61+
this.undoStateActions.undo('propertyName1');
62+
}
63+
64+
@Dispatch
65+
onRedo() {
66+
this.undoStateActions.redo('propertyName1');
67+
}
68+
69+
@Dispatch
70+
onJump(index: number) {
71+
this.undoStateActions.jump('propertyName1', index);
72+
}
73+
74+
@Dispatch
75+
onClearHistory() {
76+
this.undoStateActions.clear_history('propertyName1');
77+
}
78+
}
79+
```

docs/.nojekyll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.

docs/assets/highlight.css

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
:root {
2+
--light-hl-0: #0000FF;
3+
--dark-hl-0: #569CD6;
4+
--light-hl-1: #000000;
5+
--dark-hl-1: #D4D4D4;
6+
--light-hl-2: #0070C1;
7+
--dark-hl-2: #4FC1FF;
8+
--light-hl-3: #267F99;
9+
--dark-hl-3: #4EC9B0;
10+
--light-hl-4: #001080;
11+
--dark-hl-4: #9CDCFE;
12+
--light-hl-5: #795E26;
13+
--dark-hl-5: #DCDCAA;
14+
--light-hl-6: #A31515;
15+
--dark-hl-6: #CE9178;
16+
--light-hl-7: #CD3131;
17+
--dark-hl-7: #F44747;
18+
--light-hl-8: #AF00DB;
19+
--dark-hl-8: #C586C0;
20+
--light-hl-9: #008000;
21+
--dark-hl-9: #6A9955;
22+
--light-hl-10: #098658;
23+
--dark-hl-10: #B5CEA8;
24+
--light-code-background: #FFFFFF;
25+
--dark-code-background: #1E1E1E;
26+
}
27+
28+
@media (prefers-color-scheme: light) { :root {
29+
--hl-0: var(--light-hl-0);
30+
--hl-1: var(--light-hl-1);
31+
--hl-2: var(--light-hl-2);
32+
--hl-3: var(--light-hl-3);
33+
--hl-4: var(--light-hl-4);
34+
--hl-5: var(--light-hl-5);
35+
--hl-6: var(--light-hl-6);
36+
--hl-7: var(--light-hl-7);
37+
--hl-8: var(--light-hl-8);
38+
--hl-9: var(--light-hl-9);
39+
--hl-10: var(--light-hl-10);
40+
--code-background: var(--light-code-background);
41+
} }
42+
43+
@media (prefers-color-scheme: dark) { :root {
44+
--hl-0: var(--dark-hl-0);
45+
--hl-1: var(--dark-hl-1);
46+
--hl-2: var(--dark-hl-2);
47+
--hl-3: var(--dark-hl-3);
48+
--hl-4: var(--dark-hl-4);
49+
--hl-5: var(--dark-hl-5);
50+
--hl-6: var(--dark-hl-6);
51+
--hl-7: var(--dark-hl-7);
52+
--hl-8: var(--dark-hl-8);
53+
--hl-9: var(--dark-hl-9);
54+
--hl-10: var(--dark-hl-10);
55+
--code-background: var(--dark-code-background);
56+
} }
57+
58+
:root[data-theme='light'] {
59+
--hl-0: var(--light-hl-0);
60+
--hl-1: var(--light-hl-1);
61+
--hl-2: var(--light-hl-2);
62+
--hl-3: var(--light-hl-3);
63+
--hl-4: var(--light-hl-4);
64+
--hl-5: var(--light-hl-5);
65+
--hl-6: var(--light-hl-6);
66+
--hl-7: var(--light-hl-7);
67+
--hl-8: var(--light-hl-8);
68+
--hl-9: var(--light-hl-9);
69+
--hl-10: var(--light-hl-10);
70+
--code-background: var(--light-code-background);
71+
}
72+
73+
:root[data-theme='dark'] {
74+
--hl-0: var(--dark-hl-0);
75+
--hl-1: var(--dark-hl-1);
76+
--hl-2: var(--dark-hl-2);
77+
--hl-3: var(--dark-hl-3);
78+
--hl-4: var(--dark-hl-4);
79+
--hl-5: var(--dark-hl-5);
80+
--hl-6: var(--dark-hl-6);
81+
--hl-7: var(--dark-hl-7);
82+
--hl-8: var(--dark-hl-8);
83+
--hl-9: var(--dark-hl-9);
84+
--hl-10: var(--dark-hl-10);
85+
--code-background: var(--dark-code-background);
86+
}
87+
88+
.hl-0 { color: var(--hl-0); }
89+
.hl-1 { color: var(--hl-1); }
90+
.hl-2 { color: var(--hl-2); }
91+
.hl-3 { color: var(--hl-3); }
92+
.hl-4 { color: var(--hl-4); }
93+
.hl-5 { color: var(--hl-5); }
94+
.hl-6 { color: var(--hl-6); }
95+
.hl-7 { color: var(--hl-7); }
96+
.hl-8 { color: var(--hl-8); }
97+
.hl-9 { color: var(--hl-9); }
98+
.hl-10 { color: var(--hl-10); }
99+
pre, code { background: var(--code-background); }

docs/assets/main.js

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/search.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)