@pdfme/ui 5.2.0 → 5.2.1

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.
@@ -3,5 +3,6 @@ export declare const DESTROYED_ERR_MSG = "[@pdfme/ui] this instance is already d
3
3
  export declare const SELECTABLE_CLASSNAME = "selectable";
4
4
  export declare const RULER_HEIGHT = 30;
5
5
  export declare const PAGE_GAP = 10;
6
+ export declare const LEFT_SIDEBAR_WIDTH = 45;
6
7
  export declare const RIGHT_SIDEBAR_WIDTH = 400;
7
8
  export declare const BACKGROUND_COLOR = "rgb(74, 74, 74)";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -8,9 +8,11 @@ import { theme, Button } from 'antd';
8
8
  import { useDraggable } from '@dnd-kit/core';
9
9
  import { CSS } from "@dnd-kit/utilities";
10
10
  import Renderer from '../Renderer';
11
+ import { LEFT_SIDEBAR_WIDTH } from '../../constants';
11
12
  import { PluginsRegistry } from '../../contexts';
12
13
  import PluginIcon from "./PluginIcon";
13
14
 
15
+
14
16
  const Draggable = (props: { plugin: Plugin<any>, scale: number, basePdf: BasePdf, children: React.ReactNode }) => {
15
17
  const { scale, basePdf, plugin } = props;
16
18
  const { token } = theme.useToken();
@@ -67,7 +69,7 @@ const LeftSidebar = ({ height, scale, basePdf }: { height: number, scale: number
67
69
  position: 'absolute',
68
70
  zIndex: 1,
69
71
  height,
70
- width: 45,
72
+ width: LEFT_SIDEBAR_WIDTH,
71
73
  background: token.colorBgLayout,
72
74
  textAlign: 'center',
73
75
  overflow: isDragging ? 'visible' : 'auto',
@@ -15,7 +15,7 @@ import { DndContext } from '@dnd-kit/core';
15
15
  import RightSidebar from './RightSidebar/index';
16
16
  import LeftSidebar from './LeftSidebar';
17
17
  import Canvas from './Canvas/index';
18
- import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH } from '../../constants';
18
+ import { RULER_HEIGHT, RIGHT_SIDEBAR_WIDTH, LEFT_SIDEBAR_WIDTH } from '../../constants';
19
19
  import { I18nContext, OptionsContext, PluginsRegistry } from '../../contexts';
20
20
  import {
21
21
  schemasList2template,
@@ -235,8 +235,9 @@ const TemplateEditor = ({
235
235
  void updateTemplate(template);
236
236
  }
237
237
 
238
- const sizeExcSidebar = {
239
- width: sidebarOpen ? size.width - RIGHT_SIDEBAR_WIDTH : size.width,
238
+ const canvasWidth = size.width - LEFT_SIDEBAR_WIDTH;
239
+ const sizeExcSidebars = {
240
+ width: sidebarOpen ? canvasWidth - RIGHT_SIDEBAR_WIDTH : canvasWidth,
240
241
  height: size.height,
241
242
  };
242
243
 
@@ -271,66 +272,69 @@ const TemplateEditor = ({
271
272
  }}
272
273
  onDragStart={onEditEnd}
273
274
  >
274
- <CtlBar
275
- size={sizeExcSidebar}
276
- pageCursor={pageCursor}
277
- pageNum={schemasList.length}
278
- setPageCursor={(p) => {
279
- if (!canvasRef.current) return;
280
- canvasRef.current.scrollTop = getPagesScrollTopByIndex(pageSizes, p, scale);
281
- setPageCursor(p);
282
- onEditEnd();
283
- }}
284
- zoomLevel={zoomLevel}
285
- setZoomLevel={setZoomLevel}
286
- {...pageManipulation}
287
- />
288
275
  <LeftSidebar
289
276
  height={canvasRef.current ? canvasRef.current.clientHeight : 0}
290
277
  scale={scale}
291
278
  basePdf={template.basePdf}
292
279
  />
293
280
 
294
- <RightSidebar
295
- hoveringSchemaId={hoveringSchemaId}
296
- onChangeHoveringSchemaId={onChangeHoveringSchemaId}
297
- height={canvasRef.current ? canvasRef.current.clientHeight : 0}
298
- size={size}
299
- pageSize={pageSizes[pageCursor] ?? []}
300
- activeElements={activeElements}
301
- schemasList={schemasList}
302
- schemas={schemasList[pageCursor] ?? []}
303
- changeSchemas={changeSchemas}
304
- onSortEnd={onSortEnd}
305
- onEdit={id => {
306
- const editingElem = document.getElementById(id);
307
- editingElem && onEdit([editingElem]);
308
- }}
309
- onEditEnd={onEditEnd}
310
- deselectSchema={onEditEnd}
311
- sidebarOpen={sidebarOpen}
312
- setSidebarOpen={setSidebarOpen}
313
- />
314
-
315
- <Canvas
316
- ref={canvasRef}
317
- paperRefs={paperRefs}
318
- basePdf={template.basePdf}
319
- hoveringSchemaId={hoveringSchemaId}
320
- onChangeHoveringSchemaId={onChangeHoveringSchemaId}
321
- height={size.height - RULER_HEIGHT * ZOOM}
322
- pageCursor={pageCursor}
323
- scale={scale}
324
- size={sizeExcSidebar}
325
- pageSizes={pageSizes}
326
- backgrounds={backgrounds}
327
- activeElements={activeElements}
328
- schemasList={schemasList}
329
- changeSchemas={changeSchemas}
330
- removeSchemas={removeSchemas}
331
- sidebarOpen={sidebarOpen}
332
- onEdit={onEdit}
333
- />
281
+ <div style={{ position: 'absolute', width: canvasWidth, marginLeft: LEFT_SIDEBAR_WIDTH }}>
282
+ <CtlBar
283
+ size={sizeExcSidebars}
284
+ pageCursor={pageCursor}
285
+ pageNum={schemasList.length}
286
+ setPageCursor={(p) => {
287
+ if (!canvasRef.current) return;
288
+ canvasRef.current.scrollTop = getPagesScrollTopByIndex(pageSizes, p, scale);
289
+ setPageCursor(p);
290
+ onEditEnd();
291
+ }}
292
+ zoomLevel={zoomLevel}
293
+ setZoomLevel={setZoomLevel}
294
+ {...pageManipulation}
295
+ />
296
+
297
+ <RightSidebar
298
+ hoveringSchemaId={hoveringSchemaId}
299
+ onChangeHoveringSchemaId={onChangeHoveringSchemaId}
300
+ height={canvasRef.current ? canvasRef.current.clientHeight : 0}
301
+ size={size}
302
+ pageSize={pageSizes[pageCursor] ?? []}
303
+ activeElements={activeElements}
304
+ schemasList={schemasList}
305
+ schemas={schemasList[pageCursor] ?? []}
306
+ changeSchemas={changeSchemas}
307
+ onSortEnd={onSortEnd}
308
+ onEdit={id => {
309
+ const editingElem = document.getElementById(id);
310
+ editingElem && onEdit([editingElem]);
311
+ }}
312
+ onEditEnd={onEditEnd}
313
+ deselectSchema={onEditEnd}
314
+ sidebarOpen={sidebarOpen}
315
+ setSidebarOpen={setSidebarOpen}
316
+ />
317
+
318
+ <Canvas
319
+ ref={canvasRef}
320
+ paperRefs={paperRefs}
321
+ basePdf={template.basePdf}
322
+ hoveringSchemaId={hoveringSchemaId}
323
+ onChangeHoveringSchemaId={onChangeHoveringSchemaId}
324
+ height={size.height - RULER_HEIGHT * ZOOM}
325
+ pageCursor={pageCursor}
326
+ scale={scale}
327
+ size={sizeExcSidebars}
328
+ pageSizes={pageSizes}
329
+ backgrounds={backgrounds}
330
+ activeElements={activeElements}
331
+ schemasList={schemasList}
332
+ changeSchemas={changeSchemas}
333
+ removeSchemas={removeSchemas}
334
+ sidebarOpen={sidebarOpen}
335
+ onEdit={onEdit}
336
+ />
337
+ </div>
334
338
  </DndContext>
335
339
  </Root>
336
340
  );
package/src/constants.ts CHANGED
@@ -8,6 +8,8 @@ export const RULER_HEIGHT = 30;
8
8
 
9
9
  export const PAGE_GAP = 10;
10
10
 
11
+ export const LEFT_SIDEBAR_WIDTH = 45;
12
+
11
13
  export const RIGHT_SIDEBAR_WIDTH = 400;
12
14
 
13
15
  export const BACKGROUND_COLOR = 'rgb(74, 74, 74)';