Skip to content

Commit

Permalink
Merge pull request #13 from orca-team/dev_lzh
Browse files Browse the repository at this point in the history
Dev lzh
  • Loading branch information
NicoKam authored Mar 6, 2024
2 parents 3c3b8d2 + 28e5ce7 commit b20c653
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
6 changes: 6 additions & 0 deletions packages/pdf-viewer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @orca-fe/pdf-viewer

## 1.21.6

### Patch Changes

- 354a8a2: 新增插件实例ID,解决状态冲突问题等

## 1.21.5

### Patch Changes
Expand Down
3 changes: 3 additions & 0 deletions packages/pdf-viewer/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ export default () => {
| onDataChange | 绘图数据变化时的回调函数 | `(data: ShapeDataType[][], action: 'add' / 'change' / 'delete', pageIndex: number, index: number) => void` | - | |
| disabledButton | 是否禁用按钮 | `boolean` | `false` | |
| autoCheck | 是否自动选中 | `boolean` | `true` | |
| popupVisible | 是否展示绘图下拉弹出窗 | `boolean` | `true` | |
| drawingVisible | 是否展示绘图按钮 | `boolean` | `true` | |
| drawingPluginId | 插件实例ID (解决插件组合使用,状态冲突问题) | `string` | `PDFPainterPlugin` | |
| onChangeStart | 开始绘图时的回调函数 | `(pageIndex: number, index: number) => void` | - | |
| defaultChecked | 默认选中的区域 | `[number, number]` | - | |
| checked | 选中的区域 | `[number, number]` | - | |
Expand Down
2 changes: 1 addition & 1 deletion packages/pdf-viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-fe/pdf-viewer",
"version": "1.21.5",
"version": "1.21.6",
"description": "PDF Viewer",
"keywords": [
"react",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type PDFPainterPluginHandle = {

const eArr = [];

const ef = () => {};
const ef = () => { };

/**
* PDFPainterPlugin 绘图插件属性
Expand Down Expand Up @@ -70,6 +70,15 @@ export interface PDFPainterPluginProps {
/** 开始绘图时的回调函数 */
onChangeStart?: (pageIndex: number, index: number) => void;

/** 是否展示绘图下拉弹出窗 */
popupVisible?: boolean;

/** 是否展示绘图按钮 */
drawingVisible?: boolean;

/** 插件实例ID */
drawingPluginId?: string;

buttonName?: string;
}

Expand All @@ -84,7 +93,7 @@ const drawingNamePDFPainterPlugin = 'PDFPainterPlugin';
*/
const PDFPainterPlugin = React.forwardRef<PDFPainterPluginHandle, PDFPainterPluginProps>((props, pRef) => {
const [l] = useLocale(zhCN);
const { disabledButton, autoCheck = true, onChangeStart = ef, buttonName = l.paint } = props;
const { disabledButton, autoCheck = true, onChangeStart = ef, buttonName = l.paint, popupVisible = true, drawingVisible = true, drawingPluginId = drawingNamePDFPainterPlugin } = props;
const styles = useStyle();

const { internalState, setInternalState } = useContext(PDFViewerContext);
Expand Down Expand Up @@ -118,11 +127,11 @@ const PDFPainterPlugin = React.forwardRef<PDFPainterPluginHandle, PDFPainterPlug
});

/* 绘图功能 */
const drawing = internalState.drawingPluginName === drawingNamePDFPainterPlugin;
const drawing = internalState.drawingPluginName === drawingPluginId;

const setDrawing = useMemoizedFn((b: boolean) => {
setInternalState({
drawingPluginName: b ? drawingNamePDFPainterPlugin : '',
setInternalState({ // 这里设置的时候,已经是全局的了
drawingPluginName: b ? drawingPluginId : '',
});
});

Expand Down Expand Up @@ -222,10 +231,10 @@ const PDFPainterPlugin = React.forwardRef<PDFPainterPluginHandle, PDFPainterPlug
<>
{!disabledButton && (
<ToolbarPortal>
<div className={styles.root}>
<div className={styles.root} style={{ display: drawingVisible ? 'block' : 'none' }}>
<Trigger
action="click"
popupVisible={drawing}
popupVisible={popupVisible ? drawing : popupVisible}
popupAlign={{
points: ['tr', 'br'],
offset: [0, 3],
Expand Down

0 comments on commit b20c653

Please sign in to comment.