Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:fullscreen copy #111

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface Options {
message?: string;
format?: string; // MIME type
onCopy?: (clipboardData: object) => void;
container?: HTMLElement
}

declare function copy(text: string, options?: Options): boolean;
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function copy(text, options) {
if (!options) {
options = {};
}
options.container = options.container || document.body
debug = options.debug || false;
try {
reselectPrevious = deselectCurrent();
Expand Down Expand Up @@ -69,7 +70,7 @@ function copy(text, options) {
}
});

document.body.appendChild(mark);
options.container.appendChild(mark);

range.selectNodeContents(mark);
selection.addRange(range);
Expand Down Expand Up @@ -102,7 +103,7 @@ function copy(text, options) {
}

if (mark) {
document.body.removeChild(mark);
options.container.removeChild(mark);
}
reselectPrevious();
}
Expand Down