File tree Expand file tree Collapse file tree 9 files changed +26
-16
lines changed
react/src/components/FieldPluginExample
vue2/src/components/FieldPluginExample
vue3/src/components/FieldPluginExample
messaging/pluginMessage/pluginToContainerMessage Expand file tree Collapse file tree 9 files changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,9 @@ function ModalCloseButton() {
55
55
} ,
56
56
setup ( { container, actions } ) {
57
57
container . querySelector ( '.btn-close' ) . addEventListener ( 'click' , ( ) => {
58
- actions . setModalOpen ( ! currentData . isModalOpen )
58
+ actions . setModalOpen ( ! currentData . isModalOpen , {
59
+ width : '50%' ,
60
+ } )
59
61
} )
60
62
} ,
61
63
update ( { container, data } ) {
@@ -114,7 +116,7 @@ function ModalToggle() {
114
116
container
115
117
. querySelector ( '.btn-modal-toggle' )
116
118
. addEventListener ( 'click' , ( ) => {
117
- actions . setModalOpen ( ! currentData . isModalOpen )
119
+ actions . setModalOpen ( ! currentData . isModalOpen , { width : '50%' } )
118
120
} )
119
121
} ,
120
122
update ( { container, data } ) {
Original file line number Diff line number Diff line change 1
1
import { FunctionComponent } from 'react'
2
+ import type { SetModalOpen } from '@storyblok/field-plugin'
2
3
3
4
const ModalToggle : FunctionComponent < {
4
5
isModalOpen : boolean
5
- setModalOpen : (
6
- isModalOpen : boolean ,
7
- modalSize ?: { width : string ; height : string } ,
8
- ) => void
6
+ setModalOpen : SetModalOpen < number >
9
7
} > = ( { isModalOpen, setModalOpen } ) => {
10
8
return (
11
9
< div >
12
10
< h2 > Modal</ h2 >
13
11
< button
14
12
className = "btn w-full"
15
13
type = "button"
16
- onClick = { ( ) => setModalOpen ( ! isModalOpen ) }
14
+ onClick = { ( ) => setModalOpen ( ! isModalOpen , { width : '50%' } ) }
17
15
>
18
16
{ isModalOpen ? 'Close' : 'Open' } modal
19
17
</ button >
Original file line number Diff line number Diff line change 4
4
<button
5
5
class =" btn w-full"
6
6
type =" button"
7
- @click =" () => setModalOpen(!isModalOpen)"
7
+ @click =" () => setModalOpen(!isModalOpen, { width: '50%' } )"
8
8
>
9
9
{{ isModalOpen ? 'Close' : 'Open' }} modal
10
10
</button >
Original file line number Diff line number Diff line change @@ -13,7 +13,12 @@ const props = defineProps<{
13
13
<button
14
14
class =" btn w-full"
15
15
type =" button"
16
- @click =" () => props.setModalOpen(!props.isModalOpen)"
16
+ @click ="
17
+ () =>
18
+ props.setModalOpen(!props.isModalOpen, {
19
+ width: '50%',
20
+ })
21
+ "
17
22
>
18
23
{{ props.isModalOpen ? 'Close' : 'Open' }} modal
19
24
</button >
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ export const ModalToggle: PluginComponent = (props) => {
9
9
< Button
10
10
variant = "outlined"
11
11
color = "secondary"
12
- onClick = { ( ) => actions . setModalOpen ( ! data . isModalOpen ) }
12
+ onClick = { ( ) =>
13
+ actions . setModalOpen ( ! data . isModalOpen , { width : '50%' } )
14
+ }
13
15
>
14
16
Toggle Modal
15
17
</ Button >
Original file line number Diff line number Diff line change @@ -4,8 +4,12 @@ import { FieldPluginData } from './FieldPluginData'
4
4
export type SetContent < Content > = (
5
5
content : Content ,
6
6
) => Promise < FieldPluginData < Content > >
7
+
8
+ export type ModalSize = { width ?: string ; height ?: string }
9
+
7
10
export type SetModalOpen < Content > = (
8
11
isModalOpen : boolean ,
12
+ modalSize ?: ModalSize ,
9
13
) => Promise < FieldPluginData < Content > >
10
14
export type RequestContext = ( ) => Promise < StoryData >
11
15
export type SelectAsset = ( ) => Promise < Asset >
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export type FieldPluginData<Content> = {
9
9
options : Record < string , string >
10
10
spaceId : number | undefined
11
11
userId : number | undefined
12
- userPermissions : Record < string , any > | undefined
12
+ userPermissions : Record < string , string [ ] | number [ ] > | undefined
13
13
isSpaceAdmin : boolean
14
14
interfaceLang : string
15
15
storyLang : string
Original file line number Diff line number Diff line change @@ -107,10 +107,7 @@ export const createPluginActions: CreatePluginActions = ({
107
107
)
108
108
} )
109
109
} ,
110
- setModalOpen : (
111
- isModalOpen : boolean ,
112
- modalSize ?: { width : string ; height : string } ,
113
- ) => {
110
+ setModalOpen : ( isModalOpen , modalSize ) => {
114
111
return new Promise ( ( resolve ) => {
115
112
const callbackId = pushCallback ( 'stateChanged' , ( message ) =>
116
113
resolve (
Original file line number Diff line number Diff line change 1
1
import { hasKey } from '../../../utils'
2
2
import { isMessageToContainer , MessageToContainer } from './MessageToContainer'
3
+ import type { ModalSize } from 'packages/field-plugin/src/createFieldPlugin'
3
4
4
5
export type ModalChangeMessage = MessageToContainer < 'toggleModal' > & {
5
6
status : boolean
6
- modalSize ?: { width : string ; height : string }
7
+ modalSize ?: ModalSize
7
8
}
9
+
8
10
export const isModalChangeMessage = ( obj : unknown ) : obj is ModalChangeMessage =>
9
11
isMessageToContainer ( obj ) &&
10
12
obj . event === 'toggleModal' &&
You can’t perform that action at this time.
0 commit comments