@doist/typist 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/components/typist-editor.d.ts.map +1 -1
- package/dist/components/typist-editor.js +4 -5
- package/dist/extensions/core/extra-editor-commands/commands/insert-markdown-content.js +2 -2
- package/dist/extensions/shared/copy-markdown-source.js +2 -2
- package/dist/helpers/schema.d.ts +9 -1
- package/dist/helpers/schema.d.ts.map +1 -1
- package/dist/helpers/schema.js +11 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/serializers/html/html.d.ts +9 -1
- package/dist/serializers/html/html.d.ts.map +1 -1
- package/dist/serializers/html/html.js +20 -2
- package/dist/serializers/markdown/markdown.d.ts +9 -1
- package/dist/serializers/markdown/markdown.d.ts.map +1 -1
- package/dist/serializers/markdown/markdown.js +20 -2
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [1.2.0](https://github.com/Doist/typist/compare/v1.1.2...v1.2.0) (2023-03-17)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- **serializers:** Add `get*` functions for reusable singular instances ([#88](https://github.com/Doist/typist/issues/88)) ([b2c77c3](https://github.com/Doist/typist/commit/b2c77c30b15cd3dd676fc01531ecbeb5a6f7b952))
|
|
6
|
+
|
|
1
7
|
## [1.1.2](https://github.com/Doist/typist/compare/v1.1.1...v1.1.2) (2023-03-06)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typist-editor.d.ts","sourceRoot":"","sources":["../../src/components/typist-editor.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAqB,wBAAwB,EAAE,MAAM,wCAAwC,CAAA;AAMpG,OAAO,EAAE,2BAA2B,EAA2B,MAAM,wBAAw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AAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAA;IAE3D;;OAEG;IACH,OAAO,CAAC,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAA;IAE7C;;OAEG;IACH,SAAS,CAAC,EAAE,wBAAwB,CAAC,WAAW,CAAC,CAAA;CACpD,CAAA;AAED;;;GAGG;AACH,QAAA,MAAM,YAAY,+GAgNhB,CAAA;AAEF,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,YAAY,EACR,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,GACd,CAAA"}
|
|
@@ -7,8 +7,8 @@ import { ExtraEditorCommands } from '../extensions/core/extra-editor-commands/ex
|
|
|
7
7
|
import { ViewEventHandlers } from '../extensions/core/view-event-handlers';
|
|
8
8
|
import { isMultilineDocument, isPlainTextDocument } from '../helpers/schema';
|
|
9
9
|
import { useEditor } from '../hooks/use-editor';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { getHTMLSerializerInstance } from '../serializers/html/html';
|
|
11
|
+
import { getMarkdownSerializerInstance } from '../serializers/markdown/markdown';
|
|
12
12
|
import { getAllNodesAttributesByType, resolveContentSelection } from './typist-editor.helper';
|
|
13
13
|
/**
|
|
14
14
|
* The `TypistEditor` component represents a plain-text or a rich-text editing control, built on
|
|
@@ -17,7 +17,6 @@ import { getAllNodesAttributesByType, resolveContentSelection } from './typist-e
|
|
|
17
17
|
const TypistEditor = forwardRef(function TypistEditor({ autoFocus, className, content = '', contentSelection, editable = true, extensions, placeholder, onBeforeCreate, onCreate, onUpdate, onSelectionUpdate, onTransaction, onFocus, onBlur, onDestroy, 'aria-describedby': ariaDescribedBy, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, onClick, onKeyDown, }, ref) {
|
|
18
18
|
const allExtensions = useMemo(function initializeExtensions() {
|
|
19
19
|
return [
|
|
20
|
-
// Custom core extensions
|
|
21
20
|
...(placeholder
|
|
22
21
|
? [
|
|
23
22
|
Placeholder.configure({
|
|
@@ -39,10 +38,10 @@ const TypistEditor = forwardRef(function TypistEditor({ autoFocus, className, co
|
|
|
39
38
|
return getSchema(allExtensions);
|
|
40
39
|
}, [allExtensions]);
|
|
41
40
|
const htmlSerializer = useMemo(function initializeHTMLSerializer() {
|
|
42
|
-
return
|
|
41
|
+
return getHTMLSerializerInstance(schema);
|
|
43
42
|
}, [schema]);
|
|
44
43
|
const markdownSerializer = useMemo(function initializeMarkdownSerializer() {
|
|
45
|
-
return
|
|
44
|
+
return getMarkdownSerializerInstance(schema);
|
|
46
45
|
}, [schema]);
|
|
47
46
|
const htmlContent = useMemo(function generateHTMLContent() {
|
|
48
47
|
return htmlSerializer.serialize(content);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DOMParser } from 'prosemirror-model';
|
|
2
2
|
import { parseHtmlToElement } from '../../../../helpers/dom';
|
|
3
|
-
import {
|
|
3
|
+
import { getHTMLSerializerInstance } from '../../../../serializers/html/html';
|
|
4
4
|
/**
|
|
5
5
|
* Inserts the provided Markdown as HTML into the editor.
|
|
6
6
|
*
|
|
@@ -12,7 +12,7 @@ function insertMarkdownContent(markdown, parseOptions) {
|
|
|
12
12
|
// Check if the transaction should be dispatched
|
|
13
13
|
// ref: https://tiptap.dev/api/commands#dry-run-for-commands
|
|
14
14
|
if (dispatch) {
|
|
15
|
-
const htmlContent =
|
|
15
|
+
const htmlContent = getHTMLSerializerInstance(editor.schema).serialize(markdown);
|
|
16
16
|
// Inserts the HTML content into the editor while preserving the current selection
|
|
17
17
|
tr.replaceSelection(DOMParser.fromSchema(editor.schema).parseSlice(parseHtmlToElement(htmlContent), parseOptions));
|
|
18
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension, getHTMLFromFragment } from '@tiptap/core';
|
|
2
|
-
import {
|
|
2
|
+
import { getMarkdownSerializerInstance } from '../../serializers/markdown/markdown';
|
|
3
3
|
/**
|
|
4
4
|
* The `CopyMarkdownSource` extension adds the ability to copy the editor underlying Markdown
|
|
5
5
|
* source, and write it to the system clipboard. This extension has full support for both the
|
|
@@ -18,7 +18,7 @@ const CopyMarkdownSource = Extension.create({
|
|
|
18
18
|
// Get a fragment of the editor's content based on the selection
|
|
19
19
|
const nodeSelection = editor.state.doc.cut(editor.state.selection.from, editor.state.selection.to);
|
|
20
20
|
// Serialize the selected content HTML to Markdown
|
|
21
|
-
const markdownContent =
|
|
21
|
+
const markdownContent = getMarkdownSerializerInstance(editor.schema).serialize(getHTMLFromFragment(nodeSelection.content, editor.schema));
|
|
22
22
|
// Writes the selected Markdown content to the system clipboard
|
|
23
23
|
navigator?.clipboard
|
|
24
24
|
?.writeText(markdownContent)
|
package/dist/helpers/schema.d.ts
CHANGED
|
@@ -15,5 +15,13 @@ declare function isMultilineDocument(schema: Schema): boolean;
|
|
|
15
15
|
* @returns True if the schema contains a plain-text document, false otherwise.
|
|
16
16
|
*/
|
|
17
17
|
declare function isPlainTextDocument(schema: Schema): boolean;
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Computes a string ID that identifies a given editor schema which can be used for object mapping.
|
|
20
|
+
*
|
|
21
|
+
* @param schema The current editor document schema.
|
|
22
|
+
*
|
|
23
|
+
* @returns A string ID matching the editor schema.
|
|
24
|
+
*/
|
|
25
|
+
declare function computeSchemaId(schema: Schema): string;
|
|
26
|
+
export { computeSchemaId, isMultilineDocument, isPlainTextDocument };
|
|
19
27
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/helpers/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;;;;;GAMG;AACH,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/helpers/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;;;;;GAMG;AACH,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;;;GAMG;AACH,iBAAS,eAAe,CAAC,MAAM,EAAE,MAAM,UAEtC;AAED,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,CAAA"}
|
package/dist/helpers/schema.js
CHANGED
|
@@ -18,4 +18,14 @@ function isMultilineDocument(schema) {
|
|
|
18
18
|
function isPlainTextDocument(schema) {
|
|
19
19
|
return Boolean(schema.topNodeType.spec.content?.startsWith('paragraph'));
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Computes a string ID that identifies a given editor schema which can be used for object mapping.
|
|
23
|
+
*
|
|
24
|
+
* @param schema The current editor document schema.
|
|
25
|
+
*
|
|
26
|
+
* @returns A string ID matching the editor schema.
|
|
27
|
+
*/
|
|
28
|
+
function computeSchemaId(schema) {
|
|
29
|
+
return [...Object.keys(schema.marks), ...Object.keys(schema.nodes)].join();
|
|
30
|
+
}
|
|
31
|
+
export { computeSchemaId, isMultilineDocument, isPlainTextDocument };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export { RichTextKit } from './extensions/rich-text/rich-text-kit';
|
|
|
9
9
|
export type { SuggestionExtensionResult, SuggestionOptions, SuggestionRendererProps, SuggestionRendererRef, SuggestionStorage, } from './factories/create-suggestion-extension';
|
|
10
10
|
export { createSuggestionExtension } from './factories/create-suggestion-extension';
|
|
11
11
|
export { isMultilineDocument, isPlainTextDocument } from './helpers/schema';
|
|
12
|
-
export { createHTMLSerializer } from './serializers/html/html';
|
|
13
|
-
export { createMarkdownSerializer } from './serializers/markdown/markdown';
|
|
12
|
+
export { createHTMLSerializer, getHTMLSerializerInstance } from './serializers/html/html';
|
|
13
|
+
export { createMarkdownSerializer, getMarkdownSerializerInstance, } from './serializers/markdown/markdown';
|
|
14
14
|
export { canInsertNodeAt } from './utilities/can-insert-node-at';
|
|
15
15
|
export { canInsertSuggestion } from './utilities/can-insert-suggestion';
|
|
16
16
|
export type { AnyConfig, Editor as CoreEditor, EditorEvents, MarkRange, Range } from '@tiptap/core';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,GACd,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAA;AAChF,cAAc,oEAAoE,CAAA;AAClF,cAAc,0EAA0E,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AACrE,YAAY,EACR,uBAAuB,EACvB,oBAAoB,GACvB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAClE,YAAY,EACR,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,GACpB,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAA;AACn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AE,MAAM,cAAc,CAAA;AACnG,OAAO,EACH,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,0BAA0B,EAC1B,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,OAAO,EACP,cAAc,EACd,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,eAAe,EACf,YAAY,GACf,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC9C,cAAc,mCAAmC,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC/E,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC9D,YAAY,EACR,sBAAsB,EACtB,iBAAiB,IAAI,uBAAuB,GAC/C,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ export { PlainTextKit } from './extensions/plain-text/plain-text-kit';
|
|
|
6
6
|
export { RichTextKit } from './extensions/rich-text/rich-text-kit';
|
|
7
7
|
export { createSuggestionExtension } from './factories/create-suggestion-extension';
|
|
8
8
|
export { isMultilineDocument, isPlainTextDocument } from './helpers/schema';
|
|
9
|
-
export { createHTMLSerializer } from './serializers/html/html';
|
|
10
|
-
export { createMarkdownSerializer } from './serializers/markdown/markdown';
|
|
9
|
+
export { createHTMLSerializer, getHTMLSerializerInstance } from './serializers/html/html';
|
|
10
|
+
export { createMarkdownSerializer, getMarkdownSerializerInstance, } from './serializers/markdown/markdown';
|
|
11
11
|
export { canInsertNodeAt } from './utilities/can-insert-node-at';
|
|
12
12
|
export { canInsertSuggestion } from './utilities/can-insert-suggestion';
|
|
13
13
|
export { combineTransactionSteps, defaultBlockAt, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarksBetween, getMarkType, getNodeAttributes, getNodeType, getSchema, getText, getTextBetween, isActive, isList, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isTextSelection, mergeAttributes, posToDOMRect, } from '@tiptap/core';
|
|
@@ -29,6 +29,14 @@ declare const INITIAL_MARKED_OPTIONS: marked.MarkedOptions;
|
|
|
29
29
|
* @returns A normalized object for the HTML serializer.
|
|
30
30
|
*/
|
|
31
31
|
declare function createHTMLSerializer(schema: Schema): HTMLSerializerReturnType;
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Returns a singleton instance of a HTML serializer based on the provided editor schema.
|
|
34
|
+
*
|
|
35
|
+
* @param schema The editor schema connected to the HTML serializer instance.
|
|
36
|
+
*
|
|
37
|
+
* @returns The HTML serializer instance for the given editor schema.
|
|
38
|
+
*/
|
|
39
|
+
declare function getHTMLSerializerInstance(schema: Schema): HTMLSerializerReturnType;
|
|
40
|
+
export { createHTMLSerializer, getHTMLSerializerInstance, INITIAL_MARKED_OPTIONS };
|
|
33
41
|
export type { HTMLSerializerReturnType };
|
|
34
42
|
//# sourceMappingURL=html.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/serializers/html/html.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAc/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;GAEG;AACH,KAAK,wBAAwB,GAAG;IAC5B;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;CAC1C,CAAA;
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/serializers/html/html.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAc/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;GAEG;AACH,KAAK,wBAAwB,GAAG;IAC5B;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;CAC1C,CAAA;AASD;;;;GAIG;AACH,QAAA,MAAM,sBAAsB,EAAE,MAAM,CAAC,aAMpC,CAAA;AAmCD;;;;;;;;GAQG;AACH,iBAAS,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,wBAAwB,CAiDtE;AAOD;;;;;;GAMG;AACH,iBAAS,yBAAyB,CAAC,MAAM,EAAE,MAAM,4BAQhD;AAED,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,CAAA;AAElF,YAAY,EAAE,wBAAwB,EAAE,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { escape, kebabCase } from 'lodash-es';
|
|
2
2
|
import { marked } from 'marked';
|
|
3
3
|
import { REGEX_LINE_BREAKS } from '../../constants/regular-expressions';
|
|
4
|
-
import { isPlainTextDocument } from '../../helpers/schema';
|
|
4
|
+
import { computeSchemaId, isPlainTextDocument } from '../../helpers/schema';
|
|
5
5
|
import { buildSuggestionSchemaPartialRegex } from '../../helpers/serializer';
|
|
6
6
|
import { checkbox } from './extensions/checkbox';
|
|
7
7
|
import { code } from './extensions/code';
|
|
@@ -94,4 +94,22 @@ function createHTMLSerializer(schema) {
|
|
|
94
94
|
},
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Object that holds multiple HTML serializer instances based on a given ID.
|
|
99
|
+
*/
|
|
100
|
+
const htmlSerializerInstanceById = {};
|
|
101
|
+
/**
|
|
102
|
+
* Returns a singleton instance of a HTML serializer based on the provided editor schema.
|
|
103
|
+
*
|
|
104
|
+
* @param schema The editor schema connected to the HTML serializer instance.
|
|
105
|
+
*
|
|
106
|
+
* @returns The HTML serializer instance for the given editor schema.
|
|
107
|
+
*/
|
|
108
|
+
function getHTMLSerializerInstance(schema) {
|
|
109
|
+
const id = computeSchemaId(schema);
|
|
110
|
+
if (!htmlSerializerInstanceById[id]) {
|
|
111
|
+
htmlSerializerInstanceById[id] = createHTMLSerializer(schema);
|
|
112
|
+
}
|
|
113
|
+
return htmlSerializerInstanceById[id];
|
|
114
|
+
}
|
|
115
|
+
export { createHTMLSerializer, getHTMLSerializerInstance, INITIAL_MARKED_OPTIONS };
|
|
@@ -30,6 +30,14 @@ declare const BULLET_LIST_MARKER = "-";
|
|
|
30
30
|
* @returns A normalized object for the Markdown serializer.
|
|
31
31
|
*/
|
|
32
32
|
declare function createMarkdownSerializer(schema: Schema): MarkdownSerializerReturnType;
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Returns a singleton instance of a Markdown serializer based on the provided editor schema.
|
|
35
|
+
*
|
|
36
|
+
* @param schema The editor schema connected to the Markdown serializer instance.
|
|
37
|
+
*
|
|
38
|
+
* @returns The Markdown serializer instance for the given editor schema.
|
|
39
|
+
*/
|
|
40
|
+
declare function getMarkdownSerializerInstance(schema: Schema): MarkdownSerializerReturnType;
|
|
41
|
+
export { BULLET_LIST_MARKER, createMarkdownSerializer, getMarkdownSerializerInstance };
|
|
34
42
|
export type { MarkdownSerializerReturnType };
|
|
35
43
|
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/serializers/markdown/markdown.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAChC;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CACtC,CAAA;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/serializers/markdown/markdown.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;GAEG;AACH,KAAK,4BAA4B,GAAG;IAChC;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CACtC,CAAA;AASD;;GAEG;AACH,QAAA,MAAM,kBAAkB,MAAM,CAAA;AA8C9B;;;;;;;;;;;;GAYG;AACH,iBAAS,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,4BAA4B,CAiG9E;AAOD;;;;;;GAMG;AACH,iBAAS,6BAA6B,CAAC,MAAM,EAAE,MAAM,gCAQpD;AAED,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,CAAA;AAEtF,YAAY,EAAE,4BAA4B,EAAE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Turndown from 'turndown';
|
|
2
2
|
import { REGEX_PUNCTUATION } from '../../constants/regular-expressions';
|
|
3
|
-
import { isPlainTextDocument } from '../../helpers/schema';
|
|
3
|
+
import { computeSchemaId, isPlainTextDocument } from '../../helpers/schema';
|
|
4
4
|
import { image } from './plugins/image';
|
|
5
5
|
import { listItem } from './plugins/list-item';
|
|
6
6
|
import { paragraph } from './plugins/paragraph';
|
|
@@ -145,4 +145,22 @@ function createMarkdownSerializer(schema) {
|
|
|
145
145
|
},
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Object that holds multiple Markdown serializer instances based on a given ID.
|
|
150
|
+
*/
|
|
151
|
+
const markdownSerializerInstanceById = {};
|
|
152
|
+
/**
|
|
153
|
+
* Returns a singleton instance of a Markdown serializer based on the provided editor schema.
|
|
154
|
+
*
|
|
155
|
+
* @param schema The editor schema connected to the Markdown serializer instance.
|
|
156
|
+
*
|
|
157
|
+
* @returns The Markdown serializer instance for the given editor schema.
|
|
158
|
+
*/
|
|
159
|
+
function getMarkdownSerializerInstance(schema) {
|
|
160
|
+
const id = computeSchemaId(schema);
|
|
161
|
+
if (!markdownSerializerInstanceById[id]) {
|
|
162
|
+
markdownSerializerInstanceById[id] = createMarkdownSerializer(schema);
|
|
163
|
+
}
|
|
164
|
+
return markdownSerializerInstanceById[id];
|
|
165
|
+
}
|
|
166
|
+
export { BULLET_LIST_MARKER, createMarkdownSerializer, getMarkdownSerializerInstance };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doist/typist",
|
|
3
3
|
"description": "The mighty Tiptap-based rich-text editor React component that powers Doist products.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://typist.doist.dev/",
|
|
7
7
|
"repository": "https://github.com/Doist/typist",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"classnames": "2.3.2",
|
|
106
106
|
"conventional-changelog-conventionalcommits": "5.0.0",
|
|
107
107
|
"emoji-regex": "10.2.1",
|
|
108
|
-
"eslint": "8.
|
|
108
|
+
"eslint": "8.36.0",
|
|
109
109
|
"eslint-formatter-codeframe": "7.32.1",
|
|
110
110
|
"eslint-import-resolver-typescript": "3.5.3",
|
|
111
111
|
"eslint-plugin-jest": "27.2.1",
|
|
@@ -115,12 +115,12 @@
|
|
|
115
115
|
"husky": "8.0.3",
|
|
116
116
|
"ignore-sync": "6.0.2",
|
|
117
117
|
"is-ci": "3.0.1",
|
|
118
|
-
"jest": "29.
|
|
119
|
-
"jest-environment-jsdom": "29.
|
|
120
|
-
"lint-staged": "13.
|
|
118
|
+
"jest": "29.5.0",
|
|
119
|
+
"jest-environment-jsdom": "29.5.0",
|
|
120
|
+
"lint-staged": "13.2.0",
|
|
121
121
|
"npm-run-all": "4.1.5",
|
|
122
122
|
"prettier": "2.8.4",
|
|
123
|
-
"react-icons": "4.
|
|
123
|
+
"react-icons": "4.8.0",
|
|
124
124
|
"react-markdown": "8.0.5",
|
|
125
125
|
"react-syntax-highlighter": "15.5.0",
|
|
126
126
|
"rehype-raw": "6.1.1",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"ts-node": "10.9.1",
|
|
133
133
|
"type-fest": "3.6.1",
|
|
134
134
|
"typescript": "4.9.5",
|
|
135
|
-
"typescript-plugin-css-modules": "4.2.
|
|
135
|
+
"typescript-plugin-css-modules": "4.2.3"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"@react-hookz/web": "^14.2.3 || >=15.x",
|