@ctzhian/tiptap 2.1.3 → 2.1.5
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/Editor/index.js +4 -43
- package/dist/EditorDiff/index.js +4 -43
- package/dist/component/ImageViewer/Item.d.ts +3 -0
- package/dist/component/ImageViewer/Item.js +20 -0
- package/dist/component/ImageViewer/Provider.d.ts +3 -0
- package/dist/component/ImageViewer/Provider.js +204 -0
- package/dist/component/ImageViewer/Toolbar.d.ts +6 -0
- package/dist/component/ImageViewer/Toolbar.js +289 -0
- package/dist/component/ImageViewer/context.d.ts +3 -0
- package/dist/component/ImageViewer/context.js +22 -0
- package/dist/component/ImageViewer/index.d.ts +11 -0
- package/dist/component/ImageViewer/index.js +8 -0
- package/dist/component/ImageViewer/styles.d.ts +1 -0
- package/dist/component/ImageViewer/styles.js +1 -0
- package/dist/component/ImageViewer/types.d.ts +51 -0
- package/dist/component/ImageViewer/types.js +1 -0
- package/dist/extension/component/Image/Readonly.d.ts +0 -1
- package/dist/extension/component/Image/Readonly.js +2 -3
- package/dist/extension/component/Image/index.d.ts +0 -1
- package/dist/extension/component/Image/index.js +2 -3
- package/dist/extension/component/TableExtendButton/index.js +2 -2
- package/dist/hook/index.js +1 -8
- package/package.json +1 -1
package/dist/Editor/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "core-js/modules/es.array.find-last.js";
|
|
2
2
|
import { EditorContent } from '@tiptap/react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { PhotoProvider } from 'react-photo-view';
|
|
5
4
|
import CustomBubbleMenu from "../component/CustomBubbleMenu";
|
|
6
5
|
import CustomDragHandle from "../component/CustomDragHandle";
|
|
6
|
+
import { ImageViewerProvider } from "../component/ImageViewer";
|
|
7
7
|
import { TableCellHandleMenu } from "../extension/component/TableCellHandleMenu";
|
|
8
8
|
import { TableExtendRowColumnButtons } from "../extension/component/TableExtendButton";
|
|
9
9
|
import { TableHandle } from "../extension/component/TableHandle";
|
|
@@ -16,48 +16,9 @@ var Editor = function Editor(_ref) {
|
|
|
16
16
|
menuInDragHandle = _ref.menuInDragHandle,
|
|
17
17
|
menuInBubbleMenu = _ref.menuInBubbleMenu,
|
|
18
18
|
onTip = _ref.onTip;
|
|
19
|
-
return /*#__PURE__*/React.createElement(
|
|
20
|
-
speed:
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
maskOpacity: 0.3,
|
|
24
|
-
toolbarRender: function toolbarRender(_ref2) {
|
|
25
|
-
var onScale = _ref2.onScale,
|
|
26
|
-
scale = _ref2.scale,
|
|
27
|
-
rotate = _ref2.rotate,
|
|
28
|
-
onRotate = _ref2.onRotate;
|
|
29
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("svg", {
|
|
30
|
-
width: "44",
|
|
31
|
-
height: "44",
|
|
32
|
-
viewBox: "0 0 768 768",
|
|
33
|
-
className: "PhotoView-Slider__toolbarIcon",
|
|
34
|
-
onClick: function onClick() {
|
|
35
|
-
return onScale(scale + 1);
|
|
36
|
-
}
|
|
37
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
38
|
-
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM415.5 223.5v129h129v63h-129v129h-63v-129h-129v-63h129v-129h63z"
|
|
39
|
-
})), /*#__PURE__*/React.createElement("svg", {
|
|
40
|
-
width: "44",
|
|
41
|
-
height: "44",
|
|
42
|
-
viewBox: "0 0 768 768",
|
|
43
|
-
className: "PhotoView-Slider__toolbarIcon",
|
|
44
|
-
onClick: function onClick() {
|
|
45
|
-
return onScale(scale - 1);
|
|
46
|
-
}
|
|
47
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
48
|
-
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM223.5 352.5h321v63h-321v-63z"
|
|
49
|
-
})), /*#__PURE__*/React.createElement("svg", {
|
|
50
|
-
width: "44",
|
|
51
|
-
height: "44",
|
|
52
|
-
viewBox: "0 0 768 768",
|
|
53
|
-
className: "PhotoView-Slider__toolbarIcon",
|
|
54
|
-
onClick: function onClick() {
|
|
55
|
-
return onRotate(rotate + 90);
|
|
56
|
-
}
|
|
57
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
58
|
-
d: "M565.5 202.5l75-75v225h-225l103.5-103.5c-34.5-34.5-82.5-57-135-57-106.5 0-192 85.5-192 192s85.5 192 192 192c84 0 156-52.5 181.5-127.5h66c-28.5 111-127.5 192-247.5 192-141 0-255-115.5-255-256.5s114-256.5 255-256.5c70.5 0 135 28.5 181.5 75z"
|
|
59
|
-
})));
|
|
60
|
-
}
|
|
19
|
+
return /*#__PURE__*/React.createElement(ImageViewerProvider, {
|
|
20
|
+
speed: 500,
|
|
21
|
+
maskOpacity: 0.3
|
|
61
22
|
}, /*#__PURE__*/React.createElement(CustomBubbleMenu, {
|
|
62
23
|
editor: editor,
|
|
63
24
|
more: menuInBubbleMenu
|
package/dist/EditorDiff/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "core-js/modules/es.array.find-last.js";
|
|
2
2
|
import { EditorContent } from "@tiptap/react";
|
|
3
3
|
import React, { useEffect } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { ImageViewerProvider } from "../component/ImageViewer";
|
|
5
5
|
import useTiptap from "../hook";
|
|
6
6
|
|
|
7
7
|
// fix: https://github.com/ueberdosis/tiptap/issues/6785
|
|
@@ -22,48 +22,9 @@ var EditorDiff = function EditorDiff(_ref) {
|
|
|
22
22
|
(_editorRef$editor = editorRef.editor) === null || _editorRef$editor === void 0 || (_editorRef$editor$com = (_editorRef$editor$com2 = _editorRef$editor.commands).hideStructuredDiff) === null || _editorRef$editor$com === void 0 || _editorRef$editor$com.call(_editorRef$editor$com2);
|
|
23
23
|
};
|
|
24
24
|
}, [oldHtml, newHtml, editorRef.editor]);
|
|
25
|
-
return /*#__PURE__*/React.createElement(
|
|
26
|
-
speed:
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
maskOpacity: 0.3,
|
|
30
|
-
toolbarRender: function toolbarRender(_ref2) {
|
|
31
|
-
var onScale = _ref2.onScale,
|
|
32
|
-
scale = _ref2.scale,
|
|
33
|
-
rotate = _ref2.rotate,
|
|
34
|
-
onRotate = _ref2.onRotate;
|
|
35
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("svg", {
|
|
36
|
-
width: "44",
|
|
37
|
-
height: "44",
|
|
38
|
-
viewBox: "0 0 768 768",
|
|
39
|
-
className: "PhotoView-Slider__toolbarIcon",
|
|
40
|
-
onClick: function onClick() {
|
|
41
|
-
return onScale(scale + 1);
|
|
42
|
-
}
|
|
43
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
44
|
-
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM415.5 223.5v129h129v63h-129v129h-63v-129h-129v-63h129v-129h63z"
|
|
45
|
-
})), /*#__PURE__*/React.createElement("svg", {
|
|
46
|
-
width: "44",
|
|
47
|
-
height: "44",
|
|
48
|
-
viewBox: "0 0 768 768",
|
|
49
|
-
className: "PhotoView-Slider__toolbarIcon",
|
|
50
|
-
onClick: function onClick() {
|
|
51
|
-
return onScale(scale - 1);
|
|
52
|
-
}
|
|
53
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
54
|
-
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM223.5 352.5h321v63h-321v-63z"
|
|
55
|
-
})), /*#__PURE__*/React.createElement("svg", {
|
|
56
|
-
width: "44",
|
|
57
|
-
height: "44",
|
|
58
|
-
viewBox: "0 0 768 768",
|
|
59
|
-
className: "PhotoView-Slider__toolbarIcon",
|
|
60
|
-
onClick: function onClick() {
|
|
61
|
-
return onRotate(rotate + 90);
|
|
62
|
-
}
|
|
63
|
-
}, /*#__PURE__*/React.createElement("path", {
|
|
64
|
-
d: "M565.5 202.5l75-75v225h-225l103.5-103.5c-34.5-34.5-82.5-57-135-57-106.5 0-192 85.5-192 192s85.5 192 192 192c84 0 156-52.5 181.5-127.5h66c-28.5 111-127.5 192-247.5 192-141 0-255-115.5-255-256.5s114-256.5 255-256.5c70.5 0 135 28.5 181.5 75z"
|
|
65
|
-
})));
|
|
66
|
-
}
|
|
25
|
+
return /*#__PURE__*/React.createElement(ImageViewerProvider, {
|
|
26
|
+
speed: 500,
|
|
27
|
+
maskOpacity: 0.3
|
|
67
28
|
}, /*#__PURE__*/React.createElement(EditorContent, {
|
|
68
29
|
editor: editorRef.editor
|
|
69
30
|
}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PhotoView } from 'react-photo-view';
|
|
3
|
+
export var ImageViewerItem = function ImageViewerItem(_ref) {
|
|
4
|
+
var src = _ref.src,
|
|
5
|
+
children = _ref.children,
|
|
6
|
+
render = _ref.render,
|
|
7
|
+
overlay = _ref.overlay,
|
|
8
|
+
width = _ref.width,
|
|
9
|
+
height = _ref.height,
|
|
10
|
+
_ref$triggers = _ref.triggers,
|
|
11
|
+
triggers = _ref$triggers === void 0 ? ['onClick'] : _ref$triggers;
|
|
12
|
+
return /*#__PURE__*/React.createElement(PhotoView, {
|
|
13
|
+
src: src,
|
|
14
|
+
render: render,
|
|
15
|
+
overlay: overlay,
|
|
16
|
+
width: width,
|
|
17
|
+
height: height,
|
|
18
|
+
triggers: triggers
|
|
19
|
+
}, children);
|
|
20
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
8
|
+
import { PhotoProvider } from 'react-photo-view';
|
|
9
|
+
import { ImageViewerContext } from "./context";
|
|
10
|
+
import { ImageViewerItem } from "./Item";
|
|
11
|
+
import { customStyles } from "./styles";
|
|
12
|
+
import { CustomToolbar } from "./Toolbar";
|
|
13
|
+
export var ImageViewerProvider = function ImageViewerProvider(_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
_ref$speed = _ref.speed,
|
|
16
|
+
speed = _ref$speed === void 0 ? 500 : _ref$speed,
|
|
17
|
+
_ref$maskOpacity = _ref.maskOpacity,
|
|
18
|
+
maskOpacity = _ref$maskOpacity === void 0 ? 0.3 : _ref$maskOpacity,
|
|
19
|
+
_onVisibleChange = _ref.onVisibleChange,
|
|
20
|
+
_onIndexChange = _ref.onIndexChange,
|
|
21
|
+
_ref$loop = _ref.loop,
|
|
22
|
+
loop = _ref$loop === void 0 ? 3 : _ref$loop,
|
|
23
|
+
photoClosable = _ref.photoClosable,
|
|
24
|
+
_ref$maskClosable = _ref.maskClosable,
|
|
25
|
+
maskClosable = _ref$maskClosable === void 0 ? true : _ref$maskClosable,
|
|
26
|
+
_ref$pullClosable = _ref.pullClosable,
|
|
27
|
+
pullClosable = _ref$pullClosable === void 0 ? true : _ref$pullClosable,
|
|
28
|
+
className = _ref.className,
|
|
29
|
+
maskClassName = _ref.maskClassName,
|
|
30
|
+
photoWrapClassName = _ref.photoWrapClassName,
|
|
31
|
+
photoClassName = _ref.photoClassName,
|
|
32
|
+
loadingElement = _ref.loadingElement,
|
|
33
|
+
brokenElement = _ref.brokenElement,
|
|
34
|
+
portalContainer = _ref.portalContainer;
|
|
35
|
+
var _useState = useState(''),
|
|
36
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
37
|
+
currentSrc = _useState2[0],
|
|
38
|
+
setCurrentSrc = _useState2[1];
|
|
39
|
+
var _useState3 = useState(false),
|
|
40
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
41
|
+
visible = _useState4[0],
|
|
42
|
+
setVisible = _useState4[1];
|
|
43
|
+
var _useState5 = useState(1),
|
|
44
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
45
|
+
scale = _useState6[0],
|
|
46
|
+
setScale = _useState6[1];
|
|
47
|
+
var _useState7 = useState(0),
|
|
48
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
49
|
+
rotate = _useState8[0],
|
|
50
|
+
setRotate = _useState8[1];
|
|
51
|
+
var _useState9 = useState(null),
|
|
52
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
53
|
+
onScale = _useState10[0],
|
|
54
|
+
setOnScale = _useState10[1];
|
|
55
|
+
var _useState11 = useState(null),
|
|
56
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
57
|
+
onRotate = _useState12[0],
|
|
58
|
+
setOnRotate = _useState12[1];
|
|
59
|
+
var _useState13 = useState(null),
|
|
60
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
61
|
+
onClose = _useState14[0],
|
|
62
|
+
setOnClose = _useState14[1];
|
|
63
|
+
var imageSrcsRef = useRef([]);
|
|
64
|
+
var overlayStateRef = useRef({
|
|
65
|
+
scale: 1,
|
|
66
|
+
rotate: 0,
|
|
67
|
+
visible: false,
|
|
68
|
+
onScale: null,
|
|
69
|
+
onRotate: null,
|
|
70
|
+
onClose: null,
|
|
71
|
+
index: undefined
|
|
72
|
+
});
|
|
73
|
+
var callbacksRef = useRef({
|
|
74
|
+
onScale: null,
|
|
75
|
+
onRotate: null,
|
|
76
|
+
onClose: null
|
|
77
|
+
});
|
|
78
|
+
useEffect(function () {
|
|
79
|
+
if (typeof document !== 'undefined' && !document.getElementById('image-viewer-custom-styles')) {
|
|
80
|
+
var styleElement = document.createElement('style');
|
|
81
|
+
styleElement.id = 'image-viewer-custom-styles';
|
|
82
|
+
styleElement.textContent = customStyles;
|
|
83
|
+
document.head.appendChild(styleElement);
|
|
84
|
+
}
|
|
85
|
+
}, []);
|
|
86
|
+
useLayoutEffect(function () {
|
|
87
|
+
var state = overlayStateRef.current;
|
|
88
|
+
setScale(state.scale);
|
|
89
|
+
setRotate(state.rotate);
|
|
90
|
+
setVisible(state.visible);
|
|
91
|
+
callbacksRef.current.onScale = state.onScale;
|
|
92
|
+
callbacksRef.current.onRotate = state.onRotate;
|
|
93
|
+
callbacksRef.current.onClose = state.onClose;
|
|
94
|
+
setOnScale(function () {
|
|
95
|
+
return state.onScale;
|
|
96
|
+
});
|
|
97
|
+
setOnRotate(function () {
|
|
98
|
+
return state.onRotate;
|
|
99
|
+
});
|
|
100
|
+
setOnClose(function () {
|
|
101
|
+
return state.onClose;
|
|
102
|
+
});
|
|
103
|
+
if (state.visible && state.index !== undefined) {
|
|
104
|
+
var src = imageSrcsRef.current[state.index];
|
|
105
|
+
if (src) {
|
|
106
|
+
setCurrentSrc(src);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
useEffect(function () {
|
|
111
|
+
var srcs = [];
|
|
112
|
+
React.Children.forEach(children, function (child) {
|
|
113
|
+
if ( /*#__PURE__*/React.isValidElement(child) && child.type === ImageViewerItem) {
|
|
114
|
+
var src = child.props.src;
|
|
115
|
+
if (src) {
|
|
116
|
+
srcs.push(src);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
imageSrcsRef.current = srcs;
|
|
121
|
+
}, [children]);
|
|
122
|
+
var contextValue = {
|
|
123
|
+
setCurrentSrc: setCurrentSrc,
|
|
124
|
+
visible: visible,
|
|
125
|
+
setVisible: setVisible,
|
|
126
|
+
scale: scale,
|
|
127
|
+
setScale: setScale,
|
|
128
|
+
rotate: rotate,
|
|
129
|
+
setRotate: setRotate,
|
|
130
|
+
getScale: function getScale() {
|
|
131
|
+
return overlayStateRef.current.scale;
|
|
132
|
+
},
|
|
133
|
+
getRotate: function getRotate() {
|
|
134
|
+
return overlayStateRef.current.rotate;
|
|
135
|
+
},
|
|
136
|
+
onScale: callbacksRef.current.onScale,
|
|
137
|
+
setOnScale: setOnScale,
|
|
138
|
+
onRotate: callbacksRef.current.onRotate,
|
|
139
|
+
setOnRotate: setOnRotate,
|
|
140
|
+
onClose: callbacksRef.current.onClose,
|
|
141
|
+
setOnClose: setOnClose
|
|
142
|
+
};
|
|
143
|
+
var handleSpeed = typeof speed === 'function' ? speed : function () {
|
|
144
|
+
return typeof speed === 'number' ? speed : 500;
|
|
145
|
+
};
|
|
146
|
+
return /*#__PURE__*/React.createElement(ImageViewerContext.Provider, {
|
|
147
|
+
value: contextValue
|
|
148
|
+
}, /*#__PURE__*/React.createElement(PhotoProvider, {
|
|
149
|
+
bannerVisible: false,
|
|
150
|
+
speed: handleSpeed,
|
|
151
|
+
maskOpacity: maskOpacity,
|
|
152
|
+
loop: loop,
|
|
153
|
+
photoClosable: photoClosable,
|
|
154
|
+
maskClosable: maskClosable,
|
|
155
|
+
pullClosable: pullClosable,
|
|
156
|
+
className: className,
|
|
157
|
+
maskClassName: maskClassName,
|
|
158
|
+
photoWrapClassName: photoWrapClassName,
|
|
159
|
+
photoClassName: photoClassName,
|
|
160
|
+
loadingElement: loadingElement,
|
|
161
|
+
brokenElement: brokenElement,
|
|
162
|
+
portalContainer: portalContainer,
|
|
163
|
+
overlayRender: function overlayRender(_ref2) {
|
|
164
|
+
var overlayOnScale = _ref2.onScale,
|
|
165
|
+
overlayScale = _ref2.scale,
|
|
166
|
+
overlayRotate = _ref2.rotate,
|
|
167
|
+
overlayOnRotate = _ref2.onRotate,
|
|
168
|
+
overlayOnClose = _ref2.onClose,
|
|
169
|
+
index = _ref2.index,
|
|
170
|
+
overlayVisible = _ref2.visible;
|
|
171
|
+
overlayStateRef.current = {
|
|
172
|
+
scale: overlayScale,
|
|
173
|
+
rotate: overlayRotate,
|
|
174
|
+
visible: overlayVisible,
|
|
175
|
+
onScale: overlayOnScale,
|
|
176
|
+
onRotate: overlayOnRotate,
|
|
177
|
+
onClose: overlayOnClose,
|
|
178
|
+
index: index
|
|
179
|
+
};
|
|
180
|
+
return null;
|
|
181
|
+
},
|
|
182
|
+
onVisibleChange: function onVisibleChange(visible, index) {
|
|
183
|
+
setVisible(visible);
|
|
184
|
+
if (visible && index !== undefined) {
|
|
185
|
+
var src = imageSrcsRef.current[index];
|
|
186
|
+
if (src) {
|
|
187
|
+
setCurrentSrc(src);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
_onVisibleChange === null || _onVisibleChange === void 0 || _onVisibleChange(visible, index);
|
|
191
|
+
},
|
|
192
|
+
onIndexChange: function onIndexChange(index) {
|
|
193
|
+
if (index !== undefined) {
|
|
194
|
+
var src = imageSrcsRef.current[index];
|
|
195
|
+
if (src) {
|
|
196
|
+
setCurrentSrc(src);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
_onIndexChange === null || _onIndexChange === void 0 || _onIndexChange(index);
|
|
200
|
+
}
|
|
201
|
+
}, children), /*#__PURE__*/React.createElement(CustomToolbar, {
|
|
202
|
+
currentSrc: currentSrc
|
|
203
|
+
}));
|
|
204
|
+
};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { Box, IconButton, Stack, Tooltip } from '@mui/material';
|
|
8
|
+
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
|
9
|
+
import { createPortal } from 'react-dom';
|
|
10
|
+
import { AnticlockwiseLineIcon, ClockwiseLineIcon, CloseCircleFillIcon, Download2LineIcon, FullscreenExitLineIcon, FullscreenLineIcon, ResetLeftFillIcon } from "../Icons";
|
|
11
|
+
import { ImageViewerContext } from "./context";
|
|
12
|
+
export var CustomToolbar = function CustomToolbar(_ref) {
|
|
13
|
+
var currentSrc = _ref.currentSrc;
|
|
14
|
+
var _useContext = useContext(ImageViewerContext),
|
|
15
|
+
visible = _useContext.visible,
|
|
16
|
+
scale = _useContext.scale,
|
|
17
|
+
rotate = _useContext.rotate,
|
|
18
|
+
getScale = _useContext.getScale,
|
|
19
|
+
getRotate = _useContext.getRotate,
|
|
20
|
+
onScale = _useContext.onScale,
|
|
21
|
+
onRotate = _useContext.onRotate,
|
|
22
|
+
onClose = _useContext.onClose;
|
|
23
|
+
var _useState = useState(false),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
isFullscreen = _useState2[0],
|
|
26
|
+
setIsFullscreen = _useState2[1];
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
var handleFullscreenChange = function handleFullscreenChange() {
|
|
29
|
+
setIsFullscreen(!!document.fullscreenElement);
|
|
30
|
+
};
|
|
31
|
+
document.addEventListener('fullscreenchange', handleFullscreenChange);
|
|
32
|
+
return function () {
|
|
33
|
+
document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
var handleDownload = useCallback(function () {
|
|
37
|
+
if (currentSrc) {
|
|
38
|
+
var link = document.createElement('a');
|
|
39
|
+
link.href = currentSrc;
|
|
40
|
+
link.download = currentSrc.split('/').pop() || 'image';
|
|
41
|
+
document.body.appendChild(link);
|
|
42
|
+
link.click();
|
|
43
|
+
document.body.removeChild(link);
|
|
44
|
+
}
|
|
45
|
+
}, [currentSrc]);
|
|
46
|
+
var handleFullscreen = useCallback(function () {
|
|
47
|
+
if (!document.fullscreenElement) {
|
|
48
|
+
var _document$documentEle, _document$documentEle2;
|
|
49
|
+
(_document$documentEle = (_document$documentEle2 = document.documentElement).requestFullscreen) === null || _document$documentEle === void 0 || _document$documentEle.call(_document$documentEle2);
|
|
50
|
+
} else {
|
|
51
|
+
var _document$exitFullscr, _document;
|
|
52
|
+
(_document$exitFullscr = (_document = document).exitFullscreen) === null || _document$exitFullscr === void 0 || _document$exitFullscr.call(_document);
|
|
53
|
+
}
|
|
54
|
+
}, []);
|
|
55
|
+
var handleReset = useCallback(function () {
|
|
56
|
+
if (onScale) onScale(1);
|
|
57
|
+
if (onRotate) onRotate(0);
|
|
58
|
+
}, [onScale, onRotate]);
|
|
59
|
+
if (!visible) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
var toolbarContent = /*#__PURE__*/React.createElement(Box, {
|
|
63
|
+
className: "PhotoView-Slider__toolbar-custom",
|
|
64
|
+
sx: {
|
|
65
|
+
position: 'fixed',
|
|
66
|
+
bottom: 0,
|
|
67
|
+
left: 0,
|
|
68
|
+
right: 0,
|
|
69
|
+
display: 'flex',
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
padding: '16px 24px',
|
|
73
|
+
zIndex: 10000,
|
|
74
|
+
pointerEvents: 'none',
|
|
75
|
+
'& > *': {
|
|
76
|
+
pointerEvents: 'auto'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
80
|
+
direction: "row",
|
|
81
|
+
spacing: 1,
|
|
82
|
+
alignItems: "center",
|
|
83
|
+
sx: {
|
|
84
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
85
|
+
borderRadius: '8px',
|
|
86
|
+
padding: '8px 12px',
|
|
87
|
+
backdropFilter: 'blur(10px)'
|
|
88
|
+
}
|
|
89
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
90
|
+
title: "\u653E\u5927",
|
|
91
|
+
placement: "top"
|
|
92
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
93
|
+
onClick: function onClick() {
|
|
94
|
+
if (onScale) {
|
|
95
|
+
var currentScale = getScale();
|
|
96
|
+
onScale(Math.min(currentScale + 0.5, 5));
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
sx: {
|
|
100
|
+
color: 'white',
|
|
101
|
+
'&:hover': {
|
|
102
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)'
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
size: "small"
|
|
106
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
107
|
+
width: "20",
|
|
108
|
+
height: "20",
|
|
109
|
+
viewBox: "0 0 768 768",
|
|
110
|
+
fill: "currentColor"
|
|
111
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
112
|
+
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM415.5 223.5v129h129v63h-129v129h-63v-129h-129v-63h129v-129h63z"
|
|
113
|
+
})))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
114
|
+
title: "\u7F29\u5C0F",
|
|
115
|
+
placement: "top"
|
|
116
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
117
|
+
onClick: function onClick() {
|
|
118
|
+
if (onScale) {
|
|
119
|
+
var currentScale = getScale();
|
|
120
|
+
onScale(Math.max(currentScale - 0.5, 0.5));
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
sx: {
|
|
124
|
+
color: 'white',
|
|
125
|
+
'&:hover': {
|
|
126
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)'
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
size: "small"
|
|
130
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
131
|
+
width: "20",
|
|
132
|
+
height: "20",
|
|
133
|
+
viewBox: "0 0 768 768",
|
|
134
|
+
fill: "currentColor"
|
|
135
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
136
|
+
d: "M384 640.5q105 0 180.75-75.75t75.75-180.75-75.75-180.75-180.75-75.75-180.75 75.75-75.75 180.75 75.75 180.75 180.75 75.75zM384 64.5q132 0 225.75 93.75t93.75 225.75-93.75 225.75-225.75 93.75-225.75-93.75-93.75-225.75 93.75-225.75 225.75-93.75zM223.5 352.5h321v63h-321v-63z"
|
|
137
|
+
})))), /*#__PURE__*/React.createElement(Box, {
|
|
138
|
+
sx: {
|
|
139
|
+
width: '1px',
|
|
140
|
+
height: '24px',
|
|
141
|
+
backgroundColor: 'rgba(255, 255, 255, 0.3)',
|
|
142
|
+
mx: 0.5
|
|
143
|
+
}
|
|
144
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
145
|
+
title: "\u9006\u65F6\u9488\u65CB\u8F6C",
|
|
146
|
+
placement: "top"
|
|
147
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
148
|
+
onClick: function onClick() {
|
|
149
|
+
if (onRotate) {
|
|
150
|
+
var currentRotate = getRotate();
|
|
151
|
+
onRotate(currentRotate - 90);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
sx: {
|
|
155
|
+
color: 'white',
|
|
156
|
+
'&:hover': {
|
|
157
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)'
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
size: "small"
|
|
161
|
+
}, /*#__PURE__*/React.createElement(AnticlockwiseLineIcon, {
|
|
162
|
+
sx: {
|
|
163
|
+
fontSize: '20px'
|
|
164
|
+
}
|
|
165
|
+
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
166
|
+
title: "\u987A\u65F6\u9488\u65CB\u8F6C",
|
|
167
|
+
placement: "top"
|
|
168
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
169
|
+
onClick: function onClick() {
|
|
170
|
+
if (onRotate) {
|
|
171
|
+
var currentRotate = getRotate();
|
|
172
|
+
onRotate(currentRotate + 90);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
sx: {
|
|
176
|
+
color: 'white',
|
|
177
|
+
'&:hover': {
|
|
178
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)'
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
size: "small"
|
|
182
|
+
}, /*#__PURE__*/React.createElement(ClockwiseLineIcon, {
|
|
183
|
+
sx: {
|
|
184
|
+
fontSize: '20px'
|
|
185
|
+
}
|
|
186
|
+
}))), /*#__PURE__*/React.createElement(Box, {
|
|
187
|
+
sx: {
|
|
188
|
+
width: '1px',
|
|
189
|
+
height: '24px',
|
|
190
|
+
backgroundColor: 'rgba(255, 255, 255, 0.3)',
|
|
191
|
+
mx: 0.5
|
|
192
|
+
}
|
|
193
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
194
|
+
title: "\u91CD\u7F6E",
|
|
195
|
+
placement: "top"
|
|
196
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
197
|
+
onClick: handleReset,
|
|
198
|
+
sx: {
|
|
199
|
+
color: 'white',
|
|
200
|
+
'&:hover': {
|
|
201
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)'
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
size: "small"
|
|
205
|
+
}, /*#__PURE__*/React.createElement(ResetLeftFillIcon, {
|
|
206
|
+
sx: {
|
|
207
|
+
fontSize: '20px'
|
|
208
|
+
}
|
|
209
|
+
}))), currentSrc && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
|
|
210
|
+
sx: {
|
|
211
|
+
width: '1px',
|
|
212
|
+
height: '24px',
|
|
213
|
+
backgroundColor: 'rgba(255, 255, 255, 0.3)',
|
|
214
|
+
mx: 0.5
|
|
215
|
+
}
|
|
216
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
217
|
+
title: "\u4E0B\u8F7D",
|
|
218
|
+
placement: "top"
|
|
219
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
220
|
+
onClick: handleDownload,
|
|
221
|
+
sx: {
|
|
222
|
+
color: 'white',
|
|
223
|
+
'&:hover': {
|
|
224
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)'
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
size: "small"
|
|
228
|
+
}, /*#__PURE__*/React.createElement(Download2LineIcon, {
|
|
229
|
+
sx: {
|
|
230
|
+
fontSize: '20px'
|
|
231
|
+
}
|
|
232
|
+
})))), /*#__PURE__*/React.createElement(Box, {
|
|
233
|
+
sx: {
|
|
234
|
+
width: '1px',
|
|
235
|
+
height: '24px',
|
|
236
|
+
backgroundColor: 'rgba(255, 255, 255, 0.3)',
|
|
237
|
+
mx: 0.5
|
|
238
|
+
}
|
|
239
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
240
|
+
title: isFullscreen ? '退出全屏' : '全屏',
|
|
241
|
+
placement: "top"
|
|
242
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
243
|
+
onClick: handleFullscreen,
|
|
244
|
+
sx: {
|
|
245
|
+
color: 'white',
|
|
246
|
+
'&:hover': {
|
|
247
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)'
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
size: "small"
|
|
251
|
+
}, isFullscreen ? /*#__PURE__*/React.createElement(FullscreenExitLineIcon, {
|
|
252
|
+
sx: {
|
|
253
|
+
fontSize: '20px'
|
|
254
|
+
}
|
|
255
|
+
}) : /*#__PURE__*/React.createElement(FullscreenLineIcon, {
|
|
256
|
+
sx: {
|
|
257
|
+
fontSize: '20px'
|
|
258
|
+
}
|
|
259
|
+
}))), /*#__PURE__*/React.createElement(Box, {
|
|
260
|
+
sx: {
|
|
261
|
+
width: '1px',
|
|
262
|
+
height: '24px',
|
|
263
|
+
backgroundColor: 'rgba(255, 255, 255, 0.3)',
|
|
264
|
+
mx: 0.5
|
|
265
|
+
}
|
|
266
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
267
|
+
title: "\u5173\u95ED",
|
|
268
|
+
placement: "top"
|
|
269
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
270
|
+
onClick: function onClick() {
|
|
271
|
+
return onClose && onClose();
|
|
272
|
+
},
|
|
273
|
+
sx: {
|
|
274
|
+
color: 'white',
|
|
275
|
+
'&:hover': {
|
|
276
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)'
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
size: "small"
|
|
280
|
+
}, /*#__PURE__*/React.createElement(CloseCircleFillIcon, {
|
|
281
|
+
sx: {
|
|
282
|
+
fontSize: '20px'
|
|
283
|
+
}
|
|
284
|
+
})))));
|
|
285
|
+
if (typeof document !== 'undefined') {
|
|
286
|
+
return /*#__PURE__*/createPortal(toolbarContent, document.body);
|
|
287
|
+
}
|
|
288
|
+
return toolbarContent;
|
|
289
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var ImageViewerContext = /*#__PURE__*/React.createContext({
|
|
3
|
+
setCurrentSrc: function setCurrentSrc() {},
|
|
4
|
+
visible: false,
|
|
5
|
+
setVisible: function setVisible() {},
|
|
6
|
+
scale: 1,
|
|
7
|
+
setScale: function setScale() {},
|
|
8
|
+
rotate: 0,
|
|
9
|
+
setRotate: function setRotate() {},
|
|
10
|
+
getScale: function getScale() {
|
|
11
|
+
return 1;
|
|
12
|
+
},
|
|
13
|
+
getRotate: function getRotate() {
|
|
14
|
+
return 0;
|
|
15
|
+
},
|
|
16
|
+
onScale: null,
|
|
17
|
+
setOnScale: function setOnScale() {},
|
|
18
|
+
onRotate: null,
|
|
19
|
+
setOnRotate: function setOnRotate() {},
|
|
20
|
+
onClose: null,
|
|
21
|
+
setOnClose: function setOnClose() {}
|
|
22
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import 'react-photo-view/dist/react-photo-view.css';
|
|
3
|
+
import { ImageViewerItem } from './Item';
|
|
4
|
+
import { ImageViewerProvider } from './Provider';
|
|
5
|
+
export type { ImageViewerItemProps, ImageViewerProviderProps } from './types';
|
|
6
|
+
export { ImageViewerItem, ImageViewerProvider };
|
|
7
|
+
declare const _default: {
|
|
8
|
+
Provider: import("react").FC<import("./types").ImageViewerProviderProps>;
|
|
9
|
+
Item: import("react").FC<import("./types").ImageViewerItemProps>;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import 'react-photo-view/dist/react-photo-view.css';
|
|
2
|
+
import { ImageViewerItem } from "./Item";
|
|
3
|
+
import { ImageViewerProvider } from "./Provider";
|
|
4
|
+
export { ImageViewerItem, ImageViewerProvider };
|
|
5
|
+
export default {
|
|
6
|
+
Provider: ImageViewerProvider,
|
|
7
|
+
Item: ImageViewerItem
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const customStyles = "\n .PhotoView-Slider__toolbar {\n display: none !important;\n }\n \n .PhotoView-Slider__banner {\n display: none !important;\n }\n \n .PhotoView-Slider__toolbar-custom {\n position: fixed !important;\n bottom: 0 !important;\n top: auto !important;\n left: 0 !important;\n right: 0 !important;\n z-index: 10000 !important;\n transform: none !important;\n }\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var customStyles = "\n .PhotoView-Slider__toolbar {\n display: none !important;\n }\n \n .PhotoView-Slider__banner {\n display: none !important;\n }\n \n .PhotoView-Slider__toolbar-custom {\n position: fixed !important;\n bottom: 0 !important;\n top: auto !important;\n left: 0 !important;\n right: 0 !important;\n z-index: 10000 !important;\n transform: none !important;\n }\n";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
export interface ImageViewerProviderProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
speed?: number | ((type: number) => number);
|
|
5
|
+
maskOpacity?: number | null;
|
|
6
|
+
onVisibleChange?: (visible: boolean, index: number) => void;
|
|
7
|
+
onIndexChange?: (index: number) => void;
|
|
8
|
+
loop?: boolean | number;
|
|
9
|
+
photoClosable?: boolean;
|
|
10
|
+
maskClosable?: boolean;
|
|
11
|
+
pullClosable?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
maskClassName?: string;
|
|
14
|
+
photoWrapClassName?: string;
|
|
15
|
+
photoClassName?: string;
|
|
16
|
+
loadingElement?: JSX.Element;
|
|
17
|
+
brokenElement?: JSX.Element | ((photoProps: {
|
|
18
|
+
src: string;
|
|
19
|
+
}) => JSX.Element);
|
|
20
|
+
portalContainer?: HTMLElement;
|
|
21
|
+
}
|
|
22
|
+
export interface ImageViewerItemProps {
|
|
23
|
+
src: string;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
render?: (props: {
|
|
26
|
+
attrs: Partial<React.HTMLAttributes<HTMLElement>>;
|
|
27
|
+
scale: number;
|
|
28
|
+
rotate: number;
|
|
29
|
+
}) => ReactNode;
|
|
30
|
+
overlay?: ReactNode;
|
|
31
|
+
width?: number;
|
|
32
|
+
height?: number;
|
|
33
|
+
triggers?: Array<'onClick' | 'onDoubleClick'>;
|
|
34
|
+
}
|
|
35
|
+
export interface ImageViewerContextType {
|
|
36
|
+
setCurrentSrc: (src: string) => void;
|
|
37
|
+
visible: boolean;
|
|
38
|
+
setVisible: (visible: boolean) => void;
|
|
39
|
+
scale: number;
|
|
40
|
+
setScale: (scale: number) => void;
|
|
41
|
+
rotate: number;
|
|
42
|
+
setRotate: (rotate: number) => void;
|
|
43
|
+
getScale: () => number;
|
|
44
|
+
getRotate: () => number;
|
|
45
|
+
onScale: ((scale: number) => void) | null;
|
|
46
|
+
setOnScale: (fn: ((scale: number) => void) | null) => void;
|
|
47
|
+
onRotate: ((rotate: number) => void) | null;
|
|
48
|
+
setOnRotate: (fn: ((rotate: number) => void) | null) => void;
|
|
49
|
+
onClose: (() => void) | null;
|
|
50
|
+
setOnClose: (fn: (() => void) | null) => void;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Box } from "@mui/material";
|
|
2
2
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {
|
|
5
|
-
import 'react-photo-view/dist/react-photo-view.css';
|
|
4
|
+
import { ImageViewerItem } from "../../../component/ImageViewer";
|
|
6
5
|
var ReadonlyImage = function ReadonlyImage(_ref) {
|
|
7
6
|
var attrs = _ref.attrs;
|
|
8
7
|
return /*#__PURE__*/React.createElement(NodeViewWrapper, {
|
|
@@ -13,7 +12,7 @@ var ReadonlyImage = function ReadonlyImage(_ref) {
|
|
|
13
12
|
position: 'relative',
|
|
14
13
|
display: 'inline-block'
|
|
15
14
|
}
|
|
16
|
-
}, /*#__PURE__*/React.createElement(
|
|
15
|
+
}, /*#__PURE__*/React.createElement(ImageViewerItem, {
|
|
17
16
|
src: attrs.src
|
|
18
17
|
}, /*#__PURE__*/React.createElement("img", {
|
|
19
18
|
src: attrs.src,
|
|
@@ -14,9 +14,8 @@ import { ToolbarItem } from "../../../component/Toolbar";
|
|
|
14
14
|
import { alpha, Box, Button, Divider, Stack, TextField, useTheme } from "@mui/material";
|
|
15
15
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
16
16
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
17
|
-
import { PhotoView } from "react-photo-view";
|
|
18
|
-
import 'react-photo-view/dist/react-photo-view.css';
|
|
19
17
|
import { HoverPopover } from "../../../component/HoverPopover";
|
|
18
|
+
import { ImageViewerItem } from "../../../component/ImageViewer";
|
|
20
19
|
import CropImage from "./Crop";
|
|
21
20
|
import InsertImage from "./Insert";
|
|
22
21
|
import ReadonlyImage from "./Readonly";
|
|
@@ -410,7 +409,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
410
409
|
onMouseLeave: function onMouseLeave() {
|
|
411
410
|
return setIsHovering(false);
|
|
412
411
|
}
|
|
413
|
-
}, /*#__PURE__*/React.createElement(
|
|
412
|
+
}, /*#__PURE__*/React.createElement(ImageViewerItem, {
|
|
414
413
|
src: attrs.src
|
|
415
414
|
}, /*#__PURE__*/React.createElement("img", {
|
|
416
415
|
ref: imageRef,
|
|
@@ -144,8 +144,8 @@ export var TableExtendRowColumnButton = function TableExtendRowColumnButton(_ref
|
|
|
144
144
|
}
|
|
145
145
|
}, /*#__PURE__*/React.createElement(AddLineIcon, {
|
|
146
146
|
sx: {
|
|
147
|
-
width: '
|
|
148
|
-
height: '
|
|
147
|
+
width: '0.75rem',
|
|
148
|
+
height: '0.75rem',
|
|
149
149
|
flexShrink: 0,
|
|
150
150
|
color: 'var(--mui-palette-text-disabled)'
|
|
151
151
|
}
|
package/dist/hook/index.js
CHANGED
|
@@ -10,7 +10,6 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
10
10
|
import { getExtensions } from "../extension";
|
|
11
11
|
import { migrateMathStrings } from '@tiptap/extension-mathematics';
|
|
12
12
|
import { useEditor } from '@tiptap/react';
|
|
13
|
-
import { renderToMarkdown } from '@tiptap/static-renderer/pm/markdown';
|
|
14
13
|
var useTiptap = function useTiptap(_ref) {
|
|
15
14
|
var exclude = _ref.exclude,
|
|
16
15
|
extensionsProps = _ref.extensions,
|
|
@@ -119,13 +118,7 @@ var useTiptap = function useTiptap(_ref) {
|
|
|
119
118
|
},
|
|
120
119
|
getMarkdown: function getMarkdown() {
|
|
121
120
|
if (!editor) return '';
|
|
122
|
-
|
|
123
|
-
return editor.getMarkdown();
|
|
124
|
-
}
|
|
125
|
-
return renderToMarkdown({
|
|
126
|
-
extensions: editor.extensionManager.extensions,
|
|
127
|
-
content: editor.getJSON()
|
|
128
|
-
});
|
|
121
|
+
return editor.getMarkdown();
|
|
129
122
|
},
|
|
130
123
|
getText: function getText() {
|
|
131
124
|
return (editor === null || editor === void 0 ? void 0 : editor.getText()) || '';
|