Commit Graph

22 Commits

Author SHA1 Message Date
Kevin Ansfield 5606b9c068 Implemented first iteration of content snippets
closes https://github.com/TryGhost/Team/issues/411

- adds "Create snippet" icon to the editor toolbar
- uses the same link input component design for specifying snippet titles
- snippets are loaded in the background when the editor is accessed
- snippets are listed at the bottom of the card menus of the + and / menus
- clicking a snippet inserts the snippet's contents in place of the current blank section
2020-10-15 18:03:35 +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 72c600486c Koenig - Unsplash integration
refs https://github.com/TryGhost/Ghost/issues/9724
- standardised `{{gh-unsplash}}` actions and action arguments to better represent a generic "image source"
- added `{{gh-unsplash searchTerm="ghosts"}}` parameter
- added `payload` param to `card` definitions used for plus/slash menus so that default payload params can be passed to cards
- added a concept of "image selectors" to image card
  - if a `payload.imageSelector` param is received by the card it will look it up in it's list of known selectors and display the appropriate image selection component
  - if the card was created with an image selector param and the image selector is closed without selecting an image then the card will be removed
- delete image cards during cleanup if they were created via selector but have no src
2018-08-10 18:11:35 +01:00
Kevin Ansfield dc040582d2 🐛 Koenig - Fixed numpad Enter key not behaving like normal Enter key
refs https://github.com/TryGhost/Ghost/issues/9724
- `event.code` represents physical key location rather than the associated key value. Eg, `event.code` could be `NumpadEnter` rather than the expected `Enter` value
- ensure we use `event.key` anywhere that we are acting on the key value so that re-mapped or virtual keys still work as expected
2018-07-30 14:40:00 +01:00
Kevin Ansfield 8a747b1cc9 Koenig - Fixed error from plus menu when leaving editor
refs https://github.com/TryGhost/Ghost/issues/9724
- leaving the editor could result in the plus menu being removed from DOM before teardown has fully cleared up the event handlers resulting in an error being thrown in the mousemove handler where we assumed the element is present
2018-07-25 15:48:44 +01:00
Kevin Ansfield 61b210c70f 🐛 Koenig - Fixed required double-click on (+) when cursor is not in same paragraph
refs https://github.com/TryGhost/Ghost/issues/9724
- ignore the range change which would otherwise close the menu when clicking a (+) next to a different paragraph then the one the cursor is currently on
2018-07-18 15:04:02 +01:00
Kevin Ansfield 2427a3001b Koenig - Improved closing of (+) menu when cursor moves
refs https://github.com/TryGhost/Ghost/issues/9623
- close menu if it's open and the cursor position changes within the document
  - closes when you start typing rather than hiding text behind the menu
- watch for arrow keys and close the menu if pressed
  - closes when <kbd>Up</kbd> is pressed and the title is selected rather than the cursor being moved within the document
2018-06-20 15:45:43 +01:00
Kevin Ansfield 7967ee3894 Koenig - Embed card
refs https://github.com/TryGhost/Ghost/issues/9623
requires https://github.com/TryGhost/Ghost/pull/9666
- `{{koenig-card-embed}}`
    - URL input
    - perform oembed lookup & fetch on <kbd>Enter</kbd>
    - remove card if enter pressed with empty URL
    - show error message on server error
        - "retry" returns to input bar
        - "paste as link" removes card and outputs link
        - "X" removes card
    - force embedded <script> tags to run
    - wrap embed html with `.koenig-embed-{video,photo,rich}` class
- add embed cards to the (+) and /-menus
    - "section" support in the card menus
    - refactor to use single card menu map and content component for both menus
    - update /-menu keyboard movement to handle sections
- add parameter support to /-menu commands
  - `/embed {url}` will insert embed card and automatically fetch oembed for supplied url
2018-06-12 14:07:50 +01:00
Kevin Ansfield f232d3b984 🐛 Koenig - Fixed creation of unnecessary undo states
refs https://github.com/TryGhost/Ghost/issues/9623
- only use `editor.run` calls when performing edits, do not use them when only moving the cursor/selection
2018-05-23 14:20:03 +01:00
Kevin Ansfield 5462081cbe Koenig - Fixed card creation from plus menu
refs f3f3526818
- perform a check for a click originating on the plus menu in `{{koenig-card}}` to avoid an immediate deselection as soon as an editable card is created
- removed unnecessary `.koenig-plus-menu` class in favour of `[data-kg="plus-menu"]` selector
2018-05-23 14:11:42 +01:00
Kevin Ansfield 5a3acaa967 Koenig - Fixed errors when dragging selection
refs https://github.com/TryGhost/Ghost/issues/9623
- catches and ignores `editor.positionAtPoint` TypeError due to not having a correct node value whilst dragging with a selection
- fixes error thrown from the triple-click handling which expected a value to always be present
2018-05-17 13:56:37 +01:00
Zimo 8d7f13b285 Koenig - Replace custom CSS classes with Spirit
no issue
- Koenig container styles for Spirit
- Applying Spirit styles to card menu
- Applying Spirit styles to generic cards
- Replacing icon styles with Spirit
- Fix slash menu selected state
- Cleanup of unused files + fix empty HTML
2018-05-02 15:54:22 +01:00
Kevin Ansfield 302596830c Koenig - Switch `this.get` for ES5 getters
no issue
- Ember 3.1 adds support for ES5 getters to replace (mostly) the need for `this.get` - https://www.emberjs.com/blog/2018/04/13/ember-3-1-released.html#toc_es5-getters-for-computed-properties-2-of-4
- updating Koenig now because it's a fairly isolated part of Ghost-Admin and a good playground for new standards that we can migrate to in the main codebase
2018-05-01 17:13:53 +01:00
Kevin Ansfield 2ba01265d8 Koenig - Fixed error when pasting text with a whole paragraph selected
refs https://github.com/TryGhost/Ghost/issues/9505
2018-04-13 16:42:20 +01:00
Kevin Ansfield 97e5925fec Koenig - Move list creation from card menus to toolbar
refs https://github.com/TryGhost/Ghost/issues/9505
- remove unordered and bullet list icons from the (+) and / menus
- add unordered and bullet list icons to the formatting toolbar
- reorder toolbar icons to match latest design specs
- remove now-unused `replaceWithListItem` actions
2018-03-15 14:35:39 +00:00
Kevin Ansfield e8258d68d3 Koenig - Close (+) menu when pressing Escape
refs https://github.com/TryGhost/Ghost/issues/9311
- close menu and reset the caret position in the editor when <kbd>Esacape</kbd> is pressed whilst the (+) menu is open
2018-03-14 10:50:38 +00:00
Kevin Ansfield 2d95392624 Koenig - Slash menu
refs https://github.com/TryGhost/Ghost/issues/9311
- adds `{{koenig-slash-menu}}` component that renders a quick-access card/block menu when typing `/` at the beginning of a new paragraph
2018-02-03 17:54:57 +01:00
Kevin Ansfield d25d7922ac Koenig - Move list/card replacement actions into {{koenig-editor}} 2018-02-03 17:54:57 +01:00
Kevin Ansfield 4d92e5a357 Koenig - Show (+) button on blank paragraph mouseover
refs https://github.com/TryGhost/Ghost/issues/9311
- add a mousemove event handler that shows the (+) next to blank paragraphs when the pointer is over them
- fix sticky button when adding a card mid-document by hiding it, we get another `didReceiveAttrs` call with the new range when adding a blank paragraph so it's still shown in that situation
- fix the incorrect button position when adding a card at the bottom of the doc by re-positioning in the next runloop. Problem seems to stem from the component card being rendered after we get the new range so our position calculations are out of sync
2018-02-02 12:56:55 +01:00
Kevin Ansfield e0b9b1805f Koenig - Fix plus menu teardown but
no issue
- fixed typo that was throwing an error on `willDestroyElement` of `{{koenig-plus-menu}}`
2018-02-01 18:29:33 +01:00
Kevin Ansfield 60a1a781e7 Koenig - Re-position toolbar and plus menu on window resize
refs https://github.com/TryGhost/Ghost/issues/9311
- extract positioning routines into methods
- throttle positioning method calls on window resizes
2018-02-01 17:48:16 +01:00
Kevin Ansfield 584dece638 Koenig - (+) card/list selection menu
refs https://github.com/TryGhost/Ghost/issues/9311
- re-implement the (+) card/list selection menu from the old Koenig alpha with improved positioning and event handling
- buttons work for the currently available cards - `<hr>` and `markdown`
2018-01-31 15:49:20 +01:00