From 12c8a50a0f677e759bcf5fa7b271698891b72fba Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Wed, 15 Apr 2020 17:51:57 -0700 Subject: [PATCH] Update the options object to reflect its properties, update the public option interface to include keymap and other little things (#3826) --- core/options.js | 24 +++++++++++++++++++ typings/templates/blockly-interfaces.template | 6 +++++ 2 files changed, 30 insertions(+) diff --git a/core/options.js b/core/options.js index fd97f8d94..84fce92dc 100644 --- a/core/options.js +++ b/core/options.js @@ -106,31 +106,55 @@ Blockly.Options = function(options) { var renderer = options['renderer'] || 'geras'; + /** @type {boolean} */ this.RTL = rtl; + /** @type {boolean} */ this.oneBasedIndex = oneBasedIndex; + /** @type {boolean} */ this.collapse = hasCollapse; + /** @type {boolean} */ this.comments = hasComments; + /** @type {boolean} */ this.disable = hasDisable; + /** @type {boolean} */ this.readOnly = readOnly; + /** @type {number} */ this.maxBlocks = options['maxBlocks'] || Infinity; + /** @type {?Object.} */ this.maxInstances = options['maxInstances']; + /** @type {string} */ this.pathToMedia = pathToMedia; + /** @type {boolean} */ this.hasCategories = hasCategories; + /** @type {!Object} */ this.moveOptions = Blockly.Options.parseMoveOptions(options, hasCategories); /** @deprecated January 2019 */ this.hasScrollbars = this.moveOptions.scrollbars; + /** @type {boolean} */ this.hasTrashcan = hasTrashcan; + /** @type {number} */ this.maxTrashcanContents = maxTrashcanContents; + /** @type {boolean} */ this.hasSounds = hasSounds; + /** @type {boolean} */ this.hasCss = hasCss; + /** @type {boolean} */ this.horizontalLayout = horizontalLayout; + /** @type {Node} */ this.languageTree = languageTree; + /** @type {!Object} */ this.gridOptions = Blockly.Options.parseGridOptions_(options); + /** @type {!Object} */ this.zoomOptions = Blockly.Options.parseZoomOptions_(options); + /** @type {number} */ this.toolboxPosition = toolboxPosition; + /** @type {!Blockly.Theme} */ this.theme = Blockly.Options.parseThemeOptions_(options); + /** @type {!Object} */ this.keyMap = keyMap; + /** @type {string} */ this.renderer = renderer; + /** @type {?Object} */ this.rendererOverrides = options['rendererOverrides']; /** diff --git a/typings/templates/blockly-interfaces.template b/typings/templates/blockly-interfaces.template index 31fa80fbb..4afd7fe2c 100644 --- a/typings/templates/blockly-interfaces.template +++ b/typings/templates/blockly-interfaces.template @@ -5,6 +5,7 @@ declare module Blockly { toolbox?: HTMLElement | string; readOnly?: boolean; trashcan?: boolean; + maxInstances?: {[type: string]: number;}; maxTrashcanContents?: number; collapse?: boolean; comments?: boolean; @@ -35,14 +36,19 @@ declare module Blockly { maxScale?: number; minScale?: number; scaleSpeed?: number; + pinch?: boolean; }; renderer?: string; + keyMap?: {[type: string]: Blockly.Action;}; } interface BlocklyThemeOptions { + base?: string; blockStyles?: {[blocks: string]: Blockly.Theme.BlockStyle;}; categoryStyles?: {[category: string]: Blockly.Theme.CategoryStyle;}; componentStyles?: {[component: string]: any;}; + fontStyle?: Blockly.Theme.FontStyle; + startHats?: boolean; } interface Metrics {