diff --git a/packages/doenetml-worker/src/components/BooleanInput.js b/packages/doenetml-worker/src/components/BooleanInput.js index 49f428d9c..f7be01803 100644 --- a/packages/doenetml-worker/src/components/BooleanInput.js +++ b/packages/doenetml-worker/src/components/BooleanInput.js @@ -4,6 +4,7 @@ import { returnAnchorStateVariableDefinition, } from "../utils/graphical"; import { + returnLabelAttributes, returnLabelStateVariableDefinitions, returnWrapNonLabelsSugarFunction, } from "../utils/label"; @@ -48,12 +49,6 @@ export default class BooleanInput extends Input { defaultValue: false, public: true, }; - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; attributes.asToggleButton = { createComponentOfType: "boolean", createStateVariable: "asToggleButton", @@ -73,6 +68,8 @@ export default class BooleanInput extends Input { forRenderer: true, }; + Object.assign(attributes, returnLabelAttributes()); + Object.assign(attributes, returnAnchorAttributes()); return attributes; diff --git a/packages/doenetml-worker/src/components/CallAction.js b/packages/doenetml-worker/src/components/CallAction.js index a4b94581c..68d8f7f9e 100644 --- a/packages/doenetml-worker/src/components/CallAction.js +++ b/packages/doenetml-worker/src/components/CallAction.js @@ -4,7 +4,10 @@ import { returnAnchorAttributes, returnAnchorStateVariableDefinition, } from "../utils/graphical"; -import { returnLabelStateVariableDefinitions } from "../utils/label"; +import { + returnLabelAttributes, + returnLabelStateVariableDefinitions, +} from "../utils/label"; import { addStandardTriggeringStateVariableDefinitions, returnStandardTriggeringAttributes, @@ -56,13 +59,6 @@ export default class CallAction extends InlineComponent { // attributes.width = {default: 300}; // attributes.height = {default: 50}; - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; - attributes.actionName = { createComponentOfType: "text", createStateVariable: "actionName", @@ -78,6 +74,8 @@ export default class CallAction extends InlineComponent { forRenderer: true, }; + Object.assign(attributes, returnLabelAttributes()); + Object.assign(attributes, returnAnchorAttributes()); let triggerAttributes = returnStandardTriggeringAttributes( diff --git a/packages/doenetml-worker/src/components/ChoiceInput.js b/packages/doenetml-worker/src/components/ChoiceInput.js index 58d640de2..b25b00cbc 100644 --- a/packages/doenetml-worker/src/components/ChoiceInput.js +++ b/packages/doenetml-worker/src/components/ChoiceInput.js @@ -2,7 +2,10 @@ import Input from "./abstract/Input"; import me from "math-expressions"; import { enumerateCombinations, enumeratePermutations } from "@doenet/utils"; import { setUpVariantSeedAndRng } from "../utils/variants"; -import { returnLabelStateVariableDefinitions } from "../utils/label"; +import { + returnLabelAttributes, + returnLabelStateVariableDefinitions, +} from "../utils/label"; export default class Choiceinput extends Input { constructor(args) { @@ -102,12 +105,7 @@ export default class Choiceinput extends Input { fallBackToParentStateVariable: "submitLabelNoCorrectness", }; - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; + Object.assign(attributes, returnLabelAttributes()); return attributes; } diff --git a/packages/doenetml-worker/src/components/Function.js b/packages/doenetml-worker/src/components/Function.js index 9f8600206..7782141aa 100644 --- a/packages/doenetml-worker/src/components/Function.js +++ b/packages/doenetml-worker/src/components/Function.js @@ -16,7 +16,10 @@ import { returnRoundingAttributes, returnRoundingStateVariableDefinitions, } from "../utils/rounding"; -import { returnWrapNonLabelsSugarFunction } from "../utils/label"; +import { + returnLabelAttributes, + returnWrapNonLabelsSugarFunction, +} from "../utils/label"; import { find_local_global_maxima, find_local_global_minima, @@ -79,12 +82,8 @@ export default class Function extends InlineComponent { // include attributes of graphical components // for case when function is adapted into a curve - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; + Object.assign(attributes, returnLabelAttributes()); + attributes.applyStyleToLabel = { createComponentOfType: "boolean", createStateVariable: "applyStyleToLabel", diff --git a/packages/doenetml-worker/src/components/MathInput.js b/packages/doenetml-worker/src/components/MathInput.js index 16f21718f..fc841cbb3 100644 --- a/packages/doenetml-worker/src/components/MathInput.js +++ b/packages/doenetml-worker/src/components/MathInput.js @@ -7,6 +7,7 @@ import { returnRoundingStateVariableDefinitions, } from "../utils/rounding"; import { + returnLabelAttributes, returnLabelStateVariableDefinitions, returnWrapNonLabelsSugarFunction, } from "../utils/label"; @@ -130,12 +131,9 @@ export default class MathInput extends Input { public: true, forRenderer: true, }; - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; + + Object.assign(attributes, returnLabelAttributes()); + return attributes; } diff --git a/packages/doenetml-worker/src/components/Slider.js b/packages/doenetml-worker/src/components/Slider.js index 0f8ba9ad9..ca410eb9d 100644 --- a/packages/doenetml-worker/src/components/Slider.js +++ b/packages/doenetml-worker/src/components/Slider.js @@ -1,7 +1,10 @@ import { roundForDisplay } from "../utils/math"; import BaseComponent from "./abstract/BaseComponent"; import me from "math-expressions"; -import { returnLabelStateVariableDefinitions } from "../utils/label"; +import { + returnLabelAttributes, + returnLabelStateVariableDefinitions, +} from "../utils/label"; import { returnRoundingAttributeComponentShadowing, returnRoundingAttributes, @@ -50,12 +53,6 @@ export default class Slider extends BaseComponent { createStateVariable: "initialValue", defaultValue: null, }; - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; attributes.showControls = { createComponentOfType: "boolean", createStateVariable: "showControls", @@ -99,6 +96,8 @@ export default class Slider extends BaseComponent { forRenderer: true, }; + Object.assign(attributes, returnLabelAttributes()); + Object.assign(attributes, returnRoundingAttributes()); attributes.bindValueTo = { diff --git a/packages/doenetml-worker/src/components/TextInput.js b/packages/doenetml-worker/src/components/TextInput.js index 8f801059e..0d5d71e35 100644 --- a/packages/doenetml-worker/src/components/TextInput.js +++ b/packages/doenetml-worker/src/components/TextInput.js @@ -4,6 +4,7 @@ import { returnAnchorStateVariableDefinition, } from "../utils/graphical"; import { + returnLabelAttributes, returnLabelStateVariableDefinitions, returnWrapNonLabelsSugarFunction, } from "../utils/label"; @@ -73,12 +74,6 @@ export default class Textinput extends Input { forRenderer: true, public: true, }; - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; attributes.draggable = { createComponentOfType: "boolean", createStateVariable: "draggable", @@ -89,6 +84,8 @@ export default class Textinput extends Input { Object.assign(attributes, returnAnchorAttributes()); + Object.assign(attributes, returnLabelAttributes()); + return attributes; } diff --git a/packages/doenetml-worker/src/components/TriggerSet.js b/packages/doenetml-worker/src/components/TriggerSet.js index cf73ae85c..7e81cd5fb 100644 --- a/packages/doenetml-worker/src/components/TriggerSet.js +++ b/packages/doenetml-worker/src/components/TriggerSet.js @@ -3,7 +3,10 @@ import { returnAnchorAttributes, returnAnchorStateVariableDefinition, } from "../utils/graphical"; -import { returnLabelStateVariableDefinitions } from "../utils/label"; +import { + returnLabelAttributes, + returnLabelStateVariableDefinitions, +} from "../utils/label"; import { addStandardTriggeringStateVariableDefinitions, returnStandardTriggeringAttributes, @@ -30,13 +33,6 @@ export default class triggerSet extends InlineComponent { // attributes.width = {default: 300}; // attributes.height = {default: 50}; - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; - attributes.draggable = { createComponentOfType: "boolean", createStateVariable: "draggable", @@ -47,6 +43,8 @@ export default class triggerSet extends InlineComponent { Object.assign(attributes, returnAnchorAttributes()); + Object.assign(attributes, returnLabelAttributes()); + let triggerAttributes = returnStandardTriggeringAttributes( "triggerActionsIfTriggerNewlyTrue", ); diff --git a/packages/doenetml-worker/src/components/UpdateValue.js b/packages/doenetml-worker/src/components/UpdateValue.js index bfb29b78f..84dee19fd 100644 --- a/packages/doenetml-worker/src/components/UpdateValue.js +++ b/packages/doenetml-worker/src/components/UpdateValue.js @@ -3,7 +3,10 @@ import { returnAnchorAttributes, returnAnchorStateVariableDefinition, } from "../utils/graphical"; -import { returnLabelStateVariableDefinitions } from "../utils/label"; +import { + returnLabelAttributes, + returnLabelStateVariableDefinitions, +} from "../utils/label"; import { normalizeMathExpression } from "@doenet/utils"; import { addStandardTriggeringStateVariableDefinitions, @@ -33,13 +36,6 @@ export default class UpdateValue extends InlineComponent { // attributes.width = {default: 300}; // attributes.height = {default: 50}; - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; - attributes.type = { createPrimitiveOfType: "string", createStateVariable: "type", @@ -98,6 +94,8 @@ export default class UpdateValue extends InlineComponent { Object.assign(attributes, returnAnchorAttributes()); + Object.assign(attributes, returnLabelAttributes()); + let triggerAttributes = returnStandardTriggeringAttributes( "updateValueIfTriggerNewlyTrue", ); diff --git a/packages/doenetml-worker/src/components/abstract/GraphicalComponent.js b/packages/doenetml-worker/src/components/abstract/GraphicalComponent.js index 67771552a..b88229d81 100644 --- a/packages/doenetml-worker/src/components/abstract/GraphicalComponent.js +++ b/packages/doenetml-worker/src/components/abstract/GraphicalComponent.js @@ -1,18 +1,18 @@ import BaseComponent from "./BaseComponent"; import { returnSelectedStyleStateVariableDefinition } from "@doenet/utils"; -import { returnLabelStateVariableDefinitions } from "../../utils/label"; +import { + returnLabelAttributes, + returnLabelStateVariableDefinitions, +} from "../../utils/label"; export default class GraphicalComponent extends BaseComponent { static componentType = "_graphical"; static createAttributesObject() { let attributes = super.createAttributesObject(); - attributes.labelIsName = { - createComponentOfType: "boolean", - createStateVariable: "labelIsName", - defaultValue: false, - public: true, - }; + + Object.assign(attributes, returnLabelAttributes()); + attributes.applyStyleToLabel = { createComponentOfType: "boolean", createStateVariable: "applyStyleToLabel", diff --git a/packages/doenetml-worker/src/utils/label.js b/packages/doenetml-worker/src/utils/label.js index 89a7699d0..09302b55f 100644 --- a/packages/doenetml-worker/src/utils/label.js +++ b/packages/doenetml-worker/src/utils/label.js @@ -1,3 +1,14 @@ +export function returnLabelAttributes() { + return { + labelIsName: { + createComponentOfType: "boolean", + createStateVariable: "labelIsName", + defaultValue: false, + public: true, + }, + }; +} + export function returnWrapNonLabelsSugarFunction({ wrappingComponentType, createAttributeOfType,