Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit b8935a4

Browse files
committed
Merge branch 'main' into next
2 parents 325e6af + 1b42c0a commit b8935a4

File tree

12 files changed

+565
-318
lines changed

12 files changed

+565
-318
lines changed

packages/core/package.json

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
"@emotion/react": "11.11.1",
6767
"@emotion/styled": "11.11.0",
6868
"@lezer/common": "1.1.0",
69-
"@mdx-js/mdx": "2.3.0",
70-
"@mdx-js/react": "2.3.0",
69+
"@mdx-js/mdx": "3.0.0",
70+
"@mdx-js/react": "3.0.0",
7171
"@mui/base": "5.0.0-beta.18",
7272
"@mui/material": "5.14.12",
7373
"@mui/system": "5.14.12",
@@ -119,15 +119,15 @@
119119
"jwt-decode": "3.1.2",
120120
"localforage": "1.10.0",
121121
"lodash": "4.17.21",
122-
"mdast-util-gfm-footnote": "1.0.2",
123-
"mdast-util-gfm-strikethrough": "1.0.3",
124-
"mdast-util-gfm-table": "1.0.7",
125-
"mdast-util-gfm-task-list-item": "1.0.2",
126-
"micromark-extension-gfm-footnote": "1.1.0",
127-
"micromark-extension-gfm-strikethrough": "1.0.5",
128-
"micromark-extension-gfm-table": "1.0.5",
129-
"micromark-extension-gfm-task-list-item": "1.0.4",
130-
"micromark-util-combine-extensions": "1.0.0",
122+
"mdast-util-gfm-footnote": "2.0.0",
123+
"mdast-util-gfm-strikethrough": "2.0.0",
124+
"mdast-util-gfm-table": "2.0.0",
125+
"mdast-util-gfm-task-list-item": "2.0.0",
126+
"micromark-extension-gfm-footnote": "2.0.0",
127+
"micromark-extension-gfm-strikethrough": "2.0.0",
128+
"micromark-extension-gfm-table": "2.0.0",
129+
"micromark-extension-gfm-task-list-item": "2.0.1",
130+
"micromark-util-combine-extensions": "2.0.0",
131131
"minimatch": "9.0.0",
132132
"node-polyglot": "2.5.0",
133133
"ol": "7.3.0",
@@ -140,7 +140,7 @@
140140
"react-dom": "18.2.0",
141141
"react-frame-component": "5.2.6",
142142
"react-is": "18.2.0",
143-
"react-markdown": "8.0.7",
143+
"react-markdown": "9.0.1",
144144
"react-polyglot": "0.7.2",
145145
"react-redux": "8.1.3",
146146
"react-resizable-panels": "0.0.55",
@@ -151,9 +151,9 @@
151151
"react-waypoint": "10.3.0",
152152
"react-window": "1.8.9",
153153
"remark-gfm": "4.0.0",
154-
"remark-html": "15.0.2",
155-
"remark-mdx": "2.3.0",
156-
"remark-parse": "10.0.1",
154+
"remark-html": "16.0.1",
155+
"remark-mdx": "3.0.0",
156+
"remark-parse": "11.0.0",
157157
"sanitize-filename": "1.6.3",
158158
"scheduler": "0.23.0",
159159
"semaphore": "1.1.0",
@@ -164,15 +164,15 @@
164164
"stream-browserify": "3.0.0",
165165
"styled-components": "5.3.11",
166166
"symbol-observable": "4.0.0",
167-
"unified": "10.1.2",
168-
"unist-util-visit": "4.1.2",
167+
"unified": "11.0.4",
168+
"unist-util-visit": "5.0.0",
169169
"url": "0.11.0",
170170
"url-join": "5.0.0",
171171
"uuid": "9.0.1",
172172
"validate-color": "2.2.4",
173-
"vfile": "5.3.7",
174-
"vfile-message": "3.1.4",
175-
"vfile-statistics": "2.0.1",
173+
"vfile": "6.0.1",
174+
"vfile-message": "4.0.2",
175+
"vfile-statistics": "3.0.0",
176176
"what-the-diff": "0.6.0",
177177
"yaml": "2.3.2"
178178
},
@@ -211,6 +211,7 @@
211211
"@types/react-dom": "18.2.10",
212212
"@types/react-virtualized-auto-sizer": "1.0.1",
213213
"@types/react-window": "1.8.6",
214+
"@types/unist": "3.0.2",
214215
"@types/url-join": "4.0.1",
215216
"@types/uuid": "9.0.4",
216217
"@typescript-eslint/eslint-plugin": "6.7.4",

packages/core/src/widgets/markdown/plate/hooks/useMarkdownToSlate.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { getShortcodes } from '../../../../lib/registry';
88
import gfm from '../serialization/gfm';
99
import toSlatePlugin from '../serialization/slate/toSlatePlugin';
1010

11+
import type { ProcessCallback } from 'unified';
12+
import type { VFile } from 'vfile';
1113
import type { ShortcodeConfig } from '../../../../interface';
1214
import type { MdValue } from '../plateTypes';
1315

@@ -22,19 +24,22 @@ export const markdownToSlate = async (
2224
{ useMdx, shortcodeConfigs }: UseMarkdownToSlateOptions,
2325
) => {
2426
return new Promise<MdValue>(resolve => {
27+
const callback: ProcessCallback<VFile> = (err, file) => {
28+
if (err) {
29+
console.error(err);
30+
return;
31+
}
32+
resolve(file?.result as MdValue);
33+
return undefined;
34+
};
35+
2536
unified()
2637
.use(markdown)
2738
.use(gfm)
2839
// eslint-disable-next-line @typescript-eslint/no-empty-function
2940
.use(useMdx ? mdx : () => {})
3041
.use(toSlatePlugin({ shortcodeConfigs: shortcodeConfigs ?? getShortcodes(), useMdx }))
31-
.process(markdownValue, (err, file) => {
32-
if (err) {
33-
console.error(err);
34-
return;
35-
}
36-
resolve(file?.result as MdValue);
37-
});
42+
.process(markdownValue, callback);
3843
});
3944
};
4045

packages/core/src/widgets/markdown/plate/hooks/useMdx.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { evaluate } from '@mdx-js/mdx';
22
import * as provider from '@mdx-js/react';
33
import { useCallback, useEffect, useState } from 'react';
44
import * as runtime from 'react/jsx-runtime';
5-
import remarkGfm from 'remark-gfm';
65
import { VFile } from 'vfile';
76
import { VFileMessage } from 'vfile-message';
87

8+
import useDebounce from '@staticcms/core/lib/hooks/useDebounce';
99
import useDebouncedCallback from '@staticcms/core/lib/hooks/useDebouncedCallback';
10+
import remarkGfm from '../serialization/gfm';
1011
import flattenListItemParagraphs from '../serialization/slate/flattenListItemParagraphs';
11-
import useDebounce from '@staticcms/core/lib/hooks/useDebounce';
12+
13+
import type { Compatible } from 'vfile';
1214

1315
export interface UseMdxState {
1416
file: VFile | null;
@@ -33,7 +35,7 @@ export default function useMdx(
3335
};
3436

3537
try {
36-
file.result = (await evaluate(file, options)).default;
38+
file.result = (await evaluate(file as Readonly<Compatible>, options)).default;
3739
} catch (error) {
3840
const message = error instanceof VFileMessage ? error : new VFileMessage(String(error));
3941

packages/core/src/widgets/markdown/plate/serialization/gfm.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,32 @@ import type { Plugin, Processor } from 'unified';
2020
function gfmFromMarkdown() {
2121
return [
2222
gfmFootnoteFromMarkdown(),
23-
gfmStrikethroughFromMarkdown,
24-
gfmTableFromMarkdown,
25-
gfmTaskListItemFromMarkdown,
23+
gfmStrikethroughFromMarkdown(),
24+
gfmTableFromMarkdown(),
25+
gfmTaskListItemFromMarkdown(),
2626
];
2727
}
2828

2929
function gfmToMarkdown() {
3030
return {
3131
extensions: [
3232
gfmFootnoteToMarkdown(),
33-
gfmStrikethroughToMarkdown,
33+
gfmStrikethroughToMarkdown(),
3434
gfmTableToMarkdown({}),
35-
gfmTaskListItemToMarkdown,
35+
gfmTaskListItemToMarkdown(),
3636
],
3737
};
3838
}
3939

4040
function gfm() {
41-
return combineExtensions([gfmFootnote(), gfmStrikethrough({}), gfmTable, gfmTaskListItem]);
41+
return combineExtensions([gfmFootnote(), gfmStrikethrough({}), gfmTable(), gfmTaskListItem()]);
42+
}
43+
44+
declare module 'unified' {
45+
interface Data {
46+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
47+
toMarkdownExtensions?: Array<any>;
48+
}
4249
}
4350

4451
/**
@@ -47,15 +54,13 @@ function gfm() {
4754
const remarkGfm: Plugin<void[], Root> = function (this: Processor) {
4855
const data = this.data();
4956

50-
add('micromarkExtensions', gfm());
51-
add('fromMarkdownExtensions', gfmFromMarkdown());
52-
add('toMarkdownExtensions', gfmToMarkdown());
57+
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
58+
const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
59+
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
5360

54-
function add(field: string, value: unknown) {
55-
const list = (data[field] ? data[field] : (data[field] = [])) as unknown[];
56-
57-
list.push(value);
58-
}
61+
micromarkExtensions.push(gfm());
62+
fromMarkdownExtensions.push(gfmFromMarkdown());
63+
toMarkdownExtensions.push(gfmToMarkdown());
5964
};
6065

6166
export default remarkGfm;

packages/core/src/widgets/markdown/plate/serialization/slate/flattenListItemParagraphs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { visit } from 'unist-util-visit';
22

33
import type { Plugin } from 'unified';
4-
import type { Parent, Node, VisitorResult } from 'unist-util-visit/lib';
4+
import type { Node, Parent } from 'unist';
5+
import type { VisitorResult } from 'unist-util-visit';
56

67
const flattenListItemParagraphs: Plugin = function () {
78
return ast => {

packages/core/src/widgets/markdown/plate/serialization/slate/toSlatePlugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import transform from './deserializeMarkdown';
22

33
import type { ShortcodeConfig } from '@staticcms/core';
4-
import type { Plugin } from 'unified';
4+
import type { Plugin, Compiler } from 'unified';
55
import type { MdastNode } from './ast-types';
66

77
export interface ToSlatePluginOptions {
@@ -19,7 +19,7 @@ export const slateCompiler =
1919

2020
const toSlatePlugin = (options: ToSlatePluginOptions): Plugin =>
2121
function () {
22-
this.Compiler = slateCompiler(options);
22+
this.compiler = slateCompiler(options) as unknown as Compiler;
2323
};
2424

2525
export default toSlatePlugin;

packages/docs/src/components/docs/table_of_contents/DocsTableOfContents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ const StyledNav = styled('nav')(
147147
align-self: flex-start;
148148
position: sticky;
149149
top: 0;
150-
max-height: calc(100vh - 88px);
151-
overflow-y: hidden;
150+
max-height: calc(100dvh - 72px);
151+
overflow-y: auto;
152152
top: 16px;
153153
154154
&:hover {

packages/docs/src/components/layout/Page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type { DocsGroup, SearchablePage } from '../../interface';
1616

1717
const StyledPageContentWrapper = styled('div')`
1818
display: block;
19-
height: calc(100vh - 72px);
19+
height: calc(100dvh - 72px);
2020
width: 100%;
2121
position: relative;
2222
top: 72px;

packages/docs/src/pages/community.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const StyledCommunityContent = styled('div')(
1313
({ theme }) => `
1414
width: 100%;
1515
padding-top: 72px;
16-
min-height: calc(100vh - 72px);
16+
min-height: calc(100dvh - 72px);
1717
display: flex;
1818
flex-direction: column;
1919
gap: 80px;

packages/docs/src/pages/releases.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const StyledReleaseContent = styled('div')(
2121
({ theme }) => `
2222
width: 100%;
2323
padding-top: 72px;
24-
min-height: calc(100vh - 72px);
24+
min-height: calc(100dvh - 72px);
2525
display: flex;
2626
flex-direction: column;
2727
gap: 20px;

0 commit comments

Comments
 (0)