Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions e2e/signature-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ test("zoom a pdf element", async({page})=> {
await expect(page.locator(".signature-box")).toHaveCount(1)
expect(after.x).not.toBe(before.y);
})

test("duplicates a signature element", async ({ page }) => {
await page.getByTitle("Duplicate").click();
await expect(page.locator(".signature-box")).toHaveCount(2);
Comment on lines +62 to +63

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also verify that the new element is actually a copy of the original one?

Checking only that there are two .signature-box elements would also pass if the duplicate action accidentally created a new default signature instead of copying the selected element. It would be useful to compare an observable property of both elements, such as their content/size, while still allowing the expected position offset.

});
5 changes: 4 additions & 1 deletion examples/basic/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ SPDX-License-Identifier: AGPL-3.0-or-later
/>
</template>

<template #actions="{ onDelete }">
<template #actions="{ onDelete, onDuplicate }">
<DuplicateButton @duplicate="onDuplicate" />
<DeleteButton @delete="onDelete" />
</template>
</PDFElements>
Expand All @@ -63,6 +64,7 @@ import AppToolbar from './components/AppToolbar.vue'
import DocumentsList from './components/DocumentsList.vue'
import SignatureBox from './components/SignatureBox.vue'
import DeleteButton from './components/DeleteButton.vue'
import DuplicateButton from './components/DuplicateButton.vue'
import ElementsViewer from './components/ElementsViewer.vue'

export default defineComponent({
Expand All @@ -73,6 +75,7 @@ export default defineComponent({
DocumentsList,
SignatureBox,
DeleteButton,
DuplicateButton,
ElementsViewer,
},
data() {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/components/DeleteButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineComponent({
.delete-btn {
border: none;
background: transparent;
color: #ffffff;
color: currentColor;
padding: 4px;
border-radius: 4px;
cursor: pointer;
Expand Down
33 changes: 33 additions & 0 deletions examples/basic/components/DuplicateButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<button class="duplicate-btn" type="button" title="Duplicate" @click.stop="$emit('duplicate')">
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
<path d="M16 1H6a2 2 0 0 0-2 2v12h2V3h10V1zm3 4H10a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2zm0 16H10V7h9v14z"/>
</svg>
</button>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
name: 'DuplicateButton',
})
</script>

<style scoped>
.duplicate-btn {
border: none;
background: transparent;
color: currentColor;
padding: 4px;
border-radius: 4px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 120ms ease;
}
.duplicate-btn:hover {
background: rgba(255, 255, 255, 0.1);
}
</style>
Loading