@doist/typist 1.2.9 → 1.3.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 CHANGED
@@ -1,3 +1,15 @@
1
+ ## [1.3.1](https://github.com/Doist/typist/compare/v1.3.0...v1.3.1) (2023-06-13)
2
+
3
+ ### Bug Fixes
4
+
5
+ - Add support for literal autolinks (GFM based) ([#303](https://github.com/Doist/typist/issues/303)) ([4537091](https://github.com/Doist/typist/commit/45370914988eed1226722051f18a2fa49d9aa50f))
6
+
7
+ ## [1.3.0](https://github.com/Doist/typist/compare/v1.2.9...v1.3.0) (2023-06-12)
8
+
9
+ ### Features
10
+
11
+ - Add the `PasteHTMLTableAsString` extension ([#290](https://github.com/Doist/typist/issues/290)) ([ee90014](https://github.com/Doist/typist/commit/ee90014c4c8bfa8c80b11ab5cae01ba434f942b6))
12
+
1
13
  ## [1.2.9](https://github.com/Doist/typist/compare/v1.2.8...v1.2.9) (2023-06-01)
2
14
 
3
15
  ### Bug Fixes
@@ -10,6 +10,12 @@ declare const SUGGESTION_EXTENSION_PRIORITY = 1000;
10
10
  * extension can take precedence over the `ViewEventHandlers` extension event handlers.
11
11
  */
12
12
  declare const SMART_MARKDOWN_TYPING_PRIORITY = 110;
13
+ /**
14
+ * Priority for the `PasteHTMLTableAsString` extension. This needs to be higher than most paste
15
+ * extensions (e.g., `PasteSinglelineText`, `PasteMarkdown`, etc.), so that the extension can first
16
+ * parse HTML tables that might exist in the clipboard data.
17
+ */
18
+ declare const PASTE_EXTENSION_PRIORITY = 105;
13
19
  /**
14
20
  * Priority for the `ViewEventHandlers` extension. This needs to be higher than the default for most
15
21
  * of the built-in and official extensions (i.e. `100`), so that the event handlers from the
@@ -22,5 +28,5 @@ declare const VIEW_EVENT_HANDLERS_PRIORITY = 105;
22
28
  * precedence over the `Bold` extension keyboard shortcut.
23
29
  */
24
30
  declare const BLOCKQUOTE_EXTENSION_PRIORITY = 101;
25
- export { BLOCKQUOTE_EXTENSION_PRIORITY, SMART_MARKDOWN_TYPING_PRIORITY, SUGGESTION_EXTENSION_PRIORITY, VIEW_EVENT_HANDLERS_PRIORITY, };
31
+ export { BLOCKQUOTE_EXTENSION_PRIORITY, PASTE_EXTENSION_PRIORITY, SMART_MARKDOWN_TYPING_PRIORITY, SUGGESTION_EXTENSION_PRIORITY, VIEW_EVENT_HANDLERS_PRIORITY, };
26
32
  //# sourceMappingURL=extension-priorities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extension-priorities.d.ts","sourceRoot":"","sources":["../../src/constants/extension-priorities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,QAAA,MAAM,6BAA6B,OAAO,CAAA;AAE1C;;;;GAIG;AACH,QAAA,MAAM,8BAA8B,MAAM,CAAA;AAE1C;;;;GAIG;AACH,QAAA,MAAM,4BAA4B,MAAM,CAAA;AAExC;;;;GAIG;AACH,QAAA,MAAM,6BAA6B,MAAM,CAAA;AAEzC,OAAO,EACH,6BAA6B,EAC7B,8BAA8B,EAC9B,6BAA6B,EAC7B,4BAA4B,GAC/B,CAAA"}
1
+ {"version":3,"file":"extension-priorities.d.ts","sourceRoot":"","sources":["../../src/constants/extension-priorities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,QAAA,MAAM,6BAA6B,OAAO,CAAA;AAE1C;;;;GAIG;AACH,QAAA,MAAM,8BAA8B,MAAM,CAAA;AAE1C;;;;GAIG;AACH,QAAA,MAAM,wBAAwB,MAAM,CAAA;AAEpC;;;;GAIG;AACH,QAAA,MAAM,4BAA4B,MAAM,CAAA;AAExC;;;;GAIG;AACH,QAAA,MAAM,6BAA6B,MAAM,CAAA;AAEzC,OAAO,EACH,6BAA6B,EAC7B,wBAAwB,EACxB,8BAA8B,EAC9B,6BAA6B,EAC7B,4BAA4B,GAC/B,CAAA"}
@@ -10,6 +10,12 @@ const SUGGESTION_EXTENSION_PRIORITY = 1000;
10
10
  * extension can take precedence over the `ViewEventHandlers` extension event handlers.
11
11
  */
12
12
  const SMART_MARKDOWN_TYPING_PRIORITY = 110;
13
+ /**
14
+ * Priority for the `PasteHTMLTableAsString` extension. This needs to be higher than most paste
15
+ * extensions (e.g., `PasteSinglelineText`, `PasteMarkdown`, etc.), so that the extension can first
16
+ * parse HTML tables that might exist in the clipboard data.
17
+ */
18
+ const PASTE_EXTENSION_PRIORITY = 105;
13
19
  /**
14
20
  * Priority for the `ViewEventHandlers` extension. This needs to be higher than the default for most
15
21
  * of the built-in and official extensions (i.e. `100`), so that the event handlers from the
@@ -22,4 +28,4 @@ const VIEW_EVENT_HANDLERS_PRIORITY = 105;
22
28
  * precedence over the `Bold` extension keyboard shortcut.
23
29
  */
24
30
  const BLOCKQUOTE_EXTENSION_PRIORITY = 101;
25
- export { BLOCKQUOTE_EXTENSION_PRIORITY, SMART_MARKDOWN_TYPING_PRIORITY, SUGGESTION_EXTENSION_PRIORITY, VIEW_EVENT_HANDLERS_PRIORITY, };
31
+ export { BLOCKQUOTE_EXTENSION_PRIORITY, PASTE_EXTENSION_PRIORITY, SMART_MARKDOWN_TYPING_PRIORITY, SUGGESTION_EXTENSION_PRIORITY, VIEW_EVENT_HANDLERS_PRIORITY, };
@@ -18,6 +18,10 @@ type PlainTextKitOptions = {
18
18
  * Set options for the `Paragraph` extension, or `false` to disable.
19
19
  */
20
20
  paragraph: Partial<PlainTextParagraphOptions> | false;
21
+ /**
22
+ * Set to `false` to disable the `PasteHTMLTableAsString` extension.
23
+ */
24
+ pasteHTMLTableAsString: false;
21
25
  /**
22
26
  * Set to `false` to disable the `Text` extension.
23
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"plain-text-kit.d.ts","sourceRoot":"","sources":["../../../src/extensions/plain-text/plain-text-kit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAW,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAanE,OAAO,KAAK,EAAE,wBAAw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AAK,CAAA;IAE7B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IAEX;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IAEjB;;OAEG;IACH,mBAAmB,EAAE,KAAK,CAAA;CAC7B,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,YAAY,qCA8ChB,CAAA;AAEF,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,YAAY,EAAE,mBAAmB,EAAE,CAAA"}
@@ -3,6 +3,7 @@ import { History } from '@tiptap/extension-history';
3
3
  import { Text } from '@tiptap/extension-text';
4
4
  import { Typography } from '@tiptap/extension-typography';
5
5
  import { CopyMarkdownSource } from '../shared/copy-markdown-source';
6
+ import { PasteHTMLTableAsString } from '../shared/paste-html-table-as-string';
6
7
  import { PasteSinglelineText } from '../shared/paste-singleline-text';
7
8
  import { SmartMarkdownTyping } from './smart-markdown-typing/smart-markdown-typing';
8
9
  import { PasteMultilineText } from './paste-multiline-text';
@@ -25,6 +26,10 @@ const PlainTextKit = Extension.create({
25
26
  this.options?.document?.multiline === false
26
27
  ? PasteSinglelineText
27
28
  : PasteMultilineText);
29
+ if (this.options?.pasteHTMLTableAsString !== false) {
30
+ // Supports pasting tables (from spreadsheets and websites) into the editor
31
+ extensions.push(PasteHTMLTableAsString);
32
+ }
28
33
  }
29
34
  if (this.options.history !== false) {
30
35
  extensions.push(History.configure(this.options?.history));
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-image.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/rich-text-image.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD;;GAEG;AACH,KAAK,uBAAuB,GAAG;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE;QACP;;WAEG;QACH,YAAY,EAAE,MAAM,CAAA;QAEpB;;WAEG;QACH,cAAc,EAAE,OAAO,CAAA;QAEvB;;WAEG;QACH,cAAc,EAAE,MAAM,CAAA;KACzB,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AAE,aAAa,EAAE,CAAA;AAExB,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,CAAA"}
@@ -85,6 +85,10 @@ const RichTextImage = Image.extend({
85
85
  if (!onImageFilePaste) {
86
86
  return false;
87
87
  }
88
+ // Do not handle the event if there are multiple clipboard types
89
+ if ((event.clipboardData?.types || []).length > 1) {
90
+ return false;
91
+ }
88
92
  const pastedFiles = Array.from(event.clipboardData?.files || []);
89
93
  // Do not handle the event if no files were pasted
90
94
  if (pastedFiles.length === 0) {
@@ -105,6 +105,10 @@ type RichTextKitOptions = {
105
105
  * Set to `false` to disable the `PasteSinglelineText` extension.
106
106
  */
107
107
  pasteSinglelineText: false;
108
+ /**
109
+ * Set to `false` to disable the `PasteHTMLTableAsString` extension.
110
+ */
111
+ pasteHTMLTableAsString: false;
108
112
  /**
109
113
  * Set options for the `Strike` extension, or `false` to disable.
110
114
  */
@@ -1 +1 @@
1
- {"version":3,"file":"rich-text-kit.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/rich-text-kit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAiCxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,C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AAa,EAAE,KAAK,CAAA;IAEpB;;OAEG;IACH,mBAAmB,EAAE,KAAK,CAAA;IAE1B;;OAEG;IACH,sBAAsB,EAAE,KAAK,CAAA;IAE7B;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,KAAK,CAAA;IAEtC;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IAEX;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;CACpB,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,WAAW,oCAuIf,CAAA;AAEF,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,YAAY,EAAE,kBAAkB,EAAE,CAAA"}
@@ -19,6 +19,7 @@ import { Text } from '@tiptap/extension-text';
19
19
  import { Typography } from '@tiptap/extension-typography';
20
20
  import { BLOCKQUOTE_EXTENSION_PRIORITY } from '../../constants/extension-priorities';
21
21
  import { CopyMarkdownSource } from '../shared/copy-markdown-source';
22
+ import { PasteHTMLTableAsString } from '../shared/paste-html-table-as-string';
22
23
  import { PasteSinglelineText } from '../shared/paste-singleline-text';
23
24
  import { BoldAndItalics } from './bold-and-italics';
24
25
  import { CurvenoteCodemark } from './curvenote-codemark';
@@ -75,6 +76,10 @@ const RichTextKit = Extension.create({
75
76
  // pasted lines together
76
77
  extensions.push(PasteSinglelineText);
77
78
  }
79
+ if (this.options?.pasteHTMLTableAsString !== false) {
80
+ // Supports pasting tables (from spreadsheets and websites) into the editor
81
+ extensions.push(PasteHTMLTableAsString);
82
+ }
78
83
  }
79
84
  if (this.options.dropCursor !== false) {
80
85
  extensions.push(Dropcursor.configure(this.options?.dropCursor));
@@ -0,0 +1,16 @@
1
+ import { Extension } from '@tiptap/core';
2
+ /**
3
+ * The `PasteHTMLTableAsString` extension adds the ability to paste a table copied from a spreadsheet
4
+ * web app (e.g., Google Sheets, Microsoft Excel), along with tables rendered by GitHub Flavored
5
+ * Markdown (GFM), into the editor.
6
+ *
7
+ * Since Typist does not yet support tables, this extension simply pastes the table as a string of
8
+ * paragraphs (one paragraph per row), with each cell separated by a space character. However,
9
+ * whenever we do add support for tables, this extension will need to be completely rewritten.
10
+ *
11
+ * Lastly, please note that formatting is lost when the copied table comes from Google Sheets or
12
+ * Microsoft Excel, because unfortunately, these apps style the cell contents using CSS.
13
+ */
14
+ declare const PasteHTMLTableAsString: Extension<any, any>;
15
+ export { PasteHTMLTableAsString };
16
+ //# sourceMappingURL=paste-html-table-as-string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-html-table-as-string.d.ts","sourceRoot":"","sources":["../../../src/extensions/shared/paste-html-table-as-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAMxC;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,sBAAsB,qBAwD1B,CAAA;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
@@ -0,0 +1,64 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { Plugin, PluginKey } from 'prosemirror-state';
3
+ import { PASTE_EXTENSION_PRIORITY } from '../../constants/extension-priorities';
4
+ import { parseHtmlToElement } from '../../helpers/dom';
5
+ /**
6
+ * The `PasteHTMLTableAsString` extension adds the ability to paste a table copied from a spreadsheet
7
+ * web app (e.g., Google Sheets, Microsoft Excel), along with tables rendered by GitHub Flavored
8
+ * Markdown (GFM), into the editor.
9
+ *
10
+ * Since Typist does not yet support tables, this extension simply pastes the table as a string of
11
+ * paragraphs (one paragraph per row), with each cell separated by a space character. However,
12
+ * whenever we do add support for tables, this extension will need to be completely rewritten.
13
+ *
14
+ * Lastly, please note that formatting is lost when the copied table comes from Google Sheets or
15
+ * Microsoft Excel, because unfortunately, these apps style the cell contents using CSS.
16
+ */
17
+ const PasteHTMLTableAsString = Extension.create({
18
+ name: 'pasteHTMLTableAsString',
19
+ priority: PASTE_EXTENSION_PRIORITY,
20
+ addProseMirrorPlugins() {
21
+ return [
22
+ new Plugin({
23
+ key: new PluginKey('pasteHTMLTableAsString'),
24
+ props: {
25
+ transformPastedHTML(html) {
26
+ // Attempt to extract table(s) HTML from the pasted HTML
27
+ const tableHTML = html.match(/<table[^>]+>[\s\S]*?<\/table>/gi);
28
+ // Do not handle the event if no table HTML was found
29
+ if (!tableHTML) {
30
+ return html;
31
+ }
32
+ // Concatenate all tables into a single string of paragraphs
33
+ return tableHTML.reduce((result, table) => {
34
+ const { firstElementChild: tableElement } = parseHtmlToElement(table);
35
+ if (!tableElement) {
36
+ return result;
37
+ }
38
+ // Transform the table element into a string of paragraphs
39
+ return (result +
40
+ Array.from(tableElement.rows)
41
+ // Join each cell into a single string for each row
42
+ .reduce((acc, row) => {
43
+ return [
44
+ ...acc,
45
+ // Use `innerHTML` instead of `innerText` to preserve
46
+ // potential formatting (e.g., GFM) within each cell
47
+ Array.from(row.cells)
48
+ .map((cell) => cell.innerHTML)
49
+ .join(' '),
50
+ ];
51
+ }, [])
52
+ // Discard rows that are completely empty
53
+ .filter((row) => row.trim().length > 0)
54
+ // Wrap each row in a paragraph
55
+ .map((row) => `<p>${row}</p>`)
56
+ .join(''));
57
+ }, '');
58
+ },
59
+ },
60
+ }),
61
+ ];
62
+ },
63
+ });
64
+ export { PasteHTMLTableAsString };
@@ -23,7 +23,7 @@ const PasteSinglelineText = Extension.create({
23
23
  // Join break lines with a space character in-between
24
24
  .replace(/<br>/g, ' ')
25
25
  // Join paragraphs with a space character in-between
26
- .replace(/<p[^>]+>(.*?)<\/p>/g, '$1 ');
26
+ .replace(/<p[^>]*>(.*?)<\/p>/g, '$1 ');
27
27
  return isPlainTextDocument(view.state.schema)
28
28
  ? escape(bodyElement.innerText)
29
29
  : bodyElement.innerHTML;
@@ -1 +1 @@
1
- {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/serializers/html/html.ts"],"names":[],"mappings":"AAiBA,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;AA0CD;;;;;;;;GAQG;AACH,iBAAS,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,wBAAwB,CA2EtE;AAOD;;;;;;GAMG;AACH,iBAAS,yBAAyB,CAAC,MAAM,EAAE,MAAM,4BAQhD;AAED,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,CAAA;AAE1D,YAAY,EAAE,wBAAwB,EAAE,CAAA"}
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/serializers/html/html.ts"],"names":[],"mappings":"AAkBA,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;AA0CD;;;;;;;;GAQG;AACH,iBAAS,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,wBAAwB,CAiFtE;AAOD;;;;;;GAMG;AACH,iBAAS,yBAAyB,CAAC,MAAM,EAAE,MAAM,4BAQhD;AAED,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,CAAA;AAE1D,YAAY,EAAE,wBAAwB,EAAE,CAAA"}
@@ -10,6 +10,7 @@ import { rehypeCodeBlock } from './plugins/rehype-code-block';
10
10
  import { rehypeImage } from './plugins/rehype-image';
11
11
  import { rehypeSuggestions } from './plugins/rehype-suggestions';
12
12
  import { rehypeTaskList } from './plugins/rehype-task-list';
13
+ import { remarkAutolinkLiteral } from './plugins/remark-autolink-literal';
13
14
  import { remarkDisableConstructs } from './plugins/remark-disable-constructs';
14
15
  import { remarkStrikethrough } from './plugins/remark-strikethrough';
15
16
  /**
@@ -68,6 +69,11 @@ function createHTMLSerializer(schema) {
68
69
  if (schema.marks.strike) {
69
70
  unifiedProcessor.use(remarkStrikethrough);
70
71
  }
72
+ // Configure the unified processor to use a custom plugin to add support for the autolink
73
+ // literals extension from the GitHub Flavored Markdown (GFM) specification
74
+ if (schema.marks.link) {
75
+ unifiedProcessor.use(remarkAutolinkLiteral);
76
+ }
71
77
  // Configure the unified processor with an official plugin to convert Markdown into HTML to
72
78
  // support rehype (a tool that transforms HTML with plugins), followed by another official
73
79
  // plugin to minify whitespace between tags (prevents line feeds from appearing as blank)
@@ -0,0 +1,17 @@
1
+ import type { Processor } from 'unified';
2
+ /**
3
+ * A remark plugin to add support for the autolink literals extension extension from the GitHub
4
+ * Flavored Markdown (GFM) specification.
5
+ *
6
+ * This is an standalone plugin which makes use of both the `mdast-util-gfm-autolink-literal` and
7
+ * `micromark-extension-gfm-autolink-literal` packages, and the implementation is inspired by the
8
+ * third-party `remark-gfm` plugin.
9
+ *
10
+ * The reason why we don't use `remark-gfm` directly is because we don't want to support all other
11
+ * GFM features (footnotes, tables, tagfilter, and tasklists).
12
+ *
13
+ * @param options Configuration options for the plugin.
14
+ */
15
+ declare function remarkAutolinkLiteral(this: Processor): void;
16
+ export { remarkAutolinkLiteral };
17
+ //# sourceMappingURL=remark-autolink-literal.d.ts.map
@@ -0,0 +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,QAY7C;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { gfmAutolinkLiteralFromMarkdown, gfmAutolinkLiteralToMarkdown, } from 'mdast-util-gfm-autolink-literal';
2
+ import { gfmAutolinkLiteral } from 'micromark-extension-gfm-autolink-literal';
3
+ /**
4
+ * A remark plugin to add support for the autolink literals extension extension from the GitHub
5
+ * Flavored Markdown (GFM) specification.
6
+ *
7
+ * This is an standalone plugin which makes use of both the `mdast-util-gfm-autolink-literal` and
8
+ * `micromark-extension-gfm-autolink-literal` packages, and the implementation is inspired by the
9
+ * third-party `remark-gfm` plugin.
10
+ *
11
+ * The reason why we don't use `remark-gfm` directly is because we don't want to support all other
12
+ * GFM features (footnotes, tables, tagfilter, and tasklists).
13
+ *
14
+ * @param options Configuration options for the plugin.
15
+ */
16
+ function remarkAutolinkLiteral() {
17
+ const data = this.data();
18
+ function add(field, value) {
19
+ const list = (data[field] ? data[field] : (data[field] = []));
20
+ list.push(value);
21
+ }
22
+ add('micromarkExtensions', gfmAutolinkLiteral);
23
+ add('fromMarkdownExtensions', gfmAutolinkLiteralFromMarkdown);
24
+ add('toMarkdownExtensions', gfmAutolinkLiteralToMarkdown);
25
+ }
26
+ export { remarkAutolinkLiteral };
@@ -9,7 +9,7 @@ import type { Processor } from 'unified';
9
9
  * third-party `remark-gfm` plugin.
10
10
  *
11
11
  * The reason why we don't use `remark-gfm` directly is because we don't want to support all other
12
- * GFM features (autolink literals, footnotes, tables, and tasklists).
12
+ * GFM features (footnotes, tables, tagfilter, and tasklists).
13
13
  *
14
14
  * @param options Configuration options for the plugin.
15
15
  */
@@ -9,7 +9,7 @@ import { gfmStrikethrough } from 'micromark-extension-gfm-strikethrough';
9
9
  * third-party `remark-gfm` plugin.
10
10
  *
11
11
  * The reason why we don't use `remark-gfm` directly is because we don't want to support all other
12
- * GFM features (autolink literals, footnotes, tables, and tasklists).
12
+ * GFM features (footnotes, tables, tagfilter, and tasklists).
13
13
  *
14
14
  * @param options Configuration options for the plugin.
15
15
  */
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.2.9",
4
+ "version": "1.3.1",
5
5
  "license": "MIT",
6
6
  "homepage": "https://typist.doist.dev/",
7
7
  "repository": "https://github.com/Doist/typist",
@@ -14,8 +14,7 @@
14
14
  "npm": "^7.0.0 || ^8.0.0 || ^9.0.0"
15
15
  },
16
16
  "publishConfig": {
17
- "access": "public",
18
- "provenance": true
17
+ "access": "public"
19
18
  },
20
19
  "files": [
21
20
  "CHANGELOG.md",
@@ -81,7 +80,7 @@
81
80
  "devDependencies": {
82
81
  "@doist/eslint-config": "9.0.0",
83
82
  "@doist/prettier-config": "3.0.5",
84
- "@doist/reactist": "21.0.0",
83
+ "@doist/reactist": "21.0.2",
85
84
  "@mdx-js/react": "2.3.0",
86
85
  "@semantic-release/changelog": "6.0.3",
87
86
  "@semantic-release/exec": "6.0.3",
@@ -89,7 +88,7 @@
89
88
  "@storybook/addon-a11y": "7.0.18",
90
89
  "@storybook/addon-essentials": "7.0.18",
91
90
  "@storybook/addons": "7.0.18",
92
- "@storybook/csf": "0.1.0",
91
+ "@storybook/csf": "0.1.1",
93
92
  "@storybook/mdx2-csf": "1.1.0",
94
93
  "@storybook/react": "7.0.18",
95
94
  "@storybook/react-vite": "7.0.18",
@@ -98,15 +97,15 @@
98
97
  "@testing-library/react": "14.0.0",
99
98
  "@types/hast": "2.3.4",
100
99
  "@types/lodash-es": "4.17.7",
101
- "@types/react": "18.2.7",
100
+ "@types/react": "18.2.9",
102
101
  "@types/react-dom": "18.2.4",
103
102
  "@types/react-syntax-highlighter": "15.5.7",
104
103
  "@types/turndown": "5.0.1",
105
- "boring-avatars": "1.7.0",
104
+ "boring-avatars": "1.10.0",
106
105
  "classnames": "2.3.2",
107
- "conventional-changelog-conventionalcommits": "5.0.0",
106
+ "conventional-changelog-conventionalcommits": "6.0.0",
108
107
  "emoji-regex": "10.2.1",
109
- "eslint": "8.41.0",
108
+ "eslint": "8.42.0",
110
109
  "eslint-formatter-codeframe": "7.32.1",
111
110
  "eslint-import-resolver-typescript": "3.5.5",
112
111
  "eslint-plugin-simple-import-sort": "10.0.0",
@@ -118,30 +117,32 @@
118
117
  "husky": "8.0.3",
119
118
  "ignore-sync": "7.0.1",
120
119
  "is-ci": "3.0.1",
121
- "jsdom": "22.0.0",
120
+ "jsdom": "22.1.0",
122
121
  "lint-staged": "13.2.2",
123
122
  "npm-run-all": "4.1.5",
124
123
  "prettier": "2.8.8",
125
124
  "react": "18.2.0",
126
125
  "react-dom": "18.2.0",
127
- "react-icons": "4.8.0",
126
+ "react-icons": "4.9.0",
128
127
  "react-markdown": "8.0.7",
129
128
  "react-syntax-highlighter": "15.5.0",
130
129
  "rimraf": "5.0.1",
131
- "semantic-release": "21.0.2",
130
+ "semantic-release": "21.0.3",
132
131
  "storybook": "7.0.18",
133
132
  "storybook-css-modules": "1.0.8",
134
- "type-fest": "3.11.0",
135
- "typescript": "5.0.4",
133
+ "type-fest": "3.11.1",
134
+ "typescript": "5.1.3",
136
135
  "typescript-plugin-css-modules": "5.0.1",
137
- "vitest": "0.31.1"
136
+ "vitest": "0.32.0"
138
137
  },
139
138
  "peerDependencies": {
140
139
  "@react-hookz/web": "^14.2.3 || >=15.x",
141
140
  "emoji-regex": "^10.2.1",
142
141
  "hast-util-is-element": "^2.1.0",
143
142
  "lodash-es": "^4.17.21",
143
+ "mdast-util-gfm-autolink-literal": "^1.0.0",
144
144
  "mdast-util-gfm-strikethrough": "^1.0.0",
145
+ "micromark-extension-gfm-autolink-literal": "^1.0.0",
145
146
  "micromark-extension-gfm-strikethrough": "^1.0.0",
146
147
  "react": "^17.0.0 || ^18.0.0",
147
148
  "react-dom": "^17.0.0 || ^18.0.0",