Content Not Refreshed Correctly when Modifying Pasted Content in Callbacks#1107
Open
chadrschroeder wants to merge 1 commit intobasecamp:mainfrom
Open
Content Not Refreshed Correctly when Modifying Pasted Content in Callbacks#1107chadrschroeder wants to merge 1 commit intobasecamp:mainfrom
chadrschroeder wants to merge 1 commit intobasecamp:mainfrom
Conversation
…aste and trix-change callbacks are refreshed in the editor when pasting plain text
|
Bump to see what are the plans to get this merged and/or a workaround based on issue #1103 |
|
I'm seeing this as well and have a feature where I want to copy some text from a spot in my UI and paste it into Trix to be processed as another instance of an existing ContentAttachment. However, because of this bug, it doesn't work until you press space or type another character, as described above. I ended up working around this by having the copy feature write HTML to the clipboard even though I really only need plain text. For whatever reason Trix does process the paste with HTML properly. function copyDateTag(button) {
const taskDiv = button.closest('.task-date-tag');
const pastableString = taskDiv.querySelector('.pastable-date-tag-string');
const content = `${pastableString.textContent.trim()}`;
// Need to use HTML because if you paste plain text into Trix it will not
// process the pasted content as a ContentAttachment until another char
// is pressed. See https://github.com/basecamp/trix/pull/1107
const clipboardItem = new ClipboardItem({
'text/html': new Blob([content], { type: 'text/html' }),
'text/plain': new Blob([content], { type: 'text/plain' })
});
navigator.clipboard.write([clipboardItem])
.then(() => {
// Update button text while preserving the icon
const originalText = button.innerHTML;
const icon = button.querySelector('svg').outerHTML;
button.innerHTML = `${icon} Copied!`;
setTimeout(() => {
button.innerHTML = originalText;
}, 2000);
})
.catch(error => console.error('Failed to copy:', error));
}But it'd be nice to get this one merged! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1103.
When pasting plain text content or a URL, if you modify the content in a
trix-changeortrix-pastecallback, the changes aren't reflected in the editor after the paste is finished. The changes are reflected later if you start to type in the editor.This pull request updates how the render is performed to match other areas like this.