From 9163377a641a80245fe52df5d5aecaa1f6a8cf4f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 Jan 2021 15:10:18 +0100 Subject: [PATCH] Minor Fixes --- .../UI/Spaces/Docs-Space/ContextMenu.js | 109 ++++++------------ 1 file changed, 35 insertions(+), 74 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js b/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js index c18337129..8614e01a2 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js @@ -1,8 +1,8 @@ function newSuperalgosDocsContextMenu() { let thisObject = { - selectedParagraph: undefined, + selectedParagraph: undefined, getSelection: getSelection, - forceOutClick: forceOutClick, + forceOutClick: forceOutClick, initialize: initialize, finalize: finalize } @@ -123,170 +123,122 @@ function newSuperalgosDocsContextMenu() { function toJavascript() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Javascript' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Javascript') } function toJson() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Json' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Json') } function toText() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Text' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Text') } function toTitle() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Title' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Title') } function toSubtitle() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Subtitle' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Subtitle') } function toNote() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Note' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Note') } function toWarning() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Warning' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Warning') } function toError() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Error' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Error') } function toImportant() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Important' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Important') } function toSuccess() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Success' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Success') } function toCallout() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Callout' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Callout') } function toSummary() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Summary' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Summary') } function toSection() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Section' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Section') } function toList() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'List' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'List') } function toTable() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Table' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Table') } function toHierarchy() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Hierarchy' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Hierarchy') } function toGif() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Gif' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Gif') } function toPng() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Png' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Png') } function toAnchor() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Anchor' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Anchor') } function toBlock() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Block' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Block') } function toInclude() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Include' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Include') } function toChapter() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Chapter' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Chapter') } function toWebPageLink() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Link' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Link') } function toYouTubeVideo() { let docSchemaParagraph = UI.projects.superalgos.spaces.docsSpace.paragraphMap.get(UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.id) - docSchemaParagraph.style = 'Youtube' - forceOutClick() - UI.projects.superalgos.spaces.docsSpace.documentPage.render() + replaceStyle(docSchemaParagraph, 'Youtube') } function copyLink() { @@ -310,6 +262,15 @@ function newSuperalgosDocsContextMenu() { UI.projects.superalgos.utilities.clipboard.copyTextToClipboard(clipboard) forceOutClick() } + + function replaceStyle(docSchemaParagraph, style) { + if (docSchemaParagraph.style !== style) { + UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true + docSchemaParagraph.style = style + forceOutClick() + UI.projects.superalgos.spaces.docsSpace.documentPage.render() + } + } } function forceOutClick() {