@ embedpdf/ plugin- 互通
EmbedPDF的工具和指针:活动的工具,光标和触摸.
此插件与每个 EmbedPDF 框架包相伴而来 。 从您使用的那个导入 :
| 框架 | 从 | 文档 |
|---|---|---|
| 反应 | @embedpdf/react/interaction | 工具、光标和触摸 |
| 阴道 | @embedpdf/vue/interaction | 工具、光标和触摸 |
| 丝绒 | @embedpdf/svelte/interaction | 工具、光标和触摸 |
| 角质 | @embedpdf/angular/interaction | 工具、光标和触摸 |
在反应中
随时 工具 正在激活,它决定点击或拖动页面会做什么:选择
文字,卷轴,绘制一矩形,放置一章. 交互插件会跟踪它和每个
特性,使用指针通过它。 登记册 interactionPlugin()数字 :
interaction-plugin.tsx
import { interactionPlugin } from '@embedpdf/react/interaction';
import { renderPlugin } from '@embedpdf/react/render';
import { stagePlugin } from '@embedpdf/react/stage';
export const plugins = [stagePlugin(), renderPlugin(), interactionPlugin()];
然后从工具栏中切换工具 :
tool-switch.tsx
import { useInteraction, useInteractionState } from '@embedpdf/react/interaction';
export function ToolSwitch() {
const interaction = useInteraction();
const { activeToolId } = useInteractionState();
return (
<>
<button aria-pressed={activeToolId === 'pointer'} onClick={() => interaction.activateTool('pointer')}>
Select
</button>
<button aria-pressed={activeToolId === 'pan'} onClick={() => interaction.activateTool('pan')}>
Hand
</button>
</>
);
}
许可证
阿帕奇 - 2.0