Skip to content

Commit 7c93a8f

Browse files
committed
Remove newlines from sidebar
1 parent 2e74d77 commit 7c93a8f

File tree

5 files changed

+21
-35
lines changed

5 files changed

+21
-35
lines changed

DarkModeSupport/TextResources/ChatbookResources.tr

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9841,15 +9841,16 @@ VX/aMEEQzrerjFhhelYAzofFB3r8AgApYdcE
98419841
FrameMargins->0,
98429842
ImageSize->Automatic],
98439843

9844-
"NotebookAssistantSidebarCell" -> Cell[BoxData[{
9845-
DynamicBox[ToBoxes[Needs["Wolfram`Chatbook`" -> None]; RawBoxes[
9846-
Symbol["Wolfram`Chatbook`ChatbookAction"]["MakeSidebarChatDockedCell"]],
9847-
StandardForm],
9848-
DestroyAfterEvaluation->True], "\n",
9849-
DynamicBox[ToBoxes[Needs["Wolfram`Chatbook`" -> None]; RawBoxes[
9850-
Symbol["Wolfram`Chatbook`ChatModes`Common`sidebarChatInputCell"][]],
9851-
StandardForm],
9852-
DestroyAfterEvaluation->True]}],
9844+
"NotebookAssistantSidebarCell" -> Cell[BoxData[
9845+
RowBox[{
9846+
DynamicBox[ToBoxes[Needs["Wolfram`Chatbook`" -> None]; RawBoxes[
9847+
Symbol["Wolfram`Chatbook`ChatbookAction"]["MakeSidebarChatDockedCell"]],
9848+
StandardForm],
9849+
DestroyAfterEvaluation->True],
9850+
DynamicBox[ToBoxes[Needs["Wolfram`Chatbook`" -> None]; RawBoxes[
9851+
Symbol["Wolfram`Chatbook`ChatModes`Common`sidebarChatInputCell"][]],
9852+
StandardForm],
9853+
DestroyAfterEvaluation->True]}]],
98539854
Editable->True,
98549855
Selectable->False,
98559856
CellMargins->{{0, 0}, {0, 0}},
@@ -9872,8 +9873,8 @@ notebookAssistanceSidebarSettings, "ConversationTitle" -> ""|>),
98729873
GrayLevel[0.95],
98739874
RGBColor[0.1882352, 0.2078431, 0.2274509]],
98749875
CellTags->
9875-
"NotebookAssistantSidebarCell",ExpressionUUID->"6696f587-5fe9-ad4b-a610-\
9876-
df2378d4af41"],
9876+
"NotebookAssistantSidebarCell",ExpressionUUID->"63d02243-e7fb-e74f-b904-\
9877+
32a950285a1a"],
98779878

98789879
"SidebarIconHide" -> (GraphicsBox[{
98799880
Thickness[0.125],

Developer/Resources/FrontEndResources/SideBarChat/NotebookAssistantSideBarCell.wl renamed to Developer/Resources/FrontEndResources/SideBarChat/NotebookAssistantSidebarCell.wl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Cell[
99
StandardForm ],
1010
DestroyAfterEvaluation -> True
1111
],
12-
"\n",
1312
DynamicBox[
1413
ToBoxes[
1514
Needs[ "Wolfram`Chatbook`" -> None ];

Source/Chatbook/ChatModes/Evaluate.wl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ evaluateSidebarChat[ nbo_NotebookObject, sidebarCell_CellObject, input_, Dynamic
8282
scrollablePaneCell = First[ Cells[ sidebarCell, CellTags -> "SidebarScrollingContentCell" ], Missing @ "NoScrollingContent" ];
8383
If[ MissingQ @ scrollablePaneCell,
8484
lastDockedCell = ConfirmMatch[ Last[ Cells[ sidebarCell, CellTags -> "SidebarDockedCell" ], $Failed ], _CellObject, "SidebarDockedCell" ];
85-
NotebookWrite[ System`NotebookLocationSpecifier[ lastDockedCell, "After" ], RowBox[ { "\n", sidebarScrollingCell[ nbo, { cell } ] } ] ];
85+
NotebookWrite[ System`NotebookLocationSpecifier[ lastDockedCell, "After" ], sidebarScrollingCell[ nbo, { cell } ] ];
8686
scrollablePaneCell = ConfirmMatch[ First[ Cells[ sidebarCell, CellTags -> "SidebarScrollingContentCell" ], $Failed ], _CellObject, "UpdatedSidebarScrollableCell" ];
8787
, (* ELSE *)
8888
(* The scrolling pane cell should only exist if it contains content. If it exists without content then something has gone wrong. *)
8989
lastContentCell = ConfirmMatch[ Last[ Cells[ scrollablePaneCell, CellTags -> "SidebarTopCell" ], $Failed ], _CellObject, "NoSidebarScrollingContentCell" ];
90-
NotebookWrite[ System`NotebookLocationSpecifier[ lastContentCell, "After" ], RowBox[ { "\n", cell } ] ]
90+
NotebookWrite[ System`NotebookLocationSpecifier[ lastContentCell, "After" ], cell ]
9191
];
9292

9393
cellObject = ConfirmMatch[ Last[ Cells[ scrollablePaneCell, CellTags -> uuid ], $Failed ], _CellObject, "SidebarChatInputCellObject" ];

Source/Chatbook/ChatModes/UI.wl

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ writeSidebarChatSubDockedCell[ nbo_NotebookObject, sidebarCell_CellObject, conte
122122
,
123123
(* else, write a new sub-cell after the last docked cell *)
124124
lastDockedCell = ConfirmMatch[ Last[ Cells[ sidebarCell, CellTags -> "SidebarDockedCell" ], $Failed ], _CellObject, "SidebarDockedCell" ];
125-
NotebookWrite[ System`NotebookLocationSpecifier[ lastDockedCell, "After" ], RowBox[ { "\n", makeSidebarChatSubDockedCellExpression[ nbo, sidebarCell, content ] } ] ]
125+
NotebookWrite[ System`NotebookLocationSpecifier[ lastDockedCell, "After" ], makeSidebarChatSubDockedCellExpression[ nbo, sidebarCell, content ] ]
126126
];
127127
(* TODO: move selection to side bar chat's input field *)
128128
],
@@ -152,12 +152,7 @@ removeSidebarChatSubDockedCell // beginDefinition;
152152

153153
removeSidebarChatSubDockedCell[ nbo_NotebookObject, sidebarCell_CellObject ] := Module[ { subDockedCell },
154154
subDockedCell = First[ Cells[ sidebarCell, CellTags -> "SidebarSubDockedCell" ], Missing @ "NoSidebarSubDockedCell" ];
155-
If[ ! MissingQ @ subDockedCell,
156-
FrontEndExecute[ {
157-
FrontEnd`SelectionMove[ subDockedCell, Before, Cell ],
158-
FrontEnd`FrontEndToken[ nbo, "DeletePrevious" ], (* remove the newline character before the sub-cell *)
159-
FrontEnd`NotebookDelete @ subDockedCell } ]
160-
]
155+
If[ ! MissingQ @ subDockedCell, NotebookDelete @ subDockedCell ]
161156
];
162157

163158
removeSidebarChatSubDockedCell // endDefinition;
@@ -167,11 +162,7 @@ removeSidebarChatSubDockedCell // endDefinition;
167162
(*removeSidebarTopCell*)
168163
removeSidebarTopCell // beginDefinition;
169164

170-
removeSidebarTopCell[ nbo_NotebookObject, sidebarTopCell_CellObject ] :=
171-
FrontEndExecute[ {
172-
FrontEnd`SelectionMove[ sidebarTopCell, Before, Cell ],
173-
FrontEnd`FrontEndToken[ nbo, "DeletePrevious" ], (* remove the newline character before the top cell *)
174-
FrontEnd`NotebookDelete @ sidebarTopCell } ];
165+
removeSidebarTopCell[ nbo_NotebookObject, sidebarTopCell_CellObject ] := NotebookDelete @ sidebarTopCell;
175166

176167
removeSidebarTopCell // endDefinition;
177168

@@ -182,12 +173,7 @@ removeSidebarScrollingContentCell // beginDefinition;
182173

183174
removeSidebarScrollingContentCell[ nbo_NotebookObject, sidebarCell_CellObject ] := Module[ { scrollablePaneCell },
184175
scrollablePaneCell = First[ Cells[ sidebarCell, CellTags -> "SidebarScrollingContentCell" ], Missing @ "NoScrollingSidebarCell" ];
185-
If[ ! MissingQ @ scrollablePaneCell,
186-
FrontEndExecute[ {
187-
FrontEnd`SelectionMove[ scrollablePaneCell, Before, Cell ],
188-
FrontEnd`FrontEndToken[ nbo, "DeletePrevious" ], (* remove the newline character before the top cell *)
189-
FrontEnd`NotebookDelete @ scrollablePaneCell } ]
190-
]
176+
If[ ! MissingQ @ scrollablePaneCell, NotebookDelete @ scrollablePaneCell ]
191177
];
192178

193179
removeSidebarScrollingContentCell // endDefinition;
@@ -205,7 +191,7 @@ Module[ { sidebarCellObj, dockedCellObj, chatInputCellObj },
205191
With[ { sc = sidebarCellObj, cc = chatInputCellObj, dc = dockedCellObj },
206192
Cell[ BoxData @
207193
PaneBox[
208-
RowBox @ Riffle[ cells, "\n" ],
194+
RowBox @ cells,
209195
AppearanceElements -> {},
210196
ImageSize ->
211197
Dynamic[
@@ -2671,7 +2657,7 @@ loadConversation[ nbo_NotebookObject, sidebarCell_CellObject, id_ ] := Enclose[
26712657
scrollablePaneCell = First[ Cells[ sidebarCell, CellTags -> "SidebarScrollingContentCell" ], Missing @ "NoScrollingContent" ];
26722658
If[ MissingQ @ scrollablePaneCell,
26732659
lastDockedCell = ConfirmMatch[ Last[ Cells[ sidebarCell, CellTags -> "SidebarDockedCell" ], $Failed ], _CellObject, "SidebarDockedCell" ];
2674-
NotebookWrite[ System`NotebookLocationSpecifier[ lastDockedCell, "After" ], RowBox[ { "\n", sidebarScrollingCell[ nbo, cells ] } ] ]
2660+
NotebookWrite[ System`NotebookLocationSpecifier[ lastDockedCell, "After" ], sidebarScrollingCell[ nbo, cells ] ]
26752661
, (* ELSE *)
26762662
NotebookWrite[ scrollablePaneCell, sidebarScrollingCell[ nbo, cells ] ]
26772663
];

Source/Chatbook/FrontEnd.wl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ cloudCellPrint // endDefinition;
709709
cellPrintAfter[ target_ ][ cell_ ] := cellPrintAfter[ target, cell ];
710710

711711
cellPrintAfter[ target_CellObject, cell: Cell[ __, ExpressionUUID -> uuid_, ___ ] ] /; cellTaggedQ[ target, "SidebarTopCell" ] := Enclose[
712-
NotebookWrite[ System`NotebookLocationSpecifier[ target, "After" ], RowBox[ { "\n", cell } ] ];
712+
NotebookWrite[ System`NotebookLocationSpecifier[ target, "After" ], cell ];
713713
(* this should return the CellObject of the newly written inline cell in the scrolling content cell *)
714714
ConfirmMatch[ NextCell @ target, _CellObject, "SidebarCellPrintAfterCellObject" ]
715715
,

0 commit comments

Comments
 (0)