-
Notifications
You must be signed in to change notification settings - Fork 3k
[WIKI-830] fix: copy clipboard functionality in the editor #8229
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5ec45a8
feat: enhance clipboard functionality for markdown and HTML content
im-vipin 5bfebbc
fix: improve error handling and state management in CustomImageNodeVi…
im-vipin d11a768
fix: correct asset retrieval query by removing workspace filter in Du…
im-vipin eb214a5
fix: update meta tag creation in PasteAssetPlugin for clipboard HTML …
im-vipin 34b97c9
feat: implement copyMarkdownToClipboard utility for enhanced clipboar…
im-vipin 2478709
refactor: replace copyMarkdownToClipboard utility with copyTextToClip…
im-vipin 2f29caa
refactor: streamline clipboard operations by replacing copyTextToClip…
im-vipin 34d869f
refactor: simplify PasteAssetPlugin by removing unnecessary meta tag …
im-vipin b966b57
feat: implement asset duplication processing on paste for enhanced cl…
im-vipin 1397064
chore:remove async from copy markdown method
im-vipin 4a1ab62
chore: add paste html
im-vipin a2cb145
remove:prevent default
im-vipin 7b47e3c
refactor: remove hasChanges from processAssetDuplication return type …
im-vipin 2ead4e1
Merge branch 'preview' into fix-copy_content
im-vipin 3028810
Merge branch 'preview' into fix-copy_content
im-vipin d1a6f26
Merge remote-tracking branch 'origin/preview' into fix-copy_content
im-vipin 4d04a6b
fix: format options-dropdown.tsx
im-vipin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,7 @@ export const DescriptionVersionsModal = observer(function DescriptionVersionsMod | |
|
|
||
| const handleCopyMarkdown = useCallback(() => { | ||
| if (!editorRef.current) return; | ||
| copyTextToClipboard(editorRef.current.getMarkDown()).then(() => | ||
| editorRef.current.copyMarkdownToClipboard().then(() => | ||
|
||
| setToast({ | ||
| type: TOAST_TYPE.SUCCESS, | ||
| title: t("toast.success"), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,27 @@ export const getEditorRefHelpers = (args: TArgs): EditorRefApi => { | |
| }); | ||
| return markdown; | ||
| }, | ||
| copyMarkdownToClipboard: async () => { | ||
|
||
| if (!editor) return; | ||
|
|
||
| const html = editor.getHTML(); | ||
| const metaData = getEditorMetaData(html); | ||
| const markdown = convertHTMLToMarkdown({ | ||
| description_html: html, | ||
| metaData, | ||
| }); | ||
|
|
||
| const copyHandler = (event: ClipboardEvent) => { | ||
| event.preventDefault(); | ||
| event.clipboardData?.setData("text/plain", markdown); | ||
| event.clipboardData?.setData("text/html", html); | ||
| event.clipboardData?.setData("text/plane-editor-html", html); | ||
| document.removeEventListener("copy", copyHandler); | ||
| }; | ||
|
|
||
| document.addEventListener("copy", copyHandler); | ||
Palanikannan1437 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| document.execCommand("copy"); | ||
| }, | ||
| isAnyDropbarOpen: () => { | ||
| if (!editor) return false; | ||
| const utilityStorage = editor.storage.utility; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.