Skip to content

Commit 4a37b0d

Browse files
authored
Merge pull request #1014 from WolframResearch/bugfix/455056
Links to expression URIs will open the expression in a new notebook
2 parents 2c1d4d0 + 15fc401 commit 4a37b0d

File tree

9 files changed

+74
-11
lines changed

9 files changed

+74
-11
lines changed

Assets/DisplayFunctions.wxf

308 Bytes
Binary file not shown.

Developer/Resources/Styles.wl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,28 @@ Cell[
15151515
]
15161516

15171517

1518+
1519+
(* ::Subsection::Closed:: *)
1520+
(*TextExpressionLink*)
1521+
1522+
1523+
Cell[
1524+
StyleData[ "TextExpressionLink" ],
1525+
TemplateBoxOptions -> {
1526+
DisplayFunction -> Function @ ButtonBox[
1527+
#1,
1528+
Appearance -> None,
1529+
BaseStyle -> { "Text", "Hyperlink" },
1530+
ButtonFunction :> CreateDocument @ BinaryDeserialize @ BaseDecode @ #2,
1531+
DefaultBaseStyle -> { },
1532+
Evaluator -> Automatic,
1533+
Method -> "Queued"
1534+
]
1535+
}
1536+
]
1537+
1538+
1539+
15181540
(* ::Section::Closed:: *)
15191541
(*Package Footer*)
15201542

FrontEnd/Assets/Extensions/CoreExtensions.nb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Notebook[
1111
Cell["Chatbook Core.nb Extensions", "Title"],
1212
Cell[
1313
StyleData["ChatStyleSheetInformation"],
14-
TaggingRules -> <|"StyleSheetVersion" -> "2.0.8.3943617669"|>
14+
TaggingRules -> <|"StyleSheetVersion" -> "2.0.15.3945149906"|>
1515
],
1616
Cell[
1717
StyleData["NotebookAssistant`Text"],
@@ -14078,6 +14078,24 @@ Notebook[
1407814078
]
1407914079
])
1408014080
}
14081+
],
14082+
Cell[
14083+
StyleData["TextExpressionLink"],
14084+
TemplateBoxOptions -> {
14085+
DisplayFunction ->
14086+
(Function[
14087+
ButtonBox[
14088+
#1,
14089+
Appearance -> None,
14090+
BaseStyle -> {"Text", "Hyperlink"},
14091+
ButtonFunction :>
14092+
CreateDocument[BinaryDeserialize[BaseDecode[#2]]],
14093+
DefaultBaseStyle -> { },
14094+
Evaluator -> Automatic,
14095+
Method -> "Queued"
14096+
]
14097+
])
14098+
}
1408114099
]
1408214100
},
1408314101
StyleDefinitions -> "Default.nb"

FrontEnd/StyleSheets/Chatbook.nb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ Notebook[
824824
],
825825
Cell[
826826
StyleData["ChatStyleSheetInformation"],
827-
TaggingRules -> <|"StyleSheetVersion" -> "2.0.8.3943617669"|>
827+
TaggingRules -> <|"StyleSheetVersion" -> "2.0.15.3945149906"|>
828828
],
829829
Cell[
830830
StyleData["NotebookAssistant`Text"],
@@ -14957,6 +14957,24 @@ Notebook[
1495714957
]
1495814958
])
1495914959
}
14960+
],
14961+
Cell[
14962+
StyleData["TextExpressionLink"],
14963+
TemplateBoxOptions -> {
14964+
DisplayFunction ->
14965+
(Function[
14966+
ButtonBox[
14967+
#1,
14968+
Appearance -> None,
14969+
BaseStyle -> {"Text", "Hyperlink"},
14970+
ButtonFunction :>
14971+
CreateDocument[BinaryDeserialize[BaseDecode[#2]]],
14972+
DefaultBaseStyle -> { },
14973+
Evaluator -> Automatic,
14974+
Method -> "Queued"
14975+
]
14976+
])
14977+
}
1496014978
]
1496114979
},
1496214980
StyleDefinitions -> "PrivateStylesheetFormatting.nb"

FrontEnd/StyleSheets/Wolfram/WorkspaceChat.nb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Notebook[
8383
Cell[StyleData["CellExpression"], Selectable -> True],
8484
Cell[
8585
StyleData["WorkspaceChatStyleSheetInformation"],
86-
TaggingRules -> <|"WorkspaceChatStyleSheetVersion" -> "2.0.8.3943617669"|>
86+
TaggingRules -> <|"WorkspaceChatStyleSheetVersion" -> "2.0.15.3945149906"|>
8787
],
8888
Cell[
8989
StyleData["AttachedCell"],

Source/Chatbook/ChatMessages.wl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -989,13 +989,6 @@ $useRasterizationCompatibility := Enclose[
989989
]
990990
];
991991

992-
(* ::**************************************************************************************************************:: *)
993-
(* ::Subsubsection::Closed:: *)
994-
(*expressionURIQ*)
995-
expressionURIQ // beginDefinition;
996-
expressionURIQ[ uri_String ] := KeyExistsQ[ $attachments, StringDelete[ uri, StartOfString ~~ __ ~~ "://" ] ];
997-
expressionURIQ // endDefinition;
998-
999992
(* ::**************************************************************************************************************:: *)
1000993
(* ::Subsubsection::Closed:: *)
1001994
(*graphicsURIQ*)

Source/Chatbook/CommonSymbols.wl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ];
158158
`exportDataURI;
159159
`expressionURIKey;
160160
`expressionURIKeyQ;
161+
`expressionURIQ;
161162
`extractBodyChunks;
162163
`fakeOpenerView;
163164
`fastFileHash;

Source/Chatbook/Formatting.wl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,6 +2778,17 @@ $embeddedImageTemplate = "<div style=\"margin: -8px;\"><img src=\"`1`\" width=\"
27782778
(*hyperlink*)
27792779
hyperlink // beginDefinition;
27802780

2781+
hyperlink[ label_String, uri_String? expressionURIQ ] :=
2782+
If[ TrueQ @ $dynamicText,
2783+
StyleBox[ label, "Hyperlink" ],
2784+
With[ { b = BaseEncode @ BinarySerialize[ GetExpressionURI @ uri, PerformanceGoal -> "Size" ] },
2785+
Cell[
2786+
BoxData @ TemplateBox[ { ToBoxes @ label, b }, "TextExpressionLink" ],
2787+
Background -> None
2788+
]
2789+
]
2790+
];
2791+
27812792
hyperlink[ label_String | { label_String }, uri_String ] /; StringStartsQ[ uri, "paclet:" ] :=
27822793
Cell @ BoxData @ TemplateBox[
27832794
{

Source/Chatbook/Tools/ExpressionURIs.wl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ expressionURIKey // beginDefinition;
180180

181181
expressionURIKey[ str_String ] := expressionURIKey[ str ] = FixedPoint[
182182
StringDelete @ {
183-
StartOfString ~~ "![" ~~ __ ~~ "](",
183+
StartOfString ~~ ("!["|"[") ~~ __ ~~ "](",
184184
StartOfString ~~ LetterCharacter.. ~~ "://",
185185
")"~~EndOfString
186186
},

0 commit comments

Comments
 (0)