Skip to content

Commit

Permalink
Bugfix: Fixed broken insert+evaluate buttons for external languages
Browse files Browse the repository at this point in the history
  • Loading branch information
rhennigan committed Dec 2, 2024
1 parent a892fad commit ac8cbd6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion PacletInfo.wl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PacletObject[ <|
"Name" -> "Wolfram/Chatbook",
"PublisherID" -> "Wolfram",
"Version" -> "1.5.2.15",
"Version" -> "1.5.2.16",
"WolframVersion" -> "14.1+",
"Description" -> "Wolfram Notebooks + LLMs",
"License" -> "MIT",
Expand Down
47 changes: 35 additions & 12 deletions Source/Chatbook/Formatting.wl
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,7 @@ evaluateLanguageLabel[ name_String, True ] :=
wl = wolframLanguageQ @ name;
icon = If[ wl, chatbookExpression[ "WorkspaceCodeBlockInsertAndEvaluate" ], $languageIcons @ name ];
If[ ! MatchQ[ icon, _Graphics | _Dynamic | _Image | _RawBoxes ], Throw @ $insertEvaluateButtonLabel ];

labeled = labeledIcon[
If[ wl, { "WorkspaceCodeBlockInsertAndEvaluate", False }, name ],
"FormattingInsertContentAndEvaluateLabel"
];
labeled = labeledIcon[ icon, "FormattingInsertContentAndEvaluateLabel" ];

fancyTooltip[
MouseAppearance[
Expand Down Expand Up @@ -1123,15 +1119,42 @@ buttonPane[ expr_ ] :=
(* ::**************************************************************************************************************:: *)
(* ::Subsubsection::Closed:: *)
(*labeledIcon*)
labeledIcon[ iconTemplateName_String, textResource_String ] := labeledIcon[ { iconTemplateName, True }, textResource ]
labeledIcon // beginDefinition;


labeledIcon[ iconTemplateName_String, textResource_String ] :=
labeledIcon[ { iconTemplateName, True }, textResource ];


labeledIcon[ { iconTemplateName_String, useTemplateBoxQ_ }, textResource_String ] :=
Grid[
{ {
buttonPane @ If[ useTemplateBoxQ, RawBoxes @ templateBox[ { }, iconTemplateName ], chatbookExpression[ iconTemplateName ] ],
Style[ tr @ textResource, FontSize -> 12, FontColor -> RGBColor[ "#333333" ], FontFamily -> "Source Sans Pro" ]
} },
BaselinePosition -> { 1, 2 }, Alignment -> { Left, Baseline }, Spacings -> { 0, 0 } ];
labeledIcon[
If[ useTemplateBoxQ,
RawBoxes @ templateBox[ { }, iconTemplateName ],
chatbookExpression @ iconTemplateName
],
textResource
];


labeledIcon[ icon_, textResource_String ] := Grid[
{
{
buttonPane @ icon,
Style[
tr @ textResource,
FontColor -> RGBColor[ "#333333" ],
FontFamily -> "Source Sans Pro",
FontSize -> 12
]
}
},
Alignment -> { Left, Baseline },
BaselinePosition -> { 1, 2 },
Spacings -> { 0, 0 }
];


labeledIcon // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsubsection::Closed:: *)
Expand Down

0 comments on commit ac8cbd6

Please sign in to comment.