Skip to content

Commit d5d0bf3

Browse files
authored
Merge pull request #227 from bustle/y-1062-ember-5-6-support
Make ember-lts-5.12 and ember-6.12 scenarios pass
2 parents 701501d + 5bc73b2 commit d5d0bf3

8 files changed

Lines changed: 167 additions & 188 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ jobs:
6363
- ember-lts-3.28
6464
- ember-lts-4.4
6565
- ember-lts-4.12
66-
- ember-lts-5.12-failing
67-
- ember-6.12-failing
66+
- ember-lts-5.12
67+
- ember-6.12
6868
- ember-classic
6969
- embroider-safe
7070
- embroider-optimized

README.md

Lines changed: 67 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## ember-mobiledoc-editor
22

33
[![npm version](https://badge.fury.io/js/ember-mobiledoc-editor.svg)](https://badge.fury.io/js/ember-mobiledoc-editor)
4-
[![Build Status](https://travis-ci.org/bustle/ember-mobiledoc-editor.svg)](https://travis-ci.org/bustle/ember-mobiledoc-editor)
4+
[![CI](https://github.com/bustle/ember-mobiledoc-editor/actions/workflows/ci.yml/badge.svg)](https://github.com/bustle/ember-mobiledoc-editor/actions/workflows/ci.yml)
55
[![Ember Observer Score](https://emberobserver.com/badges/ember-mobiledoc-editor.svg)](https://emberobserver.com/addons/ember-mobiledoc-editor)
66

77
A Mobiledoc editor written using Ember.js UI components and
@@ -75,40 +75,44 @@ The component accepts these arguments:
7575
The action is passed the created editor instance.
7676
This action may be fired more than once if the component's `mobiledoc` property is set to a new value.
7777

78-
For example, the following index route and template would log before and
78+
For example, the following component and template would log before and
7979
after creating the MobiledocKitEditor, and every time the user modified the
8080
mobiledoc (by typing some text, e.g.).
8181

8282
```javascript
83-
// routes/index.js
84-
85-
export default Ember.Route.extend({
86-
...,
87-
actions: {
88-
mobiledocWasUpdated(updatedMobiledoc) {
89-
console.log('New mobiledoc:',updatedMobiledoc);
90-
// note that this action will be fired for every changed character,
91-
// so you may want to debounce API calls if you are using it for
92-
// an "autosave" feature.
93-
},
94-
willCreateEditor() {
95-
console.log('about to create the editor');
96-
},
97-
didCreateEditor(editor) {
98-
console.log('created the editor:', editor);
99-
}
100-
}
101-
});
83+
// components/my-editor.js
84+
import Component from '@glimmer/component';
85+
import { action } from '@ember/object';
86+
87+
export default class MyEditor extends Component {
88+
@action
89+
mobiledocWasUpdated(updatedMobiledoc) {
90+
console.log('New mobiledoc:', updatedMobiledoc);
91+
// note that this handler will be fired for every changed character,
92+
// so you may want to debounce API calls if you are using it for
93+
// an "autosave" feature.
94+
}
95+
96+
@action
97+
willCreateEditor() {
98+
console.log('about to create the editor');
99+
}
100+
101+
@action
102+
didCreateEditor(editor) {
103+
console.log('created the editor:', editor);
104+
}
105+
}
102106
```
103107

104108
```hbs
105-
{{! index.hbs }}
109+
{{! components/my-editor.hbs }}
106110
107-
{{mobiledoc-editor
108-
on-change=(action 'mobiledocWasUpdated')
109-
will-create-editor=(action 'willCreateEditor')
110-
did-create-editor=(action 'didCreateEditor')
111-
}}
111+
<MobiledocEditor
112+
@on-change={{this.mobiledocWasUpdated}}
113+
@will-create-editor={{this.willCreateEditor}}
114+
@did-create-editor={{this.didCreateEditor}}
115+
/>
112116
```
113117

114118
Of course often you want to provide a user interface to bold text, create
@@ -294,22 +298,18 @@ components as the display and edit modes of a card. Create a list of cards
294298
using the `createComponentCard` helper:
295299

296300
```js
297-
import Ember from 'ember';
301+
import Component from '@glimmer/component';
298302
import createComponentCard from 'ember-mobiledoc-editor/utils/create-component-card';
299303

300-
export default Ember.Component.extend({
301-
cards: Ember.computed(function() {
302-
return [
303-
createComponentCard('demo-card')
304-
];
305-
})
306-
});
304+
export default class MyEditor extends Component {
305+
cards = [createComponentCard('demo-card')];
306+
}
307307
```
308308

309309
And pass that list into the `{{mobiledoc-editor}}` component:
310310

311311
```hbs
312-
{{mobiledoc-editor cards=cards}}
312+
<MobiledocEditor @cards={{this.cards}} />
313313
```
314314

315315
When added to the post (or loaded from a passed-in Mobiledoc), these components
@@ -341,27 +341,23 @@ ember-mobiledoc-editor comes with a handle helper for using Ember
341341
components as an atom. Create a list of atoms using the `createComponentAtom` helper:
342342

343343
```js
344-
import Ember from 'ember';
344+
import Component from '@glimmer/component';
345345
import createComponentAtom from 'ember-mobiledoc-editor/utils/create-component-atom';
346346

347-
export default Ember.Component.extend({
348-
atoms: Ember.computed(function() {
349-
return [
350-
createComponentAtom('demo-atom')
351-
];
352-
})
353-
});
347+
export default class MyEditor extends Component {
348+
atoms = [createComponentAtom('demo-atom')];
349+
}
354350
```
355351

356352
And pass that list into the `{{mobiledoc-editor}}` component:
357353

358354
```hbs
359-
{{mobiledoc-editor atoms=atoms}}
355+
<MobiledocEditor @atoms={{this.atoms}} />
360356
```
361357

362358
### Editor Lifecycle Hooks
363359

364-
Currently editor lifecycle hooks are available by available by extending the mobiledoc-editor component.
360+
Currently editor lifecycle hooks are available by extending the mobiledoc-editor component.
365361

366362
```js
367363
import Component from 'ember-mobiledoc-editor/components/mobiledoc-editor/component';
@@ -390,48 +386,47 @@ ember-mobiledoc-editor exposes two test helpers for use in your acceptance tests
390386
Example usage:
391387
```javascript
392388
// acceptance test
393-
import { insertText, run } from '../../helpers/ember-mobiledoc-editor';
394-
import { find } from '@enber/test-helpers';
395-
test('visit /', function(assert) {
396-
visit('/');
397-
andThen(() => {
398-
let editorEl = find('.mobiledoc-editor__editor');
399-
return insertText(editorEl, 'here is some text');
400-
/* Or:
401-
return run(editorEl, (postEditor) => ...);
402-
*/
403-
});
404-
andThen(() => {
389+
import { module, test } from 'qunit';
390+
import { setupApplicationTest } from 'ember-qunit';
391+
import { visit, find } from '@ember/test-helpers';
392+
import { insertText, run } from '../helpers/ember-mobiledoc-editor';
393+
394+
module('Acceptance | editor', function (hooks) {
395+
setupApplicationTest(hooks);
396+
397+
test('visiting /', async function (assert) {
398+
await visit('/');
399+
400+
const editorEl = find('.mobiledoc-editor__editor');
401+
await insertText(editorEl, 'here is some text');
402+
// Or: await run(editorEl, (postEditor) => ...);
403+
405404
// assert text inserted, etc.
406405
});
407406
});
408407
```
409408

410409
### Developing ember-mobiledoc-editor
411410

412-
Releasing a new version:
413-
414-
This README outlines the details of collaborating on this Ember addon.
415-
416-
## Installation
411+
#### Setup
417412

418-
* `git clone <repository-url>` this repository
413+
* `git clone git@github.com:bustle/ember-mobiledoc-editor.git`
419414
* `cd ember-mobiledoc-editor`
420415
* `pnpm install`
421416

422417
Run the development server:
423418

424-
* `ember serve`
425-
* Visit your app at [http://localhost:4200](http://localhost:4200).
419+
* `pnpm start`
420+
* Visit the dummy app at [http://localhost:4200](http://localhost:4200).
426421

427-
## Running Tests
422+
#### Running Tests
428423

429-
* `pnpm test` (Runs `ember try:each` to test your addon against multiple Ember versions)
430-
* `ember test`
431-
* `ember test --server`
424+
* `pnpm test` — runs lint, the current-Ember test suite, and `ember try:each` against every supported Ember version.
425+
* `pnpm test:ember` — runs the dummy-app test suite once.
426+
* `ember test --server` — dev-friendly watcher.
432427

433-
## Building
428+
#### Building
434429

435-
* `ember build`
430+
* `pnpm build`
436431

437432
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).

config/ember-try.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,22 @@ module.exports = async function () {
4646
},
4747
},
4848
{
49-
// Needs a build-infrastructure refresh (dummy app initializer wiring
50-
// + webpack config) before it can pass. Surfacing regressions here
51-
// is still useful — allowedToFail so CI doesn't block on it.
52-
name: 'ember-lts-5.12-failing',
49+
name: 'ember-lts-5.12',
5350
npm: {
5451
devDependencies: {
55-
'@ember/string': '^4.0.0',
5652
'ember-source': '~5.12.0',
5753
'ember-resolver': '^13.0.0',
5854
},
5955
},
60-
allowedToFail: true,
6156
},
6257
{
63-
// Same story as ember-lts-5.12 — build infrastructure needs a
64-
// refresh before this can pass cleanly.
65-
name: 'ember-6.12-failing',
58+
name: 'ember-6.12',
6659
npm: {
6760
devDependencies: {
68-
'@ember/string': '^4.0.0',
6961
'ember-source': '~6.12.0',
7062
'ember-resolver': '^13.0.0',
7163
},
7264
},
73-
allowedToFail: true,
7465
},
7566
{
7667
name: 'ember-classic',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"version": "npm run update-changelog && git add CHANGELOG.md"
3030
},
3131
"dependencies": {
32+
"@ember/string": "^3.1.1 || ^4.0.0",
3233
"broccoli-funnel": "^3.0.8",
3334
"broccoli-merge-trees": "^4.2.0",
3435
"ember-auto-import": "^2.4.3",
@@ -57,7 +58,6 @@
5758
"ember-cli-sri": "^2.1.1",
5859
"ember-cli-terser": "^4.0.2",
5960
"ember-disable-prototype-extensions": "^1.1.3",
60-
"ember-export-application-global": "^2.0.1",
6161
"ember-load-initializers": "^2.1.2",
6262
"ember-maybe-import-regenerator": "^1.0.0",
6363
"ember-page-title": "^6.2.2",

pnpm-lock.yaml

Lines changed: 3 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
onlyBuiltDependencies:
2+
- core-js
3+
- fsevents

0 commit comments

Comments
 (0)