@doist/typist 6.0.0 → 6.0.2
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 +12 -0
- package/dist/constants/regular-expressions.d.ts +9 -3
- package/dist/constants/regular-expressions.d.ts.map +1 -1
- package/dist/constants/regular-expressions.js +9 -3
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.d.ts.map +1 -1
- package/dist/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.js +6 -6
- package/dist/extensions/rich-text/bold-and-italics.d.ts +0 -4
- package/dist/extensions/rich-text/bold-and-italics.d.ts.map +1 -1
- package/dist/extensions/rich-text/bold-and-italics.js +16 -4
- package/dist/extensions/rich-text/rich-text-image.js +1 -1
- package/dist/extensions/rich-text/rich-text-link.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-link.js +6 -0
- package/dist/helpers/unified.d.ts +11 -11
- package/dist/helpers/unified.d.ts.map +1 -1
- package/dist/helpers/unified.js +9 -8
- package/dist/serializers/html/plugins/rehype-code-block.d.ts.map +1 -1
- package/dist/serializers/html/plugins/rehype-code-block.js +3 -3
- 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 +2 -2
- package/dist/serializers/html/plugins/rehype-task-list.d.ts.map +1 -1
- package/dist/serializers/html/plugins/rehype-task-list.js +4 -4
- package/package.json +37 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [6.0.2](https://github.com/Doist/typist/compare/v6.0.1...v6.0.2) (2024-04-15)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **rich-text-link:** Change `openOnClick` default to `whenNotEditable` ([#744](https://github.com/Doist/typist/issues/744)) ([db729d4](https://github.com/Doist/typist/commit/db729d48702231b78c77313510a7069d5c36fdde))
|
|
6
|
+
|
|
7
|
+
## [6.0.1](https://github.com/Doist/typist/compare/v6.0.0...v6.0.1) (2024-04-15)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **deps:** update tiptap packages to v2.3.0 ([#736](https://github.com/Doist/typist/issues/736)) ([bbf77a8](https://github.com/Doist/typist/commit/bbf77a809458160d3acbfd69a61d6eb92556a4b4))
|
|
12
|
+
|
|
1
13
|
## [6.0.0](https://github.com/Doist/typist/compare/v5.0.1...v6.0.0) (2024-04-11)
|
|
2
14
|
|
|
3
15
|
### ⚠ BREAKING CHANGES
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A common
|
|
2
|
+
* A common regular expression for all line termination conventions.
|
|
3
3
|
*/
|
|
4
4
|
declare const REGEX_LINE_BREAKS: RegExp;
|
|
5
5
|
/**
|
|
6
|
-
* A
|
|
6
|
+
* A regular expression for standard punctuation characters for US-ASCII plus unicode punctuation.
|
|
7
7
|
*
|
|
8
8
|
* @see https://stackoverflow.com/a/25575009
|
|
9
9
|
*/
|
|
10
10
|
declare const REGEX_PUNCTUATION: RegExp;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The perfect URL validation regular expression for Web URLs.
|
|
13
|
+
*
|
|
14
|
+
* @see https://mathiasbynens.be/demo/url-regex
|
|
15
|
+
*/
|
|
16
|
+
declare const REGEX_WEB_URL: RegExp;
|
|
17
|
+
export { REGEX_LINE_BREAKS, REGEX_PUNCTUATION, REGEX_WEB_URL };
|
|
12
18
|
//# sourceMappingURL=regular-expressions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regular-expressions.d.ts","sourceRoot":"","sources":["../../src/constants/regular-expressions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,iBAAiB,QAAoB,CAAA;AAE3C;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,QAAoE,CAAA;AAE3F,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"regular-expressions.d.ts","sourceRoot":"","sources":["../../src/constants/regular-expressions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,iBAAiB,QAAoB,CAAA;AAE3C;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,QAAoE,CAAA;AAE3F;;;;GAIG;AACH,QAAA,MAAM,aAAa,QACwZ,CAAA;AAE3a,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A common
|
|
2
|
+
* A common regular expression for all line termination conventions.
|
|
3
3
|
*/
|
|
4
4
|
const REGEX_LINE_BREAKS = /(?:\r\n|\r|\n)/g;
|
|
5
5
|
/**
|
|
6
|
-
* A
|
|
6
|
+
* A regular expression for standard punctuation characters for US-ASCII plus unicode punctuation.
|
|
7
7
|
*
|
|
8
8
|
* @see https://stackoverflow.com/a/25575009
|
|
9
9
|
*/
|
|
10
10
|
const REGEX_PUNCTUATION = /[\u2000-\u206f\u2e00-\u2e7f'!"#$%&()*+,\-./:;<=>?@\\[\]^_`{|}~]/;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The perfect URL validation regular expression for Web URLs.
|
|
13
|
+
*
|
|
14
|
+
* @see https://mathiasbynens.be/demo/url-regex
|
|
15
|
+
*/
|
|
16
|
+
const REGEX_WEB_URL = /(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?/i;
|
|
17
|
+
export { REGEX_LINE_BREAKS, REGEX_PUNCTUATION, REGEX_WEB_URL };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-url-pasting.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA4B,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"smart-url-pasting.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/plain-text/smart-markdown-typing/plugins/smart-url-pasting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA4B,MAAM,kBAAkB,CAAA;AAanE;;;;GAIG;AACH,QAAA,MAAM,eAAe,aAsCnB,CAAA;AAEF,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state';
|
|
2
2
|
import { ClipboardDataType } from '../../../../constants/common';
|
|
3
|
+
import { REGEX_WEB_URL } from '../../../../constants/regular-expressions';
|
|
3
4
|
/**
|
|
4
|
-
* The perfect URL validation
|
|
5
|
-
*
|
|
6
|
-
* @see https://mathiasbynens.be/demo/url-regex
|
|
5
|
+
* The perfect URL validation regular expression for exact Web URLs (matches a
|
|
6
|
+
* URL from the beginning to the end without allowing for partial matches).
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const REGEX_WEB_URL_EXACT = new RegExp(`^${REGEX_WEB_URL.source}$`, REGEX_WEB_URL.flags);
|
|
9
9
|
/**
|
|
10
10
|
* This plugin replaces a selection with the pasted URL using proper link syntax; unless the
|
|
11
11
|
* selection is itself a URL, which in that case the selection will just be replaced by the pasted
|
|
@@ -21,12 +21,12 @@ const smartUrlPasting = new Plugin({
|
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
// Do not handle the event if the selected text is already a URL
|
|
24
|
-
if (
|
|
24
|
+
if (REGEX_WEB_URL_EXACT.test(selection.$head.parent.textContent)) {
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
27
|
const clipboardText = event.clipboardData?.getData(ClipboardDataType.Text).trim();
|
|
28
28
|
// Do not handle the event if the clipboard text is not a URL
|
|
29
|
-
if (!clipboardText || !
|
|
29
|
+
if (!clipboardText || !REGEX_WEB_URL_EXACT.test(clipboardText)) {
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
32
|
// Apply the Markdown link syntax to the selected and clipboard text pair
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/core';
|
|
2
|
-
export declare const starInputRegex: RegExp;
|
|
3
|
-
export declare const starPasteRegex: RegExp;
|
|
4
|
-
export declare const underscoreInputRegex: RegExp;
|
|
5
|
-
export declare const underscorePasteRegex: RegExp;
|
|
6
2
|
/**
|
|
7
3
|
* The `BoldAndItalics` extension adds the ability to use the `***` and `___` Markdown shortcuts
|
|
8
4
|
* when typing and pasting into the editor.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bold-and-italics.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/bold-and-italics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgC,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"bold-and-italics.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/bold-and-italics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAgC,MAAM,cAAc,CAAA;AAsBjE;;;GAGG;AACH,QAAA,MAAM,cAAc,gBA6BlB,CAAA;AAEF,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { Mark, markInputRule, markPasteRule } from '@tiptap/core';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The "star" (i.e. `***`) input regex for Markdown text marked with bold and italics.
|
|
4
|
+
*/
|
|
5
|
+
const starInputRegex = /(?:^|\s)(\*\*\*(?!\s+\*\*\*)((?:[^*]+))\*\*\*(?!\s+\*\*\*))$/;
|
|
6
|
+
/**
|
|
7
|
+
* The "star" (i.e. `***`) paste regex for Markdown text marked with bold and italics.
|
|
8
|
+
*/
|
|
9
|
+
const starPasteRegex = /(?:^|\s)(\*\*\*(?!\s+\*\*\*)((?:[^*]+))\*\*\*(?!\s+\*\*\*))/g;
|
|
10
|
+
/**
|
|
11
|
+
* The "underscore" (i.e. `___`) input regex for Markdown text marked with bold and italics.
|
|
12
|
+
*/
|
|
13
|
+
const underscoreInputRegex = /(?:^|\s)(___(?!\s+___)((?:[^_]+))___(?!\s+___))$/;
|
|
14
|
+
/**
|
|
15
|
+
* The "underscore" (i.e. `___`) paste regex for Markdown text marked with bold and italics.
|
|
16
|
+
*/
|
|
17
|
+
const underscorePasteRegex = /(?:^|\s)(___(?!\s+___)((?:[^_]+))___(?!\s+___))/g;
|
|
6
18
|
/**
|
|
7
19
|
* The `BoldAndItalics` extension adds the ability to use the `***` and `___` Markdown shortcuts
|
|
8
20
|
* when typing and pasting into the editor.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text-link.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/rich-text-link.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAuDzD;;;;GAIG;AACH,QAAA,MAAM,YAAY,+
|
|
1
|
+
{"version":3,"file":"rich-text-link.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/rich-text-link.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAuDzD;;;;GAIG;AACH,QAAA,MAAM,YAAY,+CAoDhB,CAAA;AAEF,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,YAAY,EAAE,WAAW,IAAI,mBAAmB,EAAE,CAAA"}
|
|
@@ -52,6 +52,12 @@ function linkPasteRule(config) {
|
|
|
52
52
|
*/
|
|
53
53
|
const RichTextLink = Link.extend({
|
|
54
54
|
inclusive: false,
|
|
55
|
+
addOptions() {
|
|
56
|
+
return {
|
|
57
|
+
...this.parent?.(),
|
|
58
|
+
openOnClick: 'whenNotEditable',
|
|
59
|
+
};
|
|
60
|
+
},
|
|
55
61
|
addAttributes() {
|
|
56
62
|
return {
|
|
57
63
|
...this.parent?.(),
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type { Element, Text } from 'hast';
|
|
2
|
-
import type { Node } from 'unist';
|
|
1
|
+
import type { Element, Node as HastNode, Text } from 'hast';
|
|
3
2
|
/**
|
|
4
|
-
* Determines whether a given node is an
|
|
3
|
+
* Determines whether a given hast node is an element node with a specific tag name.
|
|
5
4
|
*
|
|
6
|
-
* @param node The node to check.
|
|
5
|
+
* @param node The hast node to check.
|
|
7
6
|
* @param tagName The tag name to check for.
|
|
8
7
|
*
|
|
9
|
-
* @returns `true` if the node is an
|
|
8
|
+
* @returns `true` if the hast node is an element node with the specified tag name, `false`
|
|
9
|
+
* otherwise.
|
|
10
10
|
*/
|
|
11
|
-
declare function
|
|
11
|
+
declare function isHastElementNode(node: HastNode, tagName: Element['tagName']): node is Element;
|
|
12
12
|
/**
|
|
13
|
-
* Determines whether a given node is
|
|
13
|
+
* Determines whether a given hast node is a text node.
|
|
14
14
|
*
|
|
15
|
-
* @param node The node to check.
|
|
15
|
+
* @param node The hast node to check.
|
|
16
16
|
*
|
|
17
|
-
* @returns `true` if the node is a
|
|
17
|
+
* @returns `true` if the hast node is a text node, `false` otherwise.
|
|
18
18
|
*/
|
|
19
|
-
declare function isHastTextNode(node:
|
|
20
|
-
export {
|
|
19
|
+
declare function isHastTextNode(node: HastNode): node is Text;
|
|
20
|
+
export { isHastElementNode, isHastTextNode };
|
|
21
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,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../src/helpers/unified.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3D;;;;;;;;GAQG;AACH,iBAAS,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,OAAO,CAEvF;AAED;;;;;;GAMG;AACH,iBAAS,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,IAAI,CAEpD;AAED,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAA"}
|
package/dist/helpers/unified.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { is } from 'unist-util-is';
|
|
2
2
|
/**
|
|
3
|
-
* Determines whether a given node is an
|
|
3
|
+
* Determines whether a given hast node is an element node with a specific tag name.
|
|
4
4
|
*
|
|
5
|
-
* @param node The node to check.
|
|
5
|
+
* @param node The hast node to check.
|
|
6
6
|
* @param tagName The tag name to check for.
|
|
7
7
|
*
|
|
8
|
-
* @returns `true` if the node is an
|
|
8
|
+
* @returns `true` if the hast node is an element node with the specified tag name, `false`
|
|
9
|
+
* otherwise.
|
|
9
10
|
*/
|
|
10
|
-
function
|
|
11
|
+
function isHastElementNode(node, tagName) {
|
|
11
12
|
return is(node, { type: 'element', tagName });
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
* Determines whether a given node is
|
|
15
|
+
* Determines whether a given hast node is a text node.
|
|
15
16
|
*
|
|
16
|
-
* @param node The node to check.
|
|
17
|
+
* @param node The hast node to check.
|
|
17
18
|
*
|
|
18
|
-
* @returns `true` if the node is a
|
|
19
|
+
* @returns `true` if the hast node is a text node, `false` otherwise.
|
|
19
20
|
*/
|
|
20
21
|
function isHastTextNode(node) {
|
|
21
22
|
return is(node, { type: 'text' });
|
|
22
23
|
}
|
|
23
|
-
export {
|
|
24
|
+
export { isHastElementNode, isHastTextNode };
|
|
@@ -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":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;;GAKG;AACH,iBAAS,eAAe,IAAI,WAAW,CAiBtC;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { visit } from 'unist-util-visit';
|
|
2
|
-
import {
|
|
2
|
+
import { isHastElementNode, isHastTextNode } from '../../../helpers/unified';
|
|
3
3
|
/**
|
|
4
4
|
* A rehype plugin to remove the trailing newline from code blocks (i.e. the newline between the
|
|
5
5
|
* last code line and `</code></pre>`). Although that newline is part of the CommonMark
|
|
@@ -9,8 +9,8 @@ import { isHastElement, isHastTextNode } from '../../../helpers/unified';
|
|
|
9
9
|
function rehypeCodeBlock() {
|
|
10
10
|
return (...[tree]) => {
|
|
11
11
|
visit(tree, 'element', (node) => {
|
|
12
|
-
if (
|
|
13
|
-
|
|
12
|
+
if (isHastElementNode(node, 'pre') &&
|
|
13
|
+
isHastElementNode(node.children[0], 'code') &&
|
|
14
14
|
isHastTextNode(node.children[0].children[0])) {
|
|
15
15
|
node.children[0].children[0].value = node.children[0].children[0].value.replace(/\n$/, '');
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CA0BhD;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { remove } from 'unist-util-remove';
|
|
2
2
|
import { visit } from 'unist-util-visit';
|
|
3
|
-
import {
|
|
3
|
+
import { isHastElementNode } 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 (isHastElementNode(node, 'p')) {
|
|
19
|
+
const areAllChildrenImages = node.children.every((c) => isHastElementNode(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) => isHastElementNode(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":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;
|
|
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;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;GAIG;AACH,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAkCtD;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { visit } from 'unist-util-visit';
|
|
2
2
|
import { buildSuggestionSchemaPartialRegex } from '../../../helpers/serializer';
|
|
3
|
-
import {
|
|
3
|
+
import { isHastElementNode, isHastTextNode } from '../../../helpers/unified';
|
|
4
4
|
/**
|
|
5
5
|
* A rehype plugin to add support for suggestions nodes (e.g., `@username` or `#channel).
|
|
6
6
|
*
|
|
@@ -15,7 +15,7 @@ function rehypeSuggestions(schema) {
|
|
|
15
15
|
return (...[tree]) => {
|
|
16
16
|
const suggestionSchemaRegex = new RegExp(`^${suggestionSchemaPartialRegex}`);
|
|
17
17
|
visit(tree, 'element', (node) => {
|
|
18
|
-
if (
|
|
18
|
+
if (isHastElementNode(node, 'a') &&
|
|
19
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
|
|
@@ -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":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;GAEG;AACH,iBAAS,cAAc,IAAI,WAAW,CAoCrC;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { visit } from 'unist-util-visit';
|
|
2
|
-
import {
|
|
2
|
+
import { isHastElementNode, isHastTextNode } from '../../../helpers/unified';
|
|
3
3
|
/**
|
|
4
4
|
* A rehype plugin to add support for Tiptap task lists (i.e., `* [ ] Task`).
|
|
5
5
|
*/
|
|
6
6
|
function rehypeTaskList() {
|
|
7
7
|
return (...[tree]) => {
|
|
8
8
|
visit(tree, 'element', (node) => {
|
|
9
|
-
if (
|
|
10
|
-
const areAllChildrenTaskItems = node.children.every((c) =>
|
|
9
|
+
if (isHastElementNode(node, 'ul')) {
|
|
10
|
+
const areAllChildrenTaskItems = node.children.every((c) => isHastElementNode(c, 'li') &&
|
|
11
11
|
isHastTextNode(c.children[0]) &&
|
|
12
12
|
/^\[[ x]\] /i.test(c.children[0].value));
|
|
13
13
|
// Add the required attributes to the list and list items if all children are tasks,
|
|
@@ -18,7 +18,7 @@ function rehypeTaskList() {
|
|
|
18
18
|
'data-type': 'taskList',
|
|
19
19
|
};
|
|
20
20
|
node.children.forEach((c) => {
|
|
21
|
-
if (
|
|
21
|
+
if (isHastElementNode(c, 'li') && isHastTextNode(c.children[0])) {
|
|
22
22
|
c.properties = {
|
|
23
23
|
...c.properties,
|
|
24
24
|
'data-type': 'taskItem',
|
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": "6.0.
|
|
4
|
+
"version": "6.0.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://typist.doist.dev/",
|
|
7
7
|
"repository": "https://github.com/Doist/typist",
|
|
@@ -45,37 +45,37 @@
|
|
|
45
45
|
"validate:pre-push": "run-s test"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@tiptap/core": "2.
|
|
49
|
-
"@tiptap/extension-blockquote": "2.
|
|
50
|
-
"@tiptap/extension-bold": "2.
|
|
51
|
-
"@tiptap/extension-bullet-list": "2.
|
|
52
|
-
"@tiptap/extension-character-count": "2.
|
|
53
|
-
"@tiptap/extension-code": "2.
|
|
54
|
-
"@tiptap/extension-code-block": "2.
|
|
55
|
-
"@tiptap/extension-document": "2.
|
|
56
|
-
"@tiptap/extension-dropcursor": "2.
|
|
57
|
-
"@tiptap/extension-gapcursor": "2.
|
|
58
|
-
"@tiptap/extension-hard-break": "2.
|
|
59
|
-
"@tiptap/extension-heading": "2.
|
|
60
|
-
"@tiptap/extension-history": "2.
|
|
61
|
-
"@tiptap/extension-horizontal-rule": "2.
|
|
62
|
-
"@tiptap/extension-image": "2.
|
|
63
|
-
"@tiptap/extension-italic": "2.
|
|
64
|
-
"@tiptap/extension-link": "2.
|
|
65
|
-
"@tiptap/extension-list-item": "2.
|
|
66
|
-
"@tiptap/extension-list-keymap": "2.
|
|
67
|
-
"@tiptap/extension-ordered-list": "2.
|
|
68
|
-
"@tiptap/extension-paragraph": "2.
|
|
69
|
-
"@tiptap/extension-placeholder": "2.
|
|
70
|
-
"@tiptap/extension-strike": "2.
|
|
71
|
-
"@tiptap/extension-task-item": "2.
|
|
72
|
-
"@tiptap/extension-task-list": "2.
|
|
73
|
-
"@tiptap/extension-text": "2.
|
|
74
|
-
"@tiptap/extension-text-style": "2.
|
|
75
|
-
"@tiptap/extension-typography": "2.
|
|
76
|
-
"@tiptap/pm": "2.
|
|
77
|
-
"@tiptap/react": "2.
|
|
78
|
-
"@tiptap/suggestion": "2.
|
|
48
|
+
"@tiptap/core": "2.3.0",
|
|
49
|
+
"@tiptap/extension-blockquote": "2.3.0",
|
|
50
|
+
"@tiptap/extension-bold": "2.3.0",
|
|
51
|
+
"@tiptap/extension-bullet-list": "2.3.0",
|
|
52
|
+
"@tiptap/extension-character-count": "2.3.0",
|
|
53
|
+
"@tiptap/extension-code": "2.3.0",
|
|
54
|
+
"@tiptap/extension-code-block": "2.3.0",
|
|
55
|
+
"@tiptap/extension-document": "2.3.0",
|
|
56
|
+
"@tiptap/extension-dropcursor": "2.3.0",
|
|
57
|
+
"@tiptap/extension-gapcursor": "2.3.0",
|
|
58
|
+
"@tiptap/extension-hard-break": "2.3.0",
|
|
59
|
+
"@tiptap/extension-heading": "2.3.0",
|
|
60
|
+
"@tiptap/extension-history": "2.3.0",
|
|
61
|
+
"@tiptap/extension-horizontal-rule": "2.3.0",
|
|
62
|
+
"@tiptap/extension-image": "2.3.0",
|
|
63
|
+
"@tiptap/extension-italic": "2.3.0",
|
|
64
|
+
"@tiptap/extension-link": "2.3.0",
|
|
65
|
+
"@tiptap/extension-list-item": "2.3.0",
|
|
66
|
+
"@tiptap/extension-list-keymap": "2.3.0",
|
|
67
|
+
"@tiptap/extension-ordered-list": "2.3.0",
|
|
68
|
+
"@tiptap/extension-paragraph": "2.3.0",
|
|
69
|
+
"@tiptap/extension-placeholder": "2.3.0",
|
|
70
|
+
"@tiptap/extension-strike": "2.3.0",
|
|
71
|
+
"@tiptap/extension-task-item": "2.3.0",
|
|
72
|
+
"@tiptap/extension-task-list": "2.3.0",
|
|
73
|
+
"@tiptap/extension-text": "2.3.0",
|
|
74
|
+
"@tiptap/extension-text-style": "2.3.0",
|
|
75
|
+
"@tiptap/extension-typography": "2.3.0",
|
|
76
|
+
"@tiptap/pm": "2.3.0",
|
|
77
|
+
"@tiptap/react": "2.3.0",
|
|
78
|
+
"@tiptap/suggestion": "2.3.0",
|
|
79
79
|
"prosemirror-codemark": "0.4.2"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
@@ -94,18 +94,18 @@
|
|
|
94
94
|
"@storybook/mdx2-csf": "1.1.0",
|
|
95
95
|
"@storybook/react": "8.0.6",
|
|
96
96
|
"@storybook/react-vite": "8.0.6",
|
|
97
|
-
"@testing-library/dom": "
|
|
97
|
+
"@testing-library/dom": "10.0.0",
|
|
98
98
|
"@testing-library/jest-dom": "6.4.2",
|
|
99
|
-
"@testing-library/react": "14.
|
|
99
|
+
"@testing-library/react": "14.3.0",
|
|
100
100
|
"@types/hast": "3.0.4",
|
|
101
101
|
"@types/lodash-es": "4.17.12",
|
|
102
|
-
"@types/react": "18.2.
|
|
102
|
+
"@types/react": "18.2.75",
|
|
103
103
|
"@types/react-dom": "18.2.24",
|
|
104
104
|
"@types/react-syntax-highlighter": "15.5.11",
|
|
105
105
|
"@types/turndown": "5.0.4",
|
|
106
106
|
"@types/unist": "3.0.2",
|
|
107
107
|
"@vitejs/plugin-react": "4.2.1",
|
|
108
|
-
"boring-avatars": "1.10.
|
|
108
|
+
"boring-avatars": "1.10.2",
|
|
109
109
|
"classnames": "2.5.1",
|
|
110
110
|
"conventional-changelog-conventionalcommits": "7.0.2",
|
|
111
111
|
"emoji-regex": "10.3.0",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"rehype-raw": "7.0.0",
|
|
134
134
|
"remark-gfm": "4.0.0",
|
|
135
135
|
"rimraf": "5.0.5",
|
|
136
|
-
"semantic-release": "23.0.
|
|
136
|
+
"semantic-release": "23.0.8",
|
|
137
137
|
"storybook": "8.0.6",
|
|
138
138
|
"storybook-css-modules": "1.0.8",
|
|
139
139
|
"tippy.js": "6.3.7",
|