feffery_utils_components 0.2.0-rc10 → 0.2.0-rc11
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/DESCRIPTION +1 -1
- package/NAMESPACE +1 -0
- package/Project.toml +1 -1
- package/README.md +1 -1
- package/feffery_utils_components/FefferyDiv.py +1 -1
- package/feffery_utils_components/FefferyDom2Image.py +68 -0
- package/feffery_utils_components/__init__.py +2 -1
- package/feffery_utils_components/_imports_.py +2 -0
- package/feffery_utils_components/alias.py +2 -0
- package/feffery_utils_components/async-feffery_animated_3d_background_p5.js +1 -1
- package/feffery_utils_components/async-feffery_animated_3d_background_three.js +2 -2
- package/feffery_utils_components/async-feffery_animated_image.js +1 -1
- package/feffery_utils_components/async-feffery_aplayer.js +1 -1
- package/feffery_utils_components/async-feffery_auto_animate.js +1 -1
- package/feffery_utils_components/async-feffery_auto_fit.js +1 -1
- package/feffery_utils_components/async-feffery_captcha.js +1 -1
- package/feffery_utils_components/async-feffery_color_pickers.js +1 -1
- package/feffery_utils_components/async-feffery_dom2image.js +4 -0
- package/feffery_utils_components/async-feffery_dom2image.js.LICENSE.txt +1 -0
- package/feffery_utils_components/async-feffery_dplayer.js +1 -1
- package/feffery_utils_components/async-feffery_emoji_picker.js +1 -1
- package/feffery_utils_components/async-feffery_excel_preview.js +1 -1
- package/feffery_utils_components/async-feffery_extra_spinner.js +1 -1
- package/feffery_utils_components/async-feffery_fancy_button.js +1 -1
- package/feffery_utils_components/async-feffery_grid.js +1 -1
- package/feffery_utils_components/async-feffery_image_cropper.js +1 -1
- package/feffery_utils_components/async-feffery_json_viewer.js +1 -1
- package/feffery_utils_components/async-feffery_local_large_storage.js +1 -1
- package/feffery_utils_components/async-feffery_markdown_editor.js +2 -2
- package/feffery_utils_components/async-feffery_motion.js +1 -1
- package/feffery_utils_components/async-feffery_music_player.js +1 -1
- package/feffery_utils_components/async-feffery_photo_sphere_viewer.js +1 -1
- package/feffery_utils_components/async-feffery_resizable.js +1 -1
- package/feffery_utils_components/async-feffery_rich_text_editor.js +2 -2
- package/feffery_utils_components/async-feffery_rnd.js +1 -1
- package/feffery_utils_components/async-feffery_seamless_scroll.js +1 -1
- package/feffery_utils_components/async-feffery_shortcut_panel.js +1 -1
- package/feffery_utils_components/async-feffery_sortable.js +1 -1
- package/feffery_utils_components/async-feffery_word_preview.js +1 -1
- package/feffery_utils_components/async-fuc-shared.js +2 -2
- package/feffery_utils_components/feffery_utils_components.min.js +2 -2
- package/feffery_utils_components/metadata.json +110 -1
- package/feffery_utils_components/package-info.json +2 -1
- package/package.json +2 -1
- package/src/lib/components/FefferyDiv.react.js +3 -1
- package/src/lib/components/FefferyDom2Image.react.js +88 -0
- package/src/lib/fragments/FefferyDom2Image.react.js +59 -0
- package/src/lib/index.js +3 -1
- package/usage.py +50 -24
|
@@ -5944,7 +5944,7 @@
|
|
|
5944
5944
|
}
|
|
5945
5945
|
},
|
|
5946
5946
|
"src/lib/components/FefferyDiv.react.js": {
|
|
5947
|
-
"description": "",
|
|
5947
|
+
"description": "\u8fdb\u9636div\u5bb9\u5668\u7ec4\u4ef6FefferyDiv",
|
|
5948
5948
|
"displayName": "FefferyDiv",
|
|
5949
5949
|
"methods": [],
|
|
5950
5950
|
"props": {
|
|
@@ -6468,6 +6468,115 @@
|
|
|
6468
6468
|
}
|
|
6469
6469
|
}
|
|
6470
6470
|
},
|
|
6471
|
+
"src/lib/components/FefferyDom2Image.react.js": {
|
|
6472
|
+
"description": "",
|
|
6473
|
+
"displayName": "FefferyDom2Image",
|
|
6474
|
+
"methods": [],
|
|
6475
|
+
"props": {
|
|
6476
|
+
"id": {
|
|
6477
|
+
"type": {
|
|
6478
|
+
"name": "string"
|
|
6479
|
+
},
|
|
6480
|
+
"required": false,
|
|
6481
|
+
"description": "\u7ec4\u4ef6id"
|
|
6482
|
+
},
|
|
6483
|
+
"key": {
|
|
6484
|
+
"type": {
|
|
6485
|
+
"name": "string"
|
|
6486
|
+
},
|
|
6487
|
+
"required": false,
|
|
6488
|
+
"description": "\u5f3a\u5236\u5237\u65b0\u7528"
|
|
6489
|
+
},
|
|
6490
|
+
"targetSelector": {
|
|
6491
|
+
"type": {
|
|
6492
|
+
"name": "string"
|
|
6493
|
+
},
|
|
6494
|
+
"required": false,
|
|
6495
|
+
"description": "\u8bbe\u7f6e\u76ee\u6807\u5143\u7d20\u9009\u62e9\u5668\uff0c\u6bcf\u6b21\u6267\u884c\u8f6c\u6362\u64cd\u4f5c\u540e\u90fd\u4f1a\u91cd\u7f6e\u4e3a\u7a7a\u503c"
|
|
6496
|
+
},
|
|
6497
|
+
"scale": {
|
|
6498
|
+
"type": {
|
|
6499
|
+
"name": "number"
|
|
6500
|
+
},
|
|
6501
|
+
"required": false,
|
|
6502
|
+
"description": "\u7cbe\u5ea6\u7f29\u653e\u6bd4\u4f8b\uff0c\u9ed8\u8ba4\u4e3a1",
|
|
6503
|
+
"defaultValue": {
|
|
6504
|
+
"value": "1",
|
|
6505
|
+
"computed": false
|
|
6506
|
+
}
|
|
6507
|
+
},
|
|
6508
|
+
"screenshotResult": {
|
|
6509
|
+
"type": {
|
|
6510
|
+
"name": "exact",
|
|
6511
|
+
"value": {
|
|
6512
|
+
"selector": {
|
|
6513
|
+
"name": "string",
|
|
6514
|
+
"description": "\u8bb0\u5f55\u672c\u6b21\u8f6c\u6362\u7ed3\u679c\u5bf9\u5e94\u7684\u9009\u62e9\u5668",
|
|
6515
|
+
"required": false
|
|
6516
|
+
},
|
|
6517
|
+
"status": {
|
|
6518
|
+
"name": "enum",
|
|
6519
|
+
"value": [
|
|
6520
|
+
{
|
|
6521
|
+
"value": "'success'",
|
|
6522
|
+
"computed": false
|
|
6523
|
+
},
|
|
6524
|
+
{
|
|
6525
|
+
"value": "'failed'",
|
|
6526
|
+
"computed": false
|
|
6527
|
+
}
|
|
6528
|
+
],
|
|
6529
|
+
"description": "\u8bb0\u5f55\u672c\u6b21\u8f6c\u6362\u4efb\u52a1\u7684\u6267\u884c\u72b6\u6001\uff0c\u53ef\u9009\u7684\u6709'success'\u3001'failed'",
|
|
6530
|
+
"required": false
|
|
6531
|
+
},
|
|
6532
|
+
"dataUrl": {
|
|
6533
|
+
"name": "string",
|
|
6534
|
+
"description": "\u82e5\u672c\u6b21\u8f6c\u6362\u6210\u529f\uff0c\u5219\u8bb0\u5f55\u8f6c\u6362\u540e\u7684\u56fe\u7247dataUrl\u4fe1\u606f",
|
|
6535
|
+
"required": false
|
|
6536
|
+
},
|
|
6537
|
+
"timestamp": {
|
|
6538
|
+
"name": "number",
|
|
6539
|
+
"description": "\u5bf9\u5e94\u5f53\u524d\u4efb\u52a1\u5b8c\u6210\u7684\u65f6\u95f4\u6233",
|
|
6540
|
+
"required": false
|
|
6541
|
+
}
|
|
6542
|
+
}
|
|
6543
|
+
},
|
|
6544
|
+
"required": false,
|
|
6545
|
+
"description": "\u76d1\u542c\u6700\u8fd1\u4e00\u6b21\u5143\u7d20\u8f6c\u56fe\u7247\u7684\u7ed3\u679c\u6570\u636e"
|
|
6546
|
+
},
|
|
6547
|
+
"setProps": {
|
|
6548
|
+
"type": {
|
|
6549
|
+
"name": "func"
|
|
6550
|
+
},
|
|
6551
|
+
"required": false,
|
|
6552
|
+
"description": "Dash-assigned callback that should be called to report property changes\r\nto Dash, to make them available for callbacks."
|
|
6553
|
+
},
|
|
6554
|
+
"loading_state": {
|
|
6555
|
+
"type": {
|
|
6556
|
+
"name": "shape",
|
|
6557
|
+
"value": {
|
|
6558
|
+
"is_loading": {
|
|
6559
|
+
"name": "bool",
|
|
6560
|
+
"description": "Determines if the component is loading or not",
|
|
6561
|
+
"required": false
|
|
6562
|
+
},
|
|
6563
|
+
"prop_name": {
|
|
6564
|
+
"name": "string",
|
|
6565
|
+
"description": "Holds which property is loading",
|
|
6566
|
+
"required": false
|
|
6567
|
+
},
|
|
6568
|
+
"component_name": {
|
|
6569
|
+
"name": "string",
|
|
6570
|
+
"description": "Holds the name of the component that is loading",
|
|
6571
|
+
"required": false
|
|
6572
|
+
}
|
|
6573
|
+
}
|
|
6574
|
+
},
|
|
6575
|
+
"required": false,
|
|
6576
|
+
"description": ""
|
|
6577
|
+
}
|
|
6578
|
+
}
|
|
6579
|
+
},
|
|
6471
6580
|
"src/lib/components/FefferyEmojiPicker.react.js": {
|
|
6472
6581
|
"description": "",
|
|
6473
6582
|
"displayName": "FefferyEmojiPicker",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feffery_utils_components",
|
|
3
|
-
"version": "0.2.0-
|
|
3
|
+
"version": "0.2.0-rc11",
|
|
4
4
|
"description": "Build more utility components for Plotly Dash.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"localforage": "^1.10.0",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
56
|
"mathjax": "^3.2.2",
|
|
57
|
+
"modern-screenshot": "^4.4.38",
|
|
57
58
|
"nano-css": "^5.3.5",
|
|
58
59
|
"ninja-keys": "^1.1.12",
|
|
59
60
|
"nprogress": "^0.2.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "feffery_utils_components",
|
|
3
|
-
"version": "0.2.0-
|
|
3
|
+
"version": "0.2.0-rc11",
|
|
4
4
|
"description": "Build more utility components for Plotly Dash.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"localforage": "^1.10.0",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
56
56
|
"mathjax": "^3.2.2",
|
|
57
|
+
"modern-screenshot": "^4.4.38",
|
|
57
58
|
"nano-css": "^5.3.5",
|
|
58
59
|
"ninja-keys": "^1.1.12",
|
|
59
60
|
"nprogress": "^0.2.0",
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { Suspense } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
const LazyFefferyDom2Image = React.lazy(() => import(/* webpackChunkName: "feffery_dom2image" */ '../fragments/FefferyDom2Image.react'));
|
|
5
|
+
|
|
6
|
+
const FefferyDom2Image = (props) => {
|
|
7
|
+
return (
|
|
8
|
+
<Suspense fallback={null}>
|
|
9
|
+
<LazyFefferyDom2Image {...props} />
|
|
10
|
+
</Suspense>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 定义参数或属性
|
|
15
|
+
FefferyDom2Image.propTypes = {
|
|
16
|
+
/**
|
|
17
|
+
* 组件id
|
|
18
|
+
*/
|
|
19
|
+
id: PropTypes.string,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 强制刷新用
|
|
23
|
+
*/
|
|
24
|
+
key: PropTypes.string,
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 设置目标元素选择器,每次执行转换操作后都会重置为空值
|
|
28
|
+
*/
|
|
29
|
+
targetSelector: PropTypes.string,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 精度缩放比例,默认为1
|
|
33
|
+
*/
|
|
34
|
+
scale: PropTypes.number,
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 监听最近一次元素转图片的结果数据
|
|
38
|
+
*/
|
|
39
|
+
screenshotResult: PropTypes.exact({
|
|
40
|
+
/**
|
|
41
|
+
* 记录本次转换结果对应的选择器
|
|
42
|
+
*/
|
|
43
|
+
selector: PropTypes.string,
|
|
44
|
+
/**
|
|
45
|
+
* 记录本次转换任务的执行状态,可选的有'success'、'failed'
|
|
46
|
+
*/
|
|
47
|
+
status: PropTypes.oneOf(['success', 'failed']),
|
|
48
|
+
/**
|
|
49
|
+
* 若本次转换成功,则记录转换后的图片dataUrl信息
|
|
50
|
+
*/
|
|
51
|
+
dataUrl: PropTypes.string,
|
|
52
|
+
/**
|
|
53
|
+
* 对应当前任务完成的时间戳
|
|
54
|
+
*/
|
|
55
|
+
timestamp: PropTypes.number
|
|
56
|
+
}),
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Dash-assigned callback that should be called to report property changes
|
|
60
|
+
* to Dash, to make them available for callbacks.
|
|
61
|
+
*/
|
|
62
|
+
setProps: PropTypes.func,
|
|
63
|
+
|
|
64
|
+
loading_state: PropTypes.shape({
|
|
65
|
+
/**
|
|
66
|
+
* Determines if the component is loading or not
|
|
67
|
+
*/
|
|
68
|
+
is_loading: PropTypes.bool,
|
|
69
|
+
/**
|
|
70
|
+
* Holds which property is loading
|
|
71
|
+
*/
|
|
72
|
+
prop_name: PropTypes.string,
|
|
73
|
+
/**
|
|
74
|
+
* Holds the name of the component that is loading
|
|
75
|
+
*/
|
|
76
|
+
component_name: PropTypes.string
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// 设置默认参数
|
|
81
|
+
FefferyDom2Image.defaultProps = {
|
|
82
|
+
scale: 1
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default FefferyDom2Image;
|
|
86
|
+
|
|
87
|
+
export const propTypes = FefferyDom2Image.propTypes;
|
|
88
|
+
export const defaultProps = FefferyDom2Image.defaultProps;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useAsyncEffect } from 'ahooks';
|
|
2
|
+
import { domToPng } from 'modern-screenshot';
|
|
3
|
+
import { propTypes, defaultProps } from '../components/FefferyDom2Image.react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 元素转图片组件FefferyDom2Image
|
|
7
|
+
*/
|
|
8
|
+
const FefferyDom2Image = (props) => {
|
|
9
|
+
const {
|
|
10
|
+
targetSelector,
|
|
11
|
+
scale,
|
|
12
|
+
setProps,
|
|
13
|
+
loading_state
|
|
14
|
+
} = props;
|
|
15
|
+
|
|
16
|
+
// 每次targetSelector更新时,异步进行目标元素转图片操作
|
|
17
|
+
useAsyncEffect(async () => {
|
|
18
|
+
if (targetSelector) {
|
|
19
|
+
// 检查目标元素是否有效
|
|
20
|
+
let target = document.querySelector(targetSelector);
|
|
21
|
+
if (target) {
|
|
22
|
+
domToPng(
|
|
23
|
+
target,
|
|
24
|
+
{
|
|
25
|
+
scale: scale
|
|
26
|
+
}
|
|
27
|
+
).then(
|
|
28
|
+
dataUrl => {
|
|
29
|
+
setProps({
|
|
30
|
+
screenshotResult: {
|
|
31
|
+
selector: targetSelector,
|
|
32
|
+
status: 'success',
|
|
33
|
+
dataUrl: dataUrl,
|
|
34
|
+
timestamp: new Date().getTime()
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
} else {
|
|
40
|
+
setProps({
|
|
41
|
+
screenshotResult: {
|
|
42
|
+
selector: targetSelector,
|
|
43
|
+
status: 'failed',
|
|
44
|
+
dataUrl: null,
|
|
45
|
+
timestamp: new Date().getTime()
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
setProps({ targetSelector: null })
|
|
50
|
+
}
|
|
51
|
+
}, [targetSelector])
|
|
52
|
+
|
|
53
|
+
return <></>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default FefferyDom2Image;
|
|
57
|
+
|
|
58
|
+
FefferyDom2Image.defaultProps = defaultProps;
|
|
59
|
+
FefferyDom2Image.propTypes = propTypes;
|
package/src/lib/index.js
CHANGED
|
@@ -102,6 +102,7 @@ import FefferyRND from "./components/draggable/FefferyRND.react";
|
|
|
102
102
|
import FefferySortable from "./components/sortable/FefferySortable.react";
|
|
103
103
|
import FefferyAnimatedImage from "./components/FefferyAnimatedImage.react";
|
|
104
104
|
import FefferyDebugGuardian from "./components/security/FefferyDebugGuardian.react";
|
|
105
|
+
import FefferyDom2Image from "./components/FefferyDom2Image.react";
|
|
105
106
|
import './components/styles.css';
|
|
106
107
|
|
|
107
108
|
// 自定义sessionStorage事件监听
|
|
@@ -228,5 +229,6 @@ export {
|
|
|
228
229
|
FefferyRND,
|
|
229
230
|
FefferySortable,
|
|
230
231
|
FefferyAnimatedImage,
|
|
231
|
-
FefferyDebugGuardian
|
|
232
|
+
FefferyDebugGuardian,
|
|
233
|
+
FefferyDom2Image
|
|
232
234
|
};
|
package/usage.py
CHANGED
|
@@ -2,25 +2,40 @@ import dash
|
|
|
2
2
|
import json
|
|
3
3
|
from dash import html
|
|
4
4
|
import feffery_utils_components as fuc
|
|
5
|
-
from dash.dependencies import Input, Output
|
|
5
|
+
from dash.dependencies import Input, Output
|
|
6
6
|
|
|
7
7
|
app = dash.Dash(__name__)
|
|
8
8
|
|
|
9
9
|
app.layout = html.Div(
|
|
10
10
|
[
|
|
11
|
+
# 测试元素
|
|
11
12
|
fuc.FefferyDiv(
|
|
12
|
-
|
|
13
|
+
'测试内容',
|
|
14
|
+
id='demo-target',
|
|
15
|
+
shadow='always-shadow-light',
|
|
13
16
|
style={
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
+
'width': 300,
|
|
18
|
+
'height': 200,
|
|
19
|
+
'display': 'flex',
|
|
20
|
+
'justifyContent': 'center',
|
|
21
|
+
'alignItems': 'center',
|
|
22
|
+
'fontSize': 18,
|
|
23
|
+
'fontWeight': 'bold',
|
|
24
|
+
'color': 'white',
|
|
25
|
+
'background': 'linear-gradient(135deg,#17ead9,#6078ea)'
|
|
17
26
|
}
|
|
18
27
|
),
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
# 测试激活元素转图片
|
|
29
|
+
html.Button(
|
|
30
|
+
'打印',
|
|
31
|
+
id='execute-screenshot'
|
|
32
|
+
),
|
|
33
|
+
# 测试元素转图片组件
|
|
34
|
+
fuc.FefferyDom2Image(
|
|
35
|
+
id='demo-dom2image',
|
|
36
|
+
scale=2
|
|
37
|
+
),
|
|
38
|
+
html.Div(id='demo-dom2image-output')
|
|
24
39
|
],
|
|
25
40
|
style={
|
|
26
41
|
'padding': '50px 50px 0 50px'
|
|
@@ -29,23 +44,34 @@ app.layout = html.Div(
|
|
|
29
44
|
|
|
30
45
|
|
|
31
46
|
@app.callback(
|
|
32
|
-
Output('
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
Output('demo-dom2image', 'targetSelector'),
|
|
48
|
+
Input('execute-screenshot', 'n_clicks'),
|
|
49
|
+
prevent_initial_call=True
|
|
50
|
+
)
|
|
51
|
+
def demo(n_clicks):
|
|
52
|
+
|
|
53
|
+
return '#demo-target'
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@app.callback(
|
|
57
|
+
Output('demo-dom2image-output', 'children'),
|
|
58
|
+
Input('demo-dom2image', 'screenshotResult'),
|
|
35
59
|
prevent_initial_call=True
|
|
36
60
|
)
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
def update_result(screenshotResult):
|
|
62
|
+
|
|
63
|
+
return [
|
|
64
|
+
html.Pre(
|
|
65
|
+
json.dumps(
|
|
66
|
+
screenshotResult,
|
|
67
|
+
ensure_ascii=False,
|
|
68
|
+
indent=4
|
|
69
|
+
)
|
|
70
|
+
),
|
|
71
|
+
html.Img(
|
|
72
|
+
src=screenshotResult['dataUrl']
|
|
47
73
|
)
|
|
48
|
-
|
|
74
|
+
]
|
|
49
75
|
|
|
50
76
|
|
|
51
77
|
if __name__ == '__main__':
|