From 7bc4a0f7979625def5149c0cc1f1d6116fa54541 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 26 Dec 2020 17:00:29 +0100 Subject: [PATCH] Bug fixed --- ...-paragraph-styles-009-docs-list-style.json | 14 +- .../UI/Spaces/Docs-Space/DocsSpace.js | 148 ++++++++---------- 2 files changed, 72 insertions(+), 90 deletions(-) diff --git a/Projects/Superalgos/Schemas/Docs-Topics/docs-paragraph-styles-009-docs-list-style.json b/Projects/Superalgos/Schemas/Docs-Topics/docs-paragraph-styles-009-docs-list-style.json index 265fa7177..ef8fc8889 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/docs-paragraph-styles-009-docs-list-style.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/docs-paragraph-styles-009-docs-list-style.json @@ -8,17 +8,13 @@ "style": "Text", "text": "Any text you type while editting a paragraph of this style will be displayed as a item of a list, represented as a text after a bullet point. If you use colon quotation mark at some point in your text except at the end, all the text before the colon will be rendered in bold." }, + { + "style": "Title", + "text": "Example:" + }, { "style": "List", - "text": "For example: from here there is normal text." - }, - { - "style": "Text", - "text": "Example:" - }, - { - "style": "Text", - "text": "Example:" + "text": "Before colon is bold: after colon is normal text." } ] } \ No newline at end of file diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 94bcc3bb9..52df0de1e 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -463,7 +463,7 @@ function newSuperalgosDocSpace() { let paragraphs = [] let paragraph = '' let splittedSelectedParagraph = selectedParagraph.id.split('-') - let selectedParagraphIndex = Number(splittedSelectedParagraph[2]) + let selectededitableParagraphIndex = Number(splittedSelectedParagraph[2]) let selectedParagraphStyle = splittedSelectedParagraph[3] let style = selectedParagraphStyle.charAt(0).toUpperCase() + selectedParagraphStyle.slice(1); @@ -484,7 +484,7 @@ function newSuperalgosDocSpace() { if (paragraphs[0] !== '') { docSchemaParagraph.text = paragraphs[0] } else { - docsSchemaDocument.paragraphs.splice(selectedParagraphIndex, 1) + docsSchemaDocument.paragraphs.splice(selectededitableParagraphIndex, 1) if (docsSchemaDocument.paragraphs.length === 0) { let newParagraph = { style: 'Text', @@ -504,7 +504,7 @@ function newSuperalgosDocSpace() { style: style, text: paragraphs[i] } - docsSchemaDocument.paragraphs.splice(selectedParagraphIndex + i, 0, newParagraph) + docsSchemaDocument.paragraphs.splice(selectededitableParagraphIndex + i, 0, newParagraph) } } @@ -998,21 +998,6 @@ function newSuperalgosDocSpace() { renderCommandResultsPage([category + " " + type + " has no paragraphs."]) return } - /* - if (anchor !== undefined) { - let anchorFound = false - for (let i = 0; i < docsSchemaDocument.paragraphs.length; i++) { - let paragraph = docsSchemaDocument.paragraphs[i] - if (paragraph.style === 'Anchor' && paragraph.text === anchor) { - anchorFound = true - } - } - if (anchorFound === false) { - renderCommandResultsPage(["Anchor " + anchor + " does not exist."]) - return - } - } -*/ navigateTo(project, category, type, anchor, undefined) } @@ -1882,7 +1867,8 @@ function newSuperalgosDocSpace() { addDefinitionTable(docsSchemaDocument, 'definition-editable-', objectBeingRendered.category, objectBeingRendered.project, objectBeingRendered.type) - let paragraphIndex = 0 + let editableParagraphIndex = 0 + let autoGeneratedParagraphIndex = 0 if (objectBeingRendered.category === 'Topic') { generateMultiPageIndex() @@ -1942,13 +1928,13 @@ function newSuperalgosDocSpace() { the documents that share the same key thatn the document we are rendering now. With the info on those picked document we will build the index. */ - let key = 'auto-generated-index-paragraph-' + paragraphIndex + let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex let paragraph = { style: "Title", text: "" + docsSchemaDocument.topic + " Topic Index" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ let orderedIndexArray = [] let schemaArray = SCHEMAS_BY_PROJECT.get(objectBeingRendered.project).array.docsTopicSchema @@ -1980,12 +1966,12 @@ function newSuperalgosDocSpace() { for (let i = 0; i < orderedIndexArray.length; i++) { let arrayItem = orderedIndexArray[i] paragraph - key = 'auto-generated-index-paragraph-' + paragraphIndex + key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex paragraph = { style: "Title", text: "" + arrayItem.pageNumber + '. ' + arrayItem.type + "" } - paragraphIndex++ + autoGeneratedParagraphIndex++ HTML = HTML + '

' + paragraph.text + '

' } } @@ -1994,25 +1980,25 @@ function newSuperalgosDocSpace() { HTML = HTML + '
' if (docsSchemaDocument.paragraphs !== undefined) { for (let i = 0; i < docsSchemaDocument.paragraphs.length; i++) { - let key = 'editable-paragraph-' + paragraphIndex + let key = 'editable-paragraph-' + editableParagraphIndex let paragraph = docsSchemaDocument.paragraphs[i] if (paragraph.style === "Include") { renderParagraph(paragraph, key) - paragraphIndex++ + editableParagraphIndex++ let error = addIncludedParagraphs(paragraph.text) if (error !== undefined) { paragraph = { style: "Error", text: error } - key = 'error-paragraph-' + paragraphIndex + key = 'error-paragraph-' + autoGeneratedParagraphIndex renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ } } else { renderParagraph(paragraph, key) - paragraphIndex++ + editableParagraphIndex++ } } } @@ -2066,7 +2052,7 @@ function newSuperalgosDocSpace() { let blockFound = false for (let i = 0; i < includedSchemaDocument.paragraphs.length; i++) { - let key = 'included-paragraph-' + paragraphIndex + let key = 'included-paragraph-' + autoGeneratedParagraphIndex let paragraph = includedSchemaDocument.paragraphs[i] if (blockFound === false) { @@ -2079,20 +2065,20 @@ function newSuperalgosDocSpace() { } if (paragraph.style === "Include") { renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ let error = addIncludedParagraphs(paragraph.text) if (error !== undefined) { paragraph = { style: "Error", text: error } - key = 'error-paragraph-' + paragraphIndex + key = 'error-paragraph-' + autoGeneratedParagraphIndex renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ } } else { renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ } } } @@ -2298,7 +2284,7 @@ function newSuperalgosDocSpace() { Menu Items */ let paragraph - let key = 'auto-generated-paragraph-' + paragraphIndex + let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex if (appSchemaDocument === undefined || appSchemaDocument.menuItems === undefined) { return } paragraph = { @@ -2306,13 +2292,13 @@ function newSuperalgosDocSpace() { text: "" + appSchemaDocument.type + " Menu" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "Each type of node, might have a menu defines so that users can interact with the node. There is no fixed set of menu items. Instead each menu item is defined at each node's definition. Each menu item defined carries a set of properties that allow the system to execute some action when the menu item is clicked by users. The " + appSchemaDocument.type + " node has the following menu items:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ for (let i = 0; i < appSchemaDocument.menuItems.length; i++) { let menuItem = appSchemaDocument.menuItems[i] @@ -2324,7 +2310,7 @@ function newSuperalgosDocSpace() { text: 'The ' + menuItem.label + ' menu item has the following properties:' } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ for (const property in menuItem) { paragraph = { @@ -2332,7 +2318,7 @@ function newSuperalgosDocSpace() { text: property + ": " + menuItem[property] } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ } HTML = HTML + '
' @@ -2342,7 +2328,7 @@ function newSuperalgosDocSpace() { text: "When any of the menu items is grayed out, it means that " + appSchemaDocument.type + " already has the type of children that that menu item can add, and that only one children is possible in that case. " } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ } function generateChildrenNodesProperties() { @@ -2350,7 +2336,7 @@ function newSuperalgosDocSpace() { Children Nodes Properties */ let paragraph - let key = 'auto-generated-paragraph-' + paragraphIndex + let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex if (appSchemaDocument === undefined || appSchemaDocument.childrenNodesProperties === undefined) { return } @@ -2359,13 +2345,13 @@ function newSuperalgosDocSpace() { text: "" + appSchemaDocument.type + " Children" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "Each type of node might have children. If they do, a reference to the children will be present at runtime at one or more properties of the node object. There is no generic childrenNodes property with an array of children nodes. Instead what we can find is that each schema document defines which properties will hold those children references. The property names that will be used for that are the ones listed here. The " + appSchemaDocument.type + " node has the following children nodes properties:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ for (let i = 0; i < appSchemaDocument.childrenNodesProperties.length; i++) { let childrenNodesProperty = appSchemaDocument.childrenNodesProperties[i] @@ -2379,7 +2365,7 @@ function newSuperalgosDocSpace() { text: 'The ' + name + ' children node property has in turn the following properties:' } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ for (const property in childrenNodesProperty) { paragraph = { @@ -2387,7 +2373,7 @@ function newSuperalgosDocSpace() { text: property + ": " + childrenNodesProperty[property] } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ } HTML = HTML + '' @@ -2399,7 +2385,7 @@ function newSuperalgosDocSpace() { Attaching Rules */ let paragraph - let key = 'auto-generated-paragraph-' + paragraphIndex + let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex if (appSchemaDocument === undefined || (appSchemaDocument.attachingRules === undefined && appSchemaDocument.referencingRules === undefined)) { return } paragraph = { @@ -2407,13 +2393,13 @@ function newSuperalgosDocSpace() { text: "" + appSchemaDocument.type + " Attaching Rules" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "Each type of node, might have a set of rules that defines to which nodes it can be attached to. Usually the nodes it can attach to have listed at their own definitions " + appSchemaDocument.type + " as one of its potential children. That does not mean that " + appSchemaDocument.type + " can be created at those parents; only if there is a menu item for adding it, then it will be possible, otherwise it might be created at some other node and later attached to one of the nodes defined in these rules. At runtime, the node that a node is attached to, we call it Parent Node. The following are the rules that govern the attacment of " + appSchemaDocument.type + " with other nodes:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ if (appSchemaDocument.attachingRules !== undefined) { if (appSchemaDocument.attachingRules.compatibleTypes !== undefined) { @@ -2422,7 +2408,7 @@ function newSuperalgosDocSpace() { text: "Compatible Types:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ let splittedTypes = appSchemaDocument.attachingRules.compatibleTypes.split('->') listAllTheseNodes(splittedTypes, 'attaching-rules-compatible-types') @@ -2433,7 +2419,7 @@ function newSuperalgosDocSpace() { text: "Incompatible Types:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ let splittedTypes = appSchemaDocument.attachingRules.incompatibleTypes.split('->') listAllTheseNodes(splittedTypes, 'attaching-rules-incompatible-types') @@ -2454,7 +2440,7 @@ function newSuperalgosDocSpace() { Referencing Rules */ let paragraph - let key = 'auto-generated-paragraph-' + paragraphIndex + let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex if (appSchemaDocument === undefined || (appSchemaDocument.referencingRules === undefined && appSchemaDocument.referencingRules === undefined)) { return } paragraph = { @@ -2462,13 +2448,13 @@ function newSuperalgosDocSpace() { text: "" + appSchemaDocument.type + " Referencing Rules" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "Each type of node, might have a set of rules that defines to which node it can stablish a reference to. At runtime once a reference is stablished, we call the referenced node the Reference Parent. The following are the rules that govern the referencing of " + appSchemaDocument.type + " with other nodes:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ if (appSchemaDocument.referencingRules !== undefined) { if (appSchemaDocument.referencingRules.compatibleTypes !== undefined) { @@ -2477,7 +2463,7 @@ function newSuperalgosDocSpace() { text: "Compatible Types:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ let splittedTypes = appSchemaDocument.referencingRules.compatibleTypes.split('->') listAllTheseNodes(splittedTypes, 'referencing-rules-compatible-types') @@ -2488,7 +2474,7 @@ function newSuperalgosDocSpace() { text: "Incompatible Types:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ let splittedTypes = appSchemaDocument.referencingRules.incompatibleTypes.split('->') listAllTheseNodes(splittedTypes, 'referencing-rules-incompatible-types') @@ -2509,26 +2495,26 @@ function newSuperalgosDocSpace() { Configuration */ let paragraph - let key = 'auto-generated-paragraph-' + paragraphIndex + let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex if (appSchemaDocument === undefined || appSchemaDocument.editors === undefined || appSchemaDocument.editors.config !== true) { return } paragraph = { style: "Title", text: "" + appSchemaDocument.type + " Configuration" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "Each type of node, might have a configuration. The configuration can be accesed by users and changed at anytime. Whatever is at the configuration of a node is used by the processes in which the node is involved." } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Subtitle", text: "Initial Values:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ if (appSchemaDocument.initialValues === undefined || appSchemaDocument.initialValues.config === undefined) { return } @@ -2537,27 +2523,27 @@ function newSuperalgosDocSpace() { text: "Each type of node, might have a definition with the initial values for it's configuration. The Initial Values are set one the node is first created. The Initial Values for " + appSchemaDocument.type + " are:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ let initialValues = JSON.parse(appSchemaDocument.initialValues.config) paragraph = { style: "Json", text: JSON.stringify(initialValues, undefined, 4) } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Subtitle", text: "Examples:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "This is a list of properties used at the " + appSchemaDocument.type + " configuration. Expanding a property shows you sample values for that property." } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ /* Here we will scan the whole workspace, first looking for nodes of the same type, and after that, analysing their configuration in order to extract all the properties @@ -2609,7 +2595,7 @@ function newSuperalgosDocSpace() { text: value } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ } HTML = HTML + '' @@ -2621,20 +2607,20 @@ function newSuperalgosDocSpace() { Code */ let paragraph - let key = 'auto-generated-paragraph-' + paragraphIndex + let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex if (appSchemaDocument === undefined || appSchemaDocument.editors === undefined || appSchemaDocument.editors.code !== true) { return } paragraph = { style: "Title", text: "" + appSchemaDocument.type + " Code" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "Some types of node, might have code that defines it's behaviour. The code can usually be accesed by users via the Edit menu item. " } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ if (appSchemaDocument.initialValues === undefined || appSchemaDocument.initialValues.code === undefined) { return } @@ -2643,33 +2629,33 @@ function newSuperalgosDocSpace() { text: "Initial Value:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "When first created, the code of a node is initialized with the initial value present at the node's definition. The Initial Value for " + appSchemaDocument.type + " is:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Javascript", text: JSON.stringify(appSchemaDocument.initialValues.code, undefined, 4) } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Subtitle", text: "Examples:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "This is a list of examples used at the " + appSchemaDocument.type + " code collected from this workspace." } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ /* Here we will scan the whole workspace, first looking for nodes of the same type, and after that, analysing their code in order to extract examples to show. @@ -2706,7 +2692,7 @@ function newSuperalgosDocSpace() { text: code } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ HTML = HTML + '' } @@ -2717,20 +2703,20 @@ function newSuperalgosDocSpace() { Formula */ let paragraph - let key = 'auto-generated-paragraph-' + paragraphIndex + let key = 'auto-generated-paragraph-' + autoGeneratedParagraphIndex if (appSchemaDocument === undefined || appSchemaDocument.editors === undefined || appSchemaDocument.editors.formula !== true) { return } paragraph = { style: "Title", text: "" + appSchemaDocument.type + " Formula" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "Some types of node represents Formulas and they hold code that defines that formula. The code can usually be accesed by users via the Edit menu item. " } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ if (appSchemaDocument.initialValues === undefined || appSchemaDocument.initialValues.code === undefined) { return } @@ -2739,33 +2725,33 @@ function newSuperalgosDocSpace() { text: "Initial Value:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "When first created, the code of a node is initialized with the initial value present at the node's definition. The Initial Value for " + appSchemaDocument.type + " is:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Javascript", text: JSON.stringify(appSchemaDocument.initialValues.code, undefined, 4) } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Subtitle", text: "Examples:" } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ paragraph = { style: "Text", text: "This is a list of examples used at the " + appSchemaDocument.type + " code collected from this workspace." } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ /* Here we will scan the whole workspace, first looking for nodes of the same type, and after that, analysing their code in order to extract examples to show. @@ -2802,7 +2788,7 @@ function newSuperalgosDocSpace() { text: code } renderParagraph(paragraph, key) - paragraphIndex++ + autoGeneratedParagraphIndex++ HTML = HTML + '' }