@pdfme/ui 2.2.0 → 3.0.0-beta.2
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/README.md +33 -35
- package/__mocks__/form-render.js +7 -0
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +42 -4
- package/dist/index.js.map +1 -1
- package/dist/types/Designer.d.ts +3 -0
- package/dist/types/builtInPropPanel.d.ts +3 -0
- package/dist/types/builtInRenderer.d.ts +3 -0
- package/dist/types/class.d.ts +18 -38
- package/dist/types/components/CtlBar/Pager.d.ts +3 -2
- package/dist/types/components/CtlBar/Zoom.d.ts +3 -2
- package/dist/types/components/CtlBar/index.d.ts +3 -2
- package/dist/types/components/Designer/{Main → Canvas}/Guides.d.ts +2 -2
- package/dist/types/components/Designer/Canvas/Mask.d.ts +4 -0
- package/dist/types/components/Designer/Canvas/Moveable.d.ts +37 -0
- package/dist/types/components/Designer/{Main → Canvas}/Selecto.d.ts +2 -1
- package/dist/types/components/Designer/{Main → Canvas}/index.d.ts +3 -6
- package/dist/types/components/Designer/Sidebar/DetailView/AlignWidget.d.ts +4 -0
- package/dist/types/components/Designer/Sidebar/DetailView/WidgetRenderer.d.ts +7 -0
- package/dist/types/components/Designer/Sidebar/DetailView/index.d.ts +5 -4
- package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableContainer.d.ts +3 -2
- package/dist/types/components/Designer/Sidebar/ListView/SelectableSortableItem.d.ts +1 -1
- package/dist/types/components/Designer/Sidebar/ListView/index.d.ts +3 -2
- package/dist/types/components/Designer/Sidebar/index.d.ts +3 -23
- package/dist/types/components/Designer/index.d.ts +6 -107
- package/dist/types/components/Divider.d.ts +2 -1
- package/dist/types/components/ErrorScreen.d.ts +7 -0
- package/dist/types/components/Paper.d.ts +3 -2
- package/dist/types/components/Preview.d.ts +10 -2
- package/dist/types/components/Renderer.d.ts +10 -0
- package/dist/types/components/Root.d.ts +1 -1
- package/dist/types/components/Spinner.d.ts +2 -1
- package/dist/types/components/UnitPager.d.ts +3 -2
- package/dist/types/constants.d.ts +3 -3
- package/dist/types/contexts.d.ts +4 -1
- package/dist/types/helper.d.ts +4 -46
- package/dist/types/hooks.d.ts +2 -2
- package/dist/types/i18n.d.ts +4 -2
- package/dist/types/index.d.ts +1 -4
- package/dist/types/types.d.ts +25 -0
- package/package.json +19 -8
- package/src/Designer.tsx +69 -21
- package/src/Form.tsx +18 -14
- package/src/Viewer.tsx +6 -2
- package/src/builtInPropPanel.ts +5 -0
- package/src/builtInRenderer.ts +5 -0
- package/src/class.ts +25 -2
- package/src/components/CtlBar/index.tsx +4 -7
- package/src/components/Designer/{Main → Canvas}/Guides.tsx +2 -2
- package/src/components/Designer/{Main → Canvas}/Moveable.tsx +23 -19
- package/src/components/Designer/{Main → Canvas}/index.tsx +77 -30
- package/src/components/Designer/Sidebar/DetailView/AlignWidget.tsx +182 -0
- package/src/components/Designer/Sidebar/DetailView/WidgetRenderer.tsx +28 -0
- package/src/components/Designer/Sidebar/DetailView/index.tsx +153 -22
- package/src/components/Designer/Sidebar/ListView/Item.tsx +1 -1
- package/src/components/Designer/Sidebar/ListView/SelectableSortableContainer.tsx +6 -6
- package/src/components/Designer/Sidebar/ListView/index.tsx +1 -4
- package/src/components/Designer/Sidebar/index.tsx +26 -60
- package/src/components/Designer/index.tsx +53 -32
- package/src/components/{Error.tsx → ErrorScreen.tsx} +2 -2
- package/src/components/Paper.tsx +35 -9
- package/src/components/Preview.tsx +48 -50
- package/src/components/Renderer.tsx +90 -0
- package/src/components/Root.tsx +5 -1
- package/src/constants.ts +4 -4
- package/src/contexts.ts +7 -0
- package/src/helper.ts +19 -122
- package/src/hooks.ts +6 -5
- package/src/i18n.ts +48 -11
- package/src/index.ts +1 -76
- package/src/types.ts +36 -0
- package/tsconfig.json +2 -1
- package/webpack.config.js +6 -1
- package/dist/types/components/Designer/Main/Mask.d.ts +0 -3
- package/dist/types/components/Designer/Main/Moveable.d.ts +0 -31
- package/dist/types/components/Designer/Sidebar/DetailView/ExampleInputEditor.d.ts +0 -6
- package/dist/types/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.d.ts +0 -6
- package/dist/types/components/Designer/Sidebar/DetailView/TextPropEditor.d.ts +0 -6
- package/dist/types/components/Designer/Sidebar/DetailView/TypeAndKeyEditor.d.ts +0 -6
- package/dist/types/components/Error.d.ts +0 -6
- package/dist/types/components/Schemas/BarcodeSchema.d.ts +0 -15
- package/dist/types/components/Schemas/ImageSchema.d.ts +0 -15
- package/dist/types/components/Schemas/SchemaUI.d.ts +0 -15
- package/dist/types/components/Schemas/TextSchema.d.ts +0 -28
- package/src/components/Designer/Sidebar/DetailView/ExampleInputEditor.tsx +0 -85
- package/src/components/Designer/Sidebar/DetailView/PositionAndSizeEditor.tsx +0 -275
- package/src/components/Designer/Sidebar/DetailView/TextPropEditor.tsx +0 -357
- package/src/components/Designer/Sidebar/DetailView/TypeAndKeyEditor.tsx +0 -87
- package/src/components/Schemas/BarcodeSchema.tsx +0 -124
- package/src/components/Schemas/ImageSchema.tsx +0 -87
- package/src/components/Schemas/SchemaUI.tsx +0 -62
- package/src/components/Schemas/TextSchema.tsx +0 -175
- /package/src/components/Designer/{Main → Canvas}/Mask.tsx +0 -0
- /package/src/components/Designer/{Main → Canvas}/Selecto.tsx +0 -0
package/dist/types/i18n.d.ts
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
import { Lang } from '@pdfme/common';
|
2
|
-
|
2
|
+
type DictEn = typeof dictEn;
|
3
3
|
declare const dictEn: {
|
4
4
|
cancel: string;
|
5
5
|
field: string;
|
6
6
|
fieldName: string;
|
7
7
|
require: string;
|
8
8
|
uniq: string;
|
9
|
-
inputExample: string;
|
10
9
|
edit: string;
|
11
10
|
plsInputName: string;
|
12
11
|
fieldMustUniq: string;
|
@@ -20,6 +19,9 @@ declare const dictEn: {
|
|
20
19
|
errorBulkUpdateFieldName: string;
|
21
20
|
commitBulkUpdateFieldName: string;
|
22
21
|
bulkUpdateFieldName: string;
|
22
|
+
barColor: string;
|
23
|
+
textColor: string;
|
24
|
+
bgColor: string;
|
23
25
|
};
|
24
26
|
export declare const curriedI18n: (lang: Lang) => (key: keyof DictEn) => string;
|
25
27
|
export {};
|
package/dist/types/index.d.ts
CHANGED
@@ -1,7 +1,4 @@
|
|
1
1
|
import Designer from './Designer';
|
2
2
|
import Form from './Form';
|
3
3
|
import Viewer from './Viewer';
|
4
|
-
|
5
|
-
import type { Lang, Size, Alignment, SchemaType, BarCodeType, TextSchema, ImageSchema, BarcodeSchema, Schema, SchemaForUI, Font, BasePdf, Template, CommonProps, GeneratorOptions, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps } from '@pdfme/common';
|
6
|
-
export { Designer, Viewer, Form, BLANK_PDF, DEFAULT_FONT_VALUE, isTextSchema, isImageSchema, isBarcodeSchema, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, validateBarcodeInput, };
|
7
|
-
export type { Lang, Size, Alignment, SchemaType, BarCodeType, TextSchema, ImageSchema, BarcodeSchema, Schema, SchemaForUI, Font, BasePdf, Template, CommonProps, GeneratorOptions, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, };
|
4
|
+
export { Designer, Viewer, Form };
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { UIRenderProps, SchemaForUI, Size, Schema, ChangeSchemas, PropPanel } from '@pdfme/common';
|
2
|
+
export type SidebarProps = {
|
3
|
+
height: number;
|
4
|
+
hoveringSchemaId: string | null;
|
5
|
+
onChangeHoveringSchemaId: (id: string | null) => void;
|
6
|
+
size: Size;
|
7
|
+
pageSize: Size;
|
8
|
+
activeElements: HTMLElement[];
|
9
|
+
schemas: SchemaForUI[];
|
10
|
+
onSortEnd: (sortedSchemas: SchemaForUI[]) => void;
|
11
|
+
onEdit: (id: string) => void;
|
12
|
+
onEditEnd: () => void;
|
13
|
+
changeSchemas: ChangeSchemas;
|
14
|
+
addSchema: () => void;
|
15
|
+
deselectSchema: () => void;
|
16
|
+
sidebarOpen: boolean;
|
17
|
+
setSidebarOpen: (sidebarOpen: boolean) => void;
|
18
|
+
};
|
19
|
+
export type UIRender = (arg: UIRenderProps<Schema>) => Promise<void>;
|
20
|
+
export interface UIRenderer {
|
21
|
+
[key: string]: UIRender | undefined;
|
22
|
+
}
|
23
|
+
export interface PropPanelObject {
|
24
|
+
[key: string]: PropPanel<Schema> | undefined;
|
25
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/ui",
|
3
|
-
"version": "
|
3
|
+
"version": "3.0.0-beta.2",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -35,36 +35,43 @@
|
|
35
35
|
"test": "jest",
|
36
36
|
"lint:watch": "tsc -w --noEmit",
|
37
37
|
"test:watch": "jest --coverage --watch",
|
38
|
-
"prune": "ts-prune src"
|
38
|
+
"prune": "ts-prune src",
|
39
|
+
"prettier": "prettier --write 'src/**/*.{ts,tsx}'"
|
39
40
|
},
|
40
41
|
"dependencies": {
|
41
|
-
"@dnd-kit/core": "^
|
42
|
-
"@dnd-kit/sortable": "^
|
42
|
+
"@dnd-kit/core": "^6.0.8",
|
43
|
+
"@dnd-kit/sortable": "^7.0.2",
|
43
44
|
"@heroicons/react": "^2.0.13",
|
44
45
|
"@scena/react-guides": "^0.16.0",
|
46
|
+
"antd": "^5.9.4",
|
47
|
+
"form-render": "^2.2.16",
|
45
48
|
"hotkeys-js": "^3.8.7",
|
46
49
|
"pdfjs-dist": "2.12.313",
|
47
|
-
"react": "^
|
48
|
-
"react-dom": "^
|
50
|
+
"react": "^16.14.0",
|
51
|
+
"react-dom": "^16.14.0",
|
49
52
|
"react-moveable": "^0.30.3",
|
50
53
|
"react-selecto": "^1.12.0"
|
51
54
|
},
|
52
55
|
"devDependencies": {
|
53
56
|
"@pdfme/common": "file:../common",
|
57
|
+
"@pdfme/schemas": "file:../schemas",
|
54
58
|
"@testing-library/jest-dom": "^5.16.1",
|
55
59
|
"@testing-library/react": "^12.1.2",
|
56
60
|
"@types/pdfjs-dist": "^2.10.378",
|
57
61
|
"@types/react": "^17.0.52",
|
58
62
|
"@types/react-dom": "^17.0.18",
|
63
|
+
"css-loader": "^6.8.1",
|
64
|
+
"csstype": "^3.1.2",
|
59
65
|
"eslint-plugin-react": "^7.28.0",
|
60
66
|
"eslint-plugin-react-hooks": "^4.3.0",
|
61
67
|
"jest-canvas-mock": "^2.3.1",
|
62
68
|
"process": "^0.11.10",
|
69
|
+
"style-loader": "^3.3.3",
|
63
70
|
"webpack": "^5.75.0",
|
64
71
|
"webpack-cli": "^5.0.1"
|
65
72
|
},
|
66
73
|
"peerDependencies": {
|
67
|
-
"@pdfme/common": "
|
74
|
+
"@pdfme/common": "latest"
|
68
75
|
},
|
69
76
|
"jest": {
|
70
77
|
"setupFiles": [
|
@@ -74,7 +81,11 @@
|
|
74
81
|
"./__tests__/test-helpers.js"
|
75
82
|
],
|
76
83
|
"moduleNameMapper": {
|
77
|
-
"\\.(png)$": "<rootDir>/../../assetsTransformer.js"
|
84
|
+
"\\.(png|css)$": "<rootDir>/../../assetsTransformer.js",
|
85
|
+
"^antd/es/": "antd/lib/",
|
86
|
+
"^form-render/es/": "form-render/lib/",
|
87
|
+
"^rc-picker/es/": "rc-picker/lib/",
|
88
|
+
"^lodash-es$": "lodash"
|
78
89
|
},
|
79
90
|
"resolver": "ts-jest-resolver",
|
80
91
|
"moduleFileExtensions": [
|
package/src/Designer.tsx
CHANGED
@@ -1,20 +1,56 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
|
+
import { ConfigProvider, ThemeConfig } from 'antd';
|
3
4
|
import { Template, DesignerProps, checkDesignerProps, checkTemplate } from '@pdfme/common';
|
5
|
+
import type { PropPanelObject } from './types';
|
4
6
|
import { BaseUIClass } from './class';
|
5
7
|
import { DESTROYED_ERR_MSG } from './constants';
|
6
|
-
import {
|
8
|
+
import {
|
9
|
+
I18nContext,
|
10
|
+
FontContext,
|
11
|
+
RendererRegistry,
|
12
|
+
PropPanelRegistry,
|
13
|
+
OptionsContext,
|
14
|
+
} from './contexts';
|
7
15
|
import DesignerComponent from './components/Designer/index';
|
8
16
|
import { cloneDeep } from './helper';
|
17
|
+
import builtInPropPanel from './builtInPropPanel';
|
18
|
+
|
19
|
+
// TODO Custom Design for UI #243
|
20
|
+
// - https://github.com/pdfme/pdfme/issues/243
|
21
|
+
// - https://ant.design/docs/react/customize-theme
|
22
|
+
const theme: ThemeConfig = {
|
23
|
+
token: {
|
24
|
+
fontSize: 12,
|
25
|
+
},
|
26
|
+
components: {
|
27
|
+
Form: {
|
28
|
+
itemMarginBottom: 8,
|
29
|
+
verticalLabelPadding: '0 0 2px',
|
30
|
+
},
|
31
|
+
},
|
32
|
+
};
|
9
33
|
|
10
34
|
class Designer extends BaseUIClass {
|
11
35
|
private onSaveTemplateCallback?: (template: Template) => void;
|
12
36
|
private onChangeTemplateCallback?: (template: Template) => void;
|
13
37
|
|
38
|
+
private propPanelRegistry: PropPanelObject = builtInPropPanel;
|
39
|
+
|
14
40
|
constructor(props: DesignerProps) {
|
15
41
|
super(props);
|
16
42
|
checkDesignerProps(props);
|
17
43
|
|
44
|
+
const { plugins = {} } = props;
|
45
|
+
|
46
|
+
const customPropPanel = Object.entries(plugins).reduce(
|
47
|
+
(acc, [key, { propPanel }]) => Object.assign(acc, { [key]: propPanel }),
|
48
|
+
{} as PropPanelObject
|
49
|
+
);
|
50
|
+
if (Object.keys(customPropPanel).length > 0) {
|
51
|
+
this.propPanelRegistry = customPropPanel;
|
52
|
+
}
|
53
|
+
|
18
54
|
this.render();
|
19
55
|
}
|
20
56
|
|
@@ -43,29 +79,41 @@ class Designer extends BaseUIClass {
|
|
43
79
|
this.onChangeTemplateCallback = cb;
|
44
80
|
}
|
45
81
|
|
82
|
+
protected getPropPanelRegistry() {
|
83
|
+
return this.propPanelRegistry;
|
84
|
+
}
|
85
|
+
|
46
86
|
protected render() {
|
47
87
|
if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
|
48
88
|
ReactDOM.render(
|
49
|
-
<
|
50
|
-
<
|
51
|
-
<
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
89
|
+
<ConfigProvider theme={theme}>
|
90
|
+
<I18nContext.Provider value={this.getI18n()}>
|
91
|
+
<FontContext.Provider value={this.getFont()}>
|
92
|
+
<RendererRegistry.Provider value={this.getRendererRegistry()}>
|
93
|
+
<PropPanelRegistry.Provider value={this.getPropPanelRegistry()}>
|
94
|
+
<OptionsContext.Provider value={this.getOptions()}>
|
95
|
+
<DesignerComponent
|
96
|
+
template={this.template}
|
97
|
+
onSaveTemplate={(template) => {
|
98
|
+
this.template = template;
|
99
|
+
if (this.onSaveTemplateCallback) {
|
100
|
+
this.onSaveTemplateCallback(template);
|
101
|
+
}
|
102
|
+
}}
|
103
|
+
onChangeTemplate={(template) => {
|
104
|
+
this.template = template;
|
105
|
+
if (this.onChangeTemplateCallback) {
|
106
|
+
this.onChangeTemplateCallback(template);
|
107
|
+
}
|
108
|
+
}}
|
109
|
+
size={this.size}
|
110
|
+
/>
|
111
|
+
</OptionsContext.Provider>
|
112
|
+
</PropPanelRegistry.Provider>
|
113
|
+
</RendererRegistry.Provider>
|
114
|
+
</FontContext.Provider>
|
115
|
+
</I18nContext.Provider>
|
116
|
+
</ConfigProvider>,
|
69
117
|
this.domContainer
|
70
118
|
);
|
71
119
|
}
|
package/src/Form.tsx
CHANGED
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
|
|
3
3
|
import { PreviewProps } from '@pdfme/common';
|
4
4
|
import { PreviewUI } from './class';
|
5
5
|
import { DESTROYED_ERR_MSG } from './constants';
|
6
|
-
import { I18nContext, FontContext } from './contexts';
|
6
|
+
import { I18nContext, FontContext, RendererRegistry, OptionsContext } from './contexts';
|
7
7
|
import Preview from './components/Preview';
|
8
8
|
|
9
9
|
class Form extends PreviewUI {
|
@@ -23,19 +23,23 @@ class Form extends PreviewUI {
|
|
23
23
|
ReactDOM.render(
|
24
24
|
<I18nContext.Provider value={this.getI18n()}>
|
25
25
|
<FontContext.Provider value={this.getFont()}>
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
<RendererRegistry.Provider value={this.getRendererRegistry()}>
|
27
|
+
<OptionsContext.Provider value={this.getOptions()}>
|
28
|
+
<Preview
|
29
|
+
template={this.template}
|
30
|
+
size={this.size}
|
31
|
+
inputs={this.inputs}
|
32
|
+
onChangeInput={(arg: { index: number; value: string; key: string }) => {
|
33
|
+
const { index, value, key } = arg;
|
34
|
+
if (this.onChangeInputCallback) {
|
35
|
+
this.onChangeInputCallback({ index, value, key });
|
36
|
+
}
|
37
|
+
this.inputs[index][key] = value;
|
38
|
+
this.render();
|
39
|
+
}}
|
40
|
+
/>
|
41
|
+
</OptionsContext.Provider>
|
42
|
+
</RendererRegistry.Provider>
|
39
43
|
</FontContext.Provider>
|
40
44
|
</I18nContext.Provider>,
|
41
45
|
this.domContainer
|
package/src/Viewer.tsx
CHANGED
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
|
|
3
3
|
import { PreviewProps } from '@pdfme/common';
|
4
4
|
import { PreviewUI } from './class';
|
5
5
|
import { DESTROYED_ERR_MSG } from './constants';
|
6
|
-
import { I18nContext, FontContext } from './contexts';
|
6
|
+
import { I18nContext, FontContext, RendererRegistry, OptionsContext } from './contexts';
|
7
7
|
import Preview from './components/Preview';
|
8
8
|
|
9
9
|
class Viewer extends PreviewUI {
|
@@ -17,7 +17,11 @@ class Viewer extends PreviewUI {
|
|
17
17
|
ReactDOM.render(
|
18
18
|
<I18nContext.Provider value={this.getI18n()}>
|
19
19
|
<FontContext.Provider value={this.getFont()}>
|
20
|
-
<
|
20
|
+
<RendererRegistry.Provider value={this.getRendererRegistry()}>
|
21
|
+
<OptionsContext.Provider value={this.getOptions()}>
|
22
|
+
<Preview template={this.template} size={this.size} inputs={this.inputs} />
|
23
|
+
</OptionsContext.Provider>
|
24
|
+
</RendererRegistry.Provider>
|
21
25
|
</FontContext.Provider>
|
22
26
|
</I18nContext.Provider>,
|
23
27
|
this.domContainer
|
package/src/class.ts
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
import ReactDOM from 'react-dom';
|
2
|
+
import type { UIRenderer } from './types';
|
2
3
|
import { curriedI18n } from './i18n';
|
3
4
|
import { DESTROYED_ERR_MSG, DEFAULT_LANG } from './constants';
|
4
5
|
import { debounce, flatten, cloneDeep } from './helper';
|
6
|
+
import builtInRenderer from './builtInRenderer';
|
5
7
|
import {
|
6
8
|
Template,
|
7
9
|
Size,
|
@@ -65,6 +67,10 @@ export abstract class BaseUIClass {
|
|
65
67
|
|
66
68
|
private font: Font = getDefaultFont();
|
67
69
|
|
70
|
+
private rendererRegistry: UIRenderer = builtInRenderer;
|
71
|
+
|
72
|
+
private options = {};
|
73
|
+
|
68
74
|
private readonly setSize = debounce(() => {
|
69
75
|
if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
|
70
76
|
this.size = {
|
@@ -79,22 +85,31 @@ export abstract class BaseUIClass {
|
|
79
85
|
constructor(props: UIProps) {
|
80
86
|
checkUIProps(props);
|
81
87
|
|
82
|
-
const { domContainer, template, options } = props;
|
83
|
-
const { lang, font } = options || {};
|
88
|
+
const { domContainer, template, options = {}, plugins = {} } = props;
|
84
89
|
this.domContainer = domContainer;
|
85
90
|
this.template = generateColumnsAndSampledataIfNeeded(cloneDeep(template));
|
91
|
+
this.options = options;
|
86
92
|
this.size = {
|
87
93
|
height: this.domContainer!.clientHeight || window.innerHeight,
|
88
94
|
width: this.domContainer!.clientWidth || window.innerWidth,
|
89
95
|
};
|
90
96
|
this.resizeObserver.observe(this.domContainer!);
|
91
97
|
|
98
|
+
const { lang, font } = options;
|
92
99
|
if (lang) {
|
93
100
|
this.lang = lang;
|
94
101
|
}
|
95
102
|
if (font) {
|
96
103
|
this.font = font;
|
97
104
|
}
|
105
|
+
|
106
|
+
const customRenderer = Object.entries(plugins).reduce(
|
107
|
+
(acc, [key, { ui }]) => Object.assign(acc, { [key]: ui }),
|
108
|
+
{} as UIRenderer
|
109
|
+
);
|
110
|
+
if (Object.keys(customRenderer).length > 0) {
|
111
|
+
this.rendererRegistry = customRenderer;
|
112
|
+
}
|
98
113
|
}
|
99
114
|
|
100
115
|
protected getI18n() {
|
@@ -105,6 +120,14 @@ export abstract class BaseUIClass {
|
|
105
120
|
return this.font;
|
106
121
|
}
|
107
122
|
|
123
|
+
protected getRendererRegistry() {
|
124
|
+
return this.rendererRegistry;
|
125
|
+
}
|
126
|
+
|
127
|
+
protected getOptions() {
|
128
|
+
return this.options;
|
129
|
+
}
|
130
|
+
|
108
131
|
public getTemplate() {
|
109
132
|
if (!this.domContainer) throw Error(DESTROYED_ERR_MSG);
|
110
133
|
|
@@ -18,15 +18,15 @@ const CtlBar = (props: Props) => {
|
|
18
18
|
const { size, pageCursor, pageNum, setPageCursor, zoomLevel, setZoomLevel } = props;
|
19
19
|
const width = pageNum > 1 ? barWidth : barWidth / 2;
|
20
20
|
return (
|
21
|
-
<div style={{ position: 'absolute',
|
21
|
+
<div style={{ position: 'absolute', top: 'auto', bottom: '6%', width: size.width }}>
|
22
22
|
<div
|
23
23
|
style={{
|
24
24
|
display: 'flex',
|
25
25
|
alignItems: 'center',
|
26
26
|
justifyContent: 'center',
|
27
|
-
|
27
|
+
gap: '15px',
|
28
|
+
position: 'relative',
|
28
29
|
zIndex: 1,
|
29
|
-
top: '90%',
|
30
30
|
left: `calc(50% - ${width / 2}px)`,
|
31
31
|
width,
|
32
32
|
background: '#777777e6',
|
@@ -35,10 +35,7 @@ const CtlBar = (props: Props) => {
|
|
35
35
|
}}
|
36
36
|
>
|
37
37
|
{pageNum > 1 && (
|
38
|
-
|
39
|
-
<Pager pageCursor={pageCursor} pageNum={pageNum} setPageCursor={setPageCursor} />
|
40
|
-
<strong style={{ color: 'white', fontSize: '0.9rem', padding: 0 }}>|</strong>
|
41
|
-
</>
|
38
|
+
<Pager pageCursor={pageCursor} pageNum={pageNum} setPageCursor={setPageCursor} />
|
42
39
|
)}
|
43
40
|
<Zoom zoomLevel={zoomLevel} setZoomLevel={setZoomLevel} />
|
44
41
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { Ref } from 'react';
|
2
2
|
import Guides from '@scena/react-guides';
|
3
|
-
import { Size } from '@pdfme/common';
|
4
|
-
import {
|
3
|
+
import { ZOOM, Size } from '@pdfme/common';
|
4
|
+
import { RULER_HEIGHT } from '../../../constants';
|
5
5
|
|
6
6
|
const _Guides = ({
|
7
7
|
paperSize,
|
@@ -1,13 +1,5 @@
|
|
1
1
|
import React, { forwardRef, Ref } from 'react';
|
2
|
-
import Moveable, {
|
3
|
-
OnDrag,
|
4
|
-
OnResize,
|
5
|
-
OnDragEnd,
|
6
|
-
OnDragGroupEnd,
|
7
|
-
OnResizeEnd,
|
8
|
-
OnResizeGroupEnd,
|
9
|
-
OnClick,
|
10
|
-
} from 'react-moveable';
|
2
|
+
import Moveable, { OnDrag, OnResize, OnRotate, OnRotateEnd, OnClick } from 'react-moveable';
|
11
3
|
|
12
4
|
type Props = {
|
13
5
|
target: HTMLElement[];
|
@@ -15,16 +7,16 @@ type Props = {
|
|
15
7
|
horizontalGuidelines: number[];
|
16
8
|
verticalGuidelines: number[];
|
17
9
|
keepRatio: boolean;
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
onDragGroupEnd: (
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
rotatable: boolean;
|
11
|
+
onDrag: ({ target, left, top }: OnDrag) => void;
|
12
|
+
onDragEnd: ({ target }: { target: HTMLElement | SVGElement }) => void;
|
13
|
+
onDragGroupEnd: ({ targets }: { targets: (HTMLElement | SVGElement)[] }) => void;
|
14
|
+
onRotate: ({ target, rotate }: OnRotate) => void;
|
15
|
+
onRotateEnd: ({ target }: OnRotateEnd) => void;
|
16
|
+
onRotateGroupEnd: ({ targets }: { targets: (HTMLElement | SVGElement)[] }) => void;
|
17
|
+
onResize: ({ target, width, height, direction }: OnResize) => void;
|
18
|
+
onResizeEnd: ({ target }: { target: HTMLElement | SVGElement }) => void;
|
19
|
+
onResizeGroupEnd: ({ targets }: { targets: (HTMLElement | SVGElement)[] }) => void;
|
28
20
|
onClick: (e: OnClick) => void;
|
29
21
|
};
|
30
22
|
|
@@ -35,9 +27,13 @@ const _Moveable = (
|
|
35
27
|
horizontalGuidelines,
|
36
28
|
verticalGuidelines,
|
37
29
|
keepRatio,
|
30
|
+
rotatable,
|
38
31
|
onDrag,
|
39
32
|
onDragEnd,
|
40
33
|
onDragGroupEnd,
|
34
|
+
onRotate,
|
35
|
+
onRotateEnd,
|
36
|
+
onRotateGroupEnd,
|
41
37
|
onResize,
|
42
38
|
onResizeEnd,
|
43
39
|
onResizeGroupEnd,
|
@@ -51,8 +47,10 @@ const _Moveable = (
|
|
51
47
|
snappable
|
52
48
|
snapCenter
|
53
49
|
draggable
|
50
|
+
rotatable={rotatable}
|
54
51
|
resizable
|
55
52
|
throttleDrag={1}
|
53
|
+
throttleRotate={1}
|
56
54
|
throttleResize={1}
|
57
55
|
ref={ref}
|
58
56
|
target={target}
|
@@ -60,6 +58,12 @@ const _Moveable = (
|
|
60
58
|
horizontalGuidelines={horizontalGuidelines}
|
61
59
|
verticalGuidelines={verticalGuidelines}
|
62
60
|
keepRatio={keepRatio}
|
61
|
+
onRotate={onRotate}
|
62
|
+
onRotateEnd={onRotateEnd}
|
63
|
+
onRotateGroup={({ events }) => {
|
64
|
+
events.forEach(onRotate);
|
65
|
+
}}
|
66
|
+
onRotateGroupEnd={onRotateGroupEnd}
|
63
67
|
onDrag={onDrag}
|
64
68
|
onDragGroup={({ events }) => {
|
65
69
|
events.forEach(onDrag);
|