@doist/typist 3.0.0 → 4.0.1
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 +16 -0
- package/dist/helpers/unified.d.ts +15 -5
- package/dist/helpers/unified.d.ts.map +1 -1
- package/dist/helpers/unified.js +15 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/serializers/html/html.js +1 -1
- package/dist/serializers/html/plugins/rehype-code-block.d.ts.map +1 -1
- package/dist/serializers/html/plugins/rehype-code-block.js +4 -5
- package/dist/serializers/html/plugins/rehype-image.d.ts.map +1 -1
- package/dist/serializers/html/plugins/rehype-image.js +4 -4
- package/dist/serializers/html/plugins/rehype-suggestions.d.ts.map +1 -1
- package/dist/serializers/html/plugins/rehype-suggestions.js +4 -4
- package/dist/serializers/html/plugins/rehype-task-list.d.ts.map +1 -1
- package/dist/serializers/html/plugins/rehype-task-list.js +5 -6
- package/dist/serializers/html/plugins/remark-autolink-literal.d.ts.map +1 -1
- package/dist/serializers/html/plugins/remark-autolink-literal.js +6 -7
- package/dist/serializers/html/plugins/remark-disable-constructs.d.ts.map +1 -1
- package/dist/serializers/html/plugins/remark-disable-constructs.js +2 -5
- package/dist/serializers/html/plugins/remark-strikethrough.d.ts.map +1 -1
- package/dist/serializers/html/plugins/remark-strikethrough.js +6 -7
- package/package.json +70 -65
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## [4.0.1](https://github.com/Doist/typist/compare/v4.0.0...v4.0.1) (2024-02-07)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **deps:** update tiptap packages to v2.2.1 ([#643](https://github.com/Doist/typist/issues/643)) ([0abbe97](https://github.com/Doist/typist/commit/0abbe9755a9acb14ee8004202ae3f7f48ff47a0f))
|
|
6
|
+
|
|
7
|
+
## [4.0.0](https://github.com/Doist/typist/compare/v3.0.0...v4.0.0) (2024-01-30)
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
- **deps:** update unified ecosystem dependencies (#395)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- **deps:** update unified ecosystem dependencies ([#395](https://github.com/Doist/typist/issues/395)) ([e97ad83](https://github.com/Doist/typist/commit/e97ad83e7015cf49044bc72cf8ef6dce1be1f2c8))
|
|
16
|
+
|
|
1
17
|
## [3.0.0](https://github.com/Doist/typist/compare/v2.3.1...v3.0.0) (2024-01-18)
|
|
2
18
|
|
|
3
19
|
### ⚠ BREAKING CHANGES
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Element, Text } from 'hast';
|
|
2
|
+
import type { Node } from 'unist';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Determines whether a given node is an hast element with a specific tag name.
|
|
4
5
|
*
|
|
5
6
|
* @param node The node to check.
|
|
7
|
+
* @param tagName The tag name to check for.
|
|
6
8
|
*
|
|
7
|
-
* @returns `true` if the node is
|
|
9
|
+
* @returns `true` if the node is an hast element with the specified tag name, `false` otherwise.
|
|
8
10
|
*/
|
|
9
|
-
declare function
|
|
10
|
-
|
|
11
|
+
declare function isHastElement(node: Node, tagName: Element['tagName']): node is Element;
|
|
12
|
+
/**
|
|
13
|
+
* Determines whether a given node is hast a text node.
|
|
14
|
+
*
|
|
15
|
+
* @param node The node to check.
|
|
16
|
+
*
|
|
17
|
+
* @returns `true` if the node is a hast text node, `false` otherwise.
|
|
18
|
+
*/
|
|
19
|
+
declare function isHastTextNode(node: Node): node is Text;
|
|
20
|
+
export { isHastElement, isHastTextNode };
|
|
11
21
|
//# sourceMappingURL=unified.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../src/helpers/unified.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../src/helpers/unified.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC;;;;;;;GAOG;AACH,iBAAS,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,OAAO,CAE/E;AAED;;;;;;GAMG;AACH,iBAAS,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,CAEhD;AAED,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,CAAA"}
|
package/dist/helpers/unified.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { is } from 'unist-util-is';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Determines whether a given node is an hast element with a specific tag name.
|
|
4
4
|
*
|
|
5
5
|
* @param node The node to check.
|
|
6
|
+
* @param tagName The tag name to check for.
|
|
6
7
|
*
|
|
7
|
-
* @returns `true` if the node is
|
|
8
|
+
* @returns `true` if the node is an hast element with the specified tag name, `false` otherwise.
|
|
8
9
|
*/
|
|
9
|
-
function
|
|
10
|
+
function isHastElement(node, tagName) {
|
|
11
|
+
return is(node, { type: 'element', tagName });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Determines whether a given node is hast a text node.
|
|
15
|
+
*
|
|
16
|
+
* @param node The node to check.
|
|
17
|
+
*
|
|
18
|
+
* @returns `true` if the node is a hast text node, `false` otherwise.
|
|
19
|
+
*/
|
|
20
|
+
function isHastTextNode(node) {
|
|
10
21
|
return is(node, { type: 'text' });
|
|
11
22
|
}
|
|
12
|
-
export {
|
|
23
|
+
export { isHastElement, isHastTextNode };
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export type { SuggestionExtensionResult, SuggestionOptions, SuggestionRendererPr
|
|
|
12
12
|
export { createSuggestionExtension } from './factories/create-suggestion-extension';
|
|
13
13
|
export { isMultilineDocument, isPlainTextDocument } from './helpers/schema';
|
|
14
14
|
export { createHTMLSerializer, getHTMLSerializerInstance } from './serializers/html/html';
|
|
15
|
+
export { remarkAutolinkLiteral } from './serializers/html/plugins/remark-autolink-literal';
|
|
16
|
+
export { remarkStrikethrough } from './serializers/html/plugins/remark-strikethrough';
|
|
15
17
|
export { createMarkdownSerializer, getMarkdownSerializerInstance, } from './serializers/markdown/markdown';
|
|
16
18
|
export { canInsertNodeAt } from './utilities/can-insert-node-at';
|
|
17
19
|
export { canInsertSuggestion } from './utilities/can-insert-suggestion';
|
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,cAAc,kCAAkC,CAAA;AAChD,cAAc,uEAAuE,CAAA;AACrF,cAAc,oEAAoE,CAAA;AAClF,cAAc,0EAA0E,CAAA;AACxF,cAAc,6EAA6E,CAAA;AAC3F,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,yBA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;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
|
@@ -9,6 +9,8 @@ export { RichTextKit } from './extensions/rich-text/rich-text-kit';
|
|
|
9
9
|
export { createSuggestionExtension } from './factories/create-suggestion-extension';
|
|
10
10
|
export { isMultilineDocument, isPlainTextDocument } from './helpers/schema';
|
|
11
11
|
export { createHTMLSerializer, getHTMLSerializerInstance } from './serializers/html/html';
|
|
12
|
+
export { remarkAutolinkLiteral } from './serializers/html/plugins/remark-autolink-literal';
|
|
13
|
+
export { remarkStrikethrough } from './serializers/html/plugins/remark-strikethrough';
|
|
12
14
|
export { createMarkdownSerializer, getMarkdownSerializerInstance, } from './serializers/markdown/markdown';
|
|
13
15
|
export { canInsertNodeAt } from './utilities/can-insert-node-at';
|
|
14
16
|
export { canInsertSuggestion } from './utilities/can-insert-suggestion';
|
|
@@ -107,7 +107,7 @@ function createHTMLSerializer(schema) {
|
|
|
107
107
|
// Configure the unified processor with an official plugin that defines how to take a syntax
|
|
108
108
|
// tree as input and turn it into serialized HTML
|
|
109
109
|
unifiedProcessor.use(rehypeStringify, {
|
|
110
|
-
|
|
110
|
+
characterReferences: {
|
|
111
111
|
// Compatibility with the previous implementation in Marked
|
|
112
112
|
useNamedReferences: true,
|
|
113
113
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehype-code-block.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/rehype-code-block.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rehype-code-block.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/rehype-code-block.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;;GAKG;AACH,iBAAS,eAAe,IAAI,WAAW,CAiBtC;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { isElement } from 'hast-util-is-element';
|
|
2
1
|
import { visit } from 'unist-util-visit';
|
|
3
|
-
import {
|
|
2
|
+
import { isHastElement, isHastTextNode } from '../../../helpers/unified';
|
|
4
3
|
/**
|
|
5
4
|
* A rehype plugin to remove the trailing newline from code blocks (i.e. the newline between the
|
|
6
5
|
* last code line and `</code></pre>`). Although that newline is part of the CommonMark
|
|
@@ -10,9 +9,9 @@ import { isTextNode } from '../../../helpers/unified';
|
|
|
10
9
|
function rehypeCodeBlock() {
|
|
11
10
|
return (...[tree]) => {
|
|
12
11
|
visit(tree, 'element', (node) => {
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (isHastElement(node, 'pre') &&
|
|
13
|
+
isHastElement(node.children[0], 'code') &&
|
|
14
|
+
isHastTextNode(node.children[0].children[0])) {
|
|
16
15
|
node.children[0].children[0].value = node.children[0].children[0].value.replace(/\n$/, '');
|
|
17
16
|
}
|
|
18
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehype-image.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/rehype-image.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rehype-image.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/rehype-image.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CA0BhD;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isElement } from 'hast-util-is-element';
|
|
2
1
|
import { remove } from 'unist-util-remove';
|
|
3
2
|
import { visit } from 'unist-util-visit';
|
|
3
|
+
import { isHastElement } from '../../../helpers/unified';
|
|
4
4
|
/**
|
|
5
5
|
* A rehype plugin to remove the wrapping paragraph from images and to remove all inline images if
|
|
6
6
|
* the editor was configured without inline image support (Tiptap default).
|
|
@@ -15,8 +15,8 @@ function rehypeImage(schema) {
|
|
|
15
15
|
}
|
|
16
16
|
return (...[tree]) => {
|
|
17
17
|
visit(tree, 'element', (node, index, parent) => {
|
|
18
|
-
if (
|
|
19
|
-
const areAllChildrenImages = node.children.every((c) =>
|
|
18
|
+
if (isHastElement(node, 'p')) {
|
|
19
|
+
const areAllChildrenImages = node.children.every((c) => isHastElement(c, 'img'));
|
|
20
20
|
// Replace the paragraph with the image children if all children are images, or
|
|
21
21
|
// remove all images from the paragraph if it contains non-image children since the
|
|
22
22
|
// editor does not support inline images
|
|
@@ -24,7 +24,7 @@ function rehypeImage(schema) {
|
|
|
24
24
|
parent.children.splice(index, 1, ...node.children);
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
remove(node, (n) =>
|
|
27
|
+
remove(node, (n) => isHastElement(n, 'img'));
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehype-suggestions.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/rehype-suggestions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rehype-suggestions.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/rehype-suggestions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;;;GAIG;AACH,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAkCtD;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { isElement } from 'hast-util-is-element';
|
|
2
1
|
import { visit } from 'unist-util-visit';
|
|
3
2
|
import { buildSuggestionSchemaPartialRegex } from '../../../helpers/serializer';
|
|
4
|
-
import {
|
|
3
|
+
import { isHastElement, isHastTextNode } from '../../../helpers/unified';
|
|
5
4
|
/**
|
|
6
5
|
* A rehype plugin to add support for suggestions nodes (e.g., `@username` or `#channel).
|
|
7
6
|
*
|
|
@@ -16,10 +15,11 @@ function rehypeSuggestions(schema) {
|
|
|
16
15
|
return (...[tree]) => {
|
|
17
16
|
const suggestionSchemaRegex = new RegExp(`^${suggestionSchemaPartialRegex}`);
|
|
18
17
|
visit(tree, 'element', (node) => {
|
|
19
|
-
if (
|
|
18
|
+
if (isHastElement(node, 'a') &&
|
|
19
|
+
suggestionSchemaRegex.test(String(node.properties?.href))) {
|
|
20
20
|
const [, schema, id] = /^([a-z-]+):\/\/(\S+)$/i.exec(String(node.properties?.href)) || [];
|
|
21
21
|
// Replace the link element with a span containing the suggestion attributes
|
|
22
|
-
if (schema && id &&
|
|
22
|
+
if (schema && id && isHastTextNode(node.children[0])) {
|
|
23
23
|
node.tagName = 'span';
|
|
24
24
|
node.properties = {
|
|
25
25
|
[`data-${schema}`]: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehype-task-list.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/rehype-task-list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rehype-task-list.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/rehype-task-list.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG1C;;GAEG;AACH,iBAAS,cAAc,IAAI,WAAW,CAoCrC;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { isElement } from 'hast-util-is-element';
|
|
2
1
|
import { visit } from 'unist-util-visit';
|
|
3
|
-
import {
|
|
2
|
+
import { isHastElement, isHastTextNode } from '../../../helpers/unified';
|
|
4
3
|
/**
|
|
5
4
|
* A rehype plugin to add support for Tiptap task lists (i.e., `* [ ] Task`).
|
|
6
5
|
*/
|
|
7
6
|
function rehypeTaskList() {
|
|
8
7
|
return (...[tree]) => {
|
|
9
8
|
visit(tree, 'element', (node) => {
|
|
10
|
-
if (
|
|
11
|
-
const areAllChildrenTaskItems = node.children.every((c) =>
|
|
12
|
-
|
|
9
|
+
if (isHastElement(node, 'ul')) {
|
|
10
|
+
const areAllChildrenTaskItems = node.children.every((c) => isHastElement(c, 'li') &&
|
|
11
|
+
isHastTextNode(c.children[0]) &&
|
|
13
12
|
/^\[[ x]\] /i.test(c.children[0].value));
|
|
14
13
|
// Add the required attributes to the list and list items if all children are tasks,
|
|
15
14
|
// removing the `[ ] ` or `[x] ` at the beginning of the task item text
|
|
@@ -19,7 +18,7 @@ function rehypeTaskList() {
|
|
|
19
18
|
'data-type': 'taskList',
|
|
20
19
|
};
|
|
21
20
|
node.children.forEach((c) => {
|
|
22
|
-
if (
|
|
21
|
+
if (isHastElement(c, 'li') && isHastTextNode(c.children[0])) {
|
|
23
22
|
c.properties = {
|
|
24
23
|
...c.properties,
|
|
25
24
|
'data-type': 'taskItem',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-autolink-literal.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/remark-autolink-literal.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;;;;GAYG;AACH,iBAAS,qBAAqB,CAAC,IAAI,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"remark-autolink-literal.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/remark-autolink-literal.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;;;;GAYG;AACH,iBAAS,qBAAqB,CAAC,IAAI,EAAE,SAAS,QAU7C;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
|
|
@@ -15,12 +15,11 @@ import { gfmAutolinkLiteral } from 'micromark-extension-gfm-autolink-literal';
|
|
|
15
15
|
*/
|
|
16
16
|
function remarkAutolinkLiteral() {
|
|
17
17
|
const data = this.data();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
add('toMarkdownExtensions', gfmAutolinkLiteralToMarkdown);
|
|
18
|
+
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
19
|
+
const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
|
|
20
|
+
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
21
|
+
micromarkExtensions.push(gfmAutolinkLiteral());
|
|
22
|
+
fromMarkdownExtensions.push(gfmAutolinkLiteralFromMarkdown());
|
|
23
|
+
toMarkdownExtensions.push(gfmAutolinkLiteralToMarkdown());
|
|
25
24
|
}
|
|
26
25
|
export { remarkAutolinkLiteral };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-disable-constructs.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/remark-disable-constructs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;GAKG;AACH,iBAAS,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"remark-disable-constructs.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/remark-disable-constructs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;GAKG;AACH,iBAAS,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAiD/D;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA"}
|
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
function remarkDisableConstructs(schema) {
|
|
8
8
|
const data = this.data();
|
|
9
|
-
function add(field, value) {
|
|
10
|
-
const list = (data[field] ? data[field] : (data[field] = []));
|
|
11
|
-
list.push(value);
|
|
12
|
-
}
|
|
13
9
|
const disabledConstructs = [];
|
|
14
10
|
if (!schema.nodes.blockquote) {
|
|
15
11
|
disabledConstructs.push('blockQuote');
|
|
@@ -38,8 +34,9 @@ function remarkDisableConstructs(schema) {
|
|
|
38
34
|
if (!schema.marks.link) {
|
|
39
35
|
disabledConstructs.push('labelStartLink');
|
|
40
36
|
}
|
|
37
|
+
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
41
38
|
// https://github.com/micromark/micromark#case-turn-off-constructs
|
|
42
|
-
|
|
39
|
+
micromarkExtensions.push({
|
|
43
40
|
disable: {
|
|
44
41
|
null: disabledConstructs,
|
|
45
42
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-strikethrough.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/remark-strikethrough.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAA;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;;;;GAYG;AACH,iBAAS,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAE,OAAY,
|
|
1
|
+
{"version":3,"file":"remark-strikethrough.d.ts","sourceRoot":"","sources":["../../../../src/serializers/html/plugins/remark-strikethrough.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAA;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;;;;GAYG;AACH,iBAAS,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAE,OAAY,QAUlE;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -15,12 +15,11 @@ import { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough';
|
|
|
15
15
|
*/
|
|
16
16
|
function remarkStrikethrough(options = {}) {
|
|
17
17
|
const data = this.data();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
add('toMarkdownExtensions', gfmStrikethroughToMarkdown);
|
|
18
|
+
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
19
|
+
const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
|
|
20
|
+
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
21
|
+
micromarkExtensions.push(gfmStrikethrough(options));
|
|
22
|
+
fromMarkdownExtensions.push(gfmStrikethroughFromMarkdown());
|
|
23
|
+
toMarkdownExtensions.push(gfmStrikethroughToMarkdown());
|
|
25
24
|
}
|
|
26
25
|
export { remarkStrikethrough };
|
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": "
|
|
4
|
+
"version": "4.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://typist.doist.dev/",
|
|
7
7
|
"repository": "https://github.com/Doist/typist",
|
|
@@ -46,63 +46,65 @@
|
|
|
46
46
|
"validate:pre-push": "run-s test"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@tiptap/core": "2.1
|
|
50
|
-
"@tiptap/extension-blockquote": "2.1
|
|
51
|
-
"@tiptap/extension-bold": "2.1
|
|
52
|
-
"@tiptap/extension-bullet-list": "2.1
|
|
53
|
-
"@tiptap/extension-character-count": "2.1
|
|
54
|
-
"@tiptap/extension-code": "2.1
|
|
55
|
-
"@tiptap/extension-code-block": "2.1
|
|
56
|
-
"@tiptap/extension-document": "2.1
|
|
57
|
-
"@tiptap/extension-dropcursor": "2.1
|
|
58
|
-
"@tiptap/extension-gapcursor": "2.1
|
|
59
|
-
"@tiptap/extension-hard-break": "2.1
|
|
60
|
-
"@tiptap/extension-heading": "2.1
|
|
61
|
-
"@tiptap/extension-history": "2.1
|
|
62
|
-
"@tiptap/extension-horizontal-rule": "2.1
|
|
63
|
-
"@tiptap/extension-image": "2.1
|
|
64
|
-
"@tiptap/extension-italic": "2.1
|
|
65
|
-
"@tiptap/extension-link": "2.1
|
|
66
|
-
"@tiptap/extension-list-item": "2.1
|
|
67
|
-
"@tiptap/extension-list-keymap": "2.1
|
|
68
|
-
"@tiptap/extension-ordered-list": "2.1
|
|
69
|
-
"@tiptap/extension-paragraph": "2.1
|
|
70
|
-
"@tiptap/extension-placeholder": "2.1
|
|
71
|
-
"@tiptap/extension-strike": "2.1
|
|
72
|
-
"@tiptap/extension-task-item": "2.1
|
|
73
|
-
"@tiptap/extension-task-list": "2.1
|
|
74
|
-
"@tiptap/extension-text": "2.1
|
|
75
|
-
"@tiptap/extension-text-style": "2.1
|
|
76
|
-
"@tiptap/extension-typography": "2.1
|
|
77
|
-
"@tiptap/pm": "2.1
|
|
78
|
-
"@tiptap/react": "2.1
|
|
79
|
-
"@tiptap/suggestion": "2.1
|
|
49
|
+
"@tiptap/core": "2.2.1",
|
|
50
|
+
"@tiptap/extension-blockquote": "2.2.1",
|
|
51
|
+
"@tiptap/extension-bold": "2.2.1",
|
|
52
|
+
"@tiptap/extension-bullet-list": "2.2.1",
|
|
53
|
+
"@tiptap/extension-character-count": "2.2.1",
|
|
54
|
+
"@tiptap/extension-code": "2.2.1",
|
|
55
|
+
"@tiptap/extension-code-block": "2.2.1",
|
|
56
|
+
"@tiptap/extension-document": "2.2.1",
|
|
57
|
+
"@tiptap/extension-dropcursor": "2.2.1",
|
|
58
|
+
"@tiptap/extension-gapcursor": "2.2.1",
|
|
59
|
+
"@tiptap/extension-hard-break": "2.2.1",
|
|
60
|
+
"@tiptap/extension-heading": "2.2.1",
|
|
61
|
+
"@tiptap/extension-history": "2.2.1",
|
|
62
|
+
"@tiptap/extension-horizontal-rule": "2.2.1",
|
|
63
|
+
"@tiptap/extension-image": "2.2.1",
|
|
64
|
+
"@tiptap/extension-italic": "2.2.1",
|
|
65
|
+
"@tiptap/extension-link": "2.2.1",
|
|
66
|
+
"@tiptap/extension-list-item": "2.2.1",
|
|
67
|
+
"@tiptap/extension-list-keymap": "2.2.1",
|
|
68
|
+
"@tiptap/extension-ordered-list": "2.2.1",
|
|
69
|
+
"@tiptap/extension-paragraph": "2.2.1",
|
|
70
|
+
"@tiptap/extension-placeholder": "2.2.1",
|
|
71
|
+
"@tiptap/extension-strike": "2.2.1",
|
|
72
|
+
"@tiptap/extension-task-item": "2.2.1",
|
|
73
|
+
"@tiptap/extension-task-list": "2.2.1",
|
|
74
|
+
"@tiptap/extension-text": "2.2.1",
|
|
75
|
+
"@tiptap/extension-text-style": "2.2.1",
|
|
76
|
+
"@tiptap/extension-typography": "2.2.1",
|
|
77
|
+
"@tiptap/pm": "2.2.1",
|
|
78
|
+
"@tiptap/react": "2.2.1",
|
|
79
|
+
"@tiptap/suggestion": "2.2.1",
|
|
80
80
|
"prosemirror-codemark": "0.4.2"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@doist/eslint-config": "11.0.0",
|
|
84
84
|
"@doist/prettier-config": "4.0.0",
|
|
85
|
-
"@doist/reactist": "
|
|
85
|
+
"@doist/reactist": "23.1.0",
|
|
86
86
|
"@mdx-js/react": "3.0.0",
|
|
87
|
-
"@rollup/rollup-linux-x64-gnu": "4.9.
|
|
87
|
+
"@rollup/rollup-linux-x64-gnu": "4.9.6",
|
|
88
88
|
"@semantic-release/changelog": "6.0.3",
|
|
89
89
|
"@semantic-release/exec": "6.0.3",
|
|
90
90
|
"@semantic-release/git": "10.0.1",
|
|
91
|
-
"@storybook/addon-a11y": "7.6.
|
|
92
|
-
"@storybook/addon-essentials": "7.6.
|
|
93
|
-
"@storybook/addons": "7.6.
|
|
91
|
+
"@storybook/addon-a11y": "7.6.12",
|
|
92
|
+
"@storybook/addon-essentials": "7.6.12",
|
|
93
|
+
"@storybook/addons": "7.6.12",
|
|
94
94
|
"@storybook/csf": "0.1.2",
|
|
95
95
|
"@storybook/mdx2-csf": "1.1.0",
|
|
96
|
-
"@storybook/react": "7.6.
|
|
97
|
-
"@storybook/react-vite": "7.6.
|
|
96
|
+
"@storybook/react": "7.6.12",
|
|
97
|
+
"@storybook/react-vite": "7.6.12",
|
|
98
98
|
"@testing-library/dom": "9.3.4",
|
|
99
|
-
"@testing-library/jest-dom": "6.
|
|
100
|
-
"@testing-library/react": "14.1
|
|
99
|
+
"@testing-library/jest-dom": "6.4.1",
|
|
100
|
+
"@testing-library/react": "14.2.1",
|
|
101
|
+
"@types/hast": "3.0.4",
|
|
101
102
|
"@types/lodash-es": "4.17.12",
|
|
102
|
-
"@types/react": "18.2.
|
|
103
|
+
"@types/react": "18.2.51",
|
|
103
104
|
"@types/react-dom": "18.2.18",
|
|
104
105
|
"@types/react-syntax-highlighter": "15.5.11",
|
|
105
106
|
"@types/turndown": "5.0.4",
|
|
107
|
+
"@types/unist": "3.0.2",
|
|
106
108
|
"@vitejs/plugin-react": "4.2.1",
|
|
107
109
|
"boring-avatars": "1.10.1",
|
|
108
110
|
"classnames": "2.5.1",
|
|
@@ -114,30 +116,32 @@
|
|
|
114
116
|
"eslint-plugin-simple-import-sort": "10.0.0",
|
|
115
117
|
"eslint-plugin-storybook": "0.6.15",
|
|
116
118
|
"eslint-plugin-unicorn": "50.0.1",
|
|
117
|
-
"eslint-plugin-vitest": "0.3.
|
|
119
|
+
"eslint-plugin-vitest": "0.3.21",
|
|
118
120
|
"eslint-plugin-vitest-globals": "1.4.0",
|
|
119
121
|
"github-markdown-css": "5.5.0",
|
|
120
122
|
"husky": "8.0.3",
|
|
121
123
|
"ignore-sync": "7.0.1",
|
|
122
124
|
"is-ci": "3.0.1",
|
|
123
|
-
"jsdom": "
|
|
124
|
-
"lint-staged": "15.2.
|
|
125
|
-
"npm-run-
|
|
125
|
+
"jsdom": "24.0.0",
|
|
126
|
+
"lint-staged": "15.2.1",
|
|
127
|
+
"npm-run-all2": "6.1.2",
|
|
126
128
|
"prettier": "3.2.4",
|
|
127
129
|
"react": "18.2.0",
|
|
128
130
|
"react-dom": "18.2.0",
|
|
129
131
|
"react-icons": "5.0.1",
|
|
130
|
-
"react-markdown": "
|
|
132
|
+
"react-markdown": "9.0.1",
|
|
131
133
|
"react-syntax-highlighter": "15.5.0",
|
|
134
|
+
"rehype-raw": "7.0.0",
|
|
135
|
+
"remark-gfm": "4.0.0",
|
|
132
136
|
"rimraf": "5.0.5",
|
|
133
137
|
"semantic-release": "23.0.0",
|
|
134
138
|
"tippy.js": "6.3.7",
|
|
135
|
-
"storybook": "7.6.
|
|
139
|
+
"storybook": "7.6.12",
|
|
136
140
|
"storybook-css-modules": "1.0.8",
|
|
137
|
-
"type-fest": "4.
|
|
141
|
+
"type-fest": "4.10.2",
|
|
138
142
|
"typescript": "5.3.3",
|
|
139
143
|
"typescript-plugin-css-modules": "5.0.2",
|
|
140
|
-
"vitest": "1.2.
|
|
144
|
+
"vitest": "1.2.2"
|
|
141
145
|
},
|
|
142
146
|
"peerDependencies": {
|
|
143
147
|
"@react-hookz/web": "^14.2.3 || >=15.x",
|
|
@@ -145,24 +149,25 @@
|
|
|
145
149
|
"hast-util-is-element": "^2.1.0",
|
|
146
150
|
"linkifyjs": "^4.1.1",
|
|
147
151
|
"lodash-es": "^4.17.21",
|
|
148
|
-
"mdast-util-gfm-autolink-literal": "^
|
|
149
|
-
"mdast-util-gfm-strikethrough": "^
|
|
150
|
-
"micromark-extension-gfm-autolink-literal": "^
|
|
151
|
-
"micromark-extension-gfm-strikethrough": "^
|
|
152
|
+
"mdast-util-gfm-autolink-literal": "^2.0.0",
|
|
153
|
+
"mdast-util-gfm-strikethrough": "^2.0.0",
|
|
154
|
+
"micromark-extension-gfm-autolink-literal": "^2.0.0",
|
|
155
|
+
"micromark-extension-gfm-strikethrough": "^2.0.0",
|
|
152
156
|
"react": "^17.0.0 || ^18.0.0",
|
|
153
157
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
154
|
-
"rehype": "^
|
|
155
|
-
"rehype-minify-whitespace": "^
|
|
156
|
-
"rehype-raw": "^
|
|
157
|
-
"rehype-stringify": "^
|
|
158
|
-
"remark": "^
|
|
159
|
-
"remark-breaks": "^
|
|
160
|
-
"remark-gfm": "^
|
|
161
|
-
"remark-
|
|
158
|
+
"rehype": "^13.0.0",
|
|
159
|
+
"rehype-minify-whitespace": "^6.0.0",
|
|
160
|
+
"rehype-raw": "^7.0.0",
|
|
161
|
+
"rehype-stringify": "^10.0.0",
|
|
162
|
+
"remark": "^15.0.0",
|
|
163
|
+
"remark-breaks": "^4.0.0",
|
|
164
|
+
"remark-gfm": "^4.0.0",
|
|
165
|
+
"remark-parse": "^11.0.0",
|
|
166
|
+
"remark-rehype": "^11.0.0",
|
|
162
167
|
"turndown": "^7.1.0",
|
|
163
|
-
"unified": "^
|
|
164
|
-
"unist-util-is": "^
|
|
168
|
+
"unified": "^11.0.0",
|
|
169
|
+
"unist-util-is": "^6.0.0",
|
|
165
170
|
"unist-util-remove": "^4.0.0",
|
|
166
|
-
"unist-util-visit": "^
|
|
171
|
+
"unist-util-visit": "^5.0.0"
|
|
167
172
|
}
|
|
168
173
|
}
|