@@ -22,6 +22,48 @@ namespace Lean.Meta.Hint
2222
2323open Elab Tactic PrettyPrinter TryThis
2424
25+ /--
26+ A widget for a clickable link (or icon) that inserts text into the document at a given position.
27+
28+ The props to this widget are of the following form:
29+ ```json
30+ {
31+ "range" : {
32+ "start" : {"line" : 100 , "character" : 0 },
33+ "end" : {"line" : 100 , "character" : 5 }
34+ },
35+ "suggestion" : " hi" ,
36+ "acceptSuggestionProps" : {
37+ "kind" : " text" ,
38+ "hoverText" : " Displayed on hover" ,
39+ "linkText" : " Displayed as the text of the link"
40+ }
41+ }
42+ ```
43+ ... or the following form, where `codiconName` is one of the icons at
44+ https://microsoft.github.io/vscode-codicons/dist/codicon.html and `gaps` determines
45+ whether there are clickable spaces surrounding the icon:
46+ ```json
47+ {
48+ "range" : {
49+ "start" : {"line" : 100 , "character" : 0 },
50+ "end" : {"line" : 100 , "character" : 5 }
51+ },
52+ "suggestion" : " hi" ,
53+ "acceptSuggestionProps" : {
54+ "kind" : " icon" ,
55+ "hoverText" : " Displayed on hover" ,
56+ "codiconName" : " search" ,
57+ "gaps" : true
58+ }
59+ }
60+ ```
61+
62+ Note: we cannot add the `builtin_widget_module` attribute here because that would require importing
63+ `Lean.Widget.UserWidget`, which in turn imports much of `Lean.Elab` -- the module where we want to
64+ be able to use this widget. Instead, we register the attribute post-hoc when we declare the regular
65+ "Try This" widget in `Lean.Meta.Tactic.TryThis`.
66+ -/
2567def textInsertionWidget : Widget.Module where
2668 javascript := "
2769import * as React from 'react';
0 commit comments