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

Persist attachment editing #445

Merged
merged 7 commits into from Sep 29, 2017
Merged

Persist attachment editing #445

merged 7 commits into from Sep 29, 2017

Conversation

@javan
Copy link
Member

javan commented Sep 20, 2017

Problem: If a sync happens while editing an attachment, editing stops and the cursor collapses before it. So, if you're editing an attachment's caption while it uploads, that'll abruptly move the cursor out of the caption editing <textarea> and you'll be typing outside of the attachment.

Idea: Prevent syncing while editing attachments. And, while syncs are prevented, use the shadow element for serialization to ensure the <input> element's value stays current.

@javan javan added the WIP label Sep 20, 2017
@documentView.sync()
@reinstallAttachmentEditor()
@delegate?.compositionControllerDidSyncDocumentView?()
@element.shadowing = @attachmentEditor?

This comment has been minimized.

@javan

javan Sep 20, 2017 Author Member

Using this property to indicate that the shadow element should be used for serializing. Setting it here is less than ideal, but it works for testing the idea.

if value < 100
element.value = value
else
element.style.display = "none"

This comment has been minimized.

@javan

javan Sep 20, 2017 Author Member

Without this change, the progress bar will remain at 100% if you're editing an attachment when it finishes uploading. Would be better to receive a delegate call informing the view that its attachment is no longer pending (it has a url attribute). Currently it's only informed about progress:

constructor: ->
super
@attachment = @object
@attachment.uploadProgressDelegate = this

@@ -23,7 +23,7 @@ class Trix.DocumentView extends Trix.ObjectView
render: ->
@childViews = []

@shadowElement = makeElement("div")
@element.shadowElement = @shadowElement = makeElement("div")

This comment has been minimized.

@javan

javan Sep 20, 2017 Author Member

The editor element should probably create this element when constructed if it's going to be a permanent property. Setting it here is too far removed. Generally, moving serialization out of the element and into EditorController might help centralize the work:

when "change", "attachment-add", "attachment-edit", "attachment-remove"
@inputElement?.value = Trix.serializeToContentType(this, "text/html")

@javan javan force-pushed the persist-attachment-editing-2 branch from 9ba6728 to 6609ac9 Sep 28, 2017
@javan javan merged commit 57aa713 into master Sep 29, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@javan javan deleted the persist-attachment-editing-2 branch Sep 29, 2017
@javan javan removed the WIP label Sep 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.