mirror of
https://github.com/codex-team/editor.js
synced 2026-03-14 14:45:47 +01:00
6.1 KiB
6.1 KiB
Editor.js specs
This document will describe various test cases of the editor.js functionality. Features will be organized by modules. Cases covered by tests should be marked by the checkmark.
Configuration
-
Zero configuration
- Editor.js should be initialized on the element with the default
editorjsid. - Editor.js should throw an error in case when there is no element with
editorjsid. - Editor.js should be initialized with the Paragraph tool only.
- The Inline Toolbar of the Paragraph tool should contain all default Inline Tools -
bold,italic,link.
- Editor.js should be initialized on the element with the default
-
holderproperty- Editor.js should be initialized on the element with passed via
holderproperty. - Editor.js should throw an error if passed
holdervalue is not an Element node.
- Editor.js should be initialized on the element with passed via
-
autofocusproperty- With the empty editor
- If
truepassed, the caret should be placed to the first empty block. - If
falsepassed, the caret shouldn't be placed anywhere. - If omitted, the caret shouldn't be placed anywhere.
- If
- With the not-empty editor
- If
truepassed, the caret should be placed to the end of the last block. - If
falsepassed, the caret shouldn't be placed anywhere. - If omitted, the caret shouldn't be placed anywhere.
- If
- With the empty editor
-
placeholderproperty- With the empty editor
- If
stringpassed, the string should be placed as a placeholder to the first empty block only. - If
falsepassed, the first empty block should be placed without a placeholder. - If omitted, the first empty block should be placed without a placeholder.
- If
- With the empty editor
-
minHeightproperty- If
numberpassed, the height of the editor's bottom area from the last Block should be thenumber. - If omitted the height of editor's bottom area from the last Block should be the default
300.
- If
-
logLevelproperty- If
VERBOSEpassed, the editor should output all messages to the console. - If
INFOpassed, the editor should output info and debug messages to the console. - If
WARNpassed, the editor should output only warning messages to the console. - If
ERRORpassed, the editor should output only error messages to the console. - If omitted, the editor should output all messages to the console.
- If
-
defaultBlockproperty- If
stringpassed- If passed
stringin thetoolsoption, the passed tool should be used as the default tool. - If passed
stringnot in thetoolsoption, the Paragraph tool should be used as the default tool.
- If passed
- If omitted the Paragraph tool should be used as default tool.
- If
-
sanitizerproperty- If
objectpassed- The Editor.js should clean the HTML tags according to mentioned configuration.
- If omitted the Editor.js should be initialized with the default
sanitizerconfiguration, which allows the tags likeparagraph,anchor, andboldfor cleaning HTML.
- If
-
toolsproperty- If omitted,the Editor.js should be initialized with the Paragraph tool only.
- If
objectpassed- Editor.js should be initialized with all the passed tools.
- The keys of the object should be represented as
typefields for corresponded blocks in output JSON - If value is a JavaScript class, the class should be used as a tool
- If value is an
object- Checking the
classproperty- If omitted, the tool should be skipped with a warning in a console.
- If existed, the value of the
classproperty should be used as a tool
- Checking the
configproperty- If
objectpassed Editor.js should initializetooland pass this object asconfigparameter of the tool's constructor
- If
- Checking the
shortcutproperty- If
stringpassed Editor.js should append thetoolwhen such keys combination executed.
- If
- Checking the
inilineToolbarproperty- If
truepassed, the Editor.js should show the Inline Toolbar for this tool with common settings. - If
falsepassed, the Editor.js should not show the Inline Toolbar for this tool. - If
arraypassed, the Editor.js should show the Inline Toolbar for this tool with a passed list of tools and their order. - If omitted, the Editor.js should not show the Inline Toolbar for this tool.
- If
- Checking the
toolboxproperty- If it contains
title, this title should be used as a tool title - If it contains
icon, this HTML code (maybe SVG) should be used as a tool icon
- If it contains
- Checking the
-
onReadyproperty- If
functionpassed, the Editor.js should call thefunctionwhen it's ready to work. - If omitted, the Editor.js should be initialized with the
toolsonly.
- If
-
onChangeproperty- If
functionpassed,the Editor.js should call thefunctionwhen something changed in Editor.js DOM. - If omitted, the Editor.js should be initialized with the
toolsonly.
- If
-
dataproperty- If omitted
- the Editor.js should be initialized with the
toolsonly. - the Editor.js should be empty.
- the Editor.js should be initialized with the
- If
objectpassed- Checking the
blocksproperty- If
arrayofobjectpassed,- for each
object- Checking the
typeanddataproperty- the Editor.js should be initialize with
blockof classtype - If
typenot present intools, the Editor.js should throw an error.
- the Editor.js should be initialize with
- Checking the
- for each
- If omitted
- the Editor.js should be initialized with the
toolsonly. - the Editor.js should be empty.
- the Editor.js should be initialized with the
- If
- Checking the
- If omitted
-
readOnlyproperty- If
truepassed,- If any
toolhave not readOnly getter defined,The Editor.js should throw an error. - otherwise, the Editor.js should be initialize with readOnly mode.
- If any
- If
falsepassed,the Editor.js should be initialized with thetoolsonly. - If omitted,the Editor.js should be initialized with the
toolsonly.
- If
-
i18nproperty