Commit Graph

225 Commits

Author SHA1 Message Date
Marco Zehe 52b53d068b
Various A11y post screen fixes (#1584)
refs #11863

* 🐛 Gave various buttons accessible labels

Hidden span elements are not rendered to assistive technologies, so duplicate the text in an aria-label on the button element.

* 🐛 Fixed various accessibility issues in the editor

* Made menus menus and menu item menuitems.
* Added labels to buttons where there were only hidden spans, or no text at all.
* Made separators show up for screen readers.
2020-05-28 16:01:09 +01:00
Kevin Ansfield d6058dbf27 Co-located component template files
no issue

Keeps component JS backing files and template files in the same directory which avoids hunting across directories when working with components. Also lets you see all components when looking at one directory, whereas previously template-only or js-only components may not have been obvious without looking at both directories.

- ran [codemod](https://github.com/ember-codemods/ember-component-template-colocation-migrator/) for app-level components
- manually moved in-repo-addon component templates in `lib/koenig-editor`
- removed all explicit `layout` imports as JS/template associations are now made at build-time removing the need for them
- updated `.embercli` to default to new flat component structure
2020-05-18 13:14:08 +01:00
Kevin Ansfield b071c4e0ff Fixed embed card sizing for Vimeo embeds with larger thumbnails
no issue

- we're adjusting the oembed endpoint to fetch larger thumbnails if possible and that results in Vimeo embed iframes being larger than the editor width which created large blank spaces above/below the video due to the iframe height not adjusting correctly
- in the embed card's resize routine, if we look for an embedded iframe and find a width/height attribute then we can use the aspect ratio to assign the correct height for the outer and inner iframes
2020-04-30 09:07:04 +01:00
Kevin Ansfield 50ac92a41c Added oembed metadata to embed card payloads
refs https://github.com/TryGhost/Ghost/issues/11756

- we'd like to render fallbacks for embed cards in constrained environments such as emails where the `html` contents may not be suitable
- oembed gives us data to be able to create fallbacks this such as a `thumbnail_url`, author information, and sizing but we were not storing it
- this change removes the `html` and `type` data from the response object as the existing top-level payload properties then stores the remainder of the response under a `metadata` property
2020-04-29 10:43:03 +01:00
Kevin Ansfield d726998844 Added help text to email card
no issue

- show help at bottom of email card in edit mode with text explaining that the email card will only be included in emails
- set default content of the email card that includes the `{first_name}` replacement string
- changed behaviour to place cursor at end of the card contents when entering edit mode
2020-04-23 12:11:23 +01:00
Peter Zimon 9129f3bb31 Fixed slash menu positioning bug
no refs.

- fixed visual bug that made Slash menu appear on top of the text
2020-04-21 11:12:47 +02:00
Kevin Ansfield 6b738bdcd8 Fixed formatting only being applied to first replacement string in email card
no issue
2020-04-20 12:15:11 +01:00
Kevin Ansfield 051bcbc774 Fixed linting 2020-04-17 17:59:08 +01:00
Kevin Ansfield f022401849 Prevent {} text replacements from receiving any formatting
no issue

- we don't want to allow text replacement strings to be split in half by html tags so we disallow any formats to be applied to them
- in the `<KoenigTextReplacementHtmlInput>`'s mobiledoc editor's `didUpdatePost` hook handler we loop over all markers in the post and if they have a code markup (we use this to represent replacement strings) then we strip any other markups
2020-04-17 17:49:16 +01:00
Kevin Ansfield 3ce08aba21 Fixed <code> being persisted to email card payload
no issue

- `<code>` formatting is internal to the text replacement html input and shouldn't be persisted in the payload html
- adjust `cleanTextReplacementHtml` to strip out all `<code>` tags
- adjust `<CleanTextReplacementHtmlInput>` to strip `<code>` formatting when outputting html via the `onChange` action and to also put the `<code>` formatting back when receiving html
- adjust `<KoenigEmailCard>` to add the `<code>` formatting back around any replacement strings so that they are visible in the editor
2020-04-17 16:00:19 +01:00
Kevin Ansfield 2e63e0f496 Fixed {} chars being removed when applying text replacement format
no issue

- we want to keep the `{` and `}` chars when applying/removing formatting from text replacement strings so that you can see the full string with formatting
- added ability to specify a non-replaced special format which is used by the <kbd>Backspace</kbd> handler
- added helper utility to the text expansions for applying formatting to a match without replacing the "markdown" characters
2020-04-17 14:49:54 +01:00
Kevin Ansfield e191ffe8c9 Fixed "special markups" not being separate across different editors
no issue

- if the character used to define a special markup is different such as in the text replacement editor, pressing Backspace was not inserting the correct characters
2020-04-17 14:11:19 +01:00
Kevin Ansfield 58f2755bcd Fixed mobiledoc-kit automatically upgrading document version
refs 50eaa8830b

- we previously set a fixed mobiledoc spec version in blank documents but when the editor was serializing to a json string after editing it was bumping the spec version
- makes the specific version a constant to be used when serializing any mobiledoc
2020-04-16 22:12:01 +01:00
Kevin Ansfield 7c38bdccb3 Removed errant console.log 2020-04-06 13:12:17 +01:00
Kevin Ansfield bf7b1e0e33 Added first draft of email-only card
no issue

- adds "Email" card to the card menus when developer experiments is turned on
- adds `<KoenigTextReplacementHtmlInput>` implementing most of Koenig except:
  - uses html as it's input/output format
  - replaces backtick "code" formatting with `{replacement}`
  - no headings
  - no cards at all
  - minimal toolbar but all formatting is still available using markdown text expansions or keyboard shortcuts
2020-04-06 10:56:40 +01:00
Kevin Ansfield b4feb11af1 🐛 Fixed Ctrl/Cmd+Enter toggling cards into edit mode
no issue

- the card wrapper component was registering an event handler for keyboard events when entering edit mode. This was a problem because those events were also picking up the initial ctrl/cmd+enter and then immediately toggling back out of edit mode
- added a 20ms timeout for registering the event handlers so that they're not working cross-purposes
2020-04-06 10:49:23 +01:00
Kevin Ansfield 50eaa8830b Switched to explicit mobiledoc version for new posts
no issue

- when the mobiledoc spec changes due to a mobiledoc-kit version bump, any posts created with that version will fail to load in the editor if a rollback to an earlier Ghost version occurs
- use an explicit version to avoid the problem - we should only be bumping the mobiledoc spec version if we start using features from that version and mark it as a breaking change
2020-03-26 14:27:41 +00:00
Kevin Ansfield 059cd1fa03 🐛 Fixed Ctrl+h and Ctrl+d breaking the editor when used on card boundaries in macOS
closes https://github.com/TryGhost/Ghost/issues/10240

- intercept known macOS content-modifying keyboard shortcuts and simulate the "normal" keyboard events that they map to
  - `ctrl+h`: `Backspace`
  - `ctrl+d`: `Delete`
2020-03-07 21:33:12 +00:00
Kevin Ansfield a32e7c0b65 🐛 Fixed scroll jump in editor when pasting a url onto a selection to create a link
closes https://github.com/TryGhost/Ghost/issues/10090

- when mobiledoc-kit replaces the selection the caret window selection is temporarily set to the whole editor element which was causing our scroll-cursor-into-view routine to scroll incorrectly
- adding the guard allows the first replacement cursor change to be ignored but the second cursor change to be picked up which will do nothing if the text is on-screen, or scroll if it's off screen as normal
2020-03-07 20:23:23 +00:00
Kevin Ansfield 7ca85838c8
🐛 Fixed unreachable toolbar when editing wrapped links (#1511)
closes https://github.com/TryGhost/Ghost/issues/9792

- use `getClientRects()` to get separate rectangles for each line of a link and use the mouse position to find the closest one so that the toolbar can be positioned relative to that link section on that line rather than always in the middle of the editor canvas
- pass the rectangle used for positioning the link toolbar through to the link input component so that there is no jumping of position when clicking the edit button
2020-03-07 18:22:56 +00:00
Kevin Ansfield 1bd612a359 Updated image card to trigger file browse immediately when inserting
no issue

- removes number of clicks required to insert images, especially when using the `/image` shortcut
- strips `triggerBrowse` property from the payload after inserting to avoid triggering file browse when a post with blank image cards is rendered/re-rendered
2020-02-27 14:38:53 +00:00
Kevin Ansfield f51c42ef2b Fixed linting 2020-01-21 17:48:54 +00:00
Kevin Ansfield 101ea4222d Cleaned up unused code in bookmark card
no issue

- the `willDestroyElement` hook is referencing event handlers that aren't used in the bookmark card
- stopped setting `type` in the card payload as it's not used anywhere (possible hangover from when bookmarks were a type of embed card)
2020-01-21 17:45:33 +00:00
Kevin Ansfield 92107312a8 Upgraded `eslint-plugin-ghost` and fixed new linter errors
no issue

- update imports for `@ember-data` package (https://github.com/emberjs/rfcs/blob/master/text/0395-ember-data-packages.md)
- use `computed.reads` where applicable (https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/require-computed-macros.md)
- fix usage of `scheduleOnce` so that functions are only scheduled once (https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/no-incorrect-calls-with-inline-anonymous-functions.md)
2020-01-16 17:01:12 +00:00
Kevin Ansfield 90fc381767 🐛 Fixed editor showing incorrect domain and "unsaved changes" modal for relative links
no issue

- convert relative links to absolute based on the configured blog url when displaying URLs in the link toolbar and when manually setting a relative link
  - converting to absolute in the editor prevents the in-memory mobiledoc getting out of sync with the server response when it converts relative urls to absolute
2019-10-29 11:57:29 +00:00
Kevin Ansfield e32110c73a Fixed "undefined" appearing in markdown card styles
no issue
2019-08-28 09:56:45 +01:00
Rishabh Garg 9bfd340885 Added bookmark card and integrated it as fallback for unknown embeds (#1293)
requires https://github.com/TryGhost/Ghost/pull/11024

With the bookmark card you can present links in a much richer format, similar to Twitter cards. If the URL points to a page with right meta information it can show the page title, excerpt, author, publisher and even a preview image.

Bookmark cards can be created in two ways:

1. pasting a link as the first thing in blank paragraph - we'll check to see if we can create an embed, if we can't then we'll create a bookmark card instead
2. manually selecting the bookmark card from the (+) menu or by typing "/bookmark<kbd>Enter</kbd>" or "/bookmark {url}<kbd>Enter</kbd>" for short (you might want to do this if you want the bookmark version instead of a full embed)

Pressing <kbd>Ctrl/Cmd+Z</kbd> after pasting will convert the bookmark card back to a link if that's preferred, alternatively a URL can be pasted with <kbd>Ctrl/Cmd+Shift+V</kbd> to avoid any automatic transformation to an embed/bookmark.

---

- adds "bookmark" card that functions similarly to the embed card
- if the oembed API request returns `type: "bookmark"` then the metadata is used to create a bookmark card
2019-08-27 15:10:31 +01:00
Kevin Ansfield 0e8754b886 Added ability to edit alt text for image cards
no issue

- adds an "Alt" button that is displayed in the caption input whilst an image card is selected, clicking it toggles between the rich-text caption input and a plain-text alt text input
2019-07-23 18:13:41 +01:00
Kevin Ansfield 564ee97b01 🐛 Fixed unexpected image positions when re-ordering gallery images
no issue

- the position that images were inserted did not always match the position indicator because of errors in the insert index calculations
2019-07-05 14:54:22 +01:00
Kevin Ansfield aa8c0200e3 Added ability to drag images in and out of galleries
no issue

- adjust drag handlers in the editor and gallery card to handle drag/drop of image cards as well as straight images
- adjust drag handlers in the gallery card to handle image inserts as well as re-orders
- add `onDragEnd` event/action to the Koenig drag-n-drop handler so that containers can perform cleanup if one of their draggables was successfully dropped into a different container
- change ghost element when dragging an image card to be an image rather than a card icon
  - allow `createGhostElement` function passed in when registering a drag-n-drop container to fall back to the default behaviour by returning a falsy value
2019-07-05 14:54:22 +01:00
Kevin Ansfield 0e70ac51b2
Update dependency eslint-plugin-ghost to v0.3.0 (#1247)
no issue

- update dependency `eslint-plugin-ghost` to v0.3.0
  - includes new rules from `eslint-plugin-ember` 6.3.0-6.7.0
- fixed linting failures for new rules
2019-06-24 16:33:21 +01:00
Peter Zimon 183e22e0bf 🎨 Updated admin area design and usability (#1232)
refs. https://github.com/TryGhost/Team/issues/205

Major update to Ghost Admin UI including:
- improved general consistency (typography, colors and contrast, UI components, icons)
- new design for post and pages lists, improved discoverability of filters 
- search moved to modal
- account menu is decoupled from ghost logo
- further usability fixes
2019-06-18 11:47:20 +01:00
Kevin Ansfield 556bb46f98 Use extracted @tryghost/kg-parser-plugins package
no issue

- `@tryghost/kg-parser-plugins` contains the parser plugins used by the editor and was extracted so that they can be used in server-side html-to-mobiledoc conversion
2019-05-03 10:45:08 +01:00
Kevin Ansfield 3bcb56225d Use extracted @tryghost/kg-clean-basic-html package
no issue
- `cleanBasicHtml` has been extracted to an external package so that it can be used inside the extracted `@tryghost/kg-parser-plugins` package server-side
2019-05-02 17:14:00 +01:00
Kevin Ansfield de94b4cd40 do not show card toolbar if caption has focus 2019-05-01 15:13:49 +01:00
Kevin Ansfield 538b6b3504 extract {{kg-action-bar}} component 2019-05-01 13:57:00 +01:00
Kevin Ansfield 1c2ed065c8 Added caption support to code cards
no issue
2019-04-30 18:14:49 +02:00
Kevin Ansfield 40f7babc46 Fixed invisible caret in captions for cards with no style specified 2019-04-30 17:53:19 +02:00
Kevin Ansfield 232cd9382b
Added language selection to code cards (#1180)
no issue

- Added a language indicator when in rendered mode and a language input when in edit mode
- Allow code card language to be set with <code>```lang</code>+<kbd>Space/Enter</kbd> expansion 
    - previously <code>\`\`\`</code> would immediately create a code card, the <kbd>Space/Enter</kbd> is now necessary for the insertion to occur
    - lang is optional <code>\`\`\`</code>+<kbd>Space/Enter</kbd> will insert a code card with no language selected
    - requires <kbd>Enter</kbd> to be pressed to finalise the expansion and insert the card
    - added hook for text expansions to skip newline creation for when they are triggered with <kbd>Enter</kbd>
- Set the code card editor's language mode based on selected language
    - set the CodeMirror mode based on the code card payload language
        - add a basic map of language short codes to their respective CodeMirror modes
    - observe `mode` property in `{{gh-cm-editor}}` so that the mode is properly set when it's changed after initial render
2019-04-30 16:46:29 +02:00
Kevin Ansfield 99375f73f4 Fixed slash-menu appearing empty immediately after setting title on new post
closes https://github.com/TryGhost/Ghost/issues/9847
- the text expansion is triggered twice in this situation, the first time with `""` and the second with `"/"`. The second trigger was trying to match cards to `"/"` which returned an empty card set
- added a quick workaround that ensures we never include a leading `/` in the card selection query
2019-04-29 17:08:40 +02:00
Rishabh Garg 2604e86753
Updated to use count words/images helper from SDK (#1159)
refs https://github.com/TryGhost/Ghost/issues/10618

- Updated use of `countWords`, `countImages` and `stripTags` helper from Ghost SDK
- Removed existing local utils copy
2019-04-16 12:50:59 +05:30
Kevin Ansfield c7294b2706 Fixed image card placeholder image changing on select/deselect 2019-03-22 11:35:59 +00:00
Kevin Ansfield 8af0709a58 Fixed "must use set()" error caused by image card random placeholder 2019-03-22 11:31:31 +00:00
Zimo 6ab5192acc Added random image card placeholder illustrations
no refs.
- three random illustrations loop as image placeholder illustrations
- increased padding of clickable area for better happy-go-clicky
2019-03-07 15:40:08 +01:00
Kevin Ansfield 6351c85b25
Bumped dependencies (#1108)
Bumped all non-ember-core dependencies that do not require significant work or that contain unresolvable inter-dependencies.

Skipped:
- `ember-drag-drop` - our usage needs re-working for closure actions
- `ember-infinity`, `ember-in-viewport` - one depends on the other and `ember-light-table` depends on a particular version of `ember-in-viewport` in a way that breaks if they are upgraded

Removed/bumped:
- removed ember-cli-es6-transform
- removed ember-cli-cjs-transform
- removed current-device
- removed ember-responsive
- bumped yarn.lock sub-dependencies
- bumped @ember/jquery
- bumped @tryghost/mobiledoc-kit
- bumped autoprefixer
- bumped broccoli-funnel
- bumped coveralls
- bumped ember-auto-import
- bumped ember-moment
- bumped ember-power-select
- bumped ember-simple-auth
- bumped broccoli-uglify-sourcemap
- bumped ember-cli-eslint and eslint-plugin-ghost with fixes for new rules
- bumped ember-cli-mirage
- bumped ember-cli-pretender
- bumped ember-power-calendar-moment
- bumped ember-power-datepicker
- bumped ember-composable-helpers
- bumped ember-concurrency
- bumped ember-load
- bumped eslint
- bumped walk-sync
- bumped ember-useragent
- bumped fs-extra
- bumped ember-resolver
- bumped @html-next/vertical-collection
- bumped ember-cli-babel
2019-03-05 17:34:00 +00:00
Kevin Ansfield 256d32a5fe Fixed linting 2019-02-24 16:07:09 +07:00
Kevin Ansfield af658364f6 Fixed kgStyle import statement 2019-02-24 15:48:08 +07:00
Kevin Ansfield b21af6ad77 Moved Spirit CSS library from external to internal 2019-02-24 11:19:22 +07:00
Kevin Ansfield f8b03f50b6
🎨 Separated post and page list screens (#1101)
no issue
- added `page` model
- removed `page` param from Post model
- added pages screen with associated links
- added `:type` param to editor screens to work with the right models
- removed post<->page toggle and associated tour item
2019-02-22 10:17:33 +07:00
Kevin Ansfield 92623073d0 Added `undefined` guards to uses of JSON stringify/parse copying
no issue
- added guards for JSON stringify+parse replacements of `Ember.copy` introduced in 18dd5e34f6
2019-01-30 14:44:53 +00:00