File tree 3 files changed +80
-2
lines changed
3 files changed +80
-2
lines changed Original file line number Diff line number Diff line change 3
3
/dist /
4
4
/node_modules /
5
5
/yarn.lock
6
- /mix-manifest.json
7
- /src /plugins
6
+ /mix-manifest.json
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react'
2
+ import Modal from "antd/lib/modal/Modal" ;
3
+ import Card from "antd/lib/card" ;
4
+ require ( 'antd/lib/card/style' ) ;
5
+
6
+ export default class ImagePreview extends Component {
7
+ constructor ( props ) {
8
+ super ( props ) ;
9
+
10
+ this . state = {
11
+ visible : false ,
12
+ } ;
13
+ }
14
+
15
+ componentWillMount = ( ) => {
16
+ this . setState ( { visible : true } ) ;
17
+ console . log ( this . props . store . item_in_action ) ;
18
+ } ;
19
+
20
+ componentWillUnmount = ( ) => {
21
+ this . setState ( { visible : false } ) ;
22
+ } ;
23
+
24
+ img = ( ) => {
25
+ const path = this . props . store . server ;
26
+ const query = [ 'working_dir=' + this . props . store . working_dir , 'raw=' + this . props . store . item_in_action . basename ] ;
27
+ if ( path . indexOf ( '?' ) > - 1 )
28
+ return path + '&' + query . join ( '&' ) ;
29
+ return path + '?' + query . join ( ( '&' ) ) ;
30
+ } ;
31
+
32
+ handleOk = ( ) => {
33
+ this . handleCancel ( ) ;
34
+ this . props . store . clearPlugin ( ) ;
35
+ } ;
36
+
37
+ handleCancel = ( ) => {
38
+ this . setState ( { visible : false } ) ;
39
+ } ;
40
+
41
+ render = ( ) => {
42
+ return (
43
+ < Modal
44
+ title = { this . props . store . item_in_action . basename }
45
+ visible = { this . state . visible }
46
+ onOk = { this . handleOk }
47
+ onCancel = { this . handleCancel }
48
+ >
49
+ < Card
50
+ hoverable
51
+ style = { { width : 240 } }
52
+ cover = { < img alt = "example" src = { this . img ( ) } /> }
53
+ >
54
+ < Card . Meta
55
+ title = { "Europe Street beat" }
56
+ description = { "www.instagram.com" }
57
+ />
58
+ </ Card >
59
+ </ Modal >
60
+ ) ;
61
+ } ;
62
+ } ;
Original file line number Diff line number Diff line change
1
+ import ImagePreview from "./ImagePreview" ;
2
+
3
+ export default {
4
+ image_preview : {
5
+ component : ImagePreview ,
6
+ categories : [ ] ,
7
+ context_menu : {
8
+ scopes : [ 'image' ] ,
9
+ label : 'Preview' ,
10
+ category : 'preview' ,
11
+ callback ( store , item ) {
12
+ store . item_in_action = item ;
13
+ store . selectPlugin ( 'image_preview' ) . call ( store ) ;
14
+ }
15
+ }
16
+ }
17
+ } ;
You can’t perform that action at this time.
0 commit comments