Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(extension-callout): create valid node with input rule and enter k…
…ey (#948) Fixes the input rule for callouts, hitting enter after :::info (for example) would create an empty callout (with no paragraph), this is invalid according to the schema, so the callout node would not be added. Also adds a toBeValidNode matcher to jest-prosemirror to assert that a created node is actually valid according to the schema.
- Loading branch information
Showing
7 changed files
with
248 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'jest-prosemirror': minor | ||
'@remirror/extension-callout': patch | ||
--- | ||
|
||
- Add `toBeValidNode` matcher to assert valid marks and content | ||
- Fix callout extension input rule followed by enter key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/remirror__extension-callout/__stories__/callout.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'remirror/styles/all.css'; | ||
|
||
import React from 'react'; | ||
import { CalloutExtension } from 'remirror/extensions'; | ||
import { htmlToProsemirrorNode } from '@remirror/core'; | ||
import { Remirror, ThemeProvider, useRemirror } from '@remirror/react'; | ||
|
||
export default { title: 'Callouts' }; | ||
|
||
const basicExtensions = () => [new CalloutExtension()]; | ||
|
||
export const Basic: React.FC = () => { | ||
const { manager, state, onChange } = useRemirror({ | ||
extensions: basicExtensions, | ||
content: | ||
'<div data-callout-type="info"><p>Info callout</p></div><p />' + | ||
'<div data-callout-type="warning"><p>Warning callout</p></div><p />' + | ||
'<div data-callout-type="error"><p>Error callout</p></div><p />' + | ||
'<div data-callout-type="success"><p>Success callout</p></div>', | ||
stringHandler: htmlToProsemirrorNode, | ||
}); | ||
|
||
return ( | ||
<ThemeProvider> | ||
<Remirror manager={manager} autoFocus onChange={onChange} state={state} autoRender='end' /> | ||
</ThemeProvider> | ||
); | ||
}; |
53 changes: 53 additions & 0 deletions
53
packages/remirror__extension-callout/__stories__/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"__AUTO_GENERATED__": [ | ||
"To update the configuration edit the following field.", | ||
"`package.json > @remirror > tsconfigs > '__stories__'`", | ||
"", | ||
"Then run: `pnpm -w generate:ts`" | ||
], | ||
"extends": "../../../support/tsconfig.base.json", | ||
"compilerOptions": { | ||
"types": [], | ||
"declaration": false, | ||
"noEmit": true, | ||
"skipLibCheck": true, | ||
"importsNotUsedAsValues": "remove", | ||
"paths": { | ||
"react": [ | ||
"../../../node_modules/.pnpm/@types+react@17.0.3/node_modules/@types/react/index.d.ts" | ||
], | ||
"react/jsx-dev-runtime": [ | ||
"../../../node_modules/.pnpm/@types+react@17.0.3/node_modules/@types/react/jsx-dev-runtime.d.ts" | ||
], | ||
"react/jsx-runtime": [ | ||
"../../../node_modules/.pnpm/@types+react@17.0.3/node_modules/@types/react/jsx-runtime.d.ts" | ||
], | ||
"react-dom": [ | ||
"../../../node_modules/.pnpm/@types+react-dom@17.0.3/node_modules/@types/react-dom/index.d.ts" | ||
], | ||
"reakit": [ | ||
"../../../node_modules/.pnpm/reakit@1.3.7_react-dom@17.0.2+react@17.0.2/node_modules/reakit/ts/index.d.ts" | ||
], | ||
"@remirror/react": ["../../remirror__react/src/index.ts"], | ||
"@storybook/react": [ | ||
"../../../node_modules/.pnpm/@storybook+react@6.2.8_fab8b5747c4374c1ef861a7534eabef4/node_modules/@storybook/react/types-6-0.d.ts" | ||
], | ||
"@remirror/dev": ["../../remirror__dev/src/index.ts"] | ||
} | ||
}, | ||
"include": ["./"], | ||
"references": [ | ||
{ | ||
"path": "../../testing/src" | ||
}, | ||
{ | ||
"path": "../../remirror/src" | ||
}, | ||
{ | ||
"path": "../../remirror__core/src" | ||
}, | ||
{ | ||
"path": "../../remirror__messages/src" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters