@monolith-forensics/monolith-ui 2.0.0 → 2.1.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.
- package/dist/FileViewer/FileViewer.d.ts +1 -0
- package/dist/FileViewer/FileViewer.js +2 -2
- package/dist/RichTextEditor/Enums/Fonts.d.ts +2 -1
- package/dist/RichTextEditor/Enums/Fonts.js +2 -1
- package/dist/RichTextEditor/RichTextEditor.js +4 -0
- package/package.json +1 -1
- package/dist/QueryFilter/DefaultOperators.d.ts +0 -76
- package/dist/QueryFilter/DefaultOperators.js +0 -21
- package/dist/QueryFilter/types.d.ts +0 -66
- package/dist/QueryFilter/types.js +0 -1
- package/dist/RichTextEditor/Extensions/BubbleMenuExtension.d.ts +0 -7
- package/dist/RichTextEditor/Extensions/BubbleMenuExtension.js +0 -157
- package/dist/Table/Utils/resizeHandler.d.ts +0 -3
- package/dist/Table/Utils/resizeHandler.js +0 -84
|
@@ -171,7 +171,7 @@ const resolveViewerType = (file) => {
|
|
|
171
171
|
}
|
|
172
172
|
return ViewerTypes.Code;
|
|
173
173
|
};
|
|
174
|
-
export const FileViewer = ({ file, open, isPending, onClose }) => {
|
|
174
|
+
export const FileViewer = ({ file, open, isPending, onClose, onDownload }) => {
|
|
175
175
|
const [zoomFactor, setZoomFactor] = useState(1);
|
|
176
176
|
const [rotation, setRotation] = useState(0);
|
|
177
177
|
useEffect(() => {
|
|
@@ -194,7 +194,7 @@ export const FileViewer = ({ file, open, isPending, onClose }) => {
|
|
|
194
194
|
return (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsxs(StyledContainer, { className: "mfui-FileViewer", children: [_jsxs(StyledMenu, { className: "FileViewer-menu", children: [_jsx(Button, { variant: "text", onClick: () => {
|
|
195
195
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
196
196
|
resetViewerState();
|
|
197
|
-
}, children: _jsx(XIcon, { size: 18 }) }), _jsx("div", { children: file.name }), _jsxs(StyledActionsMenu, { children: [ZoomableViewerTypes.includes(viewerType) && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "text", disabled: !file.url, "aria-label": "Zoom in", title: "Zoom in", onClick: () => setZoomFactor((prev) => prev * 1.1), children: _jsx(ZoomInIcon, { size: 18 }) }), _jsx(Button, { variant: "text", disabled: !file.url, "aria-label": "Zoom out", title: "Zoom out", onClick: () => setZoomFactor((prev) => prev * 0.9), children: _jsx(ZoomOutIcon, { size: 18 }) })] })), RotatableViewerTypes.includes(viewerType) && (_jsx(Button, { variant: "text", disabled: !file.url, "aria-label": "Rotate image", title: "Rotate image", onClick: () => setRotation((prev) => (prev + 90) % 360), children: _jsx(RotateCwIcon, { size: 18 }) })), _jsx("a", { href: file.url, download: file.name, style: { pointerEvents: !file.url ? "none" : "auto" }, children: _jsx(Button, { variant: "text", disabled: !file.url, children: _jsx(DownloadIcon, { size: 18 }) }) })] })] }), file.url ? (_jsxs(StyledInnerContainer, { onClick: handleBackgroundClick, "data-type": viewerType, children: [viewerType === ViewerTypes.PDF && (_jsx(PdfViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Image && (_jsx(ImageViewer, { file: file, zoomFactor: zoomFactor, rotation: rotation, isPending: isPending })), viewerType === ViewerTypes.Video && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Audio && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Office && (_jsx(OfficeViewer, { file: file, isPending: isPending })), viewerType === ViewerTypes.Text && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Code && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending }))] })) : (_jsx(StyledInnerContainer, { children: _jsxs("div", { style: {
|
|
197
|
+
}, children: _jsx(XIcon, { size: 18 }) }), _jsx("div", { children: file.name }), _jsxs(StyledActionsMenu, { children: [ZoomableViewerTypes.includes(viewerType) && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "text", disabled: !file.url, "aria-label": "Zoom in", title: "Zoom in", onClick: () => setZoomFactor((prev) => prev * 1.1), children: _jsx(ZoomInIcon, { size: 18 }) }), _jsx(Button, { variant: "text", disabled: !file.url, "aria-label": "Zoom out", title: "Zoom out", onClick: () => setZoomFactor((prev) => prev * 0.9), children: _jsx(ZoomOutIcon, { size: 18 }) })] })), RotatableViewerTypes.includes(viewerType) && (_jsx(Button, { variant: "text", disabled: !file.url, "aria-label": "Rotate image", title: "Rotate image", onClick: () => setRotation((prev) => (prev + 90) % 360), children: _jsx(RotateCwIcon, { size: 18 }) })), _jsx("a", { href: file.url, download: file.name, style: { pointerEvents: !file.url ? "none" : "auto" }, onClick: () => onDownload === null || onDownload === void 0 ? void 0 : onDownload(file), children: _jsx(Button, { variant: "text", disabled: !file.url, children: _jsx(DownloadIcon, { size: 18 }) }) })] })] }), file.url ? (_jsxs(StyledInnerContainer, { onClick: handleBackgroundClick, "data-type": viewerType, children: [viewerType === ViewerTypes.PDF && (_jsx(PdfViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Image && (_jsx(ImageViewer, { file: file, zoomFactor: zoomFactor, rotation: rotation, isPending: isPending })), viewerType === ViewerTypes.Video && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Audio && (_jsx(VideoViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Office && (_jsx(OfficeViewer, { file: file, isPending: isPending })), viewerType === ViewerTypes.Text && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending })), viewerType === ViewerTypes.Code && (_jsx(CodeViewer, { file: file, zoomFactor: zoomFactor, isPending: isPending }))] })) : (_jsx(StyledInnerContainer, { children: _jsxs("div", { style: {
|
|
198
198
|
margin: "auto",
|
|
199
199
|
display: "flex",
|
|
200
200
|
gap: "10px",
|
|
@@ -6,6 +6,7 @@ var Fonts;
|
|
|
6
6
|
Fonts["TIMES_NEW_ROMAN"] = "Times New Roman";
|
|
7
7
|
Fonts["SEGOE_UI"] = "Segoe UI";
|
|
8
8
|
Fonts["ROBOTO"] = "Roboto";
|
|
9
|
-
Fonts["
|
|
9
|
+
Fonts["VERDANA"] = "Verdana";
|
|
10
|
+
Fonts["CAMBRIA"] = "Cambria";
|
|
10
11
|
})(Fonts || (Fonts = {}));
|
|
11
12
|
export default Fonts;
|
|
@@ -324,6 +324,10 @@ const StyledContent = styled.div `
|
|
|
324
324
|
font-family: Roboto, sans-serif;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
+
.editor-content[data-font="Cambria"] {
|
|
328
|
+
font-family: Cambria, Georgia, "Times New Roman", serif;
|
|
329
|
+
}
|
|
330
|
+
|
|
327
331
|
.ProseMirror {
|
|
328
332
|
font-size: 14px;
|
|
329
333
|
font-weight: 400;
|
package/package.json
CHANGED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Operator } from "./types";
|
|
2
|
-
export declare const Operators: {
|
|
3
|
-
Equals: {
|
|
4
|
-
value: string;
|
|
5
|
-
label: string;
|
|
6
|
-
};
|
|
7
|
-
NotEquals: {
|
|
8
|
-
value: string;
|
|
9
|
-
label: string;
|
|
10
|
-
};
|
|
11
|
-
LessThan: {
|
|
12
|
-
value: string;
|
|
13
|
-
label: string;
|
|
14
|
-
};
|
|
15
|
-
GreaterThan: {
|
|
16
|
-
value: string;
|
|
17
|
-
label: string;
|
|
18
|
-
};
|
|
19
|
-
LessThanOrEqual: {
|
|
20
|
-
value: string;
|
|
21
|
-
label: string;
|
|
22
|
-
};
|
|
23
|
-
GreaterThanOrEqual: {
|
|
24
|
-
value: string;
|
|
25
|
-
label: string;
|
|
26
|
-
};
|
|
27
|
-
Contains: {
|
|
28
|
-
value: string;
|
|
29
|
-
label: string;
|
|
30
|
-
};
|
|
31
|
-
BeginsWith: {
|
|
32
|
-
value: string;
|
|
33
|
-
label: string;
|
|
34
|
-
};
|
|
35
|
-
EndsWith: {
|
|
36
|
-
value: string;
|
|
37
|
-
label: string;
|
|
38
|
-
};
|
|
39
|
-
DoesNotContain: {
|
|
40
|
-
value: string;
|
|
41
|
-
label: string;
|
|
42
|
-
};
|
|
43
|
-
DoesNotBeginWith: {
|
|
44
|
-
value: string;
|
|
45
|
-
label: string;
|
|
46
|
-
};
|
|
47
|
-
DoesNotEndWith: {
|
|
48
|
-
value: string;
|
|
49
|
-
label: string;
|
|
50
|
-
};
|
|
51
|
-
IsEmpty: {
|
|
52
|
-
value: string;
|
|
53
|
-
label: string;
|
|
54
|
-
};
|
|
55
|
-
IsNotEmpty: {
|
|
56
|
-
value: string;
|
|
57
|
-
label: string;
|
|
58
|
-
};
|
|
59
|
-
In: {
|
|
60
|
-
value: string;
|
|
61
|
-
label: string;
|
|
62
|
-
};
|
|
63
|
-
NIn: {
|
|
64
|
-
value: string;
|
|
65
|
-
label: string;
|
|
66
|
-
};
|
|
67
|
-
Between: {
|
|
68
|
-
value: string;
|
|
69
|
-
label: string;
|
|
70
|
-
};
|
|
71
|
-
NotBetween: {
|
|
72
|
-
value: string;
|
|
73
|
-
label: string;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
export declare const DefaultOperators: Operator[];
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const Operators = {
|
|
2
|
-
Equals: { value: "=", label: "is" },
|
|
3
|
-
NotEquals: { value: "!=", label: "is not" },
|
|
4
|
-
LessThan: { value: "<", label: "less than" },
|
|
5
|
-
GreaterThan: { value: ">", label: "greater than" },
|
|
6
|
-
LessThanOrEqual: { value: "<=", label: "less than or equal" },
|
|
7
|
-
GreaterThanOrEqual: { value: ">=", label: "greater than or equal" },
|
|
8
|
-
Contains: { value: "contains", label: "contains" },
|
|
9
|
-
BeginsWith: { value: "beginsWith", label: "begins with" },
|
|
10
|
-
EndsWith: { value: "endsWith", label: "ends with" },
|
|
11
|
-
DoesNotContain: { value: "doesNotContain", label: "does not contain" },
|
|
12
|
-
DoesNotBeginWith: { value: "doesNotBeginWith", label: "does not begin with" },
|
|
13
|
-
DoesNotEndWith: { value: "doesNotEndWith", label: "does not end with" },
|
|
14
|
-
IsEmpty: { value: "isEmpty", label: "is empty" },
|
|
15
|
-
IsNotEmpty: { value: "isNotEmpty", label: "is not empty" },
|
|
16
|
-
In: { value: "in", label: "is any of" },
|
|
17
|
-
NIn: { value: "nin", label: "is none of" },
|
|
18
|
-
Between: { value: "between", label: "between" },
|
|
19
|
-
NotBetween: { value: "notBetween", label: "not between" },
|
|
20
|
-
};
|
|
21
|
-
export const DefaultOperators = Object.values(Operators);
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { DropDownItem, DropDownMenuProps } from "../DropDownMenu";
|
|
2
|
-
export interface UseQueryFilterProps {
|
|
3
|
-
defaultFilter?: Query | null;
|
|
4
|
-
/**
|
|
5
|
-
* Filter definitions for the available fields. Pass `undefined` while the
|
|
6
|
-
* definitions are still loading (e.g. async fetch in flight) — any rules
|
|
7
|
-
* already in state will render nothing until definitions resolve. An empty
|
|
8
|
-
* array means "loaded, no definitions": every rule will render as an
|
|
9
|
-
* orphan chip and `onUnknownField` will fire for each.
|
|
10
|
-
*/
|
|
11
|
-
filterDefinitions: FilterDefinition[] | undefined;
|
|
12
|
-
showCombinator?: boolean;
|
|
13
|
-
onFilterChange?: (filter: any) => void;
|
|
14
|
-
onUnknownField?: (rule: Rule) => void;
|
|
15
|
-
}
|
|
16
|
-
export type QueryFilterType = {
|
|
17
|
-
filter: Query;
|
|
18
|
-
filterDefinitions: FilterDefinition[] | undefined;
|
|
19
|
-
showCombinator?: boolean;
|
|
20
|
-
addRule: (rule: Rule) => void;
|
|
21
|
-
/**
|
|
22
|
-
* Remove a rule by `id` (preferred) or by passing the `Rule` object. The
|
|
23
|
-
* object form falls back to reference equality when `rule.id` is missing,
|
|
24
|
-
* so chips for un-normalized orphan rules can still delete themselves.
|
|
25
|
-
*/
|
|
26
|
-
removeRule: (target: string | Rule) => void;
|
|
27
|
-
updateRule: (rule: Rule) => void;
|
|
28
|
-
updateRootCombinator: (combinator: Combinator) => void;
|
|
29
|
-
onUnknownField?: (rule: Rule) => void;
|
|
30
|
-
};
|
|
31
|
-
export type UseQueryFilter = (args: UseQueryFilterProps) => QueryFilterType;
|
|
32
|
-
export type Combinator = "and" | "or";
|
|
33
|
-
export type Operator = {
|
|
34
|
-
label: string;
|
|
35
|
-
value: string;
|
|
36
|
-
};
|
|
37
|
-
export type InputType = "text" | "number" | "date" | "datetime" | "multiselect";
|
|
38
|
-
export interface FilterDefinition {
|
|
39
|
-
dataField: string;
|
|
40
|
-
label: string;
|
|
41
|
-
pluralLabel?: string;
|
|
42
|
-
operators?: Operator[];
|
|
43
|
-
inputType?: InputType;
|
|
44
|
-
resolution?: "day" | "second" | "millisecond";
|
|
45
|
-
isoString?: boolean;
|
|
46
|
-
placeholder?: string;
|
|
47
|
-
selectOptions?: DropDownItem[];
|
|
48
|
-
dropDownOptions?: {
|
|
49
|
-
style?: React.CSSProperties;
|
|
50
|
-
};
|
|
51
|
-
query?: DropDownMenuProps["query"];
|
|
52
|
-
}
|
|
53
|
-
export interface Rule {
|
|
54
|
-
id?: string;
|
|
55
|
-
dataField: string;
|
|
56
|
-
value?: string[];
|
|
57
|
-
options?: DropDownItem[];
|
|
58
|
-
operator: Operator;
|
|
59
|
-
label: string;
|
|
60
|
-
}
|
|
61
|
-
export interface RuleGroup {
|
|
62
|
-
rules: Rule[];
|
|
63
|
-
combinator: Combinator;
|
|
64
|
-
}
|
|
65
|
-
export interface Query extends RuleGroup {
|
|
66
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { Extension, isNodeSelection, isTextSelection, posToDOMRect, } from "@tiptap/core";
|
|
2
|
-
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
-
import { ReactRenderer } from "@tiptap/react";
|
|
4
|
-
import BubbleMenuComponent from "../Components/BubbleMenu";
|
|
5
|
-
class Menu {
|
|
6
|
-
constructor({ view, editor, customMenuItems, }) {
|
|
7
|
-
this.mousedownHandler = (event) => {
|
|
8
|
-
this.preventShow = true;
|
|
9
|
-
};
|
|
10
|
-
this.mouseUpHandler = (event) => {
|
|
11
|
-
this.preventShow = false;
|
|
12
|
-
this.update(this.editor.view);
|
|
13
|
-
};
|
|
14
|
-
this.focusHandler = () => {
|
|
15
|
-
// this.editor.commands.setTextSelection({ from: 0, to: 0 });
|
|
16
|
-
// we use `setTimeout` to make sure `selection` is already updated
|
|
17
|
-
setTimeout(() => this.update(this.editor.view));
|
|
18
|
-
};
|
|
19
|
-
this.blurHandler = ({ event }) => {
|
|
20
|
-
var _a;
|
|
21
|
-
if (this.preventShow) {
|
|
22
|
-
this.preventShow = false;
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if ((event === null || event === void 0 ? void 0 : event.relatedTarget) &&
|
|
26
|
-
((_a = this.floating) === null || _a === void 0 ? void 0 : _a.contains(event === null || event === void 0 ? void 0 : event.relatedTarget))) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
// clear text selection
|
|
30
|
-
// this.editor.commands.setTextSelection({ from: 0, to: 0 });
|
|
31
|
-
this.hide();
|
|
32
|
-
};
|
|
33
|
-
this.editor = editor;
|
|
34
|
-
this.view = view;
|
|
35
|
-
this.rect = null;
|
|
36
|
-
this.preventShow = false;
|
|
37
|
-
this.floating = null;
|
|
38
|
-
this.isOpen = false;
|
|
39
|
-
// create and mount react component
|
|
40
|
-
if (!this.component) {
|
|
41
|
-
this.component = new ReactRenderer(BubbleMenuComponent, {
|
|
42
|
-
props: {
|
|
43
|
-
editor: this.editor,
|
|
44
|
-
open: false,
|
|
45
|
-
onOpen: (ref) => {
|
|
46
|
-
this.floating = ref;
|
|
47
|
-
},
|
|
48
|
-
customMenuItems,
|
|
49
|
-
},
|
|
50
|
-
editor: this.editor,
|
|
51
|
-
});
|
|
52
|
-
document.body.appendChild(this.component.element);
|
|
53
|
-
}
|
|
54
|
-
// don't show the bubble during selection of text
|
|
55
|
-
this.view.dom.addEventListener("mousedown", this.mousedownHandler, {
|
|
56
|
-
capture: true,
|
|
57
|
-
});
|
|
58
|
-
this.view.dom.addEventListener("mouseup", this.mouseUpHandler);
|
|
59
|
-
this.editor.on("blur", this.blurHandler);
|
|
60
|
-
this.editor.on("focus", this.focusHandler);
|
|
61
|
-
}
|
|
62
|
-
update(view, oldState) {
|
|
63
|
-
var _a;
|
|
64
|
-
const { state, composing } = view;
|
|
65
|
-
const { doc, selection } = state;
|
|
66
|
-
const { empty, ranges } = selection;
|
|
67
|
-
const from = Math.min(...ranges.map((range) => range.$from.pos));
|
|
68
|
-
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
69
|
-
const selectionChanged = !(oldState === null || oldState === void 0 ? void 0 : oldState.selection.eq(view.state.selection));
|
|
70
|
-
const docChanged = !(oldState === null || oldState === void 0 ? void 0 : oldState.doc.eq(view.state.doc));
|
|
71
|
-
const isSame = !selectionChanged && !docChanged;
|
|
72
|
-
if (composing || isSame) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
// Sometime check for `empty` is not enough.
|
|
76
|
-
// Doubleclick an empty paragraph returns a node size of 2.
|
|
77
|
-
// So we check also for an empty text size.
|
|
78
|
-
const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
|
|
79
|
-
// When clicking on a element inside the bubble menu the editor "blur" event
|
|
80
|
-
// is called and the bubble menu item is focussed. In this case we should
|
|
81
|
-
// consider the menu as part of the editor and keep showing the menu
|
|
82
|
-
const isChildOfMenu = (_a = this === null || this === void 0 ? void 0 : this.floating) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement);
|
|
83
|
-
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
|
|
84
|
-
if (!hasEditorFocus ||
|
|
85
|
-
empty ||
|
|
86
|
-
isEmptyTextBlock ||
|
|
87
|
-
!this.editor.isEditable ||
|
|
88
|
-
this.preventShow) {
|
|
89
|
-
this.hide();
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
// only set position when it is not already open
|
|
93
|
-
// otherwise the menu will jump around when the selection changes or text formatting is applied
|
|
94
|
-
if (!this.isOpen) {
|
|
95
|
-
if (isNodeSelection(state.selection)) {
|
|
96
|
-
let node = view.nodeDOM(from);
|
|
97
|
-
const nodeViewWrapper = node.dataset.nodeViewWrapper
|
|
98
|
-
? node
|
|
99
|
-
: node.querySelector("[data-node-view-wrapper]");
|
|
100
|
-
if (nodeViewWrapper) {
|
|
101
|
-
node = nodeViewWrapper.firstChild;
|
|
102
|
-
}
|
|
103
|
-
if (node) {
|
|
104
|
-
this.rect = node.getBoundingClientRect();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
this.rect = posToDOMRect(view, from, to);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
this.show();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
show() {
|
|
115
|
-
if (this.component) {
|
|
116
|
-
this.component.updateProps({ open: true, rect: this.rect });
|
|
117
|
-
this.isOpen = true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
hide() {
|
|
121
|
-
if (this.component) {
|
|
122
|
-
this.component.updateProps({ open: false, rect: null });
|
|
123
|
-
this.isOpen = false;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
destroy() {
|
|
127
|
-
if (this.component) {
|
|
128
|
-
this.view.dom.removeEventListener("mousedown", this.mousedownHandler);
|
|
129
|
-
this.view.dom.removeEventListener("mouseup", this.mouseUpHandler);
|
|
130
|
-
this.component.destroy();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const BubbleMenu = Extension.create({
|
|
135
|
-
name: "bubbleMenu",
|
|
136
|
-
addOptions() {
|
|
137
|
-
return {
|
|
138
|
-
bubbleMenuOptions: {},
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
addProseMirrorPlugins() {
|
|
142
|
-
return [
|
|
143
|
-
new Plugin({
|
|
144
|
-
key: new PluginKey("bubbleMenu"),
|
|
145
|
-
view: (view) => {
|
|
146
|
-
var _a;
|
|
147
|
-
return new Menu({
|
|
148
|
-
view,
|
|
149
|
-
editor: this.editor,
|
|
150
|
-
customMenuItems: ((_a = this === null || this === void 0 ? void 0 : this.options) === null || _a === void 0 ? void 0 : _a.customMenuItems) || [],
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
}),
|
|
154
|
-
];
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
export default BubbleMenu;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import TableDefaults from "../TableDefaults";
|
|
2
|
-
const enableResizeClass = (dataField) => {
|
|
3
|
-
if (dataField === undefined) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
document.querySelectorAll(`.resizer.col-${dataField}`).forEach((resizer) => {
|
|
7
|
-
resizer.classList.add("isResizing");
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
const disableResizeClass = (dataField) => {
|
|
11
|
-
if (dataField === undefined) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
document.querySelectorAll(`.resizer.col-${dataField}`).forEach((resizer) => {
|
|
15
|
-
resizer.classList.remove("isResizing");
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
const resizeHandler = ({ event, columnId, columnProps, onResize, onResizeFinished, }) => {
|
|
19
|
-
let col = event.target
|
|
20
|
-
.parentElement;
|
|
21
|
-
let newColumns = [];
|
|
22
|
-
let x = 0;
|
|
23
|
-
let w = 0;
|
|
24
|
-
const mouseMoveHandler = function (e) {
|
|
25
|
-
const selectedColumn = document.querySelectorAll(`.column-${columnId}`);
|
|
26
|
-
const columnHeaders = document.querySelectorAll(`.mfui-th.column-${columnId}`);
|
|
27
|
-
const dx = e.clientX - x;
|
|
28
|
-
let newWidth = w + dx;
|
|
29
|
-
// Calculate what the minimum width should be
|
|
30
|
-
// min width should be the defined column width or the default min width
|
|
31
|
-
if (columnProps.minWidth === undefined) {
|
|
32
|
-
if (newWidth < TableDefaults.td.minWidth)
|
|
33
|
-
newWidth = TableDefaults.td.minWidth;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
if (newWidth < columnProps.minWidth)
|
|
37
|
-
newWidth = columnProps.minWidth;
|
|
38
|
-
}
|
|
39
|
-
selectedColumn.forEach((col) => {
|
|
40
|
-
var _a;
|
|
41
|
-
col.style.width = `${newWidth}px`;
|
|
42
|
-
col.style.flex = "0 0 auto";
|
|
43
|
-
// col.style.maxWidth = `${newWidth}px`;
|
|
44
|
-
// col.style.minWidth = `${newWidth}px`;
|
|
45
|
-
newColumns.push({
|
|
46
|
-
dataField: ((_a = col === null || col === void 0 ? void 0 : col.dataset) === null || _a === void 0 ? void 0 : _a.field) || "",
|
|
47
|
-
width: newWidth,
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
newColumns = Array.from(columnHeaders).map((col) => {
|
|
51
|
-
var _a;
|
|
52
|
-
return {
|
|
53
|
-
dataField: ((_a = col === null || col === void 0 ? void 0 : col.dataset) === null || _a === void 0 ? void 0 : _a.field) || "",
|
|
54
|
-
width: newWidth,
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
onResize({
|
|
58
|
-
columns: newColumns,
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
const mouseUpHandler = function () {
|
|
62
|
-
var _a, _b, _c;
|
|
63
|
-
let newWidth = ((_c = (_b = (_a = document === null || document === void 0 ? void 0 : document.querySelector) === null || _a === void 0 ? void 0 : _a.call(document, `.column-${columnId}`)) === null || _b === void 0 ? void 0 : _b.style) === null || _c === void 0 ? void 0 : _c.width) || null;
|
|
64
|
-
if (newWidth) {
|
|
65
|
-
newWidth = newWidth.replace("px", "");
|
|
66
|
-
}
|
|
67
|
-
disableResizeClass(columnId);
|
|
68
|
-
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
69
|
-
document.removeEventListener("mouseup", mouseUpHandler);
|
|
70
|
-
onResizeFinished === null || onResizeFinished === void 0 ? void 0 : onResizeFinished({
|
|
71
|
-
column: columnProps,
|
|
72
|
-
columnId: columnId,
|
|
73
|
-
targetColumn: document.querySelector(`.column-${columnId}`),
|
|
74
|
-
newWidth,
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
x = event.clientX;
|
|
78
|
-
const styles = window.getComputedStyle(col);
|
|
79
|
-
w = parseInt(styles.width, 10);
|
|
80
|
-
document.addEventListener("mousemove", mouseMoveHandler);
|
|
81
|
-
document.addEventListener("mouseup", mouseUpHandler);
|
|
82
|
-
enableResizeClass(columnId);
|
|
83
|
-
};
|
|
84
|
-
export default resizeHandler;
|