Diplodoc utils
Diplodoc cross-packages utils.
Motivation
The Diplodoc ecosystem consists of many packages that have similar problems and needs. This package will contain all the general logic that is duplicated in our code base.
Table of contents
- AttrsParser
- [Extension Load Queue](#Extension Load Queue)
AttrsParser
Purpose
Support markdown-it-attrs-like attributes parser. Used in custom Diplodoc MarkdownIt plugins to add classes and anchors, enabling subsequent customization through CSS.
Interface
const attrs = new AttrsParser('{.class #id data-name=diplodoc}');
attrs.state
const other = attrs.parse('{data-wide title="Support quotes too"}')
other
Extension Load Queue
Purpose
This queue mechanism allows asynchronous loading of extensions by setting a property on the "window" object in the browser. This property has a Symbol data type, which makes it difficult for external manipulations to access it.
Interface
export const GLOBAL_SYMBOL: unique symbol = Symbol.for('someController');
const store = getScriptStore<SomeController>(GLOBAL_SYMBOL);
const controller = useController<SomeController>(store);
See example in diplodoc-platform/html-extension