@san-siva/blogkit 1.1.36 → 1.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/MermaidViewport.js +24 -5
- package/dist/cjs/components/MermaidViewport.js.map +1 -1
- package/dist/cjs/dynamicComponents/CodeBlockDynamic.js +28 -7
- package/dist/cjs/dynamicComponents/CodeBlockDynamic.js.map +1 -1
- package/dist/cjs/hooks/usePanZoom.js +15 -0
- package/dist/cjs/hooks/usePanZoom.js.map +1 -1
- package/dist/cjs/index.css +1 -1
- package/dist/cjs/index.css.map +1 -1
- package/dist/cjs/styles/CodeBlock.module.scss.js +1 -1
- package/dist/esm/components/MermaidViewport.js +24 -5
- package/dist/esm/components/MermaidViewport.js.map +1 -1
- package/dist/esm/dynamicComponents/CodeBlockDynamic.js +29 -8
- package/dist/esm/dynamicComponents/CodeBlockDynamic.js.map +1 -1
- package/dist/esm/hooks/usePanZoom.js +15 -0
- package/dist/esm/hooks/usePanZoom.js.map +1 -1
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.css.map +1 -1
- package/dist/esm/styles/CodeBlock.module.scss.js +1 -1
- package/dist/types/components/MermaidViewport.d.ts.map +1 -1
- package/dist/types/dynamicComponents/CodeBlockDynamic.d.ts.map +1 -1
- package/dist/types/hooks/usePanZoom.d.ts +1 -0
- package/dist/types/hooks/usePanZoom.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/MermaidViewport.tsx +38 -17
- package/src/dynamicComponents/CodeBlockDynamic.tsx +83 -25
- package/src/hooks/usePanZoom.ts +21 -0
- package/src/styles/CodeBlock.module.scss +98 -0
- package/src/styles/CodeBlock.module.scss.d.ts +6 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var styles = {"margin-top--1":"CodeBlock-module_margin-top--1__mApFz","margin-bottom--2":"CodeBlock-module_margin-bottom--2__fz9IX","code-block":"CodeBlock-module_code-block__ah1AG","code-block__wrapper":"CodeBlock-module_code-block__wrapper__-IUGO","code-block__header":"CodeBlock-module_code-block__header__93VEU","code-block__header__title":"CodeBlock-module_code-block__header__title__xxZgC","code-block__header__copy":"CodeBlock-module_code-block__header__copy__NCWSg","code-block__header__copy--active":"CodeBlock-module_code-block__header__copy--active__5ByAp","code-block--static":"CodeBlock-module_code-block--static__1gBzz"};
|
|
5
|
+
var styles = {"margin-top--1":"CodeBlock-module_margin-top--1__mApFz","margin-bottom--2":"CodeBlock-module_margin-bottom--2__fz9IX","code-block":"CodeBlock-module_code-block__ah1AG","code-block__wrapper":"CodeBlock-module_code-block__wrapper__-IUGO","code-block__header":"CodeBlock-module_code-block__header__93VEU","code-block__header__title":"CodeBlock-module_code-block__header__title__xxZgC","code-block__header__actions":"CodeBlock-module_code-block__header__actions__vClnL","code-block__header__expand":"CodeBlock-module_code-block__header__expand__PBJlP","code-block__header__expand--collapse":"CodeBlock-module_code-block__header__expand--collapse__93Kth","code-block__header__copy":"CodeBlock-module_code-block__header__copy__NCWSg","code-block__header__copy--active":"CodeBlock-module_code-block__header__copy--active__5ByAp","code-block__modal":"CodeBlock-module_code-block__modal__nNvcI","code-block__modal__content":"CodeBlock-module_code-block__modal__content__qWuic","code-block__modal__wrapper":"CodeBlock-module_code-block__modal__wrapper__me6hC","code-block--static":"CodeBlock-module_code-block--static__1gBzz"};
|
|
6
6
|
|
|
7
7
|
exports.default = styles;
|
|
8
8
|
//# sourceMappingURL=CodeBlock.module.scss.js.map
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
2
3
|
|
|
3
|
-
const MermaidViewport = ({ className, draggingClassName, pan, contentRef, contentId, hidden, }) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const MermaidViewport = ({ className, draggingClassName, pan, contentRef, contentId, hidden, }) => {
|
|
5
|
+
const viewportRef = useRef(null);
|
|
6
|
+
const { zoomAtPoint } = pan;
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const el = viewportRef.current;
|
|
9
|
+
if (!el)
|
|
10
|
+
return;
|
|
11
|
+
const onWheel = (e) => {
|
|
12
|
+
if (!e.ctrlKey)
|
|
13
|
+
return;
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
const rect = el.getBoundingClientRect();
|
|
16
|
+
zoomAtPoint(e.deltaY, e.clientX - rect.left, e.clientY - rect.top);
|
|
17
|
+
};
|
|
18
|
+
el.addEventListener('wheel', onWheel, { passive: false });
|
|
19
|
+
return () => el.removeEventListener('wheel', onWheel);
|
|
20
|
+
}, [zoomAtPoint]);
|
|
21
|
+
return (jsx("div", { ref: viewportRef, className: `${className} ${pan.isDragging ? draggingClassName : ''}`, style: hidden ? { display: 'none' } : undefined, onMouseDown: pan.onMouseDown, onMouseMove: pan.onMouseMove, onMouseUp: pan.onMouseUp, onMouseLeave: pan.onMouseUp, children: jsx("div", { style: {
|
|
22
|
+
transform: `translate(${pan.transform.x}px, ${pan.transform.y}px) scale(${pan.transform.scale})`,
|
|
23
|
+
transformOrigin: '0 0',
|
|
24
|
+
transition: pan.isDragging ? 'none' : 'transform 0.1s ease',
|
|
25
|
+
}, children: jsx("div", { ref: contentRef, id: contentId }) }) }));
|
|
26
|
+
};
|
|
8
27
|
|
|
9
28
|
export { MermaidViewport as default };
|
|
10
29
|
//# sourceMappingURL=MermaidViewport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MermaidViewport.js","sources":["../../../src/components/MermaidViewport.tsx"],"sourcesContent":["import type { PanZoom } from '../hooks/usePanZoom';\n\ninterface MermaidViewportProps {\n\tclassName: string;\n\tdraggingClassName: string;\n\tpan: PanZoom;\n\tcontentRef: React.RefObject<HTMLDivElement>;\n\tcontentId?: string;\n\thidden?: boolean;\n}\n\nconst MermaidViewport = ({\n\tclassName,\n\tdraggingClassName,\n\tpan,\n\tcontentRef,\n\tcontentId,\n\thidden,\n}: MermaidViewportProps) => (\n\t<div\n\t\tclassName={`${className} ${pan.isDragging ? draggingClassName : ''}`}\n\t\tstyle={hidden ? { display: 'none' } : undefined}\n\t\tonMouseDown={pan.onMouseDown}\n\t\tonMouseMove={pan.onMouseMove}\n\t\tonMouseUp={pan.onMouseUp}\n\t\tonMouseLeave={pan.onMouseUp}\n\t>\n\t\t<div\n\t\t\tstyle={{\n\t\t\t\ttransform: `translate(${pan.transform.x}px, ${pan.transform.y}px) scale(${pan.transform.scale})`,\n\t\t\t\ttransformOrigin: '0 0',\n\t\t\t\ttransition: pan.isDragging ? 'none' : 'transform 0.1s ease',\n\t\t\t}}\n\t\t>\n\t\t\t<div ref={contentRef} id={contentId} />\n\t\t</div>\n\t</div>\n);\n\nexport default MermaidViewport;\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MermaidViewport.js","sources":["../../../src/components/MermaidViewport.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport type { PanZoom } from '../hooks/usePanZoom';\n\ninterface MermaidViewportProps {\n\tclassName: string;\n\tdraggingClassName: string;\n\tpan: PanZoom;\n\tcontentRef: React.RefObject<HTMLDivElement>;\n\tcontentId?: string;\n\thidden?: boolean;\n}\n\nconst MermaidViewport = ({\n\tclassName,\n\tdraggingClassName,\n\tpan,\n\tcontentRef,\n\tcontentId,\n\thidden,\n}: MermaidViewportProps) => {\n\tconst viewportRef = useRef<HTMLDivElement>(null);\n\tconst { zoomAtPoint } = pan;\n\n\tuseEffect(() => {\n\t\tconst el = viewportRef.current;\n\t\tif (!el) return;\n\t\tconst onWheel = (e: WheelEvent) => {\n\t\t\tif (!e.ctrlKey) return;\n\t\t\te.preventDefault();\n\t\t\tconst rect = el.getBoundingClientRect();\n\t\t\tzoomAtPoint(e.deltaY, e.clientX - rect.left, e.clientY - rect.top);\n\t\t};\n\t\tel.addEventListener('wheel', onWheel, { passive: false });\n\t\treturn () => el.removeEventListener('wheel', onWheel);\n\t}, [zoomAtPoint]);\n\n\treturn (\n\t\t<div\n\t\t\tref={viewportRef}\n\t\t\tclassName={`${className} ${pan.isDragging ? draggingClassName : ''}`}\n\t\t\tstyle={hidden ? { display: 'none' } : undefined}\n\t\t\tonMouseDown={pan.onMouseDown}\n\t\t\tonMouseMove={pan.onMouseMove}\n\t\t\tonMouseUp={pan.onMouseUp}\n\t\t\tonMouseLeave={pan.onMouseUp}\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\ttransform: `translate(${pan.transform.x}px, ${pan.transform.y}px) scale(${pan.transform.scale})`,\n\t\t\t\t\ttransformOrigin: '0 0',\n\t\t\t\t\ttransition: pan.isDragging ? 'none' : 'transform 0.1s ease',\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<div ref={contentRef} id={contentId} />\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default MermaidViewport;\n"],"names":["_jsx"],"mappings":";;;AAaA,MAAM,eAAe,GAAG,CAAC,EACxB,SAAS,EACT,iBAAiB,EACjB,GAAG,EACH,UAAU,EACV,SAAS,EACT,MAAM,GACgB,KAAI;AAC1B,IAAA,MAAM,WAAW,GAAG,MAAM,CAAiB,IAAI,CAAC;AAChD,IAAA,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG;IAE3B,SAAS,CAAC,MAAK;AACd,QAAA,MAAM,EAAE,GAAG,WAAW,CAAC,OAAO;AAC9B,QAAA,IAAI,CAAC,EAAE;YAAE;AACT,QAAA,MAAM,OAAO,GAAG,CAAC,CAAa,KAAI;YACjC,IAAI,CAAC,CAAC,CAAC,OAAO;gBAAE;YAChB,CAAC,CAAC,cAAc,EAAE;AAClB,YAAA,MAAM,IAAI,GAAG,EAAE,CAAC,qBAAqB,EAAE;YACvC,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,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'react/jsx-runtime';
|
|
3
|
-
import { useState } from 'react';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
4
5
|
import { Prism } from 'react-syntax-highlighter';
|
|
5
6
|
import { dracula } from 'react-syntax-highlighter/dist/esm/styles/prism';
|
|
6
7
|
import 'prismjs/themes/prism-tomorrow.css';
|
|
7
8
|
import styles from '../styles/CodeBlock.module.scss.js';
|
|
8
9
|
|
|
9
10
|
const SH = Prism;
|
|
11
|
+
const lineNumberStyle = {
|
|
12
|
+
color: '#95a1b1',
|
|
13
|
+
fontSize: '0.9em',
|
|
14
|
+
paddingRight: '1em',
|
|
15
|
+
marginRight: '8px',
|
|
16
|
+
};
|
|
10
17
|
const CodeBlock = ({ language = 'javascript', code = '', hasMarginUp = false, hasMarginDown = false, }) => {
|
|
11
18
|
const [isCopyMode, setCopyMode] = useState(false);
|
|
19
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
12
20
|
const copyToClipboard = async () => {
|
|
13
21
|
try {
|
|
14
22
|
await navigator.clipboard.writeText(code);
|
|
@@ -21,13 +29,26 @@ const CodeBlock = ({ language = 'javascript', code = '', hasMarginUp = false, ha
|
|
|
21
29
|
console.error('Failed to copy:', error);
|
|
22
30
|
}
|
|
23
31
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!isExpanded)
|
|
34
|
+
return;
|
|
35
|
+
const onKey = (e) => {
|
|
36
|
+
if (e.key === 'Escape')
|
|
37
|
+
setIsExpanded(false);
|
|
38
|
+
};
|
|
39
|
+
const previousOverflow = document.body.style.overflow;
|
|
40
|
+
document.body.style.overflow = 'hidden';
|
|
41
|
+
window.addEventListener('keydown', onKey);
|
|
42
|
+
return () => {
|
|
43
|
+
document.body.style.overflow = previousOverflow;
|
|
44
|
+
window.removeEventListener('keydown', onKey);
|
|
45
|
+
};
|
|
46
|
+
}, [isExpanded]);
|
|
47
|
+
const renderHeader = (expanded) => (jsxs("div", { className: styles['code-block__header'], children: [jsx("div", { className: styles['code-block__header__title'], children: language }), jsxs("div", { className: styles['code-block__header__actions'], children: [jsx("div", { className: `${styles['code-block__header__expand']} ${expanded ? styles['code-block__header__expand--collapse'] : ''}`, onClick: () => setIsExpanded(!expanded), role: "button", "aria-label": expanded ? 'Close fullscreen' : 'Expand to fullscreen', title: expanded ? 'Close fullscreen' : 'Expand to fullscreen' }), jsx("div", { className: `${styles['code-block__header__copy']} ${isCopyMode ? styles['code-block__header__copy--active'] : ''}`, onClick: copyToClipboard, role: "button", "aria-label": "Copy code", title: "Copy code" })] })] }));
|
|
48
|
+
const renderHighlighter = () => (jsx(SH, { language: language, style: dracula, showLineNumbers: true, lineNumberStyle: lineNumberStyle, children: code }));
|
|
49
|
+
return (jsxs("div", { className: `${styles['code-block']} ${hasMarginUp ? styles['margin-top--1'] : ''} ${hasMarginDown ? styles['margin-bottom--2'] : ''}`, children: [renderHeader(false), jsx("div", { className: styles['code-block__wrapper'], children: renderHighlighter() }), isExpanded &&
|
|
50
|
+
typeof document !== 'undefined' &&
|
|
51
|
+
createPortal(jsx("div", { className: styles['code-block__modal'], onClick: () => setIsExpanded(false), role: "dialog", "aria-modal": "true", children: jsxs("div", { className: styles['code-block__modal__content'], onClick: e => e.stopPropagation(), children: [renderHeader(true), jsx("div", { className: styles['code-block__modal__wrapper'], children: renderHighlighter() })] }) }), document.body)] }));
|
|
31
52
|
};
|
|
32
53
|
|
|
33
54
|
export { CodeBlock as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlockDynamic.js","sources":["../../../src/dynamicComponents/CodeBlockDynamic.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { dracula } from 'react-syntax-highlighter/dist/esm/styles/prism';\n\nimport 'prismjs/themes/prism-tomorrow.css';\n\nconst SH = SyntaxHighlighter as any;\n\nimport styles from '../styles/CodeBlock.module.scss';\n\ninterface Properties {\n\thasMarginUp?: boolean;\n\thasMarginDown?: boolean;\n\tlanguage?: string;\n\tcode?: string;\n}\n\nconst CodeBlock = ({\n\tlanguage = 'javascript',\n\tcode = '',\n\thasMarginUp = false,\n\thasMarginDown = false,\n}: Properties) => {\n\tconst [isCopyMode, setCopyMode] = useState(false);\n\n\tconst copyToClipboard = async () => {\n\t\ttry {\n\t\t\tawait navigator.clipboard.writeText(code);\n\t\t\tsetCopyMode(true);\n\t\t\tsetTimeout(() => {\n\t\t\t\tsetCopyMode(false);\n\t\t\t}, 1000);\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to copy:', error);\n\t\t}\n\t};\n\n\tconst
|
|
1
|
+
{"version":3,"file":"CodeBlockDynamic.js","sources":["../../../src/dynamicComponents/CodeBlockDynamic.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';\nimport { dracula } from 'react-syntax-highlighter/dist/esm/styles/prism';\n\nimport 'prismjs/themes/prism-tomorrow.css';\n\nconst SH = SyntaxHighlighter as any;\n\nimport styles from '../styles/CodeBlock.module.scss';\n\ninterface Properties {\n\thasMarginUp?: boolean;\n\thasMarginDown?: boolean;\n\tlanguage?: string;\n\tcode?: string;\n}\n\nconst lineNumberStyle = {\n\tcolor: '#95a1b1',\n\tfontSize: '0.9em',\n\tpaddingRight: '1em',\n\tmarginRight: '8px',\n};\n\nconst CodeBlock = ({\n\tlanguage = 'javascript',\n\tcode = '',\n\thasMarginUp = false,\n\thasMarginDown = false,\n}: Properties) => {\n\tconst [isCopyMode, setCopyMode] = useState(false);\n\tconst [isExpanded, setIsExpanded] = useState(false);\n\n\tconst copyToClipboard = async () => {\n\t\ttry {\n\t\t\tawait navigator.clipboard.writeText(code);\n\t\t\tsetCopyMode(true);\n\t\t\tsetTimeout(() => {\n\t\t\t\tsetCopyMode(false);\n\t\t\t}, 1000);\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to copy:', error);\n\t\t}\n\t};\n\n\tuseEffect(() => {\n\t\tif (!isExpanded) return;\n\t\tconst onKey = (e: KeyboardEvent) => {\n\t\t\tif (e.key === 'Escape') setIsExpanded(false);\n\t\t};\n\t\tconst previousOverflow = document.body.style.overflow;\n\t\tdocument.body.style.overflow = 'hidden';\n\t\twindow.addEventListener('keydown', onKey);\n\t\treturn () => {\n\t\t\tdocument.body.style.overflow = previousOverflow;\n\t\t\twindow.removeEventListener('keydown', onKey);\n\t\t};\n\t}, [isExpanded]);\n\n\tconst renderHeader = (expanded: boolean) => (\n\t\t<div className={styles['code-block__header']}>\n\t\t\t<div className={styles['code-block__header__title']}>{language}</div>\n\t\t\t<div className={styles['code-block__header__actions']}>\n\t\t\t\t<div\n\t\t\t\t\tclassName={`${styles['code-block__header__expand']} ${\n\t\t\t\t\t\texpanded ? styles['code-block__header__expand--collapse'] : ''\n\t\t\t\t\t}`}\n\t\t\t\t\tonClick={() => setIsExpanded(!expanded)}\n\t\t\t\t\trole=\"button\"\n\t\t\t\t\taria-label={expanded ? 'Close fullscreen' : 'Expand to fullscreen'}\n\t\t\t\t\ttitle={expanded ? 'Close fullscreen' : 'Expand to fullscreen'}\n\t\t\t\t/>\n\t\t\t\t<div\n\t\t\t\t\tclassName={`${styles['code-block__header__copy']} ${\n\t\t\t\t\t\tisCopyMode ? styles['code-block__header__copy--active'] : ''\n\t\t\t\t\t}`}\n\t\t\t\t\tonClick={copyToClipboard}\n\t\t\t\t\trole=\"button\"\n\t\t\t\t\taria-label=\"Copy code\"\n\t\t\t\t\ttitle=\"Copy code\"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n\n\tconst renderHighlighter = () => (\n\t\t<SH\n\t\t\tlanguage={language}\n\t\t\tstyle={dracula}\n\t\t\tshowLineNumbers\n\t\t\tlineNumberStyle={lineNumberStyle}\n\t\t>\n\t\t\t{code}\n\t\t</SH>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={`${styles['code-block']} ${hasMarginUp ? styles['margin-top--1'] : ''} ${\n\t\t\t\thasMarginDown ? styles['margin-bottom--2'] : ''\n\t\t\t}`}\n\t\t>\n\t\t\t{renderHeader(false)}\n\t\t\t<div className={styles['code-block__wrapper']}>{renderHighlighter()}</div>\n\n\t\t\t{isExpanded &&\n\t\t\t\ttypeof document !== 'undefined' &&\n\t\t\t\tcreatePortal(\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={styles['code-block__modal']}\n\t\t\t\t\t\tonClick={() => setIsExpanded(false)}\n\t\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\t\taria-modal=\"true\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={styles['code-block__modal__content']}\n\t\t\t\t\t\t\tonClick={e => e.stopPropagation()}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{renderHeader(true)}\n\t\t\t\t\t\t\t<div className={styles['code-block__modal__wrapper']}>\n\t\t\t\t\t\t\t\t{renderHighlighter()}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>,\n\t\t\t\t\tdocument.body\n\t\t\t\t)}\n\t\t</div>\n\t);\n};\n\nexport default CodeBlock;\n"],"names":["SyntaxHighlighter","_jsxs","_jsx"],"mappings":";;;;;;;;AASA,MAAM,EAAE,GAAGA,KAAwB;AAWnC,MAAM,eAAe,GAAG;AACvB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,QAAQ,EAAE,OAAO;AACjB,IAAA,YAAY,EAAE,KAAK;AACnB,IAAA,WAAW,EAAE,KAAK;CAClB;AAED,MAAM,SAAS,GAAG,CAAC,EAClB,QAAQ,GAAG,YAAY,EACvB,IAAI,GAAG,EAAE,EACT,WAAW,GAAG,KAAK,EACnB,aAAa,GAAG,KAAK,GACT,KAAI;IAChB,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AA,EAC/E,aAAa,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAC9C,CAAA,CAAE,EAAA,QAAA,EAAA,CAED,YAAY,CAAC,KAAK,CAAC,EACpBC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,qBAAqB,CAAC,EAAA,QAAA,EAAG,iBAAiB,EAAE,EAAA,CAAO,EAEzE,UAAU;gBACV,OAAO,QAAQ,KAAK,WAAW;AAC/B,gBAAA,YAAY,CACXA,GAAA,CAAA,KAAA,EAAA,EACC,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,EACtC,OAAO,EAAE,MAAM,aAAa,CAAC,KAAK,CAAC,EACnC,IAAI,EAAC,QAAQ,gBACF,MAAM,EAAA,QAAA,EAEjBD,IAAA,CAAA,KAAA,EAAA,EACC,SAAS,EAAE,MAAM,CAAC,4BAA4B,CAAC,EAC/C,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAA,QAAA,EAAA,CAEhC,YAAY,CAAC,IAAI,CAAC,EACnBC,aAAK,SAAS,EAAE,MAAM,CAAC,4BAA4B,CAAC,EAAA,QAAA,EAClD,iBAAiB,EAAE,EAAA,CACf,CAAA,EAAA,CACD,EAAA,CACD,EACN,QAAQ,CAAC,IAAI,CACb,CAAA,EAAA,CACG;AAER;;;;"}
|
|
@@ -56,6 +56,20 @@ const usePanZoom = ({ initialTransform = DEFAULT_INITIAL_TRANSFORM, minScale = D
|
|
|
56
56
|
scale: Math.max(prev.scale * (1 - zoomStep), minScale),
|
|
57
57
|
}));
|
|
58
58
|
}, [apply, zoomStep, minScale]);
|
|
59
|
+
const zoomAtPoint = useCallback((deltaY, pointX, pointY) => {
|
|
60
|
+
apply(prev => {
|
|
61
|
+
const factor = deltaY < 0 ? 1 + zoomStep : 1 - zoomStep;
|
|
62
|
+
const newScale = Math.max(minScale, Math.min(maxScale, prev.scale * factor));
|
|
63
|
+
if (newScale === prev.scale)
|
|
64
|
+
return prev;
|
|
65
|
+
const ratio = newScale / prev.scale;
|
|
66
|
+
return {
|
|
67
|
+
scale: newScale,
|
|
68
|
+
x: pointX - (pointX - prev.x) * ratio,
|
|
69
|
+
y: pointY - (pointY - prev.y) * ratio,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}, [apply, zoomStep, minScale, maxScale]);
|
|
59
73
|
const reset = useCallback(() => {
|
|
60
74
|
apply(() => initialTransform);
|
|
61
75
|
}, [apply, initialTransform]);
|
|
@@ -67,6 +81,7 @@ const usePanZoom = ({ initialTransform = DEFAULT_INITIAL_TRANSFORM, minScale = D
|
|
|
67
81
|
onMouseUp,
|
|
68
82
|
zoomIn,
|
|
69
83
|
zoomOut,
|
|
84
|
+
zoomAtPoint,
|
|
70
85
|
reset,
|
|
71
86
|
};
|
|
72
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePanZoom.js","sources":["../../../src/hooks/usePanZoom.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nexport interface Transform {\n\tscale: number;\n\tx: number;\n\ty: number;\n}\n\nexport interface UsePanZoomOptions {\n\tinitialTransform?: Transform;\n\tminScale?: number;\n\tmaxScale?: number;\n\tzoomStep?: number;\n}\n\nconst DEFAULT_INITIAL_TRANSFORM: Transform = { scale: 1, x: 0, y: 0 };\nconst DEFAULT_MIN_SCALE = 0.5;\nconst DEFAULT_MAX_SCALE = 4;\nconst DEFAULT_ZOOM_STEP = 0.15;\n\nexport const usePanZoom = ({\n\tinitialTransform = DEFAULT_INITIAL_TRANSFORM,\n\tminScale = DEFAULT_MIN_SCALE,\n\tmaxScale = DEFAULT_MAX_SCALE,\n\tzoomStep = DEFAULT_ZOOM_STEP,\n}: UsePanZoomOptions = {}) => {\n\tconst [transform, setTransform] = useState<Transform>(initialTransform);\n\tconst [isDragging, setIsDragging] = useState(false);\n\tconst transformRef = useRef<Transform>(initialTransform);\n\tconst isDraggingRef = useRef(false);\n\tconst dragStart = useRef({\n\t\tmouseX: 0,\n\t\tmouseY: 0,\n\t\ttransformX: 0,\n\t\ttransformY: 0,\n\t});\n\n\tconst apply = useCallback((updater: (prev: Transform) => Transform) => {\n\t\tconst next = updater(transformRef.current);\n\t\ttransformRef.current = next;\n\t\tsetTransform(next);\n\t}, []);\n\n\tconst onMouseDown = useCallback((e: React.MouseEvent) => {\n\t\te.preventDefault();\n\t\tisDraggingRef.current = true;\n\t\tsetIsDragging(true);\n\t\tdragStart.current = {\n\t\t\tmouseX: e.clientX,\n\t\t\tmouseY: e.clientY,\n\t\t\ttransformX: transformRef.current.x,\n\t\t\ttransformY: transformRef.current.y,\n\t\t};\n\t}, []);\n\n\tconst onMouseMove = useCallback(\n\t\t(e: React.MouseEvent) => {\n\t\t\tif (!isDraggingRef.current) return;\n\t\t\tapply(prev => ({\n\t\t\t\t...prev,\n\t\t\t\tx:\n\t\t\t\t\tdragStart.current.transformX + (e.clientX - dragStart.current.mouseX),\n\t\t\t\ty:\n\t\t\t\t\tdragStart.current.transformY + (e.clientY - dragStart.current.mouseY),\n\t\t\t}));\n\t\t},\n\t\t[apply]\n\t);\n\n\tconst onMouseUp = useCallback(() => {\n\t\tisDraggingRef.current = false;\n\t\tsetIsDragging(false);\n\t}, []);\n\n\tconst zoomIn = useCallback(() => {\n\t\tapply(prev => ({\n\t\t\t...prev,\n\t\t\tscale: Math.min(prev.scale * (1 + zoomStep), maxScale),\n\t\t}));\n\t}, [apply, zoomStep, maxScale]);\n\n\tconst zoomOut = useCallback(() => {\n\t\tapply(prev => ({\n\t\t\t...prev,\n\t\t\tscale: Math.max(prev.scale * (1 - zoomStep), minScale),\n\t\t}));\n\t}, [apply, zoomStep, minScale]);\n\n\tconst reset = useCallback(() => {\n\t\tapply(() => initialTransform);\n\t}, [apply, initialTransform]);\n\n\treturn {\n\t\ttransform,\n\t\tisDragging,\n\t\tonMouseDown,\n\t\tonMouseMove,\n\t\tonMouseUp,\n\t\tzoomIn,\n\t\tzoomOut,\n\t\tre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AM,OAAO,GAAG,WAAW,CAAC,MAAK;AAChC,QAAA,KAAK,CAAC,IAAI,KAAK;AACd,YAAA,GAAG,IAAI;AACP,YAAA,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,EAAE,QAAQ,CAAC;AACtD,SAAA,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"usePanZoom.js","sources":["../../../src/hooks/usePanZoom.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\n\nexport interface Transform {\n\tscale: number;\n\tx: number;\n\ty: number;\n}\n\nexport interface UsePanZoomOptions {\n\tinitialTransform?: Transform;\n\tminScale?: number;\n\tmaxScale?: number;\n\tzoomStep?: number;\n}\n\nconst DEFAULT_INITIAL_TRANSFORM: Transform = { scale: 1, x: 0, y: 0 };\nconst DEFAULT_MIN_SCALE = 0.5;\nconst DEFAULT_MAX_SCALE = 4;\nconst DEFAULT_ZOOM_STEP = 0.15;\n\nexport const usePanZoom = ({\n\tinitialTransform = DEFAULT_INITIAL_TRANSFORM,\n\tminScale = DEFAULT_MIN_SCALE,\n\tmaxScale = DEFAULT_MAX_SCALE,\n\tzoomStep = DEFAULT_ZOOM_STEP,\n}: UsePanZoomOptions = {}) => {\n\tconst [transform, setTransform] = useState<Transform>(initialTransform);\n\tconst [isDragging, setIsDragging] = useState(false);\n\tconst transformRef = useRef<Transform>(initialTransform);\n\tconst isDraggingRef = useRef(false);\n\tconst dragStart = useRef({\n\t\tmouseX: 0,\n\t\tmouseY: 0,\n\t\ttransformX: 0,\n\t\ttransformY: 0,\n\t});\n\n\tconst apply = useCallback((updater: (prev: Transform) => Transform) => {\n\t\tconst next = updater(transformRef.current);\n\t\ttransformRef.current = next;\n\t\tsetTransform(next);\n\t}, []);\n\n\tconst onMouseDown = useCallback((e: React.MouseEvent) => {\n\t\te.preventDefault();\n\t\tisDraggingRef.current = true;\n\t\tsetIsDragging(true);\n\t\tdragStart.current = {\n\t\t\tmouseX: e.clientX,\n\t\t\tmouseY: e.clientY,\n\t\t\ttransformX: transformRef.current.x,\n\t\t\ttransformY: transformRef.current.y,\n\t\t};\n\t}, []);\n\n\tconst onMouseMove = useCallback(\n\t\t(e: React.MouseEvent) => {\n\t\t\tif (!isDraggingRef.current) return;\n\t\t\tapply(prev => ({\n\t\t\t\t...prev,\n\t\t\t\tx:\n\t\t\t\t\tdragStart.current.transformX + (e.clientX - dragStart.current.mouseX),\n\t\t\t\ty:\n\t\t\t\t\tdragStart.current.transformY + (e.clientY - dragStart.current.mouseY),\n\t\t\t}));\n\t\t},\n\t\t[apply]\n\t);\n\n\tconst onMouseUp = useCallback(() => {\n\t\tisDraggingRef.current = false;\n\t\tsetIsDragging(false);\n\t}, []);\n\n\tconst zoomIn = useCallback(() => {\n\t\tapply(prev => ({\n\t\t\t...prev,\n\t\t\tscale: Math.min(prev.scale * (1 + zoomStep), maxScale),\n\t\t}));\n\t}, [apply, zoomStep, maxScale]);\n\n\tconst zoomOut = useCallback(() => {\n\t\tapply(prev => ({\n\t\t\t...prev,\n\t\t\tscale: Math.max(prev.scale * (1 - zoomStep), minScale),\n\t\t}));\n\t}, [apply, zoomStep, minScale]);\n\n\tconst zoomAtPoint = useCallback(\n\t\t(deltaY: number, pointX: number, pointY: number) => {\n\t\t\tapply(prev => {\n\t\t\t\tconst factor = deltaY < 0 ? 1 + zoomStep : 1 - zoomStep;\n\t\t\t\tconst newScale = Math.max(\n\t\t\t\t\tminScale,\n\t\t\t\t\tMath.min(maxScale, prev.scale * factor)\n\t\t\t\t);\n\t\t\t\tif (newScale === prev.scale) return prev;\n\t\t\t\tconst ratio = newScale / prev.scale;\n\t\t\t\treturn {\n\t\t\t\t\tscale: newScale,\n\t\t\t\t\tx: pointX - (pointX - prev.x) * ratio,\n\t\t\t\t\ty: pointY - (pointY - prev.y) * ratio,\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\t[apply, zoomStep, minScale, maxScale]\n\t);\n\n\tconst reset = useCallback(() => {\n\t\tapply(() => initialTransform);\n\t}, [apply, initialTransform]);\n\n\treturn {\n\t\ttransform,\n\t\tisDragging,\n\t\tonMouseDown,\n\t\tonMouseMove,\n\t\tonMouseUp,\n\t\tzoomIn,\n\t\tzoomOut,\n\t\tzoomAtPoint,\n\t\treset,\n\t};\n};\n\nexport type PanZoom = ReturnType<typeof usePanZoom>;\n"],"names":[],"mappings":";;AAeA,MAAM,yBAAyB,GAAc,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;AACrE,MAAM,iBAAiB,GAAG,GAAG;AAC7B,MAAM,iBAAiB,GAAG,CAAC;AAC3B,MAAM,iBAAiB,GAAG,IAAI;AAEvB,MAAM,UAAU,GAAG,CAAC,EAC1B,gBAAgB,GAAG,yBAAyB,EAC5C,QAAQ,GAAG,iBAAiB,EAC5B,QAAQ,GAAG,iBAAiB,EAC5B,QAAQ,GAAG,iBAAiB,GAAA,GACN,EAAE,KAAI;IAC5B,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAY,gBAAgB,CAAC;IACvE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACnD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAY,gBAAgB,CAAC;AACxD,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC;IACnC,MAAM,SAAS,GAAG,MAAM,CAAC;AACxB,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,UAAU,EAAE,CAAC;AACb,QAAA,UAAU,EAAE,CAAC;AACb,KAAA,CAAC;AAEF,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,OAAuC,KAAI;QACrE,MAAM,IAAI,GAAG,OAAO,CAAC,Y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