Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Make File > Save work on the currently focused editor #445

Merged
merged 3 commits into from
Mar 13, 2012

Conversation

gruehle
Copy link
Member

@gruehle gruehle commented Mar 13, 2012

@peterflynn

This change has a few small parts:

  1. Add isFocused() method to Editor
  2. Add "source" property to the object returned by EditorManager.createInlineEditorFromText()
  3. Add EditorManager.getFocusedEditor() method
  4. Update FileCommandHandlers.handleFileSave() to save the document associated with the currently focused editor.

The only part I'm not sure about is #2. We now have an anonymous object floating around that ties together a document and an editor. This is probably fine for now, but will need to be changed once we have proper Document <--> Editor mapping in place.


// See if any inlines have focus
_currentEditor.getInlineWidgets().forEach(function (widget) {
if (widget.data.editor.hasFocus()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it never happens today, the inline-provider API is structured such that an inline widget could be something other than an inline editor -- meaning 'data' might not necessarily have an 'editor' property. (Eventually when we have real extensibility we may want to make this more rigid, e.g. forcing the data bag to be tagged with a type enum or be an object that we can check with instanceof... but so far we've just been checking for 'editor' to decide whether an inline widget is an inline editor or not).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional test for widget.data.editor added.

@peterflynn
Copy link
Member

Done reviewing

@peterflynn
Copy link
Member

Looks great! Merging...

peterflynn added a commit that referenced this pull request Mar 13, 2012
Make File > Save work on the currently focused editor
@peterflynn peterflynn merged commit 57b04c6 into master Mar 13, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants