Coder Social home page Coder Social logo

likaia / js-screen-shot Goto Github PK

View Code? Open in Web Editor NEW
726.0 6.0 98.0 2.31 MB

web端自定义截图插件(原生JS版)

Home Page: https://www.kaisir.cn/js-screen-shot/

License: MIT License

JavaScript 5.53% SCSS 4.63% TypeScript 89.26% HTML 0.58%
electron javascript screenshot typescript web-screenshot js-screen-shot

js-screen-shot's Introduction

Hey,I'm MagicalProgrammer. Chinese introduction please move 👉 README-CN


Hello, I'm MagicalProgrammer ,was born in 2000,A front-end development engineer with 4 years of work experience。

You may be curious about my experience. Normally speaking, it is impossible to have such a long work experience. This matter is a long story, interested developers please go to: A 19-year-old programmer's self-study road

GIF

Technology stack and development tools:


Company project experience:

I am mainly responsible for the development and optimization of the core module of the web-side animation editor in the company. Some of the main achievements are::

  • Integrate the analysis of materials in apng format, and write a set of apng-to-canvas library (support playback control and specified frame jump)
  • Implement the search function of the svg text component in the canvas, and solve the problem that the browser does not support the search for svg text type elements by default
  • Implemented the function of exporting draft content in the editor to PDF to support users' printing needs
  • Responsible for the architecture design and development of a set of node middle-tier services that modify the draft content through the API within the company (using nest for implementation)

The online address of the project:

Personal website and technical community:

In my spare time, I will summarize what I have learned into articles and post them to the Nuggets technology community. At present, I have written more than 100 articles, with a total reading volume of 900,000+ and a total of 9000+ likes.

I'm looking for a job recently, if you think I'm pretty good, you can give me a chance. 😋

js-screen-shot's People

Contributors

1042970366 avatar gitbutler-client avatar jackshawn avatar l1ol2 avatar likaia avatar lucifer-zhu avatar sulgweb avatar zkcpps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

js-screen-shot's Issues

能否增加一个初始剪裁框的配置选项

当前情况下是得需要拖动鼠标才能出现裁剪框,能否增加一个初始剪裁框的配置选项,在一进入页面时就自动生成裁剪框,出现在页面正**,框的大小有默认值,而且也支持配置

可以添加到剪贴板吗?

截图点击确认勾选后,可以自动添加到剪贴板吗?就像微信截图那样,可以把图片直接发给别人

fix: 截图效果不正确

注意看 button 的边缘在截图时被改变了。

期望效果

image

得到效果

image

环境

复现步骤

  • 运行下面的代码
  • 点击 点我,再点击 确定图标
  • 在浏览器控制台中打开 callback 回调的 base64
<head>
  <meta charset="UTF-8">
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/screenShotPlugin.umd.js"></script>
  <title>屏幕截图</title>
</head>
<body>
  <button id="btn">点我</button>
  <div>
    <button>一个按钮</button>
    <p>这是一些其他元素……</p>
  </div>
  <script>
    btn.onclick = () => {
      // 截图确认按钮回调函数
      const callback = (base64) => {
        console.log(`callback`, base64)
      }
      // 截图取消时的回调函数
      const closeFn = () => {
        console.log(`closeFn`)
      }
      new screenShotPlugin({ enableWebRtc: false, completeCallback: callback, closeCallback: closeFn })
    }
  </script>
</body>
</html>

开启 clickCutFullScreen 全屏 时,工具栏错位了,急

开启 clickCutFullScreen 全屏 时,在工具栏上,随便点开一个箭头或者框框,主工具栏,就会被顶走,然后,就回不来了,而且,选择颜色的,也显示不全。。。

image

如果可以的话,建议给工具栏加一个拖动功能,全屏时,可以随意拖动的,避免被挡住要操作的地方。
不过,如果拖动工具栏,那么,工具栏下的配置栏,在显示时,也要跟随改变位置。

另外,输入文本那个,不能修改文本颜色吗?

html2canvas模式蒙层 加载慢

大神,如题,该模式下从点击截图 到 黑色蒙版显示到窗口中,需要5秒左右怎么搞?给人的感觉是,点了截图,没反应一样。然后等5秒,黑色蒙版出来了。。

取消分享又回调事件吗

现在是点击截图,然后又想”取消“,想在“取消”的时候做一些操作。能否把取消分享的回调事件暴露出来?
image

imgSrc 参数配置

        new ScreenShot({
          enableWebRtc: false,
          imgSrc: canvas.toDataURL('image/png'),
        })

使用这个配置后,在截图界面,传入的图片和原页面截图都能看到。能否实现在截图界面只显示传入图片,将原页面截图隐藏起来?

裁剪框尺寸信息显示问题

当裁剪菜单出现在裁剪框下面时,裁剪框尺寸信息能正常显示在裁剪框左上角;
但裁剪框菜单如果出现在裁剪框上方,裁剪框尺寸信息就不显示了

页面有滚动条时,蒙层位置错误,并且截图位置错误

1.在页面有滚动条的情况下,蒙层还始终定位在左上角,没有跟随滚动条自动定位到浏览器可视窗口内

微信图片_20220624102520

2.在页面有滚动条,使用的是canvas2html模式,点击蒙层区域开始截图时,画布会吧整个页面的内容都集中在长宽为一屏的蒙层范围内,使的蒙层内的页面内容挤压,导致本来要截图的位置和蒙层生成原来点击的位置,页面内容不同

微信图片_20220624103909

          // 截图确认按钮回调函数
            const callback = (base64) =>{
                console.log(base64);
            }

            // 截图取消时的回调函数
            const closeFn = ()=>{
                console.log("截图窗口关闭");
                stopBodyScroll(false)
            }
            new screenShotPlugin({
                enableWebRtc: false,
                completeCallback: callback,
                closeCallback: closeFn,
                loadCrossImg: true,
            });

截图被压缩了,救救孩子吧

页面元素超过一屏时,画面会挤压
image
image

示例代码

<title></title>
截图
		<ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li><li>8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li><li>20</li><li>21</li><li>22</li><li>23</li><li>24</li><li>25</li><li>26</li><li>27</li><li>28</li><li>29</li><li>30</li><li>31</li><li>32</li><li>33</li><li>34</li><li>35</li><li>36</li><li>37</li><li>38</li><li>39</li><li>40</li><li>41</li><li>42</li><li>43</li><li>44</li><li>45</li><li>46</li><li>47</li><li>48</li><li>49</li><li>50</li><li>51</li><li>52</li><li>53</li><li>54</li><li>55</li><li>56</li><li>57</li><li>58</li><li>59</li><li>60</li><li>61</li><li>62</li><li>63</li><li>64</li><li>65</li><li>66</li><li>67</li><li>68</li><li>69</li><li>70</li><li>71</li><li>72</li><li>73</li><li>74</li><li>75</li><li>76</li><li>77</li><li>78</li><li>79</li><li>80</li><li>81</li><li>82</li><li>83</li><li>84</li><li>85</li><li>86</li><li>87</li><li>88</li><li>89</li><li>90</li><li>91</li><li>92</li><li>93</li><li>94</li><li>95</li><li>96</li><li>97</li><li>98</li><li>99</li><li>100</li></ul>
	</div>
	
	<script src="./screenShotPlugin.umd.js"></script>
	
	<script>
	
		// 截图确认按钮回调函数
	    const callback = (base64) =>{
	      console.log(base64);
	    }
	    // 截图取消时的回调函数
	    const closeFn = ()=>{
	      console.log("截图窗口关闭");
	    }
		
		function screenShotStart(){
			new screenShotPlugin({enableWebRtc: false, completeCallback: callback,closeCallback: closeFn});
		}
	</script>
</body>

设置level后,文字标注的输入域看不到。

我的配置
image
截图时输入效果
image
输入后,文字失去光标后的效果
image

还有,enableWebRtc模式的时候,浏览器会弹窗,所以将enableWebRtc设置false,设置后ifream的页面不显示,但是这个ifream页面本身就是允许跨域的,我页面中是也调的通的。
截图前
image
截图后
image

ie兼容性问题

定位到11519行
var nodes = path[1].children;
报错
无法获取未定义或nulll饮用的属性“1”

Take screenshot of visible part

I want to take the screenshot of the visible part directly on button click and then allow editing of the screenshot. How can I achieve this?

使用初始化的裁剪框cropBoxInfo 报错

在使用初始化的裁剪框cropBoxInfo时,如果不拖动裁剪框 直接点确认按钮,就会报下面的异常:
screenShotPlugin.common.js:12767 Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The source width is 0. at saveCanvasToBase64 (http://localhost/ui/accident/app.js:123863:21) at getCanvasImgData (http://localhost/ui/accident/app.js:123920:16) at toolClickEvent (http://localhost/ui/accident/app.js:124232:18) at HTMLDivElement.<anonymous> (http://localhost/ui/accident/app.js:124468:13)
如果拖动一下裁剪框,就能正常裁剪

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.