Переглянути джерело

add: tool 新增获取属性

liutian 1 місяць тому
батько
коміт
d64165e45a

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

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

+ 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
+  }

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

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