PSPDFKIT instance.addEventListener('annotations.create') 缺少注释类型

PSPDFKIT instance.addEventListener('annotations.create') is missing the annotation type

我正在努力使用 pspdfkit 来正确创建和显示我的注释。我想像这样创建我的注释:

 instance.addEventListener("annotations.create", createdAnnotations => {
              const annotation = createdAnnotations
              const serializedObject = toSerializableObject(annotation)
              const annotationsJson = JSON.stringify(serializedObject)
              console.log("clean", JSON.parse(annotationsJson))
              dispatch(createPdfNote(annotationsJson, documentID))
                .then(
                  err => {
                    if (!err) {
                      setSnackContent({
                        severity: "success",
                        message: "Annotation successfully created",
                      })
                    }
                  })
            })

但是在创建注释时缺少注释类型。

我如何检索它并能够使用 toSerializeObject 来创建我可以在之后重新创建的 JSON?

那是 JSON 为我创建的 instance.addEventListener:

action: null
​​additionalActions: null
​​backgroundColor: null
​​blendMode: "normal"
​​boundingBox: Object { left: 308, top: 118, width: 82, … }
​​createdAt: "2021-06-28T07:58:36.255Z"
​​creatorName: null
​​customData: null
​​hidden: false
​​id: "01F98T156YNAP5N28MAKKQJ2Y4"
​​isCommentThreadRoot: false
​​isDrawnNaturally: false
​​isSignature: false
​​lineWidth: 5
​​lines: Array [ (12) […] ]
​​name: "01F98T156YNAP5N28MAKKQJ2Y4"
​​noPrint: false
​​noRotate: false
​​noView: false
​​noZoom: false
​​note: null
​​opacity: 1
​​pageIndex: 0
​​pdfObjectId: null
​​strokeColor: Object { r: 34, g: 147, b: 251 }
​updatedAt: "2021-06-28T07:58:37.181Z"

不幸的是,我必须传递 pspdfkit 函数 toSerializeObject, fromSerializeObject 才能创建和显示注释,但是当我创建它们时它们给我错误 unsupported typeunsupported type change我尝试重新创建它们,仅使用 JSON.parse / JSON.stringify 并不能解决问题,它不会让我使用 instance.create 将创建的注释渲染到 DOM 当用户关闭查看器并再次打开它时。

所以,文档是垃圾,不会说谎...方法实际上是一个函数,检索到的数组是一个对象等等。

关于如何获得我要找的东西的答案是:

            instance.addEventListener("annotations.create", createdNote => {
              const note = createdNote.get(0)
              const serializedObjectNote = toSerializableObject(note)
              const noteJson = JSON.stringify(serializedObjectNote)
              if (!isLoadingNotes.current) {
                dispatch(createPdfNote(noteJson, documentID))
                  .then(
                    err => {
                      if (!err) {
                        setSnackContent({
                          severity: "success",
                          message: "Annotation successfully created",
                        })
                      }
                    })
              }
            })