Feat/SW-3031 imagevault updates
* chore(SW-3031): Updated dependencies * feat(SW-3031): Added Imagevault Id to title and updated delete functionality Approved-by: Michael Zetterberg
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
**/build
|
**/build
|
||||||
**/public
|
**/public
|
||||||
**/package.json
|
**/package.json
|
||||||
**/.eslintrc.cjs
|
**/eslint.config.mjs
|
||||||
**/tsconfig.json
|
**/tsconfig.json
|
||||||
|
|
||||||
.husky
|
.husky
|
||||||
|
|||||||
7848
package-lock.json
generated
7848
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
48
package.json
48
package.json
@@ -17,32 +17,34 @@
|
|||||||
"dev:rte": "cd rte && npm run dev",
|
"dev:rte": "cd rte && npm run dev",
|
||||||
"prepare": "husky"
|
"prepare": "husky"
|
||||||
},
|
},
|
||||||
"overrides": {
|
|
||||||
"@types/react": "18.2.20"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@contentstack/app-sdk": "^2.1.1",
|
"@contentstack/app-sdk": "^2.3.1",
|
||||||
"@contentstack/venus-components": "2.2.5",
|
"@contentstack/venus-components": "^3.0.0",
|
||||||
"react": "^18.3.1",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^18.3.1"
|
"react-dom": "^19.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react-dom": "^18.3.1",
|
"@eslint/compat": "^1.3.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
"@eslint/eslintrc": "^3.3.1",
|
||||||
"@typescript-eslint/parser": "^6.21.0",
|
"@eslint/js": "^9.29.0",
|
||||||
"concurrently": "^8.2.2",
|
"@types/react-dom": "^19.1.6",
|
||||||
"eslint": "^8.57.1",
|
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
||||||
"eslint-import-resolver-typescript": "^3.6.3",
|
"@typescript-eslint/parser": "^8.34.0",
|
||||||
|
"concurrently": "^9.1.2",
|
||||||
|
"eslint": "^9.29.0",
|
||||||
|
"eslint-import-resolver-typescript": "^4.4.3",
|
||||||
"eslint-plugin-import": "^2.31.0",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.10.1",
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
"eslint-plugin-react": "^7.37.2",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "^4.6.2",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"husky": "^9.1.6",
|
"globals": "^16.2.0",
|
||||||
"lint-staged": "^15.2.10",
|
"husky": "^9.1.7",
|
||||||
"prettier": "^3.3.3",
|
"lint-staged": "^16.1.2",
|
||||||
"typescript": "^5.6.3",
|
"prettier": "^3.5.3",
|
||||||
"vite": "^5.4.10",
|
"typescript": "^5.8.3",
|
||||||
"vite-plugin-lib-inject-css": "^2.1.1",
|
"vite": "^6.3.5",
|
||||||
"vite-tsconfig-paths": "^4.3.2"
|
"vite-plugin-devtools-json": "^0.2.0",
|
||||||
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
||||||
|
"vite-tsconfig-paths": "^5.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
/**
|
|
||||||
* This is intended to be a basic starting point for linting in your app.
|
|
||||||
* It relies on recommended configs out of the box for simplicity, but you can
|
|
||||||
* and should modify this configuration to best suit your team's needs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @type {import('eslint').Linter.Config} */
|
|
||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: "latest",
|
|
||||||
sourceType: "module",
|
|
||||||
ecmaFeatures: {
|
|
||||||
jsx: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
commonjs: true,
|
|
||||||
es6: true,
|
|
||||||
},
|
|
||||||
ignorePatterns: ["build/**/*", "node_modules/**/*", "public/**/*"],
|
|
||||||
|
|
||||||
// Base config
|
|
||||||
extends: ["eslint:recommended"],
|
|
||||||
|
|
||||||
overrides: [
|
|
||||||
// React
|
|
||||||
{
|
|
||||||
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
||||||
plugins: ["react", "jsx-a11y"],
|
|
||||||
rules: {
|
|
||||||
"react/jsx-uses-vars": "error",
|
|
||||||
"react/jsx-uses-react": "error",
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
"plugin:react/recommended",
|
|
||||||
"plugin:react/jsx-runtime",
|
|
||||||
"plugin:react-hooks/recommended",
|
|
||||||
"plugin:jsx-a11y/recommended",
|
|
||||||
],
|
|
||||||
settings: {
|
|
||||||
react: {
|
|
||||||
version: "detect",
|
|
||||||
},
|
|
||||||
formComponents: ["Form"],
|
|
||||||
linkComponents: [
|
|
||||||
{ name: "Link", linkAttribute: "to" },
|
|
||||||
{ name: "NavLink", linkAttribute: "to" },
|
|
||||||
],
|
|
||||||
"import/resolver": {
|
|
||||||
typescript: {
|
|
||||||
project: "./remix/tsconfig.json",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
// Typescript
|
|
||||||
{
|
|
||||||
files: ["**/*.{ts,tsx}"],
|
|
||||||
plugins: ["@typescript-eslint", "import"],
|
|
||||||
parser: "@typescript-eslint/parser",
|
|
||||||
settings: {
|
|
||||||
"import/internal-regex": "^~/",
|
|
||||||
"import/resolver": {
|
|
||||||
node: {
|
|
||||||
extensions: [".ts", ".tsx"],
|
|
||||||
},
|
|
||||||
typescript: {
|
|
||||||
alwaysTryTypes: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"plugin:import/recommended",
|
|
||||||
"plugin:import/typescript",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
// Node
|
|
||||||
{
|
|
||||||
files: [".eslintrc.cjs"],
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
@@ -27,23 +27,20 @@ export default function ConfigForm({
|
|||||||
<FieldLabel version="v2" htmlFor="baseUrl">
|
<FieldLabel version="v2" htmlFor="baseUrl">
|
||||||
Base url for contentstack
|
Base url for contentstack
|
||||||
</FieldLabel>
|
</FieldLabel>
|
||||||
<Help text="Including the region. Used as publishing source on ImageVault" />
|
<Help
|
||||||
|
type="basic"
|
||||||
|
text="Including the region. Used as publishing source on ImageVault"
|
||||||
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
id="baseUrl"
|
id="baseUrl"
|
||||||
name="baseUrl"
|
name="baseUrl"
|
||||||
type="url"
|
type="url"
|
||||||
value={finalValues.baseUrl}
|
value={finalValues.baseUrl}
|
||||||
onChange={(evt: ChangeEvent<HTMLInputElement>) => {
|
onChange={(evt: ChangeEvent<HTMLInputElement>) => {
|
||||||
setFinalValues((prev) => ({
|
setFinalValues((prev) => ({ ...prev, baseUrl: evt.target.value }))
|
||||||
...prev,
|
|
||||||
baseUrl: evt.target.value,
|
|
||||||
}))
|
|
||||||
|
|
||||||
setInstallationData({
|
setInstallationData({
|
||||||
configuration: {
|
configuration: { ...finalValues, baseUrl: evt.target.value },
|
||||||
...finalValues,
|
|
||||||
baseUrl: evt.target.value,
|
|
||||||
},
|
|
||||||
serverConfiguration: {},
|
serverConfiguration: {},
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
@@ -61,7 +58,10 @@ export default function ConfigForm({
|
|||||||
<FieldLabel version="v2" htmlFor="formatId">
|
<FieldLabel version="v2" htmlFor="formatId">
|
||||||
Format Id for images
|
Format Id for images
|
||||||
</FieldLabel>
|
</FieldLabel>
|
||||||
<Help text="Images are fetched with a certain format. This should be an id from ImageVault" />
|
<Help
|
||||||
|
type="basic"
|
||||||
|
text="Images are fetched with a certain format. This should be an id from ImageVault"
|
||||||
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
id="formatId"
|
id="formatId"
|
||||||
name="formatId"
|
name="formatId"
|
||||||
@@ -73,16 +73,10 @@ export default function ConfigForm({
|
|||||||
version="v2"
|
version="v2"
|
||||||
width="large"
|
width="large"
|
||||||
onChange={(evt: ChangeEvent<HTMLInputElement>) => {
|
onChange={(evt: ChangeEvent<HTMLInputElement>) => {
|
||||||
setFinalValues((prev) => ({
|
setFinalValues((prev) => ({ ...prev, formatId: evt.target.value }))
|
||||||
...prev,
|
|
||||||
formatId: evt.target.value,
|
|
||||||
}))
|
|
||||||
|
|
||||||
setInstallationData({
|
setInstallationData({
|
||||||
configuration: {
|
configuration: { ...finalValues, formatId: evt.target.value },
|
||||||
...finalValues,
|
|
||||||
formatId: evt.target.value,
|
|
||||||
},
|
|
||||||
serverConfiguration: {},
|
serverConfiguration: {},
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -129,6 +129,11 @@ export default function ImageEditModal({
|
|||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
</FieldComponent>
|
</FieldComponent>
|
||||||
|
|
||||||
|
<FieldComponent>
|
||||||
|
<FieldLabel htmlFor="imageVaultId">Imagevault Id</FieldLabel>
|
||||||
|
<TextInput value={fieldData.Id} name="imageVaultId" disabled />
|
||||||
|
</FieldComponent>
|
||||||
</div>
|
</div>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
cbModal,
|
cbModal,
|
||||||
} from "@contentstack/venus-components"
|
} from "@contentstack/venus-components"
|
||||||
import { isInsertResponse, openImageVault } from "~/utils/imagevault"
|
import { isInsertResponse, openImageVault } from "~/utils/imagevault"
|
||||||
import FullSizeImage from "./FullSizeImage"
|
|
||||||
import ImageEditModal from "./ImageEditModal"
|
import ImageEditModal from "./ImageEditModal"
|
||||||
|
|
||||||
import type UiLocation from "@contentstack/app-sdk/dist/src/uiLocation"
|
import type UiLocation from "@contentstack/app-sdk/dist/src/uiLocation"
|
||||||
@@ -19,6 +18,7 @@ import type {
|
|||||||
EntryDataPublishDetails,
|
EntryDataPublishDetails,
|
||||||
ImageVaultDAMConfig,
|
ImageVaultDAMConfig,
|
||||||
} from "~/utils/imagevault"
|
} from "~/utils/imagevault"
|
||||||
|
import FullSizeImage from "./FullSizeImage"
|
||||||
|
|
||||||
export type ImageVaultDAMProps = {
|
export type ImageVaultDAMProps = {
|
||||||
sdk: UiLocation
|
sdk: UiLocation
|
||||||
@@ -26,9 +26,7 @@ export type ImageVaultDAMProps = {
|
|||||||
initialData: InsertResponse | null
|
initialData: InsertResponse | null
|
||||||
}
|
}
|
||||||
|
|
||||||
type DAMButtonProps = {
|
type DAMButtonProps = { onClick: () => void }
|
||||||
onClick: () => void
|
|
||||||
}
|
|
||||||
|
|
||||||
function DAMButton({ onClick }: DAMButtonProps) {
|
function DAMButton({ onClick }: DAMButtonProps) {
|
||||||
return (
|
return (
|
||||||
@@ -60,7 +58,7 @@ function Media({ media, onDelete, onEdit }: MediaProps) {
|
|||||||
media.MediaConversions[0]
|
media.MediaConversions[0]
|
||||||
|
|
||||||
const assetUrl = Url
|
const assetUrl = Url
|
||||||
const title = media.Name
|
const title = `Id: ${media.Id} - ${media.Name}`
|
||||||
const width = FormatWidth || Width
|
const width = FormatWidth || Width
|
||||||
const height = FormatHeight || Height
|
const height = FormatHeight || Height
|
||||||
const alt =
|
const alt =
|
||||||
@@ -130,7 +128,7 @@ export default function ImageVaultDAM({
|
|||||||
if (frame?.updateHeight) {
|
if (frame?.updateHeight) {
|
||||||
// We need to recalculate the height of the iframe when an image is added.
|
// We need to recalculate the height of the iframe when an image is added.
|
||||||
// Cannot use flushSync inside useEffect.
|
// Cannot use flushSync inside useEffect.
|
||||||
setTimeout(() => frame.updateHeight(document.body.scrollHeight), 0)
|
setTimeout(() => frame.updateHeight(), 0)
|
||||||
}
|
}
|
||||||
}, [frame])
|
}, [frame])
|
||||||
|
|
||||||
@@ -139,14 +137,10 @@ export default function ImageVaultDAM({
|
|||||||
if (field) {
|
if (field) {
|
||||||
flushSync(() => {
|
flushSync(() => {
|
||||||
const data = result
|
const data = result
|
||||||
? {
|
? { ...result, FocalPoint: result.FocalPoint || { x: 50, y: 50 } }
|
||||||
...result,
|
|
||||||
FocalPoint: result.FocalPoint || { x: 50, y: 50 },
|
|
||||||
}
|
|
||||||
: null
|
: null
|
||||||
setMedia(data)
|
setMedia(data)
|
||||||
// Data inside the field is supposed to be an empty object if nothing is selected
|
field.setData(data)
|
||||||
field.setData(data || {})
|
|
||||||
document.body.style.overflow = "hidden"
|
document.body.style.overflow = "hidden"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -175,11 +169,7 @@ export default function ImageVaultDAM({
|
|||||||
modalProps: {
|
modalProps: {
|
||||||
size: "max",
|
size: "max",
|
||||||
style: {
|
style: {
|
||||||
content: {
|
content: { maxHeight: "90dvh", maxWidth: "90dvw", width: "auto" },
|
||||||
maxHeight: "90dvh",
|
|
||||||
maxWidth: "90dvw",
|
|
||||||
width: "auto",
|
|
||||||
},
|
|
||||||
overlay: {},
|
overlay: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -204,23 +194,17 @@ export default function ImageVaultDAM({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
|
||||||
<div>
|
<div>
|
||||||
<FieldLabel htmlFor="imagevaultpicker" version="v2">
|
<FieldLabel htmlFor="imagevaultpicker" version="v2">
|
||||||
ImageVault Asset
|
ImageVault Asset
|
||||||
</FieldLabel>
|
</FieldLabel>
|
||||||
</div>
|
|
||||||
|
|
||||||
{media ? (
|
{media ? (
|
||||||
<Media media={media} onDelete={handleMedia} onEdit={handleEdit} />
|
<Media media={media} onDelete={handleMedia} onEdit={handleEdit} />
|
||||||
) : (
|
) : (
|
||||||
<DAMButton
|
<DAMButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openImageVault({
|
openImageVault({ config, entryData, onSuccess: handleMedia })
|
||||||
config,
|
|
||||||
entryData,
|
|
||||||
onSuccess: handleMedia,
|
|
||||||
})
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import UiLocation from "@contentstack/app-sdk/dist/src/uiLocation"
|
import UiLocation from "@contentstack/app-sdk/dist/src/uiLocation"
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useRef, useState } from "react"
|
||||||
|
|
||||||
export class SDKLoadingError extends Error {}
|
export class SDKLoadingError extends Error {}
|
||||||
|
|
||||||
export default function useApp() {
|
export default function useApp() {
|
||||||
const modalElementId = "field"
|
const ref = useRef<HTMLDivElement>(null)
|
||||||
const [, setError] = useState()
|
const [, setError] = useState()
|
||||||
const [sdk, setSdk] = useState<UiLocation>()
|
const [sdk, setSdk] = useState<UiLocation>()
|
||||||
const [config, setConfig] = useState<Record<string, string>>()
|
const [config, setConfig] = useState<Record<string, string>>()
|
||||||
@@ -20,8 +20,7 @@ export default function useApp() {
|
|||||||
const config = await initSdk.getConfig()
|
const config = await initSdk.getConfig()
|
||||||
setConfig(config)
|
setConfig(config)
|
||||||
|
|
||||||
const iframeWrapperRef = document.getElementById(modalElementId)
|
window.iframeRef = ref.current
|
||||||
window.iframeRef = iframeWrapperRef
|
|
||||||
window.postRobot = initSdk.postRobot
|
window.postRobot = initSdk.postRobot
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let err: Error
|
let err: Error
|
||||||
@@ -43,6 +42,6 @@ export default function useApp() {
|
|||||||
return {
|
return {
|
||||||
sdk,
|
sdk,
|
||||||
config,
|
config,
|
||||||
modalElementId,
|
ref,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import "@contentstack/venus-components/build/main.css"
|
||||||
|
|
||||||
import { Suspense, lazy, useEffect, useState } from "react"
|
import { Suspense, lazy, useEffect, useState } from "react"
|
||||||
import { useScript } from "usehooks-ts"
|
import { useScript } from "usehooks-ts"
|
||||||
import useApp from "~/hooks/useApp"
|
import useApp from "~/hooks/useApp"
|
||||||
@@ -5,19 +7,26 @@ import useApp from "~/hooks/useApp"
|
|||||||
import Disclaimer from "~/components/Disclaimer"
|
import Disclaimer from "~/components/Disclaimer"
|
||||||
import InvalidConfig from "~/components/InvalidConfig"
|
import InvalidConfig from "~/components/InvalidConfig"
|
||||||
|
|
||||||
import { isImageVaultDAMConfig } from "~/utils/imagevault"
|
import { GenericObjectType } from "@contentstack/app-sdk/dist/src/types/common.types"
|
||||||
|
import UiLocation from "@contentstack/app-sdk/dist/src/uiLocation"
|
||||||
import type { InsertResponse } from "~/types/imagevault"
|
import type { InsertResponse } from "~/types/imagevault"
|
||||||
|
import { isImageVaultDAMConfig } from "~/utils/imagevault"
|
||||||
|
|
||||||
const ImageVaultDAM = lazy(() => import("~/components/ImageVaultDAM"))
|
const ImageVaultDAM = lazy(() => import("~/components/ImageVaultDAM"))
|
||||||
|
|
||||||
export default function Field() {
|
interface FieldContentProps {
|
||||||
const { sdk, config: appConfig, modalElementId } = useApp()
|
sdk?: UiLocation
|
||||||
|
appConfig?: GenericObjectType
|
||||||
|
}
|
||||||
|
|
||||||
|
function FieldContent({ sdk, appConfig }: FieldContentProps) {
|
||||||
const ivStatus = useScript(
|
const ivStatus = useScript(
|
||||||
"/scripts/imagevault-insert-media/insertmediawindow.min.js"
|
"/scripts/imagevault-insert-media/insertmediawindow.min.js"
|
||||||
)
|
)
|
||||||
|
|
||||||
const [showDisclaimer, setShowDisclaimer] = useState(false)
|
const [showDisclaimer, setShowDisclaimer] = useState(false)
|
||||||
const [fieldData, setFieldData] = useState<InsertResponse>()
|
const [fieldData, setFieldData] = useState<InsertResponse | null>()
|
||||||
|
const [dataIsLoaded, setDataIsLoaded] = useState(false)
|
||||||
|
|
||||||
const entry = sdk?.location.CustomField?.entry
|
const entry = sdk?.location.CustomField?.entry
|
||||||
const field = sdk?.location.CustomField?.field
|
const field = sdk?.location.CustomField?.field
|
||||||
@@ -31,14 +40,19 @@ export default function Field() {
|
|||||||
if (field && entry) {
|
if (field && entry) {
|
||||||
const data = field.getData()
|
const data = field.getData()
|
||||||
const title = entry.getField("title").getData().toString()
|
const title = entry.getField("title").getData().toString()
|
||||||
if (data && title) {
|
if (!title) {
|
||||||
setFieldData(data as InsertResponse)
|
throw new Error("Missing title for entry")
|
||||||
} else {
|
|
||||||
throw new Error("Missing data or title for entry")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
setFieldData(data as InsertResponse)
|
||||||
|
}
|
||||||
|
|
||||||
|
setDataIsLoaded(true)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setShowDisclaimer(true)
|
setShowDisclaimer(true)
|
||||||
|
console.log("Unable to get field data from SDK: ", e)
|
||||||
}
|
}
|
||||||
}, [entry, field])
|
}, [entry, field])
|
||||||
|
|
||||||
@@ -46,13 +60,13 @@ export default function Field() {
|
|||||||
return <Disclaimer />
|
return <Disclaimer />
|
||||||
}
|
}
|
||||||
|
|
||||||
const loaded = !!(fieldData && ivStatus === "ready" && sdk && appConfig)
|
const loaded = !!(dataIsLoaded && ivStatus === "ready" && sdk && appConfig)
|
||||||
|
|
||||||
const initialData =
|
const initialData =
|
||||||
fieldData && Object.keys(fieldData).length > 0 ? fieldData : null
|
fieldData && Object.keys(fieldData).length > 0 ? fieldData : null
|
||||||
|
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
return <p style={{ fontFamily: "Inter" }}> Loading dependecies...</p>
|
return <p style={{ fontFamily: "Inter" }}> Loading dependencies...</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isImageVaultDAMConfig(appConfig)) {
|
if (!isImageVaultDAMConfig(appConfig)) {
|
||||||
@@ -60,16 +74,21 @@ export default function Field() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fieldConfig = sdk.location.CustomField?.fieldConfig
|
const fieldConfig = sdk.location.CustomField?.fieldConfig
|
||||||
const config = {
|
const config = { ...appConfig, ...fieldConfig }
|
||||||
...appConfig,
|
|
||||||
...fieldConfig,
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id={modalElementId}>
|
|
||||||
<Suspense fallback={<p>Loading field...</p>}>
|
<Suspense fallback={<p>Loading field...</p>}>
|
||||||
<ImageVaultDAM config={config} sdk={sdk} initialData={initialData} />
|
<ImageVaultDAM config={config} sdk={sdk} initialData={initialData} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Field() {
|
||||||
|
const { sdk, config, ref } = useApp()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={ref}>
|
||||||
|
<FieldContent sdk={sdk} appConfig={config} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
1
remix/env.d.ts
vendored
1
remix/env.d.ts
vendored
@@ -1,2 +1 @@
|
|||||||
/// <reference types="@remix-run/node" />
|
|
||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|||||||
133
remix/eslint.config.mjs
Normal file
133
remix/eslint.config.mjs
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"
|
||||||
|
import { FlatCompat } from "@eslint/eslintrc"
|
||||||
|
import js from "@eslint/js"
|
||||||
|
import typescriptEslint from "@typescript-eslint/eslint-plugin"
|
||||||
|
import tsParser from "@typescript-eslint/parser"
|
||||||
|
import _import from "eslint-plugin-import"
|
||||||
|
import jsxA11Y from "eslint-plugin-jsx-a11y"
|
||||||
|
import react from "eslint-plugin-react"
|
||||||
|
import { defineConfig, globalIgnores } from "eslint/config"
|
||||||
|
import globals from "globals"
|
||||||
|
import path from "node:path"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
|
const __dirname = path.dirname(__filename)
|
||||||
|
const compat = new FlatCompat({
|
||||||
|
baseDirectory: __dirname,
|
||||||
|
recommendedConfig: js.configs.recommended,
|
||||||
|
allConfig: js.configs.all,
|
||||||
|
})
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
globalIgnores(["build/**/*", "node_modules/**/*", "public/**/*"]),
|
||||||
|
{
|
||||||
|
extends: compat.extends("eslint:recommended"),
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.commonjs,
|
||||||
|
},
|
||||||
|
|
||||||
|
ecmaVersion: "latest",
|
||||||
|
sourceType: "module",
|
||||||
|
|
||||||
|
parserOptions: {
|
||||||
|
ecmaFeatures: {
|
||||||
|
jsx: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.{js,jsx,ts,tsx}"],
|
||||||
|
|
||||||
|
extends: fixupConfigRules(
|
||||||
|
compat.extends(
|
||||||
|
"plugin:react/recommended",
|
||||||
|
"plugin:react/jsx-runtime",
|
||||||
|
"plugin:react-hooks/recommended",
|
||||||
|
"plugin:jsx-a11y/recommended"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
react: fixupPluginRules(react),
|
||||||
|
"jsx-a11y": fixupPluginRules(jsxA11Y),
|
||||||
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
react: {
|
||||||
|
version: "detect",
|
||||||
|
},
|
||||||
|
|
||||||
|
formComponents: ["Form"],
|
||||||
|
|
||||||
|
linkComponents: [
|
||||||
|
{
|
||||||
|
name: "Link",
|
||||||
|
linkAttribute: "to",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "NavLink",
|
||||||
|
linkAttribute: "to",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"import/resolver": {
|
||||||
|
typescript: {
|
||||||
|
project: "./remix/tsconfig.json",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
"react/jsx-uses-vars": "error",
|
||||||
|
"react/jsx-uses-react": "error",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.{ts,tsx}"],
|
||||||
|
|
||||||
|
extends: fixupConfigRules(
|
||||||
|
compat.extends(
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:import/recommended",
|
||||||
|
"plugin:import/typescript"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
"@typescript-eslint": fixupPluginRules(typescriptEslint),
|
||||||
|
import: fixupPluginRules(_import),
|
||||||
|
},
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
parser: tsParser,
|
||||||
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
"import/internal-regex": "^~/",
|
||||||
|
|
||||||
|
"import/resolver": {
|
||||||
|
node: {
|
||||||
|
extensions: [".ts", ".tsx"],
|
||||||
|
},
|
||||||
|
|
||||||
|
typescript: {
|
||||||
|
alwaysTryTypes: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/.eslintrc.cjs"],
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
@@ -12,14 +12,14 @@
|
|||||||
"typecheck": "tsc"
|
"typecheck": "tsc"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@remix-run/node": "^2.13.1",
|
"@remix-run/node": "^2.16.8",
|
||||||
"@remix-run/react": "^2.13.1",
|
"@remix-run/react": "^2.16.8",
|
||||||
"usehooks-ts": "^3.1.0"
|
"usehooks-ts": "^3.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@remix-run/dev": "^2.13.1"
|
"@remix-run/dev": "^2.16.8"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": ">=22.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
"**/*.tsx"
|
"**/*.tsx"
|
||||||
],
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"types": ["@remix-run/node", "vite/client"],
|
||||||
|
"skipLibCheck": true,
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { vitePlugin as remix } from "@remix-run/dev"
|
import { vitePlugin as remix } from "@remix-run/dev"
|
||||||
import { defineConfig } from "vite"
|
import { defineConfig } from "vite"
|
||||||
|
import devtoolsJson from "vite-plugin-devtools-json"
|
||||||
|
import { libInjectCss } from "vite-plugin-lib-inject-css"
|
||||||
import tsconfigPaths from "vite-tsconfig-paths"
|
import tsconfigPaths from "vite-tsconfig-paths"
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
remix({
|
remix({ ssr: false }),
|
||||||
ssr: false,
|
|
||||||
}),
|
|
||||||
tsconfigPaths(),
|
tsconfigPaths(),
|
||||||
|
libInjectCss(),
|
||||||
|
devtoolsJson(),
|
||||||
],
|
],
|
||||||
build: {
|
build: { emptyOutDir: true },
|
||||||
emptyOutDir: true,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
/**
|
|
||||||
* This is intended to be a basic starting point for linting in your app.
|
|
||||||
* It relies on recommended configs out of the box for simplicity, but you can
|
|
||||||
* and should modify this configuration to best suit your team's needs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @type {import('eslint').Linter.Config} */
|
|
||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: "latest",
|
|
||||||
sourceType: "module",
|
|
||||||
ecmaFeatures: {
|
|
||||||
jsx: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
commonjs: true,
|
|
||||||
es6: true,
|
|
||||||
},
|
|
||||||
ignorePatterns: ["node_modules/**/*"],
|
|
||||||
|
|
||||||
// Base config
|
|
||||||
extends: ["eslint:recommended"],
|
|
||||||
|
|
||||||
overrides: [
|
|
||||||
// React
|
|
||||||
{
|
|
||||||
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
||||||
plugins: ["react", "jsx-a11y"],
|
|
||||||
rules: {
|
|
||||||
"react/jsx-uses-vars": "error",
|
|
||||||
"react/jsx-uses-react": "error",
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
"plugin:react/recommended",
|
|
||||||
"plugin:react/jsx-runtime",
|
|
||||||
"plugin:react-hooks/recommended",
|
|
||||||
"plugin:jsx-a11y/recommended",
|
|
||||||
],
|
|
||||||
settings: {
|
|
||||||
react: {
|
|
||||||
version: "detect",
|
|
||||||
},
|
|
||||||
formComponents: ["Form"],
|
|
||||||
linkComponents: [
|
|
||||||
{ name: "Link", linkAttribute: "to" },
|
|
||||||
{ name: "NavLink", linkAttribute: "to" },
|
|
||||||
],
|
|
||||||
"import/resolver": {
|
|
||||||
typescript: {
|
|
||||||
project: "./rte/tsconfig.json",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
// Typescript
|
|
||||||
{
|
|
||||||
files: ["**/*.{ts,tsx}"],
|
|
||||||
plugins: ["@typescript-eslint", "import"],
|
|
||||||
parser: "@typescript-eslint/parser",
|
|
||||||
settings: {
|
|
||||||
"import/internal-regex": "^~/",
|
|
||||||
"import/resolver": {
|
|
||||||
node: {
|
|
||||||
extensions: [".ts", ".tsx"],
|
|
||||||
},
|
|
||||||
typescript: {
|
|
||||||
alwaysTryTypes: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"plugin:import/recommended",
|
|
||||||
"plugin:import/typescript",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
// Node
|
|
||||||
{
|
|
||||||
files: [".eslintrc.cjs"],
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
@@ -178,6 +178,7 @@ export default function ImageEditModal({
|
|||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<Field>
|
<Field>
|
||||||
|
{/* @ts-expect-error: Type incompatibility with Venus components */}
|
||||||
<Select
|
<Select
|
||||||
selectLabel="Alignment"
|
selectLabel="Alignment"
|
||||||
value={alignment}
|
value={alignment}
|
||||||
|
|||||||
133
rte/eslint.config.mjs
Normal file
133
rte/eslint.config.mjs
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"
|
||||||
|
import { FlatCompat } from "@eslint/eslintrc"
|
||||||
|
import js from "@eslint/js"
|
||||||
|
import typescriptEslint from "@typescript-eslint/eslint-plugin"
|
||||||
|
import tsParser from "@typescript-eslint/parser"
|
||||||
|
import _import from "eslint-plugin-import"
|
||||||
|
import jsxA11Y from "eslint-plugin-jsx-a11y"
|
||||||
|
import react from "eslint-plugin-react"
|
||||||
|
import { defineConfig, globalIgnores } from "eslint/config"
|
||||||
|
import globals from "globals"
|
||||||
|
import path from "node:path"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
|
const __dirname = path.dirname(__filename)
|
||||||
|
const compat = new FlatCompat({
|
||||||
|
baseDirectory: __dirname,
|
||||||
|
recommendedConfig: js.configs.recommended,
|
||||||
|
allConfig: js.configs.all,
|
||||||
|
})
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
globalIgnores(["node_modules/**/*"]),
|
||||||
|
{
|
||||||
|
extends: compat.extends("eslint:recommended"),
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.commonjs,
|
||||||
|
},
|
||||||
|
|
||||||
|
ecmaVersion: "latest",
|
||||||
|
sourceType: "module",
|
||||||
|
|
||||||
|
parserOptions: {
|
||||||
|
ecmaFeatures: {
|
||||||
|
jsx: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.{js,jsx,ts,tsx}"],
|
||||||
|
|
||||||
|
extends: fixupConfigRules(
|
||||||
|
compat.extends(
|
||||||
|
"plugin:react/recommended",
|
||||||
|
"plugin:react/jsx-runtime",
|
||||||
|
"plugin:react-hooks/recommended",
|
||||||
|
"plugin:jsx-a11y/recommended"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
react: fixupPluginRules(react),
|
||||||
|
"jsx-a11y": fixupPluginRules(jsxA11Y),
|
||||||
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
react: {
|
||||||
|
version: "detect",
|
||||||
|
},
|
||||||
|
|
||||||
|
formComponents: ["Form"],
|
||||||
|
|
||||||
|
linkComponents: [
|
||||||
|
{
|
||||||
|
name: "Link",
|
||||||
|
linkAttribute: "to",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "NavLink",
|
||||||
|
linkAttribute: "to",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"import/resolver": {
|
||||||
|
typescript: {
|
||||||
|
project: "./rte/tsconfig.json",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
"react/jsx-uses-vars": "error",
|
||||||
|
"react/jsx-uses-react": "error",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.{ts,tsx}"],
|
||||||
|
|
||||||
|
extends: fixupConfigRules(
|
||||||
|
compat.extends(
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:import/recommended",
|
||||||
|
"plugin:import/typescript"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
"@typescript-eslint": fixupPluginRules(typescriptEslint),
|
||||||
|
import: fixupPluginRules(_import),
|
||||||
|
},
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
parser: tsParser,
|
||||||
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
"import/internal-regex": "^~/",
|
||||||
|
|
||||||
|
"import/resolver": {
|
||||||
|
node: {
|
||||||
|
extensions: [".ts", ".tsx"],
|
||||||
|
},
|
||||||
|
|
||||||
|
typescript: {
|
||||||
|
alwaysTryTypes: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/.eslintrc.cjs"],
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
])
|
||||||
@@ -103,7 +103,7 @@ function extractContentstackEmbeddedData(
|
|||||||
plugin,
|
plugin,
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`Unable to parse JWT like: ${jwtLike}`)
|
console.log(`Unable to parse JWT like: ${jwtLike}`, e)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ async function init() {
|
|||||||
if (rte) {
|
if (rte) {
|
||||||
const savedSelection = rte?.selection?.get() ?? undefined
|
const savedSelection = rte?.selection?.get() ?? undefined
|
||||||
|
|
||||||
const appConfig = await rte.getConfig()
|
const appConfig = rte.getConfig()
|
||||||
|
|
||||||
// This is the configuration for this instance of the plugin.
|
// This is the configuration for this instance of the plugin.
|
||||||
// You edit this in the content types settings RTE plugin section.
|
// You edit this in the content types settings RTE plugin section.
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"dev": "IS_DEV=true vite build --watch",
|
"dev": "IS_DEV=true vite build --watch",
|
||||||
"lint": "eslint --ignore-path ../.gitignore --cache --cache-location ./node_modules/.cache/eslint .",
|
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
|
||||||
"prebuild": "concurrently npm:lint npm:typecheck",
|
"prebuild": "concurrently npm:lint npm:typecheck",
|
||||||
"typecheck": "tsc"
|
"typecheck": "tsc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/systemjs": "^6.15.1"
|
"@types/systemjs": "^6.15.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": ">=22.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import { resolve } from "path"
|
import { resolve } from "path"
|
||||||
import { defineConfig } from "vite"
|
import { defineConfig } from "vite"
|
||||||
|
import devtoolsJson from "vite-plugin-devtools-json"
|
||||||
import { libInjectCss } from "vite-plugin-lib-inject-css"
|
import { libInjectCss } from "vite-plugin-lib-inject-css"
|
||||||
import tsconfigPaths from "vite-tsconfig-paths"
|
import tsconfigPaths from "vite-tsconfig-paths"
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [tsconfigPaths(), libInjectCss()],
|
plugins: [tsconfigPaths(), libInjectCss(), devtoolsJson()],
|
||||||
define: {
|
define: { IS_DEV: process.env.IS_DEV === "true" ? true : false },
|
||||||
IS_DEV: process.env.IS_DEV === "true" ? true : false,
|
|
||||||
},
|
|
||||||
publicDir: false,
|
publicDir: false,
|
||||||
build: {
|
build: {
|
||||||
sourcemap: process.env.IS_DEV ? "inline" : "hidden",
|
sourcemap: process.env.IS_DEV ? "inline" : "hidden",
|
||||||
@@ -20,9 +19,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: ["react", "react-dom", "@contentstack/venus-components"],
|
external: ["react", "react-dom", "@contentstack/venus-components"],
|
||||||
output: {
|
output: { dir: "../remix/public/build/rte" },
|
||||||
dir: "../remix/public/build/rte",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user