Skip to content

Commit 1567ab2

Browse files
committed
Limit string preview with 100 characters
1 parent 1894f91 commit 1567ab2

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
snippets
2+
tests
3+
elm-stuff
4+
dist
5+
src
6+
stylesheets

elm-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.1.0",
2+
"version": "2.1.1",
33
"summary": "JSON viewer for elm apps",
44
"repository": "https://github.com/1602/json-viewer.git",
55
"license": "ISC",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-viewer-custom-element",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Custom HTML element: json-viewer",
55
"main": "build/custom-element.js",
66
"repository": "git@github.com:1602/json-viewer.git",

src/Json/Viewer.elm

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,17 @@ previewValue : JsonValue -> Html msg
237237
previewValue v =
238238
case v of
239239
JsonValue.StringValue s ->
240-
toString s
241-
|> text
242-
|> inline JsonString
240+
let
241+
strLen =
242+
String.length s
243+
in
244+
(if strLen > 100 then
245+
(String.left 50 s) ++ "" ++ (String.right 49 s)
246+
else
247+
toString s
248+
)
249+
|> text
250+
|> inline JsonString
243251

244252
JsonValue.NullValue ->
245253
"null"

0 commit comments

Comments
 (0)