setUpWorkspaceSchemas
This commit is contained in:
1 parent
8631580edb
commit
c71b8efd05
2 files changed
+75
-7
No files matched your search
@@ -54,6 +54,7 @@ function newSuperalgosDocSpace() {
|
||||
setUpContextMenu()
|
||||
setUpMenuItemsMap()
|
||||
setUpSearchEngine()
|
||||
setUpWorkspaceSchemas()
|
||||
isInitialized = true
|
||||
|
||||
function setUpContextMenu() {
|
||||
@@ -261,6 +262,66 @@ function newSuperalgosDocSpace() {
|
||||
}
|
||||
}
|
||||
|
||||
function setUpWorkspaceSchemas() {
|
||||
/*
|
||||
We will scan the whole workspace and create an array with all of its nodes.
|
||||
*/
|
||||
let rootNodes = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode.rootNodes
|
||||
let allNodesFound = []
|
||||
for (let i = 0; i < rootNodes.length; i++) {
|
||||
let rootNode = rootNodes[i]
|
||||
if (rootNode !== null) {
|
||||
let nodeArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(rootNode)
|
||||
allNodesFound = allNodesFound.concat(nodeArray)
|
||||
}
|
||||
}
|
||||
/*
|
||||
We will create a document for each node, so that can later be indexed into the search engine.
|
||||
*/
|
||||
for (let j = 0; j < PROJECTS_ARRAY.length; j++) {
|
||||
let project = PROJECTS_ARRAY[j]
|
||||
SCHEMAS_BY_PROJECT.get(project).array.workspaceNodeSchema = []
|
||||
|
||||
for (let i = 0; i < allNodesFound.length; i++) {
|
||||
let node = allNodesFound[i]
|
||||
if (node.project === project) {
|
||||
let document = {
|
||||
type: node.type,
|
||||
definition: node.name,
|
||||
paragraphs: []
|
||||
}
|
||||
if (node.config !== undefined) {
|
||||
let paragraph
|
||||
paragraph = {
|
||||
style: "Subtitle",
|
||||
text: "Config"
|
||||
}
|
||||
document.paragraphs.push(paragraph)
|
||||
paragraph = {
|
||||
syle: "Json",
|
||||
text: node.config
|
||||
}
|
||||
document.paragraphs.push(paragraph)
|
||||
}
|
||||
if (node.code !== undefined) {
|
||||
let paragraph
|
||||
paragraph = {
|
||||
style: "Subtitle",
|
||||
text: "Code"
|
||||
}
|
||||
document.paragraphs.push(paragraph)
|
||||
paragraph = {
|
||||
syle: "Javascript",
|
||||
text: node.code
|
||||
}
|
||||
document.paragraphs.push(paragraph)
|
||||
}
|
||||
}
|
||||
SCHEMAS_BY_PROJECT.get(project).array.workspaceNodeSchema.push(document)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setUpSearchEngine() {
|
||||
for (let j = 0; j < PROJECTS_ARRAY.length; j++) {
|
||||
let project = PROJECTS_ARRAY[j]
|
||||
@@ -2320,7 +2381,7 @@ function newSuperalgosDocSpace() {
|
||||
}
|
||||
|
||||
function resize() {
|
||||
thisObject.container.frame.width = 1000
|
||||
thisObject.container.frame.width = 900
|
||||
thisObject.container.frame.height = browserCanvas.height // - TOP_SPACE_HEIGHT
|
||||
thisObject.container.frame.position.x = browserCanvas.width
|
||||
thisObject.container.frame.position.y = 0 // TOP_SPACE_HEIGHT
|
||||
|
||||
@@ -9,12 +9,15 @@ function newSuperalgosUtilitiesBranches() {
|
||||
function nodeBranchToArray(node, nodeType) {
|
||||
/*
|
||||
This function scans a node branch for a certain node type and
|
||||
return an array of with all the nodes of that type found.
|
||||
return an array of with all the nodes of that type found. Note that once
|
||||
a node with a matching type is found, it's children are not further scanned.
|
||||
|
||||
If nodeType is undefined, then all nodes of this branch will be returned in
|
||||
the array, including the children of the nodes added to the result array.
|
||||
*/
|
||||
if (node === undefined) { return }
|
||||
if (nodeType === undefined) { return }
|
||||
let resultArray = []
|
||||
scanNodeBranch(node, nodeType)
|
||||
let resultArray = []
|
||||
scanNodeBranch(node)
|
||||
return resultArray
|
||||
|
||||
function scanNodeBranch(startingNode) {
|
||||
@@ -23,9 +26,13 @@ function newSuperalgosUtilitiesBranches() {
|
||||
let nodeDefinition = getNodeDefinition(startingNode)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
if (startingNode.type === nodeType) {
|
||||
if (nodeType === undefined) {
|
||||
resultArray.push(startingNode)
|
||||
return
|
||||
} else {
|
||||
if (startingNode.type === nodeType) {
|
||||
resultArray.push(startingNode)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeDefinition.childrenNodesProperties === undefined) { return }
|
||||
|
||||
Reference in new issue
Block a user