mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
Render images from repository correctly
This adds a markdown renderer for images, so that images that are referenced by their repository path are resolved correctly. In this case, the content rest endpoint is rendered as source url. For this, two new contexts (RepositoryContext and RepositoryRevisionContext) have been added, that make the repository and the current revision available, so that the content url can be resolved properly. These new contexts may be used by plugins like the scm-readme-plugin. Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com> Reviewed-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
committed by
SCM-Manager
parent
6ba792e5bc
commit
f2f2f29791
34
scm-ui/ui-api/src/RepositoryContext.tsx
Normal file
34
scm-ui/ui-api/src/RepositoryContext.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import React, { createContext, FC, useContext } from "react";
|
||||
import { Repository } from "@scm-manager/ui-types";
|
||||
|
||||
const Context = createContext<Repository | undefined>(undefined);
|
||||
|
||||
export const useRepositoryContext = () => useContext(Context);
|
||||
|
||||
export const RepositoryContextProvider: FC<{ repository: Repository }> = ({ repository, children }) => (
|
||||
<Context.Provider value={repository}>{children}</Context.Provider>
|
||||
);
|
||||
33
scm-ui/ui-api/src/RepositoryRevisionContext.tsx
Normal file
33
scm-ui/ui-api/src/RepositoryRevisionContext.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import React, { createContext, FC, useContext } from "react";
|
||||
|
||||
const Context = createContext<string | undefined>(undefined);
|
||||
|
||||
export const useRepositoryRevisionContext = () => useContext(Context);
|
||||
|
||||
export const RepositoryRevisionContextProvider: FC<{ revision?: string }> = ({ revision, children }) => (
|
||||
<Context.Provider value={revision}>{children}</Context.Provider>
|
||||
);
|
||||
@@ -71,3 +71,5 @@ export * from "./ApiProvider";
|
||||
|
||||
export * from "./LegacyContext";
|
||||
export * from "./NamespaceAndNameContext";
|
||||
export * from "./RepositoryContext";
|
||||
export * from "./RepositoryRevisionContext";
|
||||
|
||||
Reference in New Issue
Block a user