-
-
Notifications
You must be signed in to change notification settings - Fork 423
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
Can't always paste text (e.g. Slack) #741
Comments
I cannot think off the top of my head what it would be if not for those... you can open the inspector in slack and see what it is? |
Sadly the inspected fails to reveal anything, unless I'm misusing it.
|
First open the inspector, then right click on the element in question, and it will show you in the modal popup an option to focus on that inspector. Mine is in Greek, so I don't know what the command is |
That's what I meant: the inspector can only focus on the whole page, it
fails to narrow down to the subelements.
Maybe Firefox / Chrome's inspectors can do that. I'll try.
|
It can focus on sub elements, I’ve used that functionality before |
Yes, just not here. My guess is that Slack ain't pretty :p
|
My bad, I tried again and it worked :p
Here is the HTML element:
```
<div class="ql-editor" data-gramm="false" contenteditable="true" id="undefined" dir="auto" role="textbox" tabindex="0" [...] aria-multiline="true" aria-autocomplete="list" aria-expanded="false" aria-owns="chat_input_tab_ui" spellcheck="true"><p>FOOBAR</p></div>
```
I guess we need to check for `contenteditable`, maybe `role=textbox`. Thoughts?
|
contenteditable is a good attribute to check for, I don't know if it is automatically set for textarea and inputs (i.e. what will the JS test return if you try: textarea.contenteditable), but that works |
I tried the following checks in the %paste Parenscript:
```
(define-parenscript %paste ((input-text (ring-insert-clipboard (clipboard-ring *browser*))))
(let* ((tag (ps:chain document active-element tag-name))
;; We should check for parent if content-editable is "inherited".
;; See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/contenteditable.
(editable? (ps:chain document active-element content-editable))
;; See https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/textbox_role.
(role (ps:chain document active-element (get-attribute "role"))))
(when (or (string= editable? "true")
(string= role "textbox")
(string= tag "INPUT")
(string= tag "TEXTAREA"))
(let ((start-position (ps:chain document active-element selection-start))
(end-position (ps:chain document active-element selection-end)))
(setf (ps:chain document active-element value)
(+ (ps:chain document active-element value (substring 0 start-position))
(ps:lisp input-text)
(ps:chain document active-element value
(substring end-position
(ps:chain document active-element value length)))))))))
```
On Slack, it keeps erroring out:
```
<WARN> [19:25:34] JavaScript error: GError: Domain: "WebKitJavascriptError", Code: 699, Message: https://app.slack.com/client/T06G50708/CU5LWFM28:8:75: TypeError: undefined is not an object (evaluating 'document.activeElement.value.substring')
```
Any idea why that is?
|
perhaps it is trying to retrieve an attribute that does not exist, maybe it should be a list of TRY rather than an OR |
I get the same error with just the content-editable line.
Using TRY won't fix the issue because the test won't pass for the Slack
text area, and thus C-v won't work.
|
it is now possible to paste using the native paste (since it has been re-enabled). |
Since we've disabled C-v and 'paste' because it hangs (#593) we can only paste using some Javascript which inserts text into input / text tags.
This does not work everywhere however, e.g. in the Slack message area.
Could it be possible that it's neither an input nor a text tag? What are the other editable HTML elements?
The text was updated successfully, but these errors were encountered: