瀏覽代碼

add: tool 新增获取属性

liutian 1 月之前
父節點
當前提交
fe36e14881
共有 3 個文件被更改,包括 32 次插入0 次删除
  1. 15 0
      packages/webview/src/apis/getTool.js
  2. 13 0
      packages/webview/src/apis/getToolColor.js
  3. 4 0
      packages/webview/src/apis/index.js

+ 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);