Browse Source

added poc of external plugin + lib tracim

Skylsmoi 6 years ago
parent
commit
a57005317e
4 changed files with 62 additions and 12 deletions
  1. 19 4
      dist/index.html
  2. 22 0
      dist/plugin/pageHtml.plugin.js
  3. 4 3
      package.json
  4. 17 5
      src/container/WorkspaceContent.jsx

+ 19 - 4
dist/index.html View File

@@ -25,21 +25,36 @@
25 25
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
26 26
     -->
27 27
 
28
-    <!-- script src='./plugin/pageHtml.plugin.js'></script -->
28
+    <script src='./plugin/pageHtml.plugin.js'></script>
29 29
 
30 30
     <script src="./dev/jquery-3.2.1.js"></script>
31 31
     <script src="./dev/popper-1.12.3.js"></script>
32 32
     <script src="./dev/bootstrap-4.0.0-beta.2.js"></script>
33 33
 
34 34
     <script type='text/javascript'>
35
-      function GLOBAL_renderPlugin () {
36
-        pluginPageHtml.renderPlugin('pluginContainer')
35
+      GLOBAL_renderPlugin = pluginName => {
36
+        if (pluginName === 'PageHtml') {
37
+          pluginPageHtml.renderPlugin('pluginContainer')
38
+          console.log('plugin pagehtml rendered')
39
+        }
37 40
       }
38 41
 
39
-      function GLOBAL_dispatchEvent (data) {
42
+      GLOBAL_dispatchEvent = (data) => {
40 43
         var event = new CustomEvent('pluginCustomEvent', {detail: data})
41 44
         document.dispatchEvent(event)
42 45
       }
46
+
47
+      GLOBAL_unmountPlugin = () => {
48
+        console.log('btn close clicked')
49
+        pluginPageHtml.hidePlugin('pluginContainer')
50
+      }
51
+
52
+      // only usefull if plugin doesn't handle fileContent himself
53
+      GLOBAL_handleRequireRedraw = () => {
54
+        var rez = pluginA.destroyPlugin('plugin')
55
+        if (rez) GLOBAL_drawPlugin('redraw')
56
+        else console.log('Erreur, failed at destroying plugin')
57
+      }
43 58
     </script>
44 59
 
45 60
     <script type='text/javascript'>

File diff suppressed because it is too large
+ 22 - 0
dist/plugin/pageHtml.plugin.js


+ 4 - 3
package.json View File

@@ -15,7 +15,7 @@
15 15
   "license": "ISC",
16 16
   "dependencies": {
17 17
     "babel-core": "^6.26.0",
18
-    "babel-eslint": "^8.0.1",
18
+    "babel-eslint": "^8.2.1",
19 19
     "babel-loader": "^7.1.2",
20 20
     "babel-plugin-transform-class-properties": "^6.24.1",
21 21
     "babel-plugin-transform-object-assign": "^6.22.0",
@@ -34,14 +34,15 @@
34 34
     "redux": "^3.7.2",
35 35
     "redux-logger": "^3.0.6",
36 36
     "redux-thunk": "^2.2.0",
37
-    "standard": "^10.0.3",
37
+    "standard": "^11.0.0",
38 38
     "standard-loader": "^6.0.1",
39 39
     "style-loader": "^0.19.0",
40 40
     "stylus": "^0.54.5",
41 41
     "stylus-loader": "^3.0.1",
42 42
     "url-loader": "^0.6.2",
43 43
     "webpack": "^3.8.1",
44
-    "whatwg-fetch": "^2.0.3"
44
+    "whatwg-fetch": "^2.0.3",
45
+    "tracim_lib": "git://github.com/Skylsmoi/tracim_lib.git"
45 46
   },
46 47
   "devDependencies": {
47 48
     "json-server": "^0.12.0",

+ 17 - 5
src/container/WorkspaceContent.jsx View File

@@ -7,12 +7,13 @@ import PageWrapper from '../component/common/layout/PageWrapper.jsx'
7 7
 import PageTitle from '../component/common/layout/PageTitle.jsx'
8 8
 import PageContent from '../component/common/layout/PageContent.jsx'
9 9
 import DropdownCreateButton from '../component/common/Input/DropdownCreateButton.jsx'
10
-import pluginDatabase from '../plugin/index.js'
10
+// import pluginDatabase from '../plugin/index.js'
11 11
 import {
12 12
   getPluginList,
13 13
   getWorkspaceContent
14 14
 } from '../action-creator.async.js'
15 15
 import { setActiveFileContent } from '../action-creator.sync.js'
16
+import { bonjour } from 'tracim_lib'
16 17
 
17 18
 class WorkspaceContent extends React.Component {
18 19
   constructor (props) {
@@ -28,13 +29,23 @@ class WorkspaceContent extends React.Component {
28 29
   }
29 30
 
30 31
   handleClickFileItem = file => {
31
-    this.props.dispatch(setActiveFileContent(file))
32
+    // this.props.dispatch(setActiveFileContent(file))
33
+    GLOBAL_renderPlugin(file.type)
34
+  }
35
+
36
+  handleDummyBtn = () => {
37
+    // GLOBAL_dispatchEvent({
38
+    //   source: 'Tracim',
39
+    //   type: 'PageHtml_showMsg',
40
+    //   content: 'Bonjour ?'
41
+    // })
42
+    bonjour()
32 43
   }
33 44
 
34 45
   render () {
35
-    const { workspace, activeFileContent, plugin } = this.props
46
+    const { workspace, plugin } = this.props
36 47
 
37
-    const PluginContainer = (pluginDatabase.find(p => p.name === activeFileContent.type) || {container: '<div>unknow</div>'}).container
48
+    // const PluginContainer = (pluginDatabase.find(p => p.name === activeFileContent.type) || {container: '<div>unknow</div>'}).container
38 49
 
39 50
     return (
40 51
       <PageWrapper customeClass='workspace'>
@@ -47,6 +58,7 @@ class WorkspaceContent extends React.Component {
47 58
         </PageTitle>
48 59
 
49 60
         <PageContent parentClass='workspace__content'>
61
+          <button onClick={this.handleDummyBtn}>Click Me</button>
50 62
 
51 63
           <div className='workspace__content__fileandfolder folder__content active'>
52 64
             <FileItemHeader />
@@ -69,7 +81,7 @@ class WorkspaceContent extends React.Component {
69 81
           <DropdownCreateButton customClass='workspace__content__button mb-5' />
70 82
 
71 83
           <div id='pluginContainer'>
72
-            { activeFileContent.display && <PluginContainer /> }
84
+            {/* activeFileContent.display && <PluginContainer /> */}
73 85
           </div>
74 86
         </PageContent>
75 87