Skip to content

Commit 4fd9e96

Browse files
committed
Add copy button for dotted config properties
1 parent db90a71 commit 4fd9e96

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

_plugins/asciidoctor-extension.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@
5252
end
5353
end
5454

55+
# keeps copy target in hidden span because properties may contain unescaped quotes
56+
# therefore, prefer 'data-clipboard-target' over 'data-clipboard-text'
57+
config_property_id=0
58+
Extensions.register do
59+
inline_macro do
60+
named :config_property_copy_button
61+
resolve_attributes false
62+
process do |parent, target, attrs|
63+
copy_btn = %(<span id="dotted-config-property-#{config_property_id}" hidden>#{target}</span><button class="btn-copy fa fa-clipboard inline-btn-copy" data-clipboard-action="copy" data-clipboard-target="#dotted-config-property-#{config_property_id}" title="Copy to clipboard" do-not-collapse="true"></button>)
64+
config_property_id += 1
65+
create_inline_pass parent, %(#{copy_btn})
66+
end
67+
end
68+
end
5569

5670
### ALL CONFIG page processors
5771

0 commit comments

Comments
 (0)