Skip to content

Commit

Permalink
Use ‘atom-text-editor’ custom tag name for TextEditorElement
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Sobo committed Oct 9, 2014
1 parent 8e06e88 commit 1eb3d8b
Show file tree
Hide file tree
Showing 39 changed files with 121 additions and 123 deletions.
12 changes: 6 additions & 6 deletions docs/advanced/keymaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ Keymap files are encoded as JSON or CSON files containing nested hashes. They
work much like stylesheets, but instead of applying style properties to elements
matching the selector, they specify the meaning of keystrokes on elements
matching the selector. Here is an example of some bindings that apply when
keystrokes pass through elements with the class `.editor`:
keystrokes pass through `atom-text-editor` elements:

```coffee
'.editor':
'atom-text-editor':
'cmd-delete': 'editor:delete-to-beginning-of-line'
'alt-backspace': 'editor:delete-to-beginning-of-word'
'ctrl-A': 'editor:select-to-first-character-of-line'
'ctrl-shift-e': 'editor:select-to-end-of-line'
'cmd-left': 'editor:move-to-first-character-of-line'

'.editor:not(.mini)'
'atom-text-editor:not(.mini)'
'cmd-alt-[': 'editor:fold-current-row'
'cmd-alt-]': 'editor:unfold-current-row'
```

Beneath the first selector are several bindings, mapping specific *keystroke
patterns* to *commands*. When an element with the `.editor` class is focused and
patterns* to *commands*. When an element with the `atom-text-editor` class is focused and
`cmd-delete` is pressed, an custom DOM event called
`editor:delete-to-beginning-of-line` is emitted on the `.editor` element.
`editor:delete-to-beginning-of-line` is emitted on the `atom-text-editor` element.

The second selector group also targets editors, but only if they don't have the
`.mini` class. In this example, the commands for code folding don't really make
Expand Down Expand Up @@ -91,7 +91,7 @@ the current keystroke sequence and continue searching from its parent. If you
want to remove a binding from a keymap you don't control, such as keymaps in
Atom core or in packages, use the `unset!` directive.

For example, the following code removes the keybinding for `a` in the Tree View,
For example, the following code removes the keybinding for `a` in the Tree View,
which is normally used to trigger the `tree-view:add-file` command:

```coffee
Expand Down
4 changes: 2 additions & 2 deletions docs/advanced/view-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ have methods that are view-specific. For example, you could call both general
and view-specific on the global `atom.workspaceView` instance:

```coffeescript
atom.workspaceView.find('.editor.active') # standard jQuery method
atom.workspaceView.find('atom-text-editor.active') # standard jQuery method
atom.workspaceView.getActiveEditor() # view-specific method
```

Expand All @@ -20,7 +20,7 @@ If you retrieve a jQuery wrapper for an element associated with a view, use the

```coffeescript
# this is a plain jQuery object; you can't call view-specific methods
editorElement = atom.workspaceView.find('.editor.active')
editorElement = atom.workspaceView.find('atom-text-editor.active')

# get the view object by calling `.view()` to call view-specific methods
editorView = editorElement.view()
Expand Down
6 changes: 3 additions & 3 deletions docs/customizing-atom.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ with events in specific contexts. Here's a small example, excerpted from Atom's
built-in keymaps:

```coffee
'.editor':
'atom-text-editor':
'enter': 'editor:newline'

'.mini.editor input':
'atom-text-editor.mini input':
'enter': 'core:confirm'
```

Expand Down Expand Up @@ -169,7 +169,7 @@ For example, to change the color of the cursor, you could add the following
rule to your _~/.atom/styles.less_ file:

```less
.editor.is-focused .cursor {
atom-text-editor.is-focused .cursor {
border-color: pink;
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/your-first-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ _keymaps/ascii-art.cson_ and add a key binding linking `ctrl-alt-a` to the
you don't need it anymore. When finished, the file will look like this:

```coffeescript
'.editor':
'atom-text-editor':
'cmd-alt-a': 'ascii-art:convert'
```

Notice `.editor` on the first line. Just like CSS, keymap selectors *scope* key
Notice `atom-text-editor` on the first line. Just like CSS, keymap selectors *scope* key
bindings so they only apply to specific elements. In this case, our binding is
only active for elements matching the `.editor` selector. If the Tree View has
only active for elements matching the `atom-text-editor` selector. If the Tree View has
focus, pressing `cmd-alt-a` won't trigger the `ascii-art:convert` command. But
if the editor has focus, the `ascii-art:convert` method *will* be triggered.
More information on key bindings can be found in the
Expand Down
2 changes: 1 addition & 1 deletion dot-atom/keymap.cson
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# Here's an example taken from Atom's built-in keymap:
#
# '.editor':
# 'atom-text-editor':
# 'enter': 'editor:newline'
#
# '.workspace':
Expand Down
4 changes: 2 additions & 2 deletions dot-atom/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

}

.editor {
atom-text-editor {

}

.editor .cursor {
atom-text-editor .cursor {

}
6 changes: 3 additions & 3 deletions keymaps/base.cson
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'.editor':
'atom-text-editor':
# Platform Bindings
'home': 'editor:move-to-first-character-of-line'
'end': 'editor:move-to-end-of-screen-line'
'shift-home': 'editor:select-to-first-character-of-line'
'shift-end': 'editor:select-to-end-of-line'

'.editor:not(.mini)':
'atom-text-editor:not(.mini)':
# Atom Specific
'ctrl-C': 'editor:copy-path'

Expand All @@ -18,7 +18,7 @@
'.tool-panel.panel-left, .tool-panel.panel-right':
'escape': 'tool-panel:unfocus'

'.editor !important, .editor.mini !important':
'atom-text-editor !important, atom-text-editor.mini !important':
'escape': 'editor:consolidate-selections'

# allow standard input fields to work correctly
Expand Down
4 changes: 2 additions & 2 deletions keymaps/darwin.cson
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
'cmd-8': 'pane:show-item-8'
'cmd-9': 'pane:show-item-9'

'.editor':
'atom-text-editor':
# Platform Bindings
'alt-left': 'editor:move-to-beginning-of-word'
'alt-right': 'editor:move-to-end-of-word'
Expand Down Expand Up @@ -134,7 +134,7 @@
'cmd-l': 'editor:select-line'
'ctrl-t': 'editor:transpose'

'atom-workspace .editor:not(.mini)':
'atom-workspace atom-text-editor:not(.mini)':
# Atom specific
'alt-cmd-z': 'editor:checkout-head-revision'
'cmd-<': 'editor:scroll-to-cursor'
Expand Down
2 changes: 1 addition & 1 deletion keymaps/emacs.cson
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'.editor':
'atom-text-editor':
'alt-f': 'editor:move-to-end-of-word'
'alt-F': 'editor:select-to-end-of-word'
'alt-b': 'editor:move-to-beginning-of-word'
Expand Down
4 changes: 2 additions & 2 deletions keymaps/linux.cson
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
'alt-8': 'pane:show-item-8'
'alt-9': 'pane:show-item-9'

'atom-workspace .editor':
'atom-workspace atom-text-editor':
# Platform Bindings
'ctrl-left': 'editor:move-to-beginning-of-word'
'ctrl-right': 'editor:move-to-end-of-word'
Expand All @@ -99,7 +99,7 @@
'ctrl-k ctrl-l': 'editor:lower-case'
'ctrl-l': 'editor:select-line'

'atom-workspace .editor:not(.mini)':
'atom-workspace atom-text-editor:not(.mini)':
# Atom specific
'alt-ctrl-z': 'editor:checkout-head-revision'
'ctrl-<': 'editor:scroll-to-cursor'
Expand Down
4 changes: 2 additions & 2 deletions keymaps/win32.cson
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
'ctrl-k ctrl-left': 'window:focus-pane-on-left'
'ctrl-k ctrl-right': 'window:focus-pane-on-right'

'atom-workspace .editor':
'atom-workspace atom-text-editor':
# Platform Bindings
'ctrl-left': 'editor:move-to-beginning-of-word'
'ctrl-right': 'editor:move-to-end-of-word'
Expand All @@ -94,7 +94,7 @@
'ctrl-k ctrl-l': 'editor:lower-case'
'ctrl-l': 'editor:select-line'

'atom-workspace .editor:not(.mini)':
'atom-workspace atom-text-editor:not(.mini)':
# Atom specific
'alt-ctrl-z': 'editor:checkout-head-revision'
'ctrl-<': 'editor:scroll-to-cursor'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "ui-variables";

.editor {
atom-text-editor {
padding-top: @component-padding;
padding-right: @component-padding;
padding-bottom: @component-padding;
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/packages/theme-with-index-css/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.editor {
atom-text-editor {
padding-top: 1234px;
}
2 changes: 1 addition & 1 deletion spec/fixtures/packages/theme-with-index-less/index.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@padding: 4321px;

.editor {
atom-text-editor {
padding-top: @padding;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.editor {
atom-text-editor {
padding-top: 101px;
padding-right: 101px;
padding-bottom: 101px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.editor {
atom-text-editor {
/* padding-top: 103px;
padding-right: 103px;*/
padding-bottom: 103px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@number: 102px;

.editor {
atom-text-editor {
/* padding-top: 102px;*/
padding-right: @number;
padding-bottom: @number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "ui-variables";

.editor {
atom-text-editor {
padding-top: @component-padding;
padding-right: @component-padding;
padding-bottom: @component-padding;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.editor {
atom-text-editor {
padding-top: 10px;
padding-right: 10px;
padding-bottom: 10px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.editor {
atom-text-editor {
padding-right: 20px;
padding-bottom: 20px;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@number: 30px;

.editor {
atom-text-editor {
padding-bottom: @number;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.editor {
atom-text-editor {
padding-top: 100px;
padding-right: 100px;
padding-bottom: 100px;
Expand Down
2 changes: 1 addition & 1 deletion spec/package-manager-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe "PackageManager", ->
legacyCommandListener = jasmine.createSpy("legacyCommandListener")
editorView.command 'activation-command', legacyCommandListener
editorCommandListener = jasmine.createSpy("editorCommandListener")
atom.commands.add '.editor', 'activation-command', editorCommandListener
atom.commands.add 'atom-text-editor', 'activation-command', editorCommandListener
editorView[0].dispatchEvent(new CustomEvent('activation-command', bubbles: true))
expect(mainModule.activate.callCount).toBe 1
expect(mainModule.legacyActivationCommandCallCount).toBe 1
Expand Down
34 changes: 17 additions & 17 deletions spec/package-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,51 +38,51 @@ describe "Package", ->
theme = null

beforeEach ->
$("#jasmine-content").append $("<div class='editor'></div>")
$("#jasmine-content").append $("<atom-text-editor></atom-text-editor>")

afterEach ->
theme.deactivate() if theme?

describe "when the theme contains a single style file", ->
it "loads and applies css", ->
expect($(".editor").css("padding-bottom")).not.toBe "1234px"
expect($("atom-text-editor").css("padding-bottom")).not.toBe "1234px"
themePath = atom.project.resolve('packages/theme-with-index-css')
theme = new ThemePackage(themePath)
theme.activate()
expect($(".editor").css("padding-top")).toBe "1234px"
expect($("atom-text-editor").css("padding-top")).toBe "1234px"

it "parses, loads and applies less", ->
expect($(".editor").css("padding-bottom")).not.toBe "1234px"
expect($("atom-text-editor").css("padding-bottom")).not.toBe "1234px"
themePath = atom.project.resolve('packages/theme-with-index-less')
theme = new ThemePackage(themePath)
theme.activate()
expect($(".editor").css("padding-top")).toBe "4321px"
expect($("atom-text-editor").css("padding-top")).toBe "4321px"

describe "when the theme contains a package.json file", ->
it "loads and applies stylesheets from package.json in the correct order", ->
expect($(".editor").css("padding-top")).not.toBe("101px")
expect($(".editor").css("padding-right")).not.toBe("102px")
expect($(".editor").css("padding-bottom")).not.toBe("103px")
expect($("atom-text-editor").css("padding-top")).not.toBe("101px")
expect($("atom-text-editor").css("padding-right")).not.toBe("102px")
expect($("atom-text-editor").css("padding-bottom")).not.toBe("103px")

themePath = atom.project.resolve('packages/theme-with-package-file')
theme = new ThemePackage(themePath)
theme.activate()
expect($(".editor").css("padding-top")).toBe("101px")
expect($(".editor").css("padding-right")).toBe("102px")
expect($(".editor").css("padding-bottom")).toBe("103px")
expect($("atom-text-editor").css("padding-top")).toBe("101px")
expect($("atom-text-editor").css("padding-right")).toBe("102px")
expect($("atom-text-editor").css("padding-bottom")).toBe("103px")

describe "when the theme does not contain a package.json file and is a directory", ->
it "loads all stylesheet files in the directory", ->
expect($(".editor").css("padding-top")).not.toBe "10px"
expect($(".editor").css("padding-right")).not.toBe "20px"
expect($(".editor").css("padding-bottom")).not.toBe "30px"
expect($("atom-text-editor").css("padding-top")).not.toBe "10px"
expect($("atom-text-editor").css("padding-right")).not.toBe "20px"
expect($("atom-text-editor").css("padding-bottom")).not.toBe "30px"

themePath = atom.project.resolve('packages/theme-without-package-file')
theme = new ThemePackage(themePath)
theme.activate()
expect($(".editor").css("padding-top")).toBe "10px"
expect($(".editor").css("padding-right")).toBe "20px"
expect($(".editor").css("padding-bottom")).toBe "30px"
expect($("atom-text-editor").css("padding-top")).toBe "10px"
expect($("atom-text-editor").css("padding-right")).toBe "20px"
expect($("atom-text-editor").css("padding-bottom")).toBe "30px"

describe "reloading a theme", ->
beforeEach ->
Expand Down
4 changes: 2 additions & 2 deletions spec/pane-view-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ describe "PaneView", ->
describe "when the destroyed item is a model", ->
it "removes the associated view", ->
paneModel.activateItem(editor1)
expect(pane.itemViews.find('.editor').length).toBe 1
expect(pane.itemViews.find('atom-text-editor').length).toBe 1
pane.destroyItem(editor1)
expect(pane.itemViews.find('.editor').length).toBe 0
expect(pane.itemViews.find('atom-text-editor').length).toBe 0

describe "when an item is moved within the same pane", ->
it "emits a 'pane:item-moved' event with the item and the new index", ->
Expand Down
4 changes: 2 additions & 2 deletions spec/text-editor-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ describe "TextEditorElement", ->

describe "instantiation", ->
it "honors the mini attribute", ->
jasmineContent.innerHTML = "<div is='atom-text-editor' mini>"
jasmineContent.innerHTML = "<atom-text-editor mini>"
element = jasmineContent.firstChild
expect(element.getModel().isMini()).toBe true

it "honors the placeholder-text attribute", ->
jasmineContent.innerHTML = "<div is='atom-text-editor' placeholder-text='testing'>"
jasmineContent.innerHTML = "<atom-text-editor placeholder-text='testing'>"
element = jasmineContent.firstChild
expect(element.getModel().getPlaceholderText()).toBe 'testing'

Expand Down
Loading

0 comments on commit 1eb3d8b

Please sign in to comment.