From 5d9ab6a0a28d7aa7e6bc51ceb4bc7f0c8e95b4b3 Mon Sep 17 00:00:00 2001 From: Owen Conti Date: Sat, 8 Jul 2017 10:48:52 -0600 Subject: [PATCH 01/22] Fixes #3078 - Added `breaks: true` to Remarkable so newlines are rendered as line breaks. Remove `margin-top` from `

` tags within `.model` elements to fix the alignment in the model's description text. --- src/core/components/providers/markdown.jsx | 2 +- src/style/_models.scss | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/components/providers/markdown.jsx b/src/core/components/providers/markdown.jsx index ff29f021..fb2088c0 100644 --- a/src/core/components/providers/markdown.jsx +++ b/src/core/components/providers/markdown.jsx @@ -19,7 +19,7 @@ function Markdown({ source }) { } return } diff --git a/src/style/_models.scss b/src/style/_models.scss index accfb5d2..ccbd5cca 100644 --- a/src/style/_models.scss +++ b/src/style/_models.scss @@ -79,6 +79,10 @@ border-radius: 4px; background: rgba(#000,.7); } + + p { + margin: 0 0 1em 0; + } } From 14b63c5bf9593624755dc36c78ea0f93b1c3150b Mon Sep 17 00:00:00 2001 From: Owen Conti Date: Sun, 9 Jul 2017 13:59:59 -0600 Subject: [PATCH 02/22] Fixes #2926 - Add optional `title` prop to `Collapse` so collapse elements can render titles to be clickable --- src/core/components/model.jsx | 45 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/core/components/model.jsx b/src/core/components/model.jsx index de714403..39c1c8e1 100644 --- a/src/core/components/model.jsx +++ b/src/core/components/model.jsx @@ -50,14 +50,13 @@ class ObjectModel extends Component { } ) + const titleEl = title && + { isRef && schema.get("$$ref") && { schema.get("$$ref") } } + { title } + + return - { - title && - { isRef && schema.get("$$ref") && { schema.get("$$ref") } } - { title } - - } - expandDepth } collapsedContent={ collapsedContent }> + expandDepth } collapsedContent={ collapsedContent }> { braceOpen } { !isRef ? null : @@ -188,14 +187,14 @@ class ArrayModel extends Component { let items = schema.get("items") let title = schema.get("title") || name let properties = schema.filter( ( v, key) => ["type", "items", "$$ref"].indexOf(key) === -1 ) - + const titleEl = title && + + { title } + + + return - { - title && - { title } - - } - expandDepth } collapsedContent="[...]"> + expandDepth } collapsedContent="[...]"> [ ] @@ -292,12 +291,14 @@ class Collapse extends Component { static propTypes = { collapsedContent: PropTypes.any, collapsed: PropTypes.bool, - children: PropTypes.any + children: PropTypes.any, + title: PropTypes.element } static defaultProps = { collapsedContent: "{...}", collapsed: true, + title: null } constructor(props, context) { @@ -318,11 +319,15 @@ class Collapse extends Component { } render () { - return ( - - + const {title} = this.props + return ( + + { title && {title} } + + + + { this.state.collapsed ? this.state.collapsedContent : this.props.children } - { this.state.collapsed ? this.state.collapsedContent : this.props.children } - ) + ) } } From b11399a57e87362062a4cc9535da6c67e6e8bba3 Mon Sep 17 00:00:00 2001 From: Owen Conti Date: Mon, 10 Jul 2017 17:39:05 -0600 Subject: [PATCH 03/22] Revert original fix and implement fix from @1Map --- src/core/components/providers/markdown.jsx | 10 ++++++---- src/style/_markdown.scss | 3 +++ src/style/main.scss | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 src/style/_markdown.scss diff --git a/src/core/components/providers/markdown.jsx b/src/core/components/providers/markdown.jsx index fb2088c0..9e2d2f0c 100644 --- a/src/core/components/providers/markdown.jsx +++ b/src/core/components/providers/markdown.jsx @@ -18,10 +18,12 @@ function Markdown({ source }) { return null } - return + return

+ +
} Markdown.propTypes = { diff --git a/src/style/_markdown.scss b/src/style/_markdown.scss new file mode 100644 index 00000000..96e802bc --- /dev/null +++ b/src/style/_markdown.scss @@ -0,0 +1,3 @@ +.markdown { + white-space: pre; +} \ No newline at end of file diff --git a/src/style/main.scss b/src/style/main.scss index f6ff00fb..4476e159 100644 --- a/src/style/main.scss +++ b/src/style/main.scss @@ -14,4 +14,5 @@ @import 'information'; @import 'authorize'; @import 'errors'; + @import 'markdown'; } From 914b21f22846f9afa3dbd4af8331f40e5b07c89f Mon Sep 17 00:00:00 2001 From: Owen Conti Date: Mon, 10 Jul 2017 19:23:18 -0600 Subject: [PATCH 04/22] Revert back to the 'breaks' fix for newlines in markdown content --- src/core/components/providers/markdown.jsx | 4 ++-- src/style/_markdown.scss | 3 --- src/style/main.scss | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 src/style/_markdown.scss diff --git a/src/core/components/providers/markdown.jsx b/src/core/components/providers/markdown.jsx index 9e2d2f0c..e500a4a3 100644 --- a/src/core/components/providers/markdown.jsx +++ b/src/core/components/providers/markdown.jsx @@ -20,8 +20,8 @@ function Markdown({ source }) { return
} diff --git a/src/style/_markdown.scss b/src/style/_markdown.scss deleted file mode 100644 index 96e802bc..00000000 --- a/src/style/_markdown.scss +++ /dev/null @@ -1,3 +0,0 @@ -.markdown { - white-space: pre; -} \ No newline at end of file diff --git a/src/style/main.scss b/src/style/main.scss index 4476e159..f6ff00fb 100644 --- a/src/style/main.scss +++ b/src/style/main.scss @@ -14,5 +14,4 @@ @import 'information'; @import 'authorize'; @import 'errors'; - @import 'markdown'; } From 6beaaca6e6fd6511558b0978d5355bb9d2afbcd7 Mon Sep 17 00:00:00 2001 From: Owen Conti Date: Mon, 10 Jul 2017 19:46:32 -0600 Subject: [PATCH 05/22] Fixes #3361 - Check for null and undefined values in validateParam --- src/core/utils.js | 46 +++++++++++++++++++++++++--------------------- test/core/utils.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/core/utils.js b/src/core/utils.js index 448a8e9c..ae9a6320 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -228,13 +228,13 @@ export function highlight (el) { var reset = function(el) { var text = el.textContent, - pos = 0, // current position + pos = 0, // current position next1 = text[0], // next character - chr = 1, // current character - prev1, // previous character - prev2, // the one before the previous - token = // current token content - el.innerHTML = "", // (and cleaning the node) + chr = 1, // current character + prev1, // previous character + prev2, // the one before the previous + token = // current token content + el.innerHTML = "", // (and cleaning the node) // current token type: // 0: anything else (whitespaces / newlines) @@ -274,11 +274,11 @@ export function highlight (el) { (tokenType > 8 && chr == "\n") || [ // finalize conditions for other token types // 0: whitespaces - /\S/[test](chr), // merged together + /\S/[test](chr), // merged together // 1: operators - 1, // consist of a single character + 1, // consist of a single character // 2: braces - 1, // consist of a single character + 1, // consist of a single character // 3: (key)word !/[$\w]/[test](chr), // 4: regex @@ -341,12 +341,12 @@ export function highlight (el) { // condition) tokenType = 11 while (![ - 1, // 0: whitespace + 1, // 0: whitespace // 1: operator or braces - /[\/{}[(\-+*=<>:;|\\.,?!&@~]/[test](chr), // eslint-disable-line no-useless-escape - /[\])]/[test](chr), // 2: closing brace - /[$\w]/[test](chr), // 3: (key)word - chr == "/" && // 4: regex + /[\/{}[(\-+*=<>:;|\\.,?!&@~]/[test](chr), // eslint-disable-line no-useless-escape + /[\])]/[test](chr), // 2: closing brace + /[$\w]/[test](chr), // 3: (key)word + chr == "/" && // 4: regex // previous token was an // opening brace or an // operator (otherwise @@ -355,13 +355,13 @@ export function highlight (el) { // workaround for xml // closing tags prev1 != "<", - chr == "\"", // 5: string with " - chr == "'", // 6: string with ' + chr == "\"", // 5: string with " + chr == "'", // 6: string with ' // 7: xml comment chr+next1+text[pos+1]+text[pos+2] == "