Skip to content

Commit

Permalink
WIP replace usages of action helper
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemelia committed Sep 17, 2023
1 parent 9766b8a commit 0ff1fd9
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 32 deletions.
15 changes: 13 additions & 2 deletions addon/components/mobiledoc-editor/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
/* eslint-disable ember/require-tagless-components */
/* eslint-disable ember/no-classic-classes */
/* eslint-disable ember/no-classic-components */
import { _getCurrentRunLoop, schedule, begin, end, join } from '@ember/runloop';
import {
_getCurrentRunLoop,
getCurrentRunLoop,
schedule,
begin,
end,
join,
} from '@ember/runloop';
import { copy } from 'ember-copy';
import { A } from '@ember/array';
import { camelize, capitalize } from '@ember/string';
Expand Down Expand Up @@ -299,7 +306,11 @@ export default Component.extend({
// When pasting text that gets turned into a card, for example,
// the add card hook would run outside the runloop if we didn't begin a new
// one now.
if (!_getCurrentRunLoop()) {
// Check for current run loop in two ways to avoid deprecations in different Ember versions
let currRunLoop = _getCurrentRunLoop
? _getCurrentRunLoop()
: getCurrentRunLoop();
if (!currRunLoop) {
this._startedRunLoop = true;
begin();
}
Expand Down
4 changes: 2 additions & 2 deletions addon/components/mobiledoc-link-prompt/template.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form>
{{input value=this.href}}
<button {{action attrs.on-submit this.href}} type="submit">Link</button>
<button type="submit" {{action attrs.on-cancel}}>Cancel</button>
<button {{on 'click' (fn attrs.on-submit this.href)}} type="submit">Link</button>
<button type="submit" {{on 'click' attrs.on-cancel}}>Cancel</button>
</form>
24 changes: 12 additions & 12 deletions addon/components/mobiledoc-toolbar/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
type="button"
title="Bold"
class="mobiledoc-toolbar__button {{if @editor.activeMarkupTagNames.isStrong 'active'}}"
{{action @editor.toggleMarkup 'strong'}}>
{{on 'click' (fn @editor.toggleMarkup 'strong')}}>
Bold
</button>
</li>
Expand All @@ -12,7 +12,7 @@
type="button"
title="Italic"
class="mobiledoc-toolbar__button {{if @editor.activeMarkupTagNames.isEm 'active'}}"
{{action @editor.toggleMarkup 'em'}}>
{{on 'click' (fn @editor.toggleMarkup 'em')}}>
Italic
</button>
</li>
Expand All @@ -21,7 +21,7 @@
type="button"
title="Link"
class="mobiledoc-toolbar__button {{if @editor.activeMarkupTagNames.isA 'active'}}"
{{action @editor.toggleLink}}>
{{on 'click' @editor.toggleLink}}>
Link
</button>
</li>
Expand All @@ -30,7 +30,7 @@
type="button"
title="Heading"
class="mobiledoc-toolbar__button {{if @editor.activeSectionTagNames.isH1 'active'}}"
{{action @editor.toggleSection 'h1'}}>
{{on 'click' (fn @editor.toggleSection 'h1')}}>
Headline
</button>
</li>
Expand All @@ -39,7 +39,7 @@
type="button"
title="Subheading"
class="mobiledoc-toolbar__button {{if @editor.activeSectionTagNames.isH2 'active'}}"
{{action @editor.toggleSection 'h2'}}>
{{on 'click' (fn @editor.toggleSection 'h2')}}>
Subheadline
</button>
</li>
Expand All @@ -48,7 +48,7 @@
type="button"
title="Block Quote"
class="mobiledoc-toolbar__button {{if @editor.activeSectionTagNames.isBlockquote 'active'}}"
{{action @editor.toggleSection 'blockquote'}}>
{{on 'click' (fn @editor.toggleSection 'blockquote')}}>
<i class="icon-quote-block"></i>
Blockquote
</button>
Expand All @@ -58,7 +58,7 @@
type="button"
title="Pull Quote"
class="mobiledoc-toolbar__button {{if @editor.activeSectionTagNames.isPullQuote 'active'}}"
{{action @editor.toggleSection 'pull-quote'}}>
{{on 'click' (fn @editor.toggleSection 'pull-quote')}}>
Pull-quote
</button>
</li>
Expand All @@ -67,7 +67,7 @@
type="button"
title="List"
class="mobiledoc-toolbar__button {{if @editor.activeSectionTagNames.isUl 'active'}}"
{{action @editor.toggleSection 'ul'}}>
{{on 'click' (fn @editor.toggleSection 'ul')}}>
Unordered List
</button>
</li>
Expand All @@ -76,7 +76,7 @@
type="button"
title="Numbered List"
class="mobiledoc-toolbar__button {{if @editor.activeSectionTagNames.isOl 'active'}}"
{{action @editor.toggleSection 'ol'}}>
{{on 'click' (fn @editor.toggleSection 'ol')}}>
Ordered List
</button>
</li>
Expand All @@ -85,7 +85,7 @@
type="button"
title="Align Left"
class="mobiledoc-toolbar__button {{if (includes @editor.activeSectionAttributes.textAlign 'left') 'active'}}"
{{action @editor.setAttribute 'text-align' 'left'}}>
{{on 'click' (fn @editor.setAttribute 'text-align' 'left')}}>
Align Left
</button>
</li>
Expand All @@ -94,7 +94,7 @@
type="button"
title="Align Center"
class="mobiledoc-toolbar__button {{if (includes @editor.activeSectionAttributes.textAlign 'center') 'active'}}"
{{action @editor.setAttribute 'text-align' 'center'}}>
{{on 'click' (fn @editor.setAttribute 'text-align' 'center')}}>
Align Center
</button>
</li>
Expand All @@ -103,7 +103,7 @@
type="button"
title="Align Right"
class="mobiledoc-toolbar__button {{if (includes @editor.activeSectionAttributes.textAlign 'right') 'active'}}"
{{action @editor.setAttribute 'text-align' 'right'}}>
{{on 'click' (fn @editor.setAttribute 'text-align' 'right')}}>
Align Right
</button>
</li>
Expand Down
2 changes: 0 additions & 2 deletions addon/components/tether-to-selection/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { assert } from '@ember/debug';
import Component from '@ember/component';
import { computed } from '@ember/object';
import { htmlSafe } from '@ember/string';
import layout from './template';

const DIALOG_MARGIN = 16;

Expand All @@ -24,7 +23,6 @@ function isOutOfBounds(rect, boundingRect) {
}

export default Component.extend({
layout,
classNames: ['mobiledoc-selection-tether'],
attributeBindings: ['style'],
dialogAnchor: null,
Expand Down
1 change: 0 additions & 1 deletion addon/components/tether-to-selection/template.hbs

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"ember-copy": "^2.0.1",
"ember-wormhole": "^0.6.0",
"mobiledoc-dom-renderer": "^0.7.2",
"mobiledoc-kit": "~0.13.3"
"mobiledoc-kit": "~0.15.0"
},
"devDependencies": {
"@ember/jquery": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<MobiledocEditor @on-change={{action 'onChange'}} />
<MobiledocEditor @on-change={{this.onChange}} />

<div id="has-changed">HAS CHANGED {{this.changeCount}}</div>
17 changes: 6 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9322,22 +9322,17 @@ mktemp@~0.4.0:
resolved "https://registry.yarnpkg.com/mktemp/-/mktemp-0.4.0.tgz#6d0515611c8a8c84e484aa2000129b98e981ff0b"
integrity sha512-IXnMcJ6ZyTuhRmJSjzvHSRhlVPiN9Jwc6e59V0bEJ0ba6OBeX2L0E+mRN1QseeOF4mM+F1Rit6Nh7o+rl2Yn/A==

[email protected]:
version "0.7.0"
resolved "https://registry.yarnpkg.com/mobiledoc-dom-renderer/-/mobiledoc-dom-renderer-0.7.0.tgz#53ab5f14dd612b16f03513390e5cbcc2b89f6979"
integrity sha512-A+gT6D4Ru3DKY7ZYOBRORmwhRJ7rDj2vy75D2dWuZS5NgX0mCmGs0yN7qs48YlxvfCif8RFpYsaaPg6Kc3MdJg==

mobiledoc-dom-renderer@^0.7.2:
[email protected], mobiledoc-dom-renderer@^0.7.2:
version "0.7.2"
resolved "https://registry.yarnpkg.com/mobiledoc-dom-renderer/-/mobiledoc-dom-renderer-0.7.2.tgz#2640bd261079faf1b8bd2264f5a610760840ce8a"
integrity sha512-0vw/ybxCWXI0sIcBk9GVq3PMfVWJ4qpLWBal8ZoZVP/S5MMRjxFwyOctOfUmsY2dVi6BSvomp8yFqNloawwyig==

mobiledoc-kit@~0.13.3:
version "0.13.3"
resolved "https://registry.yarnpkg.com/mobiledoc-kit/-/mobiledoc-kit-0.13.3.tgz#d2af134f2b9142bd335b1b5012d1fb12358102be"
integrity sha512-616ziNPr88xLcEMuqrfavIjJQbNcvrRUmofgaLBsfprVO1nqKUrsGlr56p/SQEMlXKxbAk4GIAQ3y/Cqmfc/uw==
mobiledoc-kit@~0.15.0:
version "0.15.0"
resolved "https://registry.yarnpkg.com/mobiledoc-kit/-/mobiledoc-kit-0.15.0.tgz#e3169d716ac4d322496fb321aa0cc4c60bbdbb46"
integrity sha512-3nYzLuSxEu9YJKWcj3Iv+woK3MNsH+kXhshJNxAsM1YwKwRcShEvRJJw6GaN7zqgDxtJXhjdeI+prys/XYs+Jw==
dependencies:
mobiledoc-dom-renderer "0.7.0"
mobiledoc-dom-renderer "0.7.2"
mobiledoc-text-renderer "0.4.1"

[email protected]:
Expand Down

0 comments on commit 0ff1fd9

Please sign in to comment.