Skip to content

Commit 467af88

Browse files
authored
Merge branch 'master' into feature/autocomplete-changes
2 parents d0ba330 + e48bdce commit 467af88

File tree

14 files changed

+224
-112
lines changed

14 files changed

+224
-112
lines changed

dist/swagger-editor-bundle.js

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

dist/swagger-editor-bundle.js.map

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

dist/swagger-editor-standalone-preset.js

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

dist/swagger-editor-standalone-preset.js.map

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

dist/swagger-editor.css

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

dist/swagger-editor.js

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "swagger-editor",
33
"description": "Swagger Editor",
4-
"version": "3.1.9",
4+
"version": "3.1.10",
55
"main": "dist/swagger-editor.js",
66
"repository": "[email protected]:swagger-api/swagger-editor.git",
77
"license": "Apache-2.0",
@@ -57,8 +57,8 @@
5757
"react-redux": "^4.x.x",
5858
"react-transition-group": "^1.1.1",
5959
"redux": "^3.x.x",
60-
"swagger-client": "^3.1.2",
61-
"swagger-ui": "^3.2.2",
60+
"swagger-client": "^3.2.1",
61+
"swagger-ui": "^3.3.1",
6262
"whatwg-fetch": "^2.0.3"
6363
},
6464
"devDependencies": {

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import EditorAutosuggestSnippetsPlugin from "./plugins/editor-autosuggest-snippe
1212
import EditorAutosuggestKeywordsPlugin from "./plugins/editor-autosuggest-keywords"
1313
import EditorAutosuggestOAS3KeywordsPlugin from "./plugins/editor-autosuggest-oas3-keywords"
1414
import EditorAutosuggestRefsPlugin from "./plugins/editor-autosuggest-refs"
15+
import JumpToPathPlugin from "./plugins/jump-to-path"
1516

1617
// eslint-disable-next-line no-undef
1718
const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION } = buildInfo
@@ -28,6 +29,7 @@ const plugins = {
2829
EditorAutosuggestKeywordsPlugin,
2930
EditorAutosuggestRefsPlugin,
3031
EditorAutosuggestOAS3KeywordsPlugin,
32+
JumpToPathPlugin,
3133
}
3234

3335
const defaults = {

src/plugins/editor/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import makeEditor from "./components/editor"
22
import EditorContainer from "./components/editor-container"
3-
import JumpToPath from "./components/jump-to-path"
43
import * as actions from "./actions"
54
import reducers from "./reducers"
65
import * as selectors from "./selectors"
@@ -11,7 +10,7 @@ let Editor = makeEditor({
1110

1211
export default function () {
1312
return {
14-
components: { Editor, EditorContainer, JumpToPath },
13+
components: { Editor, EditorContainer },
1514
statePlugins: {
1615
editor: {
1716
reducers,

src/plugins/editor/components/jump-to-path.jsx renamed to src/plugins/jump-to-path/components.jsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
11
import React, { PropTypes } from "react"
22
import JumpIcon from "./jump-icon.svg"
33

4-
export default class JumpToPath extends React.Component {
4+
export class JumpToPath extends React.Component {
55
static propTypes = {
66
editorActions: PropTypes.object.isRequired,
77
specSelectors: PropTypes.object.isRequired,
88
fn: PropTypes.object.isRequired,
99
path: PropTypes.oneOfType([
1010
PropTypes.array,
1111
PropTypes.string
12-
]).isRequired,
12+
]),
1313
content: PropTypes.element,
14-
showButton: PropTypes.bool
14+
showButton: PropTypes.bool,
15+
specPath: PropTypes.array, // The location within the spec. Used as a fallback if `path` doesn't exist
16+
}
17+
18+
static defaultProps = {
19+
path: "",
1520
}
1621

1722
shouldComponentUpdate(nextProps) {
1823
let { shallowEqualKeys } = nextProps.fn
1924
return shallowEqualKeys(this.props, nextProps, [
20-
"content", "showButton", "path"
25+
"content", "showButton", "path", "specPath"
2126
])
2227
}
2328

2429
jumpToPath = (e) => {
2530
e.stopPropagation()
2631

27-
let { path, fn: { AST, transformPathToArray }, specSelectors: { specStr, specJson }, editorActions } = this.props
28-
let line = AST.getLineNumberForPath(specStr(), typeof path === "string" ? transformPathToArray(path, specJson().toJS()) : path)
29-
editorActions.jumpToLine(line)
32+
const {
33+
specPath=[],
34+
path,
35+
specSelectors,
36+
editorActions
37+
} = this.props
38+
39+
const jumpPath = specSelectors.bestJumpPath({path, specPath})
40+
editorActions.jumpToLine(specSelectors.getSpecLineFromPath(jumpPath))
3041
}
3142

3243

0 commit comments

Comments
 (0)