-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复 painter plugin 识别数据没有同步缩放的问题
- Loading branch information
Showing
10 changed files
with
220 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@orca-fe/pdf-viewer': minor | ||
--- | ||
|
||
fix: 修复 painter plugin 识别数据没有同步缩放的问题 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/pdf-viewer/src/plugins/PDFPageDebugPlugin/PDFPageDebugPlugin.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createUseStyles } from '@orca-fe/simple-jss'; | ||
import jssAutoPrefix from '@orca-fe/jss-plugin-auto-prefix'; | ||
|
||
const prefix = 'pdf-page-debug-plugin'; | ||
|
||
export default createUseStyles( | ||
{ | ||
root: { | ||
position: 'relative', | ||
}, | ||
}, | ||
{ | ||
classNamePrefix: prefix, | ||
plugins: [jssAutoPrefix({ prefix })], | ||
}, | ||
); |
17 changes: 17 additions & 0 deletions
17
packages/pdf-viewer/src/plugins/PDFPageDebugPlugin/PDFPageDebugPlugin.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable react/no-unused-prop-types */ | ||
import React from 'react'; | ||
import { usePageCoverRenderer } from '../../context'; | ||
|
||
const PDFPageDebugPlugin = () => { | ||
const renderPageCover = usePageCoverRenderer(); | ||
|
||
return ( | ||
<> | ||
{renderPageCover((pageIndex, { viewport, zoom }) => ( | ||
<div>{pageIndex}</div> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default PDFPageDebugPlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PDFPageDebugPlugin from './PDFPageDebugPlugin'; | ||
|
||
export default PDFPageDebugPlugin; |
65 changes: 65 additions & 0 deletions
65
packages/pdf-viewer/src/plugins/PDFPageDebugPlugin/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import type { Point, ShapeDataType } from '@orca-fe/painter'; | ||
import { isGraphShapeType } from '@orca-fe/painter'; | ||
import { PixelsPerInch } from '../../utils'; | ||
|
||
/** | ||
* 将 GraphShape 的 PDF 坐标转换为 CSS 坐标 | ||
* @param shape | ||
*/ | ||
export function shapePdfToCss(shape: ShapeDataType): ShapeDataType { | ||
if (isGraphShapeType(shape)) { | ||
const newShape = { ...shape }; | ||
if ('x' in newShape && typeof newShape.x === 'number') { | ||
newShape.x *= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('y' in newShape && typeof newShape.y === 'number') { | ||
newShape.y *= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('width' in newShape && typeof newShape.width === 'number') { | ||
newShape.width *= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('height' in newShape && typeof newShape.height === 'number') { | ||
newShape.height *= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('point1' in newShape && Array.isArray(newShape.point1)) { | ||
newShape.point1 = newShape.point1.map(v => v * PixelsPerInch.PDF_TO_CSS_UNITS) as Point; | ||
} | ||
if ('point2' in newShape && Array.isArray(newShape.point2)) { | ||
newShape.point2 = newShape.point2.map(v => v * PixelsPerInch.PDF_TO_CSS_UNITS) as Point; | ||
} | ||
|
||
return newShape; | ||
} | ||
return shape; | ||
} | ||
|
||
/** | ||
* 将 GraphShape 的 CSS 坐标转换为 PDF 坐标 | ||
* @param shape | ||
*/ | ||
export function shapeCssToPdf(shape: ShapeDataType): ShapeDataType { | ||
if (isGraphShapeType(shape)) { | ||
const newShape = { ...shape }; | ||
if ('x' in newShape && typeof newShape.x === 'number') { | ||
newShape.x /= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('y' in newShape && typeof newShape.y === 'number') { | ||
newShape.y /= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('width' in newShape && typeof newShape.width === 'number') { | ||
newShape.width /= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('height' in newShape && typeof newShape.height === 'number') { | ||
newShape.height /= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('point1' in newShape && Array.isArray(newShape.point1)) { | ||
newShape.point1 = newShape.point1.map(v => v / PixelsPerInch.PDF_TO_CSS_UNITS) as Point; | ||
} | ||
if ('point2' in newShape && Array.isArray(newShape.point2)) { | ||
newShape.point2 = newShape.point2.map(v => v / PixelsPerInch.PDF_TO_CSS_UNITS) as Point; | ||
} | ||
|
||
return newShape; | ||
} | ||
return shape; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import type { Point, ShapeDataType } from '@orca-fe/painter'; | ||
import { isGraphShapeType } from '@orca-fe/painter'; | ||
import { PixelsPerInch } from '../../utils'; | ||
|
||
/** | ||
* 将 GraphShape 的 PDF 坐标转换为 CSS 坐标 | ||
* @param shape | ||
*/ | ||
export function shapePdfToCss(shape: ShapeDataType): ShapeDataType { | ||
if (isGraphShapeType(shape)) { | ||
const newShape = { ...shape }; | ||
if ('x' in newShape && typeof newShape.x === 'number') { | ||
newShape.x *= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('y' in newShape && typeof newShape.y === 'number') { | ||
newShape.y *= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('width' in newShape && typeof newShape.width === 'number') { | ||
newShape.width *= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('height' in newShape && typeof newShape.height === 'number') { | ||
newShape.height *= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('point1' in newShape && Array.isArray(newShape.point1)) { | ||
newShape.point1 = newShape.point1.map(v => v * PixelsPerInch.PDF_TO_CSS_UNITS) as Point; | ||
} | ||
if ('point2' in newShape && Array.isArray(newShape.point2)) { | ||
newShape.point2 = newShape.point2.map(v => v * PixelsPerInch.PDF_TO_CSS_UNITS) as Point; | ||
} | ||
|
||
return newShape; | ||
} | ||
return shape; | ||
} | ||
|
||
/** | ||
* 将 GraphShape 的 CSS 坐标转换为 PDF 坐标 | ||
* @param shape | ||
*/ | ||
export function shapeCssToPdf(shape: ShapeDataType): ShapeDataType { | ||
if (isGraphShapeType(shape)) { | ||
const newShape = { ...shape }; | ||
if ('x' in newShape && typeof newShape.x === 'number') { | ||
newShape.x /= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('y' in newShape && typeof newShape.y === 'number') { | ||
newShape.y /= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('width' in newShape && typeof newShape.width === 'number') { | ||
newShape.width /= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('height' in newShape && typeof newShape.height === 'number') { | ||
newShape.height /= PixelsPerInch.PDF_TO_CSS_UNITS; | ||
} | ||
if ('point1' in newShape && Array.isArray(newShape.point1)) { | ||
newShape.point1 = newShape.point1.map(v => v / PixelsPerInch.PDF_TO_CSS_UNITS) as Point; | ||
} | ||
if ('point2' in newShape && Array.isArray(newShape.point2)) { | ||
newShape.point2 = newShape.point2.map(v => v / PixelsPerInch.PDF_TO_CSS_UNITS) as Point; | ||
} | ||
|
||
return newShape; | ||
} | ||
return shape; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.