File tree Expand file tree Collapse file tree 14 files changed +64
-104
lines changed Expand file tree Collapse file tree 14 files changed +64
-104
lines changed Original file line number Diff line number Diff line change
1
+ @import url ('@maxgraph/core/css/common.css' );
2
+
3
+ @import url ('./rubber-band.css' );
4
+ @import url ('./general-style.css' );
Original file line number Diff line number Diff line change
1
+ import { Client } from "@maxgraph/core" ;
2
+
3
+ /** Display the maxGraph version in the footer. */
4
+ const fillFooter = ( ) : void => {
5
+ const footer = document . querySelector < HTMLElement > ( 'footer' ) ! ;
6
+ footer . innerText = `Built with maxGraph ${ Client . VERSION } ` ;
7
+ } ;
8
+
9
+ export type FillMainContainerOptions = {
10
+ toolName : string ;
11
+ toolUrl : string ;
12
+ } ;
13
+
14
+ export const fillMainContainerInnerHtml = ( cssSelector : string , options : FillMainContainerOptions ) : void => {
15
+ document . querySelector < HTMLDivElement > ( cssSelector ) ! . innerHTML = `
16
+ <h1>maxGraph <a href="${ options . toolUrl } " target="_blank" rel="noopener noreferrer">${ options . toolName } </a> TypeScript example</h1>
17
+ <p>Display a test graph. Activated behaviours:</p>
18
+ <ul>
19
+ <li>Panning: use mouse right button</li>
20
+ <li>Cells selection with Rubberband: use mouse left button</li>
21
+ </ul>
22
+ <div id="graph-container"></div>
23
+ <footer></footer>
24
+ ` ;
25
+ fillFooter ( ) ;
26
+ } ;
Original file line number Diff line number Diff line change @@ -9,7 +9,13 @@ import {
9
9
} from '@maxgraph/core' ;
10
10
import { registerCustomShapes } from "./custom-shapes" ;
11
11
12
- export const initializeGraph = ( container : HTMLElement ) => {
12
+ /**
13
+ * Initializes the graph inside the given container.
14
+ * @param container if not set, use the element matching the selector '#graph-container'
15
+ */
16
+ export const initializeGraph = ( container ?: HTMLElement ) => {
17
+ container ??= document . querySelector < HTMLElement > ( '#graph-container' ) ! ;
18
+
13
19
// Disables the built-in context menu
14
20
InternalEvent . disableContextMenu ( container ) ;
15
21
Original file line number Diff line number Diff line change
1
+ import { initializeGraph } from './generate-graph' ;
2
+ import { fillMainContainerInnerHtml , FillMainContainerOptions } from "./fill-html-content" ;
3
+
1
4
export { initializeGraph } from './generate-graph' ;
5
+
6
+ export const initializeHtmlAndGraph = ( cssSelector : string , options : FillMainContainerOptions ) : void => {
7
+ fillMainContainerInnerHtml ( cssSelector , options ) ;
8
+ initializeGraph ( ) ;
9
+ } ;
Original file line number Diff line number Diff line change 1
- import '@maxgraph/core/css/common.css' ;
2
- import 'maxgraph-examples-shared/css/rubber-band.css'
3
- import 'maxgraph-examples-shared/css/general-style.css'
1
+ import 'maxgraph-examples-shared/css/all.css' ;
2
+ import { initializeHtmlAndGraph } from 'maxgraph-examples-shared' ;
4
3
5
- import { Client } from "@maxgraph/core" ;
6
- import { initializeGraph } from 'maxgraph-examples-shared' ;
7
-
8
- document . querySelector < HTMLDivElement > ( '#app' ) ! . innerHTML = `
9
- <h1>maxGraph Farm TypeScript example</h1>
10
- <p>Display a test graph. Activated behaviours:</p>
11
- <ul>
12
- <li>Panning: use mouse right button</li>
13
- <li>Cells selection with Rubberband: use mouse left button</li>
14
- </ul>
15
- <div id="graph-container"></div>
16
- <footer></footer>
17
- ` ;
18
-
19
- const footer = document . querySelector < HTMLElement > ( 'footer' ) ! ;
20
- footer . innerText = `Built with maxGraph ${ Client . VERSION } ` ;
21
-
22
- // Creates the graph inside the given container
23
- initializeGraph ( < HTMLElement > document . querySelector ( '#graph-container' ) ) ;
4
+ initializeHtmlAndGraph ( '#app' , { toolName : 'Farm' , toolUrl : 'https://www.farmfe.org/' } )
Original file line number Diff line number Diff line change 8
8
< script type ="module " src ="/src/index.ts "> </ script >
9
9
</ head >
10
10
< body >
11
- < h1 > maxGraph Lit Typescript example</ h1 >
11
+ < h1 > maxGraph < a href =" https://lit.dev/ " target =" _blank " rel =" noopener noreferrer " > Lit</ a > Typescript example</ h1 >
12
12
< p > Display a test graph. Activated behaviours:</ p >
13
13
< ul >
14
14
< li > Panning: use mouse right button</ li >
Original file line number Diff line number Diff line change 8
8
< script type ="module " src ="src/main.ts "> </ script >
9
9
</ head >
10
10
< body >
11
- < h1 > maxGraph Parcel TypeScript example</ h1 >
12
- < p > Display a test graph. Activated behaviours:</ p >
13
- < ul >
14
- < li > Panning: use mouse right button</ li >
15
- < li > Cells selection with Rubberband: use mouse left button</ li >
16
- </ ul >
17
- < div id ="graph-container "> </ div >
18
- < footer > </ footer >
11
+ < div id ="app "> </ div >
19
12
</ body >
20
13
</ html >
Original file line number Diff line number Diff line change @@ -2,12 +2,6 @@ import '@maxgraph/core/css/common.css';
2
2
import 'maxgraph-examples-shared/css/rubber-band.css'
3
3
import 'maxgraph-examples-shared/css/general-style.css'
4
4
5
- import { Client } from '@maxgraph/core' ;
6
- import { initializeGraph } from 'maxgraph-examples-shared' ;
5
+ import { initializeHtmlAndGraph } from 'maxgraph-examples-shared' ;
7
6
8
- // display the maxGraph version in the footer
9
- const footer = document . querySelector < HTMLElement > ( 'footer' ) ! ;
10
- footer . innerText = `Built with maxGraph ${ Client . VERSION } ` ;
11
-
12
- // Creates the graph inside the given container
13
- initializeGraph ( < HTMLElement > document . querySelector ( '#graph-container' ) ) ;
7
+ initializeHtmlAndGraph ( '#app' , { toolName : 'Parcel' , toolUrl : 'https://parceljs.org/' } )
Original file line number Diff line number Diff line change 9
9
< script type ="module " src ='bundle.js '> </ script >
10
10
</ head >
11
11
< body >
12
- < h1 > maxGraph Rollup TypeScript example</ h1 >
13
- < p > Display a test graph. Activated behaviours:</ p >
14
- < ul >
15
- < li > Panning: use mouse right button</ li >
16
- < li > Cells selection with Rubberband: mouse left button</ li >
17
- </ ul >
18
- < div id ="graph-container "> </ div >
19
- < footer > </ footer >
12
+ < div id ="app "> </ div >
20
13
</ body >
21
14
</ html >
Original file line number Diff line number Diff line change 1
1
// import './style.css'; currently loaded by the HTML page
2
- import { Client } from '@maxgraph/core' ;
3
- import { initializeGraph } from 'maxgraph-examples-shared' ;
2
+ import { initializeHtmlAndGraph } from 'maxgraph-examples-shared' ;
4
3
5
- // display the maxGraph version in the footer
6
- const footer = document . querySelector < HTMLElement > ( 'footer' ) ! ;
7
- footer . innerText = `Built with maxGraph ${ Client . VERSION } ` ;
8
-
9
- // Creates the graph inside the given container
10
- const container = document . querySelector < HTMLElement > ( '#graph-container' ) ! ;
11
-
12
- initializeGraph ( container ) ;
4
+ initializeHtmlAndGraph ( '#app' , { toolName : 'Rollup' , toolUrl : 'https://rollupjs.org/' } )
You can’t perform that action at this time.
0 commit comments