Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ak-editor-core

atlassian807Apache-2.0deprecated3.12.3TypeScript support: included

This package has been deprecated. Please use the '@atlaskit' scoped packages instead. See https://atlaskit.atlassian.com for more information

A package contains Atlassian editor core functionality

readme

AtlasKit component registry Commitizen friendly semantic-release Report an issue Ask in our forum

ak-editor-core

This packages provides core components shared across all Atlassian Editor packages.

It's the home for shared editor functionality and implements shared editor behaviours, and is the preferred destination for editor functionality.

Package organisation

Analytics

Source location: src/analytics/ Import: import { … } from 'ak-editor-core'

A set of tools for emitting analytics relating to user interaction with the product. These can be wired into product integrations. Transport is left as the responsibility for the product.

Plugins

Source location: src/plugins/ Import: import { … } from 'ak-editor-core'

Plugins (and "plugin states") are the mechanisms by which functionality is added to the editor.

Plugin principles:

  • Plugins should avoid making too many assumptions about the shape of the schema. Different products use different schemas, so the plugin should gracefully handle the absence of nodes or marks, or fail loudly in the constructor.
  • A good rule of thumb is one plugin per content-type. For example:

    • HyperlinkPlugin for hyperlinks.
    • MentionsPlugin for mentions.
    • HorizontalRulePlugin for horizontal rules.
  • Plugins are responsible for attaching keymaps and input rules that are specific to the content. For example MentionsPlugin intercepts arrow keys when the selection is in a mention query and uses them to navigate items in the mention picker.

  • Plugins will be used on all platforms (browser + mobile native).
  • Plugins should expose "logical APIs" that are suitable for integrating into UI components. For example the HyperlinkState expose:

      class HyperlinkState {
        // …
    
        // public state
        href?: string;
        text?: string;
        active = false;
        canAddLink = false;
        element?: HTMLElement;
    
        // …
      }

    These fields allow a UI to present the current hyperlink href and text, and position a floating toolbar at the correct position on the screen (thanks to element being exposed).

ProseMirror

Source location: src/prosemirror/
Import: import { … } from 'ak-editor-core'

The prosemirror directory provides a flat export of ProseMirror 0.10 objects, to solve the recurring problem figuring out which prosemirror/dist/* package to import from.

A hoped side-benefit of this approach is a simplified upgrade-path for code for ProseMirror upgrades.

It also includes TypeScript definitions for a large chunk of ProseMirror's API surface, and that of browserkeymap too. As a general practice, ProseMirror objects should be imported via this directory.

Schema

Source location: src/schema/
Import: import { … } from 'ak-editor-core'

The schema modules implement node and mark types for use in product-specific schemas. Node and mark types are responsible for:

  • encoding to DOM for editable content, including styling
  • decoding (matching against) pasted HTML content into ProseMirror nodes

Schema principles:

  • The name of a node type or mark type must always be the same across different schemas. As such node types and mark types should make an assertion in their constructor that they are named correctly.

Some complex node and mark types (to use as examples):

  • MentionQueryMarkType -- used to indicate a new editing context where typed characters perform a user-search, and arrow keys and enter are used to navigate a user-picker.
  • MentionNodeType -- an immutable node that represents a user.

UI

Source location: src/ui/
Import: import { … } from 'ak-editor-core'

The UI modules are responsible for implementing non-content elements of the user interface, for example:

  • src/ui/ChromeCollapsed -- A collapsed editor that provides an initial affordance in the UI, suitable for a comment editor.
  • src/ui/ChromeExpanded -- An expanded editor that includes a fixed toolbar, save & cancel buttons, surrounding borders, etc.
  • src/ui/Chrome -- An encapsulation of ChromeCollapsed and ChromeExpanded, providing "click to expand" behaviour.
  • src/ui/Panel -- A floating popup that can be used as the base for a floating toolbar (e.g. HyperlinkEdit).
  • src/ui/Toolbar* -- A collection of button-groups that are suitable for placing in the fixed toolbar.

A few notes on development:

  • The UI is only intended for use in a web browser, it is not used for the mobile native web view editor.
  • Although ProseMirror is not built on React, the UI is.
  • Styling is achived via TypeStyle.
  • The UI can be coupled to (have knowledge of) plugins, but not the other way around.

    This allows the plugins to be used on mobile with a completely different UI (a native one) to that which is used on web.

The UI modules are exported from the top level index.ts, which means that they'll be pulled in in the ES5 distribution. If you're building a mobile editor the ES2015 sources should be used instead as they can enable tree shaking with webpack 2.

Test helpers

Source location: src/ui/
Import: import { … } from 'ak-editor-core/test-helper'

A set of testing utilities are provided that making testing the editor easier, these include:

  • Chai extensions for making assertions about ProseMirror nodes, fragments, slices, etc.
  • Tools for emiting DOM events (e.g. clicks or pastes).
  • Tools for creating DOM sandboxes.
  • Tools for inserting content into a ProseMirror.
  • Tools for constructing a ProseMirror with an initial text selection.
  • Tools for creating node builders based on a schema.
  • A plugin for making ProseMirror synchronously flush to the DOM.

Test helpers are not exported from the root package, as a courtesy to ES5 consumers that are unable to imploy tree shaking.

Installation

Install from NPM:

npm install --save ak-editor-core

Two flavours of JavaScript are published:

  • ES5 (referenced by the main field in package.json)
  • ES2015 (referenced by the jsnext:main field in package.json)

If you're using webpack, adjust your resolve.packageMains accordingly.

Usage

Unless you're developing a new editor for a product, you've probably arrived at the wrong package. Consider using:

If you're sure you want to consume this package, refer to one of the packages above for an example of how to use it.

One important omission from this package are pre-built schemas. Due to the nature of different products using different storage backend, per-product schemas exist in product-specific editor packages that ensure that authored content does not violate the constraints of the underlying storage.

The schemas in those packages are composed on node and mark types defined in this package.

Support and feedback

We're here to help!

Let us know what you think of our components and docs, your feedback is really important for us.

Community support

Ask a question in our forum.

Check if someone has already asked the same question before.

Create a support ticket

Are you in trouble? Let us know!

changelog

3.12.3 (2017-01-27)

ak-editor-core@3.12.3 (2017-01-27)

ak-editor-core@3.12.2 (2017-01-26)

Bug Fixes

  • package: Rearrange package.json to support distributing src. (2c6b93b)

ak-editor-core@3.12.1 (2017-01-25)

ak-editor-core@3.12.0 (2017-01-25)

ak-editor-core@3.11.2 (2017-01-25)

Bug Fixes

  • component: Adding a keymap for Shift-Backspace (ec8a613)
  • package: Changed to use fence format to serialize down to BB. (7ecf925)

ak-editor-core@3.11.1 (2017-01-25)

ak-editor-core@3.11.0 (2017-01-25)

Bug Fixes

  • component: On focus update Toolbar UI to reflect cursor position (a04714d)
  • package: Added zIndex of language picker (309ed18)
  • package: Moved zIndex from language picker to panel (b0fc85f)
  • package: Removed label in toolbar icon because it overrap with tooltip. (55d91a1)

Features

  • component: Adding EmojisPlugin (3ea3d7a)

ak-editor-core@3.10.11 (2017-01-24)

Bug Fixes

  • package: Publish ES5 sources for test-helper (0e6cb2f)

Features

  • package: Added tooltip for blocktypes. (6d8f117)
  • package: Added tooltip for text formatting toolbar. (a832ea0)
  • package: Move others keymap into central keymap as well. (6d72e40)

ak-editor-core@3.10.10 (2017-01-24)

Bug Fixes

  • package: Strip ak:webpack:raw from published packages, and rewrite "types" field. (527b999)

Features

  • package: Extract keymap component and added tooltip for lists. (e1bf15c)

ak-editor-core@3.10.9 (2017-01-24)

ak-editor-core@3.10.8 (2017-01-24)

Bug Fixes

  • package: Fixed bug that cannot get correct htmlElemenet if select backward whole text (a1ebb6c)
  • package: Fixes an issue with z-index for the mention-picker and insertion of mentions (f82337f)
  • package: it should initialize all public variables on load of plugin. (17589c8)

ak-editor-core@3.10.7 (2017-01-23)

Bug Fixes

  • package: fixed bug that activeLinkNode is not correct (55443a9)
  • types: Avoid global type clashes in chai. (7bd2b78)

ak-editor-core@3.10.6 (2017-01-23)

Bug Fixes

  • package: Fixed bug that no hyperlink popup if select whole hyperlink text backwords (b9bfe2b)
  • package: TypeScript consumers of ak-editor-core to use declarations rather than source for typi (00e0fa5)

ak-editor-core@3.10.5 (2017-01-23)

Bug Fixes

  • package: Exclude src/ from the package, until a solution for 'types' field in package.json is f (ca7a419)
  • package: Fix imports and build script. (8387498)

ak-editor-core@3.10.4 (2017-01-23)

Bug Fixes

  • component: include sources in published packages. (6ade56d)
  • package: Fixed bug that cannot preserve @mention text. (0d69553)
  • package: Fixed bug that language picker not update position if enter new line. (7fd8886)
  • package: Fixed the bug that markdown and toolbar converting codeblock differently (6ca94c1)

ak-editor-core@3.10.3 (2017-01-20)

Bug Fixes

  • component: fix icons alignment in toolbar buttons, upgrade ak-icon (485be9c)
  • package: Fixed bug that with un supported content, new line not insert in the right place. (309d7c2)

ak-editor-core@3.10.2 (2017-01-19)

ak-editor-core@3.10.1 (2017-01-19)

ak-editor-core@3.10.0 (2017-01-19)

Bug Fixes

  • package: fixed estlint error. (2e3efd7)
  • package: Fixed typo (4c36299)
  • package: Fixed typo. (fc758ef)
  • package: rename test (025b591)
  • package: when show language, always shown the ones from language list. (176b616)
  • types: Fix incorrect usage of TypeStyle. (984c2f8)
  • types: Fix TypeScript declarations, add validate/typescript and enable it for CI. (70064dc)
  • types: Replace akutil-react dependency with react, update TypeScript to pull in a bugfix to .d. (660af41)

Features

  • package: Added autoformat for strike (68aea95)

ak-editor-core@3.9.1 (2017-01-17)

Bug Fixes

  • Remove it.only (c761b12)
  • Revert a change to how hyperlink DOM nodes are found. (a877bc4)

ak-editor-core@3.9.0 (2017-01-17)

Bug Fixes

  • types: Remove 'declare module' style ProseMirror definitions. (fb989f7)

ak-editor-core@3.8.0 (2017-01-16)

ak-editor-core@3.7.0 (2017-01-16)

Bug Fixes

  • component: refactor ToolbarIconButton, change style of feedback button. (c32055f)
  • component: reference to ContextName (ef817fe)
  • package: does not show language in markdown if language is not specified. (6a9bf68)
  • package: Fix bug that sometimes did not get element correctly (6d1cb9a)
  • package: fixed bug that it changes node attribute directly. It should be immutable. (776de9d)
  • package: Typo and format changed. (3c86368)
  • package.: capitalize first letter of language list. (f8199e6)
  • php should be PHP. (03de667)

Features

  • component: remove "pr" and "comment" contexts. (5692417)
  • package: Added longer language list (b99c7dd)
  • package: Added simple dropdown language picker (dd3c2b9)
  • package: added test to cover elements changes when selection change in code block plugin (e693f27)
  • package: attached language selection panel to the codeblock element. (ecc0ccc)
  • package: capitalize first letter of langugage. default to language instead of unspecified. (4c6e899)
  • package: make sure dropdown no jummping on selection. (c78e19d)
  • package: panel should only render whatever inside, but not adding too much css. (8fce562)
  • package: read from node langugage on load if they already have one. (9f9fd16)
  • package: removed languages not supported by pygments. (6452b59)
  • package: sorted language by alpha. (b073467)
  • package: Update code block node language when select from dropdown (ee64be2)
  • package: use languge and active state instead of the whole node from code block plugin (943f861)
  • package: Use latest version of ak-mention (b5144a9)
  • package: wrap language picker with panel. (2e26313)

ak-editor-core@3.6.0 (2017-01-13)

ak-editor-core@3.5.0 (2017-01-12)

Features

  • Apply new block type to multiple blocks (1f1f107)
  • package: Apply block type to multiple blocks (a87a780)

ak-editor-core@3.3.0 (2017-01-11)

ak-editor-core@3.2.2 (2017-01-11)

Bug Fixes

  • types: Consume browserkeymap with baked in types. (4be79c7)

ak-editor-core@3.2.1 (2017-01-11)

Bug Fixes

  • package: Mentions should display name (3649a24)

ak-editor-core@3.2.0 (2017-01-11)

Features

  • Refactor mention-resource, adding types, fixed keymap (8067de3)

ak-editor-core@3.1.3 (2017-01-10)

ak-editor-core@3.1.2 (2017-01-09)

Bug Fixes

  • package: Fixed cannot do paste on multiple editor if first focus on code block. (231d651)

Features

  • component: refactor block type dropdown to use ak-droplist (001ebe7)

ak-editor-core@3.1.1 (2017-01-09)

ak-editor-core@3.1.0 (2017-01-09)

Bug Fixes

Features

  • bump: go to 4.0.0 for ak-editor-core (10c6146)
  • package: removed extra new line. (b43b851)
  • package: RREAKING CHANGE: Added code block plugin. (73ad71d)

ak-editor-core@3.0.0 (2017-01-06)

Features

  • package: Added keymap for code block plugin (1d5cf28)
  • package: Added subscribe and unsubscribe feature onto code block plugin (fa81b67)
  • package: Moved code block related codes from block type plugin to code block plugin (3e3c67b)

ak-editor-core@2.1.0 (2017-01-06)

ak-editor-core@2.0.2 (2017-01-06)

Bug Fixes

  • component: unable to close block type menu by clicking trigger. (5f9200f)

ak-editor-core@2.0.1 (2017-01-06)

Bug Fixes

  • component: Bump required ak-editor-core version because of API change. (5b8aecd)
  • component: Fix editor toolbars disappearing w/ multiple instances. (29bd1bd)

Features

  • package: Added simple code block plugin (f9fa764)

ak-editor-core@2.0.0 (2017-01-05)

Features

  • component: rename analytics' exports to be less ambiguous (251cd06)
  • package: got language info from code block's parent div (33b1edb)

BREAKING CHANGES

  • component: exports are renamed so components must import them differently

ak-editor-core@1.19.2 (2017-01-03)

ak-editor-core@1.19.1 (2017-01-03)

Bug Fixes

  • Fixes a bug when mention data is null (cdf68c9)

Features

  • package: Allow code block to sets language attribute. (6c8688f)

ak-editor-core@1.19.0 (2016-12-28)

Bug Fixes

  • package: fixed eslint (4047e57)
  • package: Fixed heading test that test the wrong thing (2ebab15)
  • package: Fixed tslint; added back codemark. (688f748)

ak-editor-core@1.18.0 (2016-12-23)

Bug Fixes

  • docs: Improve documentation. (c6af35a)
  • package: Fix plugin naming for default-inputrules plugin (0f64472)
  • package: Fixes Anonymus Class error in analytics/service (1610375)
  • package: Fixing inputrules conflict between emdash and horizonal rule (9376f84)

Features

  • package: Added name constraion on Node name (6ab6d6c)
  • package: Fixed test failure. (44e7c05)

ak-editor-core@1.6.0 (2016-12-22)

Bug Fixes

  • Export privately used types to allow .d.ts creation. (c0c1330)
  • package: Removed redundant delmark and codemark codes. (45516a7)
  • package: Removed spaces (fdce285)

Features

  • package: Added analytics to core. (0dcecb8)
  • package: Constrain the name for marks (1cdd15c)
  • package: Removed del and code mark. Because not in use. (d19914f)

ak-editor-core@1.3.0 (2016-12-21)

Bug Fixes

  • package: modified chai import. (0cf4c70)
  • Fix tests failure. (58e49e3)

ak-editor-core@1.2.3 (2016-12-21)

Bug Fixes

  • build: Fix various problems that were detected in CI. (a67ca12)
  • build: Improve performance of TypeScript builds. (437bfc4)
  • package: Added back missing code after merge master. (b7acfd2)

ak-editor-core@1.2.2 (2016-12-20)

Bug Fixes

  • Move test-helper out of src/ (8178d9a)
  • Use ak-editor-core/test-helper rather than ak-editor-test. (c1b3e30)
  • bump: Bump to ak-icon@^12.0.0 (79e74fe)
  • package: synthetic-default-import (41a4478)

ak-editor-core@1.2.1 (2016-12-20)

Bug Fixes

  • build: Remove magical synthetic default imports so that published ES5 is correct. (224bf55)
  • package: Fixed key map test for horizontal rule (e90953b)
  • package: Keep only Mod-Shift-M as mono keymap (f0f2190)

Features

  • package: Use mono in BB (b7228cc)
  • package: use mono in core (2eab715)

ak-editor-core@1.2.0 (2016-12-19)

Features

  • pacakge: Added image-upload to core (b1786b3)
  • package: Added keymap for horizontal rule (c5e69ae)

ak-editor-core@0.2.0 (2016-12-19)

Features

  • Export everything from ak-editor-core from the package index. (b0e4731)
  • Release 1.0.0 of ak-editor-core (2e1cb7b)
  • package: Added @mention integration to ak-editor-core (d774d92)
  • package: Added horizontal rule. WIP (fd34563)

ak-editor-core@0.1.0 (2016-12-18)

Bug Fixes

  • Create a valid mousedown event for IE. (0669636)
  • Do not use shadowRoot symbol (45a8d3c)
  • component: Minor fixes from PR feedback, removed superfluous test, checked in symbols (70454d3)
  • target for alignment fix (20d6cc2)
  • bump: update skate version to ^3.1.2 (f6bf589)
  • component: change visual styles to have fixed width, better commit icon (957a859)
  • component: Fix on container name overflow and container link overflow ellipsis (d2b733d)
  • component: Fixed alt of img, added test for it (d3e4b34)
  • component: navigation slot children never got style (ae53dde)
  • docs: Alts fixed (b665e47)
  • docs: Fixes layer docs with updated screenshot and usage.md (1ce5ced)
  • package: Added back all missing .d.ts files to core (0b83e45)
  • package: BREAKING CHANGE: Created a package that contains core editor functions. BlockTypePlugi (db056f4)
  • package: fix import in chai.d.ts; removed unused import of repeat (088b220)
  • package: pull non tests (setup) file from test sub folder to test root folder (b2bd6cc)
  • package: Removed duplicated declaration (8b2b2f4)
  • package: Understood two level downs of .d.ts files in core (982aff2)
  • tests: fix test to determine if a local and remote date are the same (9ec6976)

Code Refactoring

Features

  • date-calendar props added & tests (c01dc70)
  • Introduce new plugin implementation. (6723d11)
  • package: Added ak-editor-plugin-lists to core (9660a89)
  • run single storybook (aa31b02)
  • lint: Add support for JSX in the eslint-config-ak-base and add docs for it. (bd59ebf)
  • package: add pre-release version of profile-card (55f8b8b)
  • package: added ak-editor-plugin-hyperlink to core. WIP(tests failed) (041a5b0)
  • package: Added ak-editor-plugin-image-upload to core (1b0a73a)
  • package: Added ak-editor-plugin-markdown-inputrules to core (57dd229)
  • package: Added ak-editor-plugin-mentions to core (1d4bd98)
  • package: Added ak-editor-plugin-text-formatting to core (c03b74d)
  • package: Added ak-editor-prosemirror to core (9160001)
  • package: Added ak-editor-schema to core (65d2b5f)
  • package: Added ak-editor-test to core (4da0315)
  • package: Added storybook for schema (078eb06)
  • styles: Remove dependency on webpack style-loader, use TypeScript instead. (38a33db)

BREAKING CHANGES

  • events exposed by ak-blanket changed

0.0.1-atlas-animation3 (2016-06-08)

1.1.6-atlas-animation (2016-06-08)

13.1.0-tmp-atlaskit-component-b (2016-06-08)

13.1.0-tmp-atlaskit-component-a (2016-06-08)

Bug Fixes

  • components: commented out a line (4b91174)

Features

  • components: Add an ! mark (2b7bdb0)