diff --git a/scm-ui/ui-components/src/SyntaxHighlighter.stories.tsx b/scm-ui/ui-components/src/SyntaxHighlighter.stories.tsx index 16331dcfd2..63961ac564 100644 --- a/scm-ui/ui-components/src/SyntaxHighlighter.stories.tsx +++ b/scm-ui/ui-components/src/SyntaxHighlighter.stories.tsx @@ -30,6 +30,7 @@ import JavaHttpServer from "./__resources__/HttpServer.java"; import GoHttpServer from "./__resources__/HttpServer.go"; import JsHttpServer from "./__resources__/HttpServer.js"; import PyHttpServer from "./__resources__/HttpServer.py"; +import Markdown from "./__resources__/test-page.md"; const Spacing = styled.div` padding: 1em; @@ -56,6 +57,11 @@ storiesOf("SyntaxHighlighter", module) )) + .add("Markdown", () => ( + + + + )) .add("Without line numbers", () => ( diff --git a/scm-ui/ui-components/src/__resources__/Diff.markdown.ts b/scm-ui/ui-components/src/__resources__/Diff.markdown.ts new file mode 100644 index 0000000000..25c5dc77b3 --- /dev/null +++ b/scm-ui/ui-components/src/__resources__/Diff.markdown.ts @@ -0,0 +1,118 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +export default { + files: [ + { + oldPath: "CHANGELOG.md", + newPath: "CHANGELOG.md", + oldEndingNewLine: true, + newEndingNewLine: true, + oldRevision: "de732d6da1cc0be8454f004c14b7666c69c91fb4", + newRevision: "148eb799f3a56909fe65b966e093a482ba542c81", + type: "modify", + language: "markdown", + hunks: [ + { + content: "@@ -5,7 +5,7 @@", + oldStart: 5, + newStart: 5, + oldLines: 7, + newLines: 7, + changes: [ + { + content: "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),", + type: "normal", + oldLineNumber: 5, + newLineNumber: 5, + isNormal: true + }, + { + content: "and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).", + type: "normal", + oldLineNumber: 6, + newLineNumber: 6, + isNormal: true + }, + { + content: "", + type: "normal", + oldLineNumber: 7, + newLineNumber: 7, + isNormal: true + }, + { + content: "## Unreleased", + type: "delete", + lineNumber: 8, + isDelete: true + }, + { + content: "## [2.7.1] - 2020-10-14", + type: "insert", + lineNumber: 8, + isInsert: true + }, + { + content: "### Fixed", + type: "normal", + oldLineNumber: 9, + newLineNumber: 9, + isNormal: true + }, + { + content: + "- Null Pointer Exception on anonymous migration with deleted repositories ([#1371](https://github.com/scm-manager/scm-manager/pull/1371))", + type: "normal", + oldLineNumber: 10, + newLineNumber: 10, + isNormal: true + }, + { + content: + "- Null Pointer Exception on parsing SVN properties ([#1373](https://github.com/scm-manager/scm-manager/pull/1373))", + type: "normal", + oldLineNumber: 11, + newLineNumber: 11, + isNormal: true + } + ] + } + ], + _links: { + lines: { + href: + "http://localhost:8081/scm/api/v2/repositories/scmadmin/scm-manager/content/fbffdea2a566dc4ac54ea38d4aade5aaf541e7f2/CHANGELOG.md?start={start}&end={end}", + templated: true + } + } + } + ], + _links: { + self: { + href: + "http://localhost:8081/scm/api/v2/repositories/scmadmin/scm-manager/diff/fbffdea2a566dc4ac54ea38d4aade5aaf541e7f2/parsed" + } + } +}; diff --git a/scm-ui/ui-components/src/repos/Diff.stories.tsx b/scm-ui/ui-components/src/repos/Diff.stories.tsx index be343c70ae..9649d97a84 100644 --- a/scm-ui/ui-components/src/repos/Diff.stories.tsx +++ b/scm-ui/ui-components/src/repos/Diff.stories.tsx @@ -29,6 +29,7 @@ import parser from "gitdiff-parser"; import simpleDiff from "../__resources__/Diff.simple"; import hunksDiff from "../__resources__/Diff.hunks"; import binaryDiff from "../__resources__/Diff.binary"; +import markdownDiff from "../__resources__/Diff.markdown"; import { DiffEventContext, File, FileControlFactory } from "./DiffTypes"; import Toast from "../toast/Toast"; import { getPath } from "./diffs"; @@ -151,6 +152,10 @@ storiesOf("Diff", module) }); return ; }) + .add("SyntaxHighlighting (Markdown)", () => { + // @ts-ignore + return ; + }) .add("CollapsingWithFunction", () => ( oldPath.endsWith(".java")} /> )) diff --git a/scm-ui/ui-components/src/repos/annotate/Annotate.stories.tsx b/scm-ui/ui-components/src/repos/annotate/Annotate.stories.tsx index 2da808c387..e69d4c62f0 100644 --- a/scm-ui/ui-components/src/repos/annotate/Annotate.stories.tsx +++ b/scm-ui/ui-components/src/repos/annotate/Annotate.stories.tsx @@ -112,6 +112,52 @@ const source: AnnotatedSource = { ] }; +const markdownSource: AnnotatedSource = { + language: "markdown", + lines: [ + { + lineNumber: 1, + code: "# Title", + ...commitCreateNewApp + }, + { + lineNumber: 2, + code: "", + ...commitCreateNewApp + }, + { + lineNumber: 3, + code: "This is a short Markdown text.", + ...commitFixedMissingImport + }, + { + lineNumber: 4, + code: "", + ...commitFixedMissingImport + }, + { + lineNumber: 5, + code: "With **bold** and __italic__ words.", + ...commitCreateNewApp + }, + { + lineNumber: 6, + code: "", + ...commitImplementMain + }, + { + lineNumber: 7, + code: "> This should be a quote", + ...commitCreateNewApp + }, + { + lineNumber: 8, + code: "", + ...commitCreateNewApp + } + ] +}; + const Robohash: FC = ({ children }) => { const binder = new Binder("robohash"); binder.bind("avatar.factory", (person: Person) => `https://robohash.org/${person.mail}.png`); @@ -124,6 +170,9 @@ storiesOf("Annotate", module) .add("Default", () => ( )) + .add("Markdown", () => ( + + )) .add("With Avatars", () => ( diff --git a/scm-ui/ui-components/src/syntax-highlighting.module.css b/scm-ui/ui-components/src/syntax-highlighting.module.css index 05fbe4b16a..4273b26931 100644 --- a/scm-ui/ui-components/src/syntax-highlighting.module.css +++ b/scm-ui/ui-components/src/syntax-highlighting.module.css @@ -22,6 +22,10 @@ * SOFTWARE. */ +/** + * IMPORTANT: If this file is changed, please run scritps/build-syntax-highlighting-javascript afterwards + */ + /* Generated with http://k88hudson.github.io/syntax-highlighting-theme-generator/www */ /* http://k88hudson.github.io/react-markdocs */ @@ -152,7 +156,8 @@ pre[class*="language-"] { } .token.important, -.token.bold { +.token.bold, +.token.title { font-weight: bold; } diff --git a/scm-ui/ui-components/src/syntax-highlighting.ts b/scm-ui/ui-components/src/syntax-highlighting.ts index c14eda92ba..7b6e928cfd 100644 --- a/scm-ui/ui-components/src/syntax-highlighting.ts +++ b/scm-ui/ui-components/src/syntax-highlighting.ts @@ -188,6 +188,9 @@ export default { bold: { fontWeight: "bold" }, + title: { + fontWeight: "bold" + }, italic: { fontStyle: "italic" },