1.17.0 • Published 1 month ago

@jinntec/jinn-codemirror v1.17.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
1 month ago

Code Editor Webcomponent

A plain javascript web component based on codemirror.

Demo

Features:

  • Editing modes for: XML, HTML, CSS, TeX, XQuery, Leiden+ and other variants of the Leiden convention
  • Configurable toolbar with support for snippets
  • Autocomplete in XML mode based on a JSON representation of the schema
  • Commands for XML editing:
    • enclose in element
    • remove enclosing parent
    • select parent
  • Linting for XML and XQuery
  • Support for markup following the Leiden+ convention, backed by a grammar
  • Conversion between EpiDoc XML fragments and Leiden+

The component comes in 3 flavours:

  1. jinn-codemirror: the generic code editor webcomponent
  2. jinn-xml-editor: extends jinn-codemirror with the option to specify an outer element which should wrap around the edited content. This is important if you want users to e.g. edit the contents of a <div> without seeing the wrapping element. The wrapper will be removed when a value is passed to the editor and added back when serializing the edited content.
  3. jinn-epidoc-editor: combines an XML Editor with an option to import and convert a transcription following Leiden conventions. Leiden markup is automatically converted to the corresponding EpiDoc XML.

API

jinn-codemirror

Source code editor component based on codemirror. Features extended support for XML and Leiden+ code.

Properties

PropertyAttributeTypeDescription
codecodestringspecifies initial content to be inserted at startup for editing
contentstringThe content edited in the editor as a string.
linterlinterstringXQuery mode: the API endpoint to use for linting.
modemodestringThe mode to use. Currently supported are 'xml', 'xquery', 'css', 'html', 'tex', 'markdown', 'leiden_plus', 'edcs', 'phi' or 'default'.
namespacestring \| null \| undefinedDefault element namespace to enforce on the root element in XML mode
placeholderplaceholderstringA placeholder string to be shown if the user has not yet entered anything.
statusstringShow a status message below the editor.
themestring \| null \| undefinedEditor theme to use. Currently dark, material-dark, material-light, solarized-dark andsolarized-light are supported.
validboolean
valueThe value edited in the editor as either an Element or string - depending on the mode set.

Methods

MethodTypeDescription
clear(): void
emitUpdateEvent(content: any): void
focus(): voidMove keyboard focus to the editor
setMode(mode: string, update?: boolean): void
styles(): string

Events

EventDescription
invalidfired if the content of the editor is invalid (requires a linter to be supported)
updatefired when the content of the editor has changed
validfired if the content of the editor is valid (requires a linter to be supported)

Slots

NameDescription
headeroptional header to be displayed above the toolbar
toolbartoolbar to be shown

jinn-xml-editor

Extends jinn-codemirror for XML editing: adds a boolean property "unwrap" to indicate if the entire root node passed in as value should be edited or just its content. Setting the property requires that a DOM element is passed via value.

Attributes

AttributeTypeDescription
check-namespacebooleanif enabled, a missing namespace will be reported as error

Properties

PropertyAttributeTypeDefaultDescription
schemaschemastringnullSchema to load for autocompletion.
schemaRootschema-rootstringnullDetermines the root element to be used for autocomplete.
unwrapunwrapstringfalseIf set, expects that a value passed in is a DOM element, which will serve as a wrapper for the content. The wrapper element itself will not be shown in the editor.

Methods

MethodType
configure(): void
emitUpdateEvent(content: string): any

jinn-epidoc-editor

Combines an XML editor with an option to import and convert markup following variants of the Leiden convention.

Properties

PropertyAttributeTypeDefaultDescription
modestring"leiden_plus"Syntax mode to use for the leiden editor, one of leiden_plus, edcs or petrae
modeSelectmode-selectbooleanfalseif set, user may choose from the supported syntaxes
placeholderstring""
schemastring \| nullnullan optional schema description (JSON syntax) to load for the XML editor
schemaRootschema-rootstringnulldetermines the root element for autocomplete
showLeidenbooleanfalseShould the leiden editor be shown initially?
unwrapboolean \| undefinedfalseIf set, expects that a value passed in is a DOM element, which will serve as a wrapper for the content.The wrapper element itself will not be shown in the editor.
validboolean \| undefinedtrue
valueThe value edited in the editor as either an Element or string -depending on the mode set.
xmlEditornull

Events

Event
invalid
valid

Slots

NameDescription
leiden-headeroptional header to be displayed above the toolbar of the leiden editor
leiden-toolbartoolbar for the leiden editor
open-leidencontrol (button by default) which opens/closes the leiden editor
xml-headeroptional header to be displayed above the toolbar of the xml editor
xml-toolbartoolbar for the xml editor
1.16.0

1 month ago

1.17.0

1 month ago

1.15.0

3 months ago

1.14.1

5 months ago

1.14.0

5 months ago

1.13.5

9 months ago

1.13.4

10 months ago

1.13.3

10 months ago

1.13.2

10 months ago

1.13.1

10 months ago

1.13.0

11 months ago

1.12.0

1 year ago

1.11.8

1 year ago

1.11.7

1 year ago

1.11.6

1 year ago

1.11.9

1 year ago

1.11.4

1 year ago

1.11.5

1 year ago

1.11.3

1 year ago

1.11.2

1 year ago

1.11.1

1 year ago

1.8.2

1 year ago

1.6.4

1 year ago

1.9.0

1 year ago

1.8.1

1 year ago

1.7.2

1 year ago

1.6.3

1 year ago

1.8.0

1 year ago

1.7.1

1 year ago

1.6.2

1 year ago

1.7.0

1 year ago

1.6.1

1 year ago

1.2.5

1 year ago

1.6.0

1 year ago

1.2.4

1 year ago

1.5.0

1 year ago

1.3.2

1 year ago

1.2.3

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.2.2

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.8.3

1 year ago

1.11.0

1 year ago

1.10.1

1 year ago

1.10.0

1 year ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago