Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const cracoConfig = (module.exports = {
'konva',
'react-konva',
'react-debounce-render',
'devlop',
'hastscript',
'hast-to-hyperscript',
'hast-util-.+',
Expand All @@ -131,6 +132,14 @@ const cracoConfig = (module.exports = {
'^.+\\.module\\.(css|sass|scss)$'
];
jestConfig.moduleNameMapper['ace-builds'] = '<rootDir>/node_modules/ace-builds';
jestConfig.moduleNameMapper['unist-util-visit-parents/do-not-use-color'] =
'<rootDir>/node_modules/unist-util-visit-parents/lib';
jestConfig.moduleNameMapper['vfile/do-not-use-conditional-minpath'] =
'<rootDir>/node_modules/vfile/lib';
jestConfig.moduleNameMapper['vfile/do-not-use-conditional-minproc'] =
'<rootDir>/node_modules/vfile/lib';
jestConfig.moduleNameMapper['vfile/do-not-use-conditional-minurl'] =
'<rootDir>/node_modules/vfile/lib';
return jestConfig;
}
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"konva": "^9.2.0",
"lodash": "^4.17.21",
"lz-string": "^1.4.4",
"mdast-util-from-markdown": "^1.3.1",
"mdast-util-to-hast": "^12.3.0",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-to-hast": "^13.0.0",
"moment": "^2.29.4",
"normalize.css": "^8.0.1",
"phaser": "^3.55.2",
Expand Down Expand Up @@ -83,11 +83,11 @@
"redux": "^4.2.1",
"redux-mock-store": "^1.5.4",
"redux-saga": "^1.2.3",
"rehype-react": "^7.2.0",
"rehype-react": "^8.0.0",
"showdown": "^2.1.0",
"sourceror": "^0.8.5",
"typesafe-actions": "^5.1.0",
"unified": "^10.1.2",
"unified": "^11.0.0",
"uuid": "^8.3.2",
"xml2js": "^0.6.0",
"yareco": "^0.1.5"
Expand Down
12 changes: 6 additions & 6 deletions src/commons/utils/StoriesHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fromMarkdown } from 'mdast-util-from-markdown';
import { defaultHandlers, toHast } from 'mdast-util-to-hast';
import { MdastNodes, Options as MdastToHastConverterOptions } from 'mdast-util-to-hast/lib';
import React from 'react';
import * as runtime from 'react/jsx-runtime';
import { IEditorProps } from 'react-ace';
import rehypeReact from 'rehype-react';
import SourceBlock, { SourceBlockProps } from 'src/features/stories/storiesComponents/SourceBlock';
Expand Down Expand Up @@ -146,7 +147,7 @@ export const scrollSync = (editor: IEditorProps, preview: HTMLElement) => {
// below is typed as `any` if we use the default typings.
// Thus, we create `HandlerType` to have type safety for the
// `node` parameter based on the actual mdast node type.
type HandlerOption = NonNullable<MdastToHastConverterOptions['handlers']>;
type HandlerOption = NonNullable<Required<MdastToHastConverterOptions['handlers']>>;
type AllowedMdElements = Exclude<keyof typeof defaultHandlers, 'toml'>;
type MdastNodeType<key extends AllowedMdElements> = Extract<MdastNodes, { type: key }>;
type HandlerType = {
Expand Down Expand Up @@ -180,13 +181,12 @@ export const renderStoryMarkdown = (markdown: string): React.ReactNode => {
return (
unified()
.use(rehypeReact, {
createElement: React.createElement,
Fragment: React.Fragment,
...runtime,
components: {
'source-block': SourceBlock
// Disable typecheck as "source-block" is not a standard HTML tag
} as any
})
}
// Disable typecheck as "source-block" is not a standard HTML tag
} as any)
// We use `any` due to incompatible type definitions (although it
// actually works). Either way, this is never exposed, and so is okay.
.stringify(hast as any)
Expand Down
Loading