@doist/typist 6.0.2 → 6.0.4
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/components/typist-editor.d.ts +0 -1
- package/dist/components/typist-editor.d.ts.map +1 -1
- package/dist/extensions/rich-text/rich-text-image.d.ts +0 -1
- package/dist/extensions/rich-text/rich-text-image.d.ts.map +1 -1
- package/dist/hooks/use-editor.d.ts.map +1 -1
- package/dist/hooks/use-editor.js +18 -2
- package/dist/utilities/can-insert-suggestion.d.ts.map +1 -1
- package/dist/utilities/can-insert-suggestion.js +2 -1
- package/package.json +33 -34
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [6.0.4](https://github.com/Doist/typist/compare/v6.0.3...v6.0.4) (2024-08-02)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- Remove `@react-hookz/web` peer dependency ([#861](https://github.com/Doist/typist/issues/861)) ([ad7644d](https://github.com/Doist/typist/commit/ad7644d0c5f33225607198b3f549a19d9632f405))
|
|
6
|
+
|
|
7
|
+
## [6.0.3](https://github.com/Doist/typist/compare/v6.0.2...v6.0.3) (2024-05-13)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- Check `code` mark presence instead of any mark in `canInsertSuggestion` ([#791](https://github.com/Doist/typist/issues/791)) ([2f70959](https://github.com/Doist/typist/commit/2f709597c029e1d68bf7d39fb20c8a9a17a0f800))
|
|
12
|
+
|
|
1
13
|
## [6.0.2](https://github.com/Doist/typist/compare/v6.0.1...v6.0.2) (2024-04-15)
|
|
2
14
|
|
|
3
15
|
### Bug Fixes
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ViewEventHandlersOptions } from '../extensions/core/view-event-handlers';
|
|
3
2
|
import { getAllNodesAttributesByType } from './typist-editor.helper';
|
|
4
3
|
import type { Editor as CoreEditor, EditorEvents, Extensions } from '@tiptap/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typist-editor.d.ts","sourceRoot":"","sources":["../../src/components/typist-editor.tsx"],"names":[],"mappings":"
|
|
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,wBAAwB,CAAA;AAE7F,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAClF,OAAO,KAAK,EAAU,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEzD;;;GAGG;AACH,KAAK,eAAe,GAAG;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,UAAU,CAAA;IAE3B;;OAEG;IACH,WAAW,EAAE,MAAM,MAAM,CAAA;IAEzB;;OAEG;IACH,2BAA2B,EAAE,CACzB,QAAQ,EAAE,MAAM,KACf,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAA;CACtD,CAAA;AAED;;GAEG;AACH,KAAK,iBAAiB,GAAG,YAAY,CAAC,cAAc,CAAC,CAAA;AAErD;;GAEG;AACH,KAAK,WAAW,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AAEzC;;GAEG;AACH,KAAK,WAAW,GAAG,YAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,CAAA;AAEhF;;GAEG;AACH,KAAK,oBAAoB,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAA;AAE3D;;GAEG;AACH,KAAK,iBAAiB,GAAG,YAAY,CAAC,aAAa,CAAC,CAAA;AAEpD;;GAEG;AACH,KAAK,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;AAEvC;;GAEG;AACH,K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B,CAAC,CAAA;IAE7D;;;;OAIG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IAEjD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,KAAK,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,+GAiNhB,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text-image.d.ts","sourceRoot":"","sources":["../../../src/extensions/rich-text/rich-text-image.ts"],"names":[],"mappings":"
|
|
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,CAAA;CACJ,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,GAC7B,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,CAAA;AAEpD;;;GAGG;AACH,OAAO,QAAQ,cAAc,CAAC;IAC1B,UAAU,QAAQ,CAAC,UAAU;QACzB,aAAa,EAAE;YACX;;eAEG;YACH,WAAW,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,UAAU,CAAA;YAEhE;;eAEG;YACH,WAAW,EAAE,CACT,UAAU,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACxC,QAAQ,CAAC,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC,KACtD,UAAU,CAAA;SAClB,CAAA;KACJ;CACJ;AAED;;GAEG;AACH,KAAK,oBAAoB,GAAG;IACxB;;OAEG;IACH,sBAAsB,EAAE,MAAM,EAAE,CAAA;IAEhC;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAA;IAEf;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEtC;;OAEG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAA;IAEtD;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;CAC1C,CAAA;AAED;;;GAGG;AACH,QAAA,MAAM,aAAa,yDAoHjB,CAAA;AAEF,OAAO,EAAE,aAAa,EAAE,CAAA;AAExB,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"use-editor.d.ts","sourceRoot":"","sources":["../../src/hooks/use-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAoC,MAAM,OAAO,CAAA;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAsBjD;;;;;;;;;;;;GAYG;AACH,iBAAS,SAAS,CACd,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,EACpC,YAAY,GAAE,cAAmB,GAClC,MAAM,CAmCR;AAED,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
package/dist/hooks/use-editor.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { useRerender } from '@react-hookz/web';
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
2
|
import { Editor } from '@tiptap/react';
|
|
3
|
+
function stateChanger(state) {
|
|
4
|
+
return (state + 1) % Number.MAX_SAFE_INTEGER;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* This is a copy of the `useRerender` hook from `@react-hookz/web`, which is a utility hook that
|
|
8
|
+
* returns a function that can be called to force a re-render of the component.
|
|
9
|
+
*
|
|
10
|
+
* Turns out we don't have the need to use any of the other hooks from `@react-hookz/web`, which is
|
|
11
|
+
* a peer dependency that often introduces breaking changes, causing upgrade issues across our
|
|
12
|
+
* projects.
|
|
13
|
+
*/
|
|
14
|
+
function useRerender() {
|
|
15
|
+
const [, setState] = useState(0);
|
|
16
|
+
return useCallback(() => {
|
|
17
|
+
setState(stateChanger);
|
|
18
|
+
}, []);
|
|
19
|
+
}
|
|
4
20
|
/**
|
|
5
21
|
* This is a fork of the official `useEditor` hook with one key difference, which is to prevent a
|
|
6
22
|
* `null` Editor object instance from being returned on the first render.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"can-insert-suggestion.d.ts","sourceRoot":"","sources":["../../src/utilities/can-insert-suggestion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;GAIG;AACH,iBAAS,mBAAmB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"can-insert-suggestion.d.ts","sourceRoot":"","sources":["../../src/utilities/can-insert-suggestion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;GAIG;AACH,iBAAS,mBAAmB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,WAsBrF;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -8,7 +8,8 @@ function canInsertSuggestion({ editor, state }) {
|
|
|
8
8
|
const isInsideCodeMark = editor.isActive('code');
|
|
9
9
|
const isInsideCodeBlockNode = selection.$from.parent.type.name === 'codeBlock';
|
|
10
10
|
const wordsBeforeSelection = (selection.$from.nodeBefore?.text ?? '').split(' ');
|
|
11
|
-
const
|
|
11
|
+
const nodeBeforeSelection = selection.$from.parent.cut(selection.$from.parentOffset - wordsBeforeSelection.slice(-1)[0].length - 1, selection.$from.parentOffset - 1).content.firstChild;
|
|
12
|
+
const hasCodeMarkBefore = (nodeBeforeSelection?.marks ?? []).some((mark) => mark.type.name === 'code');
|
|
12
13
|
const isComposingInlineCode = wordsBeforeSelection.some((word) => word.startsWith('`'));
|
|
13
14
|
return (!isInsideCodeMark && !isInsideCodeBlockNode && !hasCodeMarkBefore && !isComposingInlineCode);
|
|
14
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": "6.0.
|
|
4
|
+
"version": "6.0.4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://typist.doist.dev/",
|
|
7
7
|
"repository": "https://github.com/Doist/typist",
|
|
@@ -81,69 +81,68 @@
|
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@doist/eslint-config": "11.1.0",
|
|
83
83
|
"@doist/prettier-config": "4.0.0",
|
|
84
|
-
"@doist/reactist": "23.
|
|
84
|
+
"@doist/reactist": "23.3.0",
|
|
85
85
|
"@mdx-js/react": "3.0.1",
|
|
86
86
|
"@semantic-release/changelog": "6.0.3",
|
|
87
87
|
"@semantic-release/exec": "6.0.3",
|
|
88
88
|
"@semantic-release/git": "10.0.1",
|
|
89
|
-
"@storybook/addon-a11y": "8.
|
|
90
|
-
"@storybook/addon-essentials": "8.
|
|
91
|
-
"@storybook/blocks": "8.
|
|
92
|
-
"@storybook/csf": "0.1.
|
|
93
|
-
"@storybook/manager-api": "8.
|
|
89
|
+
"@storybook/addon-a11y": "8.2.6",
|
|
90
|
+
"@storybook/addon-essentials": "8.2.6",
|
|
91
|
+
"@storybook/blocks": "8.2.6",
|
|
92
|
+
"@storybook/csf": "0.1.11",
|
|
93
|
+
"@storybook/manager-api": "8.2.6",
|
|
94
94
|
"@storybook/mdx2-csf": "1.1.0",
|
|
95
|
-
"@storybook/react": "8.
|
|
96
|
-
"@storybook/react-vite": "8.
|
|
97
|
-
"@testing-library/dom": "10.
|
|
98
|
-
"@testing-library/jest-dom": "6.4.
|
|
99
|
-
"@testing-library/react": "
|
|
95
|
+
"@storybook/react": "8.2.6",
|
|
96
|
+
"@storybook/react-vite": "8.2.6",
|
|
97
|
+
"@testing-library/dom": "10.4.0",
|
|
98
|
+
"@testing-library/jest-dom": "6.4.8",
|
|
99
|
+
"@testing-library/react": "16.0.0",
|
|
100
100
|
"@types/hast": "3.0.4",
|
|
101
101
|
"@types/lodash-es": "4.17.12",
|
|
102
|
-
"@types/react": "18.
|
|
103
|
-
"@types/react-dom": "18.
|
|
104
|
-
"@types/react-syntax-highlighter": "15.5.
|
|
105
|
-
"@types/turndown": "5.0.
|
|
102
|
+
"@types/react": "18.3.3",
|
|
103
|
+
"@types/react-dom": "18.3.0",
|
|
104
|
+
"@types/react-syntax-highlighter": "15.5.13",
|
|
105
|
+
"@types/turndown": "5.0.5",
|
|
106
106
|
"@types/unist": "3.0.2",
|
|
107
|
-
"@vitejs/plugin-react": "4.
|
|
107
|
+
"@vitejs/plugin-react": "4.3.1",
|
|
108
108
|
"boring-avatars": "1.10.2",
|
|
109
109
|
"classnames": "2.5.1",
|
|
110
|
-
"conventional-changelog-conventionalcommits": "
|
|
110
|
+
"conventional-changelog-conventionalcommits": "8.0.0",
|
|
111
111
|
"emoji-regex": "10.3.0",
|
|
112
112
|
"eslint": "8.57.0",
|
|
113
113
|
"eslint-formatter-codeframe": "7.32.1",
|
|
114
114
|
"eslint-import-resolver-typescript": "3.6.1",
|
|
115
115
|
"eslint-plugin-simple-import-sort": "12.0.0",
|
|
116
116
|
"eslint-plugin-storybook": "0.8.0",
|
|
117
|
-
"eslint-plugin-unicorn": "
|
|
117
|
+
"eslint-plugin-unicorn": "55.0.0",
|
|
118
118
|
"eslint-plugin-vitest": "0.4.1",
|
|
119
119
|
"eslint-plugin-vitest-globals": "1.5.0",
|
|
120
|
-
"github-markdown-css": "5.
|
|
121
|
-
"husky": "9.
|
|
120
|
+
"github-markdown-css": "5.6.1",
|
|
121
|
+
"husky": "9.1.3",
|
|
122
122
|
"ignore-sync": "7.0.1",
|
|
123
123
|
"is-ci": "3.0.1",
|
|
124
|
-
"jsdom": "24.
|
|
125
|
-
"lint-staged": "15.2.
|
|
126
|
-
"npm-run-all2": "6.
|
|
124
|
+
"jsdom": "24.1.1",
|
|
125
|
+
"lint-staged": "15.2.7",
|
|
126
|
+
"npm-run-all2": "6.2.2",
|
|
127
127
|
"prettier": "3.2.5",
|
|
128
|
-
"react": "18.
|
|
129
|
-
"react-dom": "18.
|
|
130
|
-
"react-icons": "5.
|
|
128
|
+
"react": "18.3.1",
|
|
129
|
+
"react-dom": "18.3.1",
|
|
130
|
+
"react-icons": "5.2.1",
|
|
131
131
|
"react-markdown": "9.0.1",
|
|
132
132
|
"react-syntax-highlighter": "15.5.0",
|
|
133
133
|
"rehype-raw": "7.0.0",
|
|
134
134
|
"remark-gfm": "4.0.0",
|
|
135
|
-
"rimraf": "
|
|
136
|
-
"semantic-release": "
|
|
137
|
-
"storybook": "8.
|
|
135
|
+
"rimraf": "6.0.1",
|
|
136
|
+
"semantic-release": "24.0.0",
|
|
137
|
+
"storybook": "8.2.6",
|
|
138
138
|
"storybook-css-modules": "1.0.8",
|
|
139
139
|
"tippy.js": "6.3.7",
|
|
140
|
-
"type-fest": "4.
|
|
141
|
-
"typescript": "5.
|
|
140
|
+
"type-fest": "4.23.0",
|
|
141
|
+
"typescript": "5.5.4",
|
|
142
142
|
"typescript-plugin-css-modules": "5.1.0",
|
|
143
|
-
"vitest": "
|
|
143
|
+
"vitest": "2.0.4"
|
|
144
144
|
},
|
|
145
145
|
"peerDependencies": {
|
|
146
|
-
"@react-hookz/web": "^14.2.3 || >=15.x",
|
|
147
146
|
"emoji-regex": "^10.2.1",
|
|
148
147
|
"hast-util-is-element": "^3.0.0",
|
|
149
148
|
"linkifyjs": "^4.1.1",
|