Skip to content

Commit

Permalink
Merge pull request #1851 from scireum/feature/sbi/SIRI-880
Browse files Browse the repository at this point in the history
BREAKING: Uses new sirius JS clipboard helper
  • Loading branch information
sabieber authored Sep 29, 2023
2 parents 89450ac + 2d0e3a4 commit eaee8fa
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<properties>
<sirius.kernel>dev-38.3.0</sirius.kernel>
<sirius.web>dev-70.5.0</sirius.web>
<sirius.web>dev-71.0.0</sirius.web>
<sirius.db>dev-54.2.2</sirius.db>
</properties>

Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/default/assets/scripts/smart-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function openSmartValues(elementId, type, payload, signature) {
' <span class="pl-2">{{label}}</span>' +
' </a>' +
' {{#copyPayload}}' +
' <a href="javascript:copyToClipboard(\'{{copyPayload}}\')" class="smart-value-link btn btn-link ml-2 text-small">' +
' <a href="javascript:sirius.copyToClipboard(\'{{copyPayload}}\')" class="smart-value-link btn btn-link ml-2 text-small">' +
' <i class="far fa-clipboard"></i>' +
' </a>' +
' {{/copyPayload}}' +
Expand All @@ -55,4 +55,3 @@ function openSmartValues(elementId, type, payload, signature) {
$('#' + elementId).attr('data-original-title', html).tooltip('show');
});
}

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script type="text/javascript">
sirius.ready(function () {
document.querySelector('#supportLink').addEventListener('click', function () {
copyToClipboard(window.location.protocol + '//' + window.location.host + '/tenants/select/@user().getTenantId()?goto=' + encodeURIComponent(window.location.href));
sirius.copyToClipboard(window.location.protocol + '//' + window.location.host + '/tenants/select/@user().getTenantId()?goto=' + encodeURIComponent(window.location.href));

clearMessages();
addSuccessMessage('@i18n("footer.html.supportLinkCopiedSuccessfully")');
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/default/taglib/k/section.html.pasta
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
sirius.ready(function () {
document.getElementById('@copyAnchorId').addEventListener('click', function () {
const signedArticleId = document.getElementById('urlField').value;
copyToClipboard(signedArticleId + '#@anchor')
sirius.copyToClipboard(signedArticleId + '#@anchor')

clearMessages();
addSuccessMessage('@i18n("KnowledgeBase.urlClipboardSuccess")');
Expand Down
19 changes: 1 addition & 18 deletions src/main/resources/default/templates/biz/storage/list.html.pasta
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
</i:if>
<i:if test="!child.isDirectory()">
<t:dropdownItem
url="@apply('javascript:copyToClipboard(\'%s\')', child.path().replace('\'', '\\\''))"
url="@apply('javascript:sirius.copyToClipboard(\'%s\')', child.path().replace('\'', '\\\''))"
icon="fa fa-copy" labelKey="VFSController.copyPath"/>
</i:if>
</t:dropdownSection>
Expand Down Expand Up @@ -251,22 +251,5 @@
modalElement.find("#select-file-modal-search-filter").focus();
}).modal('show');
}

function copyToClipboard(value) {
if (!navigator.clipboard) {
fallbackCopyToClipboard(value);
} else {
navigator.clipboard.writeText(value)
}
}

function fallbackCopyToClipboard(value) {
const fakeElem = document.createElement('textarea');
fakeElem.value = value;
document.body.appendChild(fakeElem);
fakeElem.select();
document.execCommand('copy');
document.body.removeChild(fakeElem);
}
</script>
</t:page>

0 comments on commit eaee8fa

Please sign in to comment.