Browse Source

fix: 兼容note content、annotation type获取不到

wzl 1 year ago
parent
commit
af15765f59
2 changed files with 8 additions and 8 deletions
  1. 6 6
      packages/core/src/annotation/layer.js
  2. 2 2
      packages/core/src/annotation/text.js

+ 6 - 6
packages/core/src/annotation/layer.js

@@ -956,17 +956,17 @@ class ComPDFAnnotationLayer {
     if (this.annotations && this.annotations.length) {
       const annotation = this.annotations.find((element) => element.name === this.annotationStore.selectedElementName)
       if (annotation) {
-        if (annotation.type.replace('-', '') === 'textfield') {
+        if (annotation.type?.replace('-', '') === 'textfield') {
           this.eventBus.dispatch("textfieldPropertyPanelChanged", props);
-        } else if (annotation.type.replace('-', '') === 'checkbox') {
+        } else if (annotation.type?.replace('-', '') === 'checkbox') {
           this.eventBus.dispatch("checkboxPropertyPanelChanged", props);
-        } else if (annotation.type.replace('-', '') === 'radiobutton') {
+        } else if (annotation.type?.replace('-', '') === 'radiobutton') {
           this.eventBus.dispatch("radioButtonPropertyPanelChanged", props);
-        } else if (annotation.type.replace('-', '') === 'pushbutton') {
+        } else if (annotation.type?.replace('-', '') === 'pushbutton') {
           this.eventBus.dispatch("pushButtonPropertyPanelChanged", props);
-        } else if (annotation.type.replace('-', '') === 'listbox') {
+        } else if (annotation.type?.replace('-', '') === 'listbox') {
           this.eventBus.dispatch("listBoxPropertyPanelChanged", props);
-        } else if (annotation.type.replace('-', '') === 'combobox') {
+        } else if (annotation.type?.replace('-', '') === 'combobox') {
           this.eventBus.dispatch("comboBoxPropertyPanelChanged", props);
         }
       }

+ 2 - 2
packages/core/src/annotation/text.js

@@ -367,13 +367,13 @@ export default class Text extends Base {
     if (this.annotation.content) {
       textEditorElement.innerHTML = this.annotation.content
     } else if (this.annotation.contents) {
-      textEditorElement.innerHTML = annotation.contents
+      textEditorElement.innerHTML = this.annotation.contents
     } else if (this.annotation['contents-richtext']) {
       const parser = new window.DOMParser();
       const xmlDoc = parser.parseFromString(this.annotation['contents-richtext'], 'text/xml');
       const error = xmlDoc.getElementsByTagName("parsererror")
       if (error.length > 0) {
-        textEditorElement.innerHTML = annotation['contents-richtext']
+        textEditorElement.innerHTML = this.annotation['contents-richtext']
       } else {
         textEditorElement.innerHTML = xmlDoc.firstElementChild.innerText
       }