Kaynağa Gözat

add: tool 新增获取属性

liutian 1 ay önce
ebeveyn
işleme
fe36e14881

+ 15 - 0
packages/webview/src/apis/getTool.js

@@ -0,0 +1,15 @@
+/**
+ * Get the tool of WebViewer UI.
+ * @method UI.getTool
+ * @example
+WebViewer(...)
+  .then(function(instance) {
+    instance.UI.getTool(); // Get the tool
+  });
+ */
+
+  export default (store) => (tool) => {
+    return {
+      ...store[tool]
+    }
+  }

+ 13 - 0
packages/webview/src/apis/getToolColor.js

@@ -0,0 +1,13 @@
+/**
+ * Get the tool's color of WebViewer UI.
+ * @method UI.getToolColor
+ * @example
+WebViewer(...)
+  .then(function(instance) {
+    instance.UI.getToolColor(); // Get the color
+  });
+ */
+
+  export default (store) => (tool) => {
+    return store[tool].color
+  }

+ 4 - 0
packages/webview/src/apis/index.js

@@ -18,6 +18,8 @@ import isElementOpen from './isElementOpen';
 import setActiveElementTab from './setActiveElementTab';
 import setCustomFonts from './setCustomFonts';
 import setAnnotator from './setAnnotator';
+import getToolColor from './getToolColor';
+import getTool from './getTool';
 
 export default () => {
   const { locale } = i18n.global
@@ -55,6 +57,8 @@ export default () => {
     setActiveElementTab: setActiveElementTab(useViewer),
     setCustomFonts: setCustomFonts(useViewer),
     setAnnotator: setAnnotator(useDocument),
+    getToolColor: getToolColor(useDocument),
+    getTool: getTool(useDocument),
   }
   const documentViewer = core.getDocumentViewer(1);