Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
4e19db35
Commit
4e19db35
authored
2 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Graph will now center according to width of free space
parent
09891d72
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Implemented editor in the react framework
Pipeline
#56904
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/editor/js/components/editor.css
+1
-0
1 addition, 0 deletions
src/editor/js/components/editor.css
src/editor/js/components/editor.tsx
+18
-3
18 additions, 3 deletions
src/editor/js/components/editor.tsx
with
19 additions
and
3 deletions
src/editor/js/components/editor.css
+
1
−
0
View file @
4e19db35
div
#ks-editor
#force-graph-renderer
{
width
:
auto
;
overflow-x
:
hidden
;
flex-grow
:
1
;
}
div
#ks-editor
#sidepanel
{
...
...
This diff is collapsed.
Click to expand it.
src/editor/js/components/editor.tsx
+
18
−
3
View file @
4e19db35
...
...
@@ -20,6 +20,7 @@ type stateTypes = {
connectOnDrag
:
boolean
;
selectedNode
:
Node
;
keys
:
{
[
name
:
string
]:
boolean
};
graphWidth
:
number
;
};
type
clickPosition
=
{
graph
:
{
x
:
number
;
y
:
number
};
...
...
@@ -36,6 +37,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
private
defaultWarmupTicks
=
100
;
private
warmupTicks
=
100
;
private
renderer
:
any
;
private
graphContainer
:
any
;
private
graphInFocus
=
false
;
constructor
(
props
:
propTypes
)
{
...
...
@@ -57,8 +59,10 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
this
.
handleNodeDragEnd
=
this
.
handleNodeDragEnd
.
bind
(
this
);
this
.
handleLinkClick
=
this
.
handleLinkClick
.
bind
(
this
);
this
.
selectNode
=
this
.
selectNode
.
bind
(
this
);
this
.
handleResize
=
this
.
handleResize
.
bind
(
this
);
this
.
renderer
=
React
.
createRef
();
this
.
graphContainer
=
React
.
createRef
();
// Set as new state
this
.
state
=
{
...
...
@@ -67,6 +71,7 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
connectOnDrag
:
false
,
selectedNode
:
undefined
,
keys
:
{},
graphWidth
:
1000
,
};
Interactions
.
initInteractions
();
...
...
@@ -111,10 +116,13 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
this
.
state
.
graph
.
onChangeCallbacks
.
push
(
this
.
onHistoryChange
);
// Subscribe to global
key-press
events
// Subscribe to global events
document
.
onkeydown
=
this
.
handleKeyDown
;
document
.
onkeyup
=
this
.
handleKeyUp
;
document
.
onmousedown
=
this
.
handleMouseDown
;
window
.
onresize
=
this
.
handleResize
;
this
.
handleResize
();
return
true
;
}
...
...
@@ -157,6 +165,13 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
});
}
private
handleResize
()
{
const
newGraphWidth
=
this
.
graphContainer
.
current
.
clientWidth
;
this
.
setState
({
graphWidth
:
newGraphWidth
,
});
}
/**
* Handler for background click event on force graph. Adds new node by default.
* @param event Click event.
...
...
@@ -436,11 +451,11 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> {
<
SpaceSelect
onLoadSpace
=
{
this
.
loadSpace
}
/>
<
SpaceManager
/>
<
div
id
=
"content"
>
<
div
id
=
"force-graph-renderer"
>
<
div
id
=
"force-graph-renderer"
ref
=
{
this
.
graphContainer
}
>
{
this
.
state
.
graph
?
(
<
ReactForceGraph2d
ref
=
{
this
.
renderer
}
width
=
{
2000
}
width
=
{
this
.
state
.
graphWidth
}
graphData
=
{
{
nodes
:
this
.
state
.
graph
.
data
.
nodes
,
links
:
this
.
state
.
graph
.
links
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment