Skip to content

Commit ab67ff8

Browse files
authored
compat: move obsolete UI plugins to Editor (#1840)
* fix: modal height CSS bug * Migrate split-pane-mode and ast plugins to Editor * use js-yaml fork
1 parent efe0d8c commit ab67ff8

File tree

7 files changed

+105
-15
lines changed

7 files changed

+105
-15
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040
"watch": "webpack --config ./webpack-dist.config.js --watch --progress"
4141
},
4242
"dependencies": {
43+
"@kyleshockey/js-yaml": "^1.0.1",
4344
"ajv": "^5.2.2",
4445
"boron": "^0.2.3",
4546
"brace": "^0.10.0",
4647
"classnames": "^2.1.3",
4748
"core-js": "^2.4.1",
4849
"deepmerge": "^1.3.2",
4950
"immutable": "^3.x.x",
50-
"js-yaml": "^3.5.5",
5151
"json-beautify": "^1.0.1",
5252
"json-refs": "^3.0.4",
5353
"lodash": "^4.17.4",
@@ -63,6 +63,7 @@
6363
"react-file-download": "^0.3.2",
6464
"react-immutable-proptypes": "^2.1.0",
6565
"react-redux": "^4.x.x",
66+
"react-split-pane": "^0.1.82",
6667
"react-transition-group": "^1.1.1",
6768
"redux": "^3.x.x",
6869
"reselect": "^2.5.4",

src/plugins/ast/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import * as AST from "./ast"
2-
import JumpToPath from "./jump-to-path"
32

43
export default function() {
54
return {
6-
fn: { AST },
7-
components: { JumpToPath }
5+
fn: { AST }
86
}
97
}

src/plugins/ast/jump-to-path.jsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/plugins/editor/editor-plugins/json-to-yaml.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import YAML from "js-yaml"
1+
import YAML from "@kyleshockey/js-yaml"
22

33
export default function(editor) {
44
editor.on("paste", e => {
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import React from "react"
2+
import PropTypes from "prop-types"
3+
import SplitPane from "react-split-pane"
4+
5+
const MODE_KEY = ["split-pane-mode"]
6+
const MODE_LEFT = "left"
7+
const MODE_RIGHT = "right"
8+
const MODE_BOTH = "both" // or anything other than left/right
9+
10+
export default class SplitPaneMode extends React.Component {
11+
12+
static propTypes = {
13+
threshold: PropTypes.number,
14+
15+
children: PropTypes.array,
16+
17+
layoutSelectors: PropTypes.object.isRequired,
18+
layoutActions: PropTypes.object.isRequired,
19+
};
20+
21+
static defaultProps = {
22+
threshold: 100, // in pixels
23+
children: [],
24+
};
25+
26+
initializeComponent = (c) => {
27+
this.splitPane = c
28+
}
29+
30+
onDragFinished = () => {
31+
let { threshold, layoutActions } = this.props
32+
let { position, draggedSize } = this.splitPane.state
33+
this.draggedSize = draggedSize
34+
35+
let nearLeftEdge = position <= threshold
36+
let nearRightEdge = draggedSize <= threshold
37+
38+
layoutActions
39+
.changeMode(MODE_KEY, (
40+
nearLeftEdge
41+
? MODE_RIGHT : nearRightEdge
42+
? MODE_LEFT : MODE_BOTH
43+
))
44+
}
45+
46+
sizeFromMode = (mode, defaultSize) => {
47+
if(mode === MODE_LEFT) {
48+
this.draggedSize = null
49+
return "0px"
50+
} else if (mode === MODE_RIGHT) {
51+
this.draggedSize = null
52+
return "100%"
53+
}
54+
// mode === "both"
55+
return this.draggedSize || defaultSize
56+
}
57+
58+
render() {
59+
let { children, layoutSelectors } = this.props
60+
61+
const mode = layoutSelectors.whatMode(MODE_KEY)
62+
const left = mode === MODE_RIGHT ? <noscript/> : children[0]
63+
const right = mode === MODE_LEFT ? <noscript/> : children[1]
64+
const size = this.sizeFromMode(mode, "50%")
65+
66+
return (
67+
<SplitPane
68+
disabledClass={""}
69+
ref={this.initializeComponent}
70+
split='vertical'
71+
defaultSize={"50%"}
72+
primary="second"
73+
minSize={0}
74+
size={size}
75+
onDragFinished={this.onDragFinished}
76+
allowResize={mode !== MODE_LEFT && mode !== MODE_RIGHT }
77+
resizerStyle={{"flex": "0 0 auto", "position": "relative"}}
78+
>
79+
{ left }
80+
{ right }
81+
</SplitPane>
82+
)
83+
}
84+
85+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import SplitPaneMode from "./components/split-pane-mode"
2+
export default function SplitPaneModePlugin() {
3+
return {
4+
// statePlugins: {
5+
// layout: {
6+
// actions,
7+
// selectors,
8+
// }
9+
// },
10+
11+
components: {
12+
SplitPaneMode
13+
}
14+
}
15+
}

src/standalone/topbar/topbar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "whatwg-fetch"
55
import DropdownMenu from "./DropdownMenu"
66
import Modal from "boron/DropModal"
77
import reactFileDownload from "react-file-download"
8-
import YAML from "js-yaml"
8+
import YAML from "@kyleshockey/js-yaml"
99
import beautifyJson from "json-beautify"
1010

1111
import "react-dd-menu/dist/react-dd-menu.css"

0 commit comments

Comments
 (0)