({
)
return (
-
-
-
+ {containsRteField && }
+ >
)
}
diff --git a/src/components/Modals/ObjectModals/ObjectAreaAnnotateModal/ObjectAreaAnnotateModal.tsx b/src/components/Modals/ObjectModals/ObjectAreaAnnotateModal/ObjectAreaAnnotateModal.tsx
new file mode 100644
index 00000000..1adf103a
--- /dev/null
+++ b/src/components/Modals/ObjectModals/ObjectAreaAnnotateModal/ObjectAreaAnnotateModal.tsx
@@ -0,0 +1,165 @@
+import { Button, FormikSelect } from '@pzh-ui/components'
+import { Form, Formik } from 'formik'
+import { useMemo } from 'react'
+import { z } from 'zod'
+import { toFormikValidationSchema } from 'zod-formik-adapter'
+
+import Modal from '@/components/Modal'
+import useModalStore from '@/store/modalStore'
+import { SCHEMA_OBJECT_ANNOTATE_AREA } from '@/validation/objectAnnotate'
+
+import { ModalStateMap } from '../../types'
+
+type Values = z.infer
+
+const ObjectAreaAnnotateModal = () => {
+ const setActiveModal = useModalStore(state => state.setActiveModal)
+ const modalState = useModalStore(
+ state => state.modalStates['objectAreaAnnotate']
+ ) as ModalStateMap['objectAreaAnnotate']
+
+ const groupOptions = [
+ {
+ label: 'Gebiedengroep 1',
+ value: 'group-1',
+ },
+ ]
+
+ const areaTypeOptions = [{ label: 'Type 1', value: 'type-1' }]
+
+ const areaGroupOptions = [
+ {
+ label: 'Gebiedengroep 1',
+ value: 'group-1',
+ },
+ ]
+
+ const isEmptySelection = useMemo(
+ () => modalState?.editor.state.selection.empty,
+ [modalState?.editor.state.selection.empty]
+ )
+
+ const hasValues = useMemo(
+ () => {
+ const values = modalState?.editor?.getAttributes('area')
+
+ return !!values && !!Object.keys(values).length
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [modalState?.editor, modalState?.editor?.state.selection]
+ )
+
+ const initialValues: Values = useMemo(() => {
+ const previousValues = modalState?.editor?.getAttributes('area')
+
+ return {
+ group: previousValues?.['data-gebiedengroep'] ?? '',
+ areaType: previousValues?.['data-type'] ?? '',
+ areaGroup: previousValues?.['data-gebiedsaanwijzing'] ?? '',
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [modalState?.editor, modalState?.editor?.state.selection])
+
+ const handleSubmit = (payload: Values) => {
+ const groupName = groupOptions.find(
+ option => option.value === payload.group
+ )?.label
+
+ modalState?.editor
+ ?.chain()
+ .focus()
+ .extendMarkRange('area')
+ .setArea({
+ 'data-gebiedengroep': payload.group,
+ 'data-type': payload.areaType,
+ 'data-gebiedsaanwijzing': payload.areaGroup,
+ text: isEmptySelection ? groupName : undefined,
+ })
+ .run()
+
+ setActiveModal(null)
+ }
+
+ return (
+
+
+ {({ isValid, isSubmitting, dirty }) => (
+
+ )}
+
+
+ )
+}
+
+export default ObjectAreaAnnotateModal
diff --git a/src/components/Modals/ObjectModals/ObjectAreaAnnotateModal/index.ts b/src/components/Modals/ObjectModals/ObjectAreaAnnotateModal/index.ts
new file mode 100644
index 00000000..fc0b1424
--- /dev/null
+++ b/src/components/Modals/ObjectModals/ObjectAreaAnnotateModal/index.ts
@@ -0,0 +1 @@
+export { default } from './ObjectAreaAnnotateModal'
diff --git a/src/components/Modals/types.ts b/src/components/Modals/types.ts
index f2440ead..dfe46655 100644
--- a/src/components/Modals/types.ts
+++ b/src/components/Modals/types.ts
@@ -1,3 +1,5 @@
+import { Editor } from '@tiptap/core'
+
import {
DocumentType,
Module,
@@ -23,6 +25,7 @@ export type ModalType =
| 'moduleEditObject'
| 'moduleDeleteObject'
| 'areaAdd'
+ | 'objectAreaAnnotate'
| 'objectDetails'
| 'objectAddConnection'
| 'objectDelete'
@@ -50,6 +53,9 @@ export interface ModalStateMap {
object: ModuleObjectShort
module: Module
}
+ objectAreaAnnotate: {
+ editor: Editor
+ }
publicationAdd: {
documentType: DocumentType
procedureType: ProcedureType
diff --git a/src/validation/objectAnnotate.ts b/src/validation/objectAnnotate.ts
new file mode 100644
index 00000000..700294ea
--- /dev/null
+++ b/src/validation/objectAnnotate.ts
@@ -0,0 +1,9 @@
+import { object } from 'zod'
+
+import { schemaDefaults } from './zodSchema'
+
+export const SCHEMA_OBJECT_ANNOTATE_AREA = object({
+ group: schemaDefaults.requiredString(),
+ areaType: schemaDefaults.requiredString(),
+ areaGroup: schemaDefaults.requiredString(),
+})
diff --git a/yarn.lock b/yarn.lock
index ed81bff7..7497f691 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2815,9 +2815,9 @@ __metadata:
languageName: node
linkType: hard
-"@pzh-ui/components@npm:^0.0.546":
- version: 0.0.546
- resolution: "@pzh-ui/components@npm:0.0.546"
+"@pzh-ui/components@npm:^0.0.548":
+ version: 0.0.548
+ resolution: "@pzh-ui/components@npm:0.0.548"
dependencies:
"@floating-ui/react": "npm:^0.24.8"
"@headlessui/react": "npm:^1.5.0"
@@ -2869,7 +2869,7 @@ __metadata:
react-stately: "npm:^3.30.1"
react-toastify: "npm:^9.1.2"
tailwind-merge: "npm:^2.2.2"
- checksum: 0511a073e52dee587cffaa3b88d67996ab6bd1cb16d4f965ddd02507c4026448338d940130adc5e060b3f8e522b5692a0286b0964fcc08aa6caf42841872d465
+ checksum: 5677bf6d9a836e21ffb76b8b89b2603722c11208f32553bae81f3430125f26bf15ab052be23d905ca9e10eca05d693ca4589c43163985c8baf9ce1d26d67cc0d
languageName: node
linkType: hard
@@ -13064,7 +13064,7 @@ __metadata:
"@axe-core/react": "npm:^4.8.2"
"@faker-js/faker": "npm:^8.3.1"
"@headlessui/react": "npm:^1.7.17"
- "@pzh-ui/components": "npm:^0.0.546"
+ "@pzh-ui/components": "npm:^0.0.548"
"@pzh-ui/config": "npm:^0.0.70"
"@pzh-ui/css": "npm:^0.0.97"
"@pzh-ui/icons": "npm:^0.0.61"