Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8392257
Add symmetric counterparts to all actions
dmt0 Jun 24, 2023
bf91ccb
Don't like this rule
dmt0 Jun 24, 2023
6d43722
Refactor
dmt0 Jun 24, 2023
09515de
Do trace garbage collection in handleUpdate, cause we have access to …
dmt0 Jun 30, 2023
2ad5dec
Undo/redo buttons for development
dmt0 Jun 24, 2023
64edf57
Expose undo/redo to parent components
dmt0 Jun 26, 2023
6db3ab3
Undo/redo functionality
dmt0 Jun 26, 2023
ea30063
Consistency
dmt0 Jun 29, 2023
540033a
Crash fix
dmt0 Jul 11, 2023
81ae14c
Optimizations: skip duplicate and empty updates
dmt0 Jul 11, 2023
5f5c240
Package updates
dmt0 Jul 11, 2023
3e64c91
Refactor
dmt0 Jul 12, 2023
796a1a5
Add opType arg to onUpdate
dmt0 Jul 12, 2023
6fbd874
Undo for changes through plot UI
dmt0 Jul 24, 2023
7d5f71e
Undo/redo buttons inside lib
dmt0 Jul 25, 2023
aba4119
export actionBuffer
dmt0 Jul 26, 2023
2d4b719
More undo implementation
dmt0 Jul 26, 2023
c9b7eea
Rename to history
dmt0 Jul 28, 2023
34ce930
onAddToUndo hook
dmt0 Jul 30, 2023
483f548
Optimize away draggable undo actions less aggressively
dmt0 Aug 31, 2023
0d95687
Proper optimization for rangesliders
dmt0 Sep 1, 2023
e0a34eb
fixup opt less aggressively
dmt0 Sep 1, 2023
5161d5c
Rework optimization for all draggable items
dmt0 Sep 1, 2023
5846d1e
merge fix
dmt0 Oct 26, 2023
5b0a697
Translations
dmt0 Oct 26, 2023
9a61791
Refactor
dmt0 Dec 5, 2023
099187a
Remove debugging
dmt0 Dec 5, 2023
d809b51
Added documentation
dmt0 Dec 5, 2023
fbdea71
Package updates + version bump
dmt0 Dec 5, 2023
1b24ac3
Remove unused
dmt0 Dec 5, 2023
75ff131
Prettier fix
dmt0 Dec 5, 2023
ef81ddd
Doesn't support node 14
dmt0 Dec 5, 2023
d339442
Fix jest tests
dmt0 Dec 5, 2023
1d35b1c
Bump percy cli
dmt0 Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": ["eslint:recommended", "prettier"],
"parser": "@babel/eslint-parser",
"ignorePatterns": ["examples/demo/build/**"],
"parserOptions": {
"ecmaVersion": 13,
"sourceType": "module",
Expand Down Expand Up @@ -72,7 +73,6 @@
"no-extend-native": ["error"],
"no-extra-bind": ["error"],
"no-extra-boolean-cast": ["error"],
"no-inline-comments": ["error"],
"no-implicit-coercion": ["error"],
"no-implied-eval": ["error"],
"no-inner-declarations": ["off"],
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,33 @@ For use in containers bound to annotations e.g. as children of `<AnnotationAccor
* `connectShapeToLayout( Container )`: returns a wrapped container component that can be bound to a shape such that its children are bound to that shape's figure entry under the `layout.shapes` key, e.g. the `<Fold>`s in `<ShapeAccordion />` above.
* `connectImagesToLayout( Container )`: returns a wrapped container component that can be bound to an image such that its children are bound to that image's figure entry under the `layout.image` key, e.g. the `<Fold>`s in `<ImageAccordion />` above.

### Action History

You can show/hide undo/redo buttons via `showUndoRedo` prop of `<PlotlyEditor />`.

You can trigger undo/redo actions programmatically by passing a ref to `PlotlyEditor` or `EditorControls` and calling `undo` or `redo` methods on the ref. E.g.:

```javascript
const rceRef = useRef(null);
...
<EditModeController
ref={rceRef}
...
/>
...
rceRef.current.undo()
```

Use `onAddToUndo` and `onAddToRedo` hooks to trigger events when an action is added to undo or redo history in the `<PlotlyEditor />` component.

```javascript
<PlotlyEditor
...
onAddToUndo={() => { console.log('action added to undo') }}
onAddToRedo={() => { console.log('action added to redo') }}
/>
```

## Mapbox Access Tokens

To use Satellite Maps in the Editor, [Mapbox access tokens](https://www.mapbox.com/help/how-access-tokens-work/) are required.
Expand Down
1 change: 1 addition & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"plugins": [
"react-hot-loader/babel",
"@babel/plugin-transform-object-rest-spread",
"@babel/plugin-proposal-export-default-from",
[
"module-resolver",
{
Expand Down
27 changes: 25 additions & 2 deletions dev/App.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import {Component} from 'react';
import {Component, createRef} from 'react';
import {hot} from 'react-hot-loader/root';
import plotly from 'plotly.js/dist/plotly-with-meta';
import '../src/styles/main.scss';
import AceEditor from 'react-ace';
import Select from 'react-select';
import PlotlyEditor, {DefaultEditor, Panel} from '../src';
import PlotlyEditor, {Button, DefaultEditor, Panel} from '../src';
import Inspector from 'react-inspector';
import dataSources from './dataSources';

// https://github.com/plotly/react-chart-editor#mapbox-access-tokens
import ACCESS_TOKENS from '../accessTokens';

// Have actual buttons outside the component for testing undo/redo
const SHOW_EXTERNAL_UNDO_REDO = false;

// import {customConfigTest} from '../src/__stories__';

const dataSourceOptions = Object.keys(dataSources).map((name) => ({
Expand Down Expand Up @@ -117,6 +120,8 @@ class App extends Component {
this.loadMock = this.loadMock.bind(this);
this.loadJSON = this.loadJSON.bind(this);
this.updateState = this.updateState.bind(this);

this.PlotlyEditor = createRef();
}

UNSAFE_componentWillMount() {
Expand Down Expand Up @@ -167,7 +172,24 @@ class App extends Component {
render() {
return (
<div className="app">
{SHOW_EXTERNAL_UNDO_REDO && (
<div>
<Button
label="Undo"
onClick={() => {
this.PlotlyEditor.current.undo();
}}
/>
<Button
label="Redo"
onClick={() => {
this.PlotlyEditor.current.redo();
}}
/>
</div>
)}
<PlotlyEditor
ref={this.PlotlyEditor}
data={this.state.data}
layout={this.state.layout}
frames={this.state.frames}
Expand All @@ -181,6 +203,7 @@ class App extends Component {
debug
advancedTraceTypeSelector
showFieldTooltips
// showUndoRedo
// glByDefault
// traceTypesConfig={traceTypesConfig}
// makeDefaultTrace={() => ({type: 'scattergl', mode: 'markers'})}
Expand Down
3 changes: 3 additions & 0 deletions jestSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global.structuredClone = function (obj) {
return JSON.parse(JSON.stringify(obj));
};
48 changes: 27 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@figlinq/react-chart-editor",
"description": "plotly.js chart editor react component UI",
"version": "0.50.2",
"version": "0.51.0",
"author": "Figlinq",
"bugs": {
"url": "https://github.com/figlinq/react-chart-editor/issues"
Expand All @@ -26,13 +26,14 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@appigram/react-rangeslider": "^2.2.19",
"@figlinq/plotly-icons": "^3.0.2",
"@figlinq/react-rangeslider": "^3.0.1",
"@hello-pangea/color-picker": "^3.2.2",
"@mdi/js": "^7.2.96",
"@mdi/js": "^7.3.67",
"@mdi/react": "^1.6.1",
"@plotly/draft-js-export-html": "^1.2.0",
"classnames": "^2.3.2",
"deep-object-diff": "^1.1.9",
"draft-js": "^0.11.7",
"draft-js-import-html": "^1.4.1",
"draft-js-utils": "^1.4.1",
Expand All @@ -45,37 +46,39 @@
"react-dropzone": "^14.2.3",
"react-plotly.js": "^2.6.0",
"react-resizable-rotatable-draggable": "^0.2.0",
"react-select": "^5.7.7",
"react-select": "^5.8.0",
"react-tabs": "^4.2.1",
"styled-components": "^5.3.8",
"tinycolor2": "^1.6.0"
},
"devDependencies": {
"@babel/cli": "7.23.0",
"@babel/core": "7.23.0",
"@babel/eslint-parser": "7.22.15",
"@babel/cli": "7.23.4",
"@babel/core": "7.23.5",
"@babel/eslint-parser": "7.23.3",
"@babel/node": "7.22.19",
"@babel/plugin-transform-object-rest-spread": "7.22.15",
"@babel/preset-env": "7.22.20",
"@babel/preset-react": "7.22.15",
"@babel/traverse": "7.23.0",
"@babel/plugin-proposal-export-default-from": "^7.23.3",
"@babel/plugin-transform-object-rest-spread": "7.23.4",
"@babel/preset-env": "7.23.5",
"@babel/preset-react": "7.23.3",
"@babel/traverse": "7.23.5",
"@hot-loader/react-dom": "16.14.0",
"@percy/cli": "1.26.1",
"@percy/cli": "1.27.5",
"@percy/storybook": "4.3.6",
"@storybook/builder-webpack5": "^6.5.14",
"@storybook/manager-webpack5": "^6.5.14",
"@storybook/react": "6.5.16",
"autoprefixer": "10.4.16",
"babel-jest": "26.6.3",
"babel-loader": "9.1.3",
"babel-plugin-module-resolver": "5.0.0",
"babel-plugin-module-resolver": "4.1.0",
"caniuse-lite": "^1.0.30001566",
"css-loader": "6.8.1",
"cssnano": "6.0.1",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.7",
"eslint": "8.50.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.28.1",
"eslint": "8.55.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-jsx": "0.1.0",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-percy": "0.2.4",
Expand All @@ -84,12 +87,12 @@
"jest": "26.6.3",
"jest-cli": "26.6.3",
"mkdirp": "3.0.1",
"plotly.js": "2.26.2",
"postcss": "8.4.31",
"plotly.js": "2.27.1",
"postcss": "8.4.32",
"postcss-cli": "10.1.0",
"postcss-combine-duplicated-selectors": "10.0.3",
"postcss-import": "15.1.0",
"postcss-preset-env": "8.5.1",
"postcss-preset-env": "9.3.0",
"prettier": "2.8.8",
"react": "16.14.0",
"react-ace": "7.0.5",
Expand All @@ -99,10 +102,10 @@
"react-test-renderer": "16.14.0",
"request": "2.88.2",
"rimraf": "5.0.5",
"sass": "1.68.0",
"sass": "1.69.5",
"sass-loader": "13.3.2",
"style-loader": "3.3.3",
"webpack": "5.88.2",
"webpack": "5.89.0",
"webpack-cli": "5.1.4",
"webpack-dev-server": "4.15.1"
},
Expand All @@ -124,6 +127,9 @@
},
"transformIgnorePatterns": [
"@figlink/plotly-icons"
],
"setupFiles": [
"<rootDir>/jestSetup.js"
]
},
"keywords": [
Expand Down
Loading