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

Improve multi-file insertion performance #355

Merged
merged 3 commits into from
Dec 21, 2016
Merged
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
2 changes: 1 addition & 1 deletion src/trix/controllers/input_controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Trix.InputController extends Trix.BasicObject
Promise.all(operations).then (files) =>
@handleInput ->
@delegate?.inputControllerWillAttachFiles()
@responder?.insertFile(file) for file in files
@responder?.insertFiles(files)
@requestRender()

# Input handlers
Expand Down
1 change: 1 addition & 0 deletions src/trix/inspector/views/performance_view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Trix.Inspector.registerView class extends Trix.Inspector.View
@data = {}
@track("documentView.render")
@track("documentView.sync")
@track("documentView.garbageCollectCachedViews")
@track("composition.replaceHTML")

@render()
Expand Down
8 changes: 8 additions & 0 deletions src/trix/models/composition.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ class Trix.Composition extends Trix.BasicObject
attachment = Trix.Attachment.attachmentForFile(file)
@insertAttachment(attachment)

insertFiles: (files) ->
text = new Trix.Text
for file in files when @delegate?.compositionShouldAcceptFile(file)
attachment = Trix.Attachment.attachmentForFile(file)
attachmentText = Trix.Text.textForAttachmentWithAttributes(attachment, @currentAttributes)
text = text.appendText(attachmentText)
@insertText(text)

insertAttachment: (attachment) ->
text = Trix.Text.textForAttachmentWithAttributes(attachment, @currentAttributes)
@insertText(text)
Expand Down
3 changes: 2 additions & 1 deletion src/trix/views/object_view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class Trix.ObjectView extends Trix.BasicObject
recordChildView: (view) ->
view.parentView = this
view.rootView = @rootView
@childViews.push(view)
unless view in @childViews
@childViews.push(view)
view

getAllChildViews: ->
Expand Down