You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param {{title:string, scrollable:boolean?}} config The config for the modal
623
+
* @param {{content:CSSStyleDeclaration?, overlay:CSSStyleDeclaration?}?} styles Sets styles on parts of the modal. If specified, at least one of the parts should have styles.
624
+
* @param {Array<{
625
+
* name:string,
626
+
* role:"ok"|"close"|null,
627
+
* class:"ok"|"cancel"|null,
628
+
* style:CSSStyleDeclaration?,
629
+
* dontClose:boolean?,
630
+
* callback:function():void
631
+
* }>?} buttons Buttons to place onto the modal. `role` makes the button callback run for other types of interactions.
632
+
* @returns {Promise<HTMLElement>}
633
+
*/
634
+
handleCustomPrompt(config,styles,buttons){
621
635
returnnewPromise((resolve,reject)=>{
622
636
/* validate arguments */
623
637
if(config&&isObject(config)){
@@ -631,18 +645,6 @@ class Blocks extends React.Component {
631
645
if(styles&&(!styles.content&&!styles.overlay)){
632
646
returnreject("Custom Modal -- If Param 2 is specified, specify CSS styles within either: 'content' or 'overlay'");
633
647
}
634
-
if(isObject(enterInfo)){
635
-
if(!enterInfo.name||!enterInfo.callback)returnreject("Custom Modal -- Missing name/callback property in Param 3");
636
-
if(enterInfo.callback&&typeofenterInfo.callback!=='function')returnreject("Custom Modal -- callback property in Param 3 must be a function");
637
-
}else{
638
-
returnreject("Custom Modal -- Param 3 must be a object with properties: 'name' (string) and 'callback' (function)");
639
-
}
640
-
if(isObject(closeInfo)){
641
-
if(!closeInfo.name||!closeInfo.callback)returnreject("Custom Modal -- Missing name/callback property in Param 4");
642
-
if(closeInfo.callback&&typeofcloseInfo.callback!=='function')returnreject("Custom Modal -- callback property in Param 4 must be a function");
643
-
}else{
644
-
returnreject("Custom Modal -- Param 4 must be a object with properties: 'name' (string) and 'callback' (function)");
645
-
}
646
648
647
649
// create the callback for when the node is created. an HTML element (or modal) with ref={functionHere} will run the function with the HTMLElement as 1st arg
648
650
constthisPromptId=uid();
@@ -656,7 +658,7 @@ class Blocks extends React.Component {
656
658
this.setState({
657
659
customPrompts: this.state.customPrompts.concat({
658
660
id: thisPromptId,
659
-
config, styles,enterInfo, closeInfo
661
+
config, styles,buttons
660
662
})
661
663
});
662
664
});
@@ -676,23 +678,36 @@ class Blocks extends React.Component {
676
678
* and additional potentially conflicting variable names from the VM
677
679
* to the variable validation prompt callback used in scratch-blocks.
0 commit comments