Skip to content

Commit 4d14031

Browse files
Merge branch 'main' of github.com:storyblok/field-plugin into feat/SHAPE-8085-field-plugin-sdk-ai-prompt-new-action
# Conflicts: # packages/field-plugin/src/createFieldPlugin/FieldPluginActions.ts # packages/field-plugin/src/createFieldPlugin/createPluginActions/createPluginActions.test.ts # packages/field-plugin/src/createFieldPlugin/createPluginActions/createPluginActions.ts # packages/field-plugin/src/createFieldPlugin/createPluginActions/createPluginMessageListener/handlePluginMessage.ts # packages/field-plugin/src/messaging/pluginMessage/containerToPluginMessage/index.ts # packages/lib-helpers/test/src/index.ts # packages/sandbox/src/dom/createSandboxMessageListener.ts
2 parents 86b8431 + 240f5e3 commit 4d14031

38 files changed

+531
-24
lines changed

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@storyblok/field-plugin-cli",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"license": "MIT",
55
"type": "module",
66
"bin": {

packages/cli/templates/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"deploy": "npm run build && npx @storyblok/field-plugin-cli@latest deploy"
1111
},
1212
"dependencies": {
13-
"@storyblok/field-plugin": "1.4.2"
13+
"@storyblok/field-plugin": "1.5.0"
1414
},
1515
"devDependencies": {
1616
"vite": "5.4.11",

packages/cli/templates/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"deploy": "npm run build && npx @storyblok/field-plugin-cli@latest deploy"
1313
},
1414
"dependencies": {
15-
"@storyblok/field-plugin": "1.4.2",
15+
"@storyblok/field-plugin": "1.5.0",
1616
"react": "^18.3.1",
1717
"react-dom": "^18.3.1"
1818
},

packages/cli/templates/react/src/components/FieldPluginExample/ModalToggle.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { FunctionComponent } from 'react'
2+
import type { SetModalOpen } from '@storyblok/field-plugin'
23

34
const ModalToggle: FunctionComponent<{
45
isModalOpen: boolean
5-
setModalOpen: (isModalOpen: boolean) => void
6+
setModalOpen: SetModalOpen<number>
67
}> = ({ isModalOpen, setModalOpen }) => {
78
return (
89
<div>

packages/cli/templates/vue2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"deploy": "npm run build && npx @storyblok/field-plugin-cli@latest deploy"
1313
},
1414
"dependencies": {
15-
"@storyblok/field-plugin": "1.4.2",
15+
"@storyblok/field-plugin": "1.5.0",
1616
"vue": "^2.7.14"
1717
},
1818
"devDependencies": {

packages/cli/templates/vue3/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"deploy": "npm run build && npx @storyblok/field-plugin-cli@latest deploy"
1212
},
1313
"dependencies": {
14-
"@storyblok/field-plugin": "1.4.2",
14+
"@storyblok/field-plugin": "1.5.0",
1515
"vue": "^3.2.47"
1616
},
1717
"devDependencies": {

packages/demo/src/components/ContextRequester.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ export const ContextRequester: PluginComponent = (props) => {
55
const { data, actions } = props
66
return (
77
<Stack gap={2}>
8-
<Typography variant="subtitle1">Story</Typography>
9-
<Typography textAlign="center">{JSON.stringify(data.story)}</Typography>
8+
<Typography variant="subtitle1">Story: </Typography>
9+
<Typography textAlign="center">
10+
{JSON.stringify(data.story, null, 2)}
11+
</Typography>
12+
<Typography variant="subtitle1">Is AI enabled: </Typography>
13+
<Typography textAlign="center">
14+
{data.isAIEnabled ? 'Yes' : 'No'}
15+
</Typography>
1016
<Button
1117
variant="outlined"
1218
color="secondary"

packages/demo/src/components/ModalToggle.tsx

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,53 @@
1-
import { Button, Stack, Typography } from '@mui/material'
1+
import { useState } from 'react'
2+
import { Button, Stack, Typography, TextField, Grid } from '@mui/material'
23
import { PluginComponent } from './FieldPluginDemo'
4+
import type { ModalSize } from '@storyblok/field-plugin'
35

46
export const ModalToggle: PluginComponent = (props) => {
57
const { actions, data } = props
8+
const [modalSize, setModalSize] = useState<ModalSize>({
9+
width: '50%',
10+
height: '100%',
11+
})
12+
613
return (
714
<Stack gap={2}>
815
<Typography variant="subtitle1">Modal</Typography>
16+
<Grid
17+
container
18+
spacing={2}
19+
>
20+
<Grid
21+
xs={6}
22+
item
23+
>
24+
<TextField
25+
label="Set modal width:"
26+
value={modalSize.width}
27+
fullWidth
28+
onChange={(e) =>
29+
setModalSize({ ...modalSize, width: e.target.value })
30+
}
31+
/>
32+
</Grid>
33+
<Grid
34+
xs={6}
35+
item
36+
>
37+
<TextField
38+
label="Set modal height:"
39+
value={modalSize.height}
40+
fullWidth
41+
onChange={(e) =>
42+
setModalSize({ ...modalSize, height: e.target.value })
43+
}
44+
/>
45+
</Grid>
46+
</Grid>
947
<Button
1048
variant="outlined"
1149
color="secondary"
12-
onClick={() => actions.setModalOpen(!data.isModalOpen)}
50+
onClick={() => actions.setModalOpen(!data.isModalOpen, modalSize)}
1351
>
1452
Toggle Modal
1553
</Button>

packages/demo/src/components/NonModalView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ValueMutator } from './ValueMutator'
44
import { HeightChangeDemo } from './HeightChangeDemo'
55
import { AssetSelector } from './AssetSelector'
66
import { ContextRequester } from './ContextRequester'
7+
import { UserContextRequester } from './UserContextRequester'
78
import { PluginComponent } from './FieldPluginDemo'
89
import { LanguageView } from './LanguageView'
910
import { PromptAI } from './PromptAI'
@@ -13,9 +14,9 @@ export const NonModalView: PluginComponent = (props) => (
1314
<Stack gap={6}>
1415
<ModalToggle {...props} />
1516
<ValueMutator {...props} />
16-
<ModalToggle {...props} />
1717
<AssetSelector {...props} />
1818
<ContextRequester {...props} />
19+
<UserContextRequester {...props} />
1920
<HeightChangeDemo {...props} />
2021
<LanguageView {...props} />
2122
<PromptAI {...props} />
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { useState } from 'react'
2+
import { Button, Stack, Typography } from '@mui/material'
3+
import { PluginComponent } from './FieldPluginDemo'
4+
import { UserData } from '@storyblok/field-plugin'
5+
6+
export const UserContextRequester: PluginComponent = (props) => {
7+
const { actions } = props
8+
const [user, setUser] = useState<UserData>({
9+
isSpaceAdmin: false,
10+
permissions: undefined,
11+
})
12+
return (
13+
<Stack gap={2}>
14+
<Typography variant="subtitle1">User data: </Typography>
15+
<Typography>Permissions: </Typography>
16+
<Typography textAlign="center">
17+
{JSON.stringify(user.permissions, null, 2)}
18+
</Typography>
19+
<Typography>Is space admin? </Typography>
20+
<Typography textAlign="center">
21+
{user.isSpaceAdmin ? 'Yes' : 'No'}
22+
</Typography>
23+
<Button
24+
variant="outlined"
25+
color="secondary"
26+
onClick={async () => setUser(await actions.requestUserContext())}
27+
>
28+
Request User Context
29+
</Button>
30+
</Stack>
31+
)
32+
}

0 commit comments

Comments
 (0)