import { InnerBlocks, useBlockProps, InspectorControls } from '@wordpress/block-editor'; import { CheckboxControl, PanelBody, PanelRow, SelectControl } from '@wordpress/components'; import { BlockFrame } from '@l-clutch/core/block-editor'; export default function edit({ attributes, setAttributes }) { const blockProps = useBlockProps(); const onChangeReadable = (value) => { setAttributes({ ...attributes, readable: value === 'true' ? true : false }); }; const changeReadableRoles = (role, enable) => { if (enable && !attributes.readableRoles.includes(role)) { setAttributes({ readableRoles: [...attributes.readableRoles, role] }); } else if (!enable && attributes.readableRoles.includes(role)) { setAttributes({ readableRoles: attributes.readableRoles.filter((r) => r !== role) }); } }; const onChangeAddedFriend = (value) => { setAttributes({ ...attributes, readableLineUser: { addedFriend: value } }); }; return (

対象ユーザー

{[ { label: '管理者', value: 'administrator' }, { label: '編集者', value: 'editor' }, { label: '著者', value: 'author' }, { label: '投稿者', value: 'contributor' }, { label: '閲覧者', value: 'subscriber' }, { label: 'LINEユーザー', value: 'l-clutch_line-user' }, { label: '非ログインユーザー', value: 'not_logged_in' }, ].map((role) => (
changeReadableRoles(role.value, isChecked)} /> {role.value === 'l-clutch_line-user' && attributes.readableRoles.includes(role.value) && (
)}
))}
); }