Skip to content

Commit 6daf616

Browse files
committed
fix: rename title to heading for clarity and consistency. #693
1 parent cc8b004 commit 6daf616

File tree

12 files changed

+148
-82
lines changed

12 files changed

+148
-82
lines changed

core/commands.d.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ declare module '@uiw/react-md-editor/commands' {
1414
import { codeEdit, codeLive, codePreview } from '@uiw/react-md-editor/esm/commands/preview';
1515
import { quote } from '@uiw/react-md-editor/esm/commands/quote';
1616
import { strikethrough } from '@uiw/react-md-editor/esm/commands/strikeThrough';
17-
import { title } from '@uiw/react-md-editor/esm/commands/title';
18-
import { title1 } from '@uiw/react-md-editor/esm/commands/title1';
19-
import { title2 } from '@uiw/react-md-editor/esm/commands/title2';
20-
import { title3 } from '@uiw/react-md-editor/esm/commands/title3';
21-
import { title4 } from '@uiw/react-md-editor/esm/commands/title4';
22-
import { title5 } from '@uiw/react-md-editor/esm/commands/title5';
23-
import { title6 } from '@uiw/react-md-editor/esm/commands/title6';
17+
import { title, heading } from '@uiw/react-md-editor/esm/commands/title';
18+
import { title1, heading1 } from '@uiw/react-md-editor/esm/commands/title1';
19+
import { title2, heading2 } from '@uiw/react-md-editor/esm/commands/title2';
20+
import { title3, heading3 } from '@uiw/react-md-editor/esm/commands/title3';
21+
import { title4, heading4 } from '@uiw/react-md-editor/esm/commands/title4';
22+
import { title5, heading5 } from '@uiw/react-md-editor/esm/commands/title5';
23+
import { title6, heading6 } from '@uiw/react-md-editor/esm/commands/title6';
2424
import { table } from '@uiw/react-md-editor/esm/commands/table';
2525
import { issue } from '@uiw/react-md-editor/esm/commands/issue';
2626
import { help } from '@uiw/react-md-editor/esm/commands/help';
@@ -117,6 +117,13 @@ declare module '@uiw/react-md-editor/commands' {
117117
title4,
118118
title5,
119119
title6,
120+
heading,
121+
heading1,
122+
heading2,
123+
heading3,
124+
heading4,
125+
heading5,
126+
heading6,
120127
bold,
121128
codeBlock,
122129
comment,

core/nohighlight.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ declare module '@uiw/react-md-editor/nohighlight' {
22
import MDEditor from '@uiw/react-md-editor/esm/Editor.nohighlight';
33
import * as commands from '@uiw/react-md-editor/esm/commands';
44
import * as MarkdownUtil from '@uiw/react-md-editor/esm/utils/markdownUtils';
5+
export { headingExecute } from '@uiw/react-md-editor/esm/commands/title';
56
export * from '@uiw/react-md-editor/esm/commands';
67
export * from '@uiw/react-md-editor/esm/commands/group';
78
export * from '@uiw/react-md-editor/esm/utils/markdownUtils';
89
export * from '@uiw/react-md-editor/esm/utils/InsertTextAtPosition';
910
export * from '@uiw/react-md-editor/esm/Editor.nohighlight';
1011
export * from '@uiw/react-md-editor/esm/Context';
12+
export * from '@uiw/react-md-editor/esm/Types';
1113
export { MarkdownUtil, commands };
1214
export default MDEditor;
1315
}

core/src/commands/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import { checkedListCommand, orderedListCommand, unorderedListCommand } from './
1515
import { codeEdit, codeLive, codePreview } from './preview';
1616
import { quote } from './quote';
1717
import { strikethrough } from './strikeThrough';
18-
import { title } from './title';
19-
import { title1 } from './title1';
20-
import { title2 } from './title2';
21-
import { title3 } from './title3';
22-
import { title4 } from './title4';
23-
import { title5 } from './title5';
24-
import { title6 } from './title6';
18+
import { title, heading } from './title';
19+
import { title1, heading1 } from './title1';
20+
import { title2, heading2 } from './title2';
21+
import { title3, heading3 } from './title3';
22+
import { title4, heading4 } from './title4';
23+
import { title5, heading5 } from './title5';
24+
import { title6, heading6 } from './title6';
2525
import { table } from './table';
2626
import { issue } from './issue';
2727
import { help } from './help';
@@ -188,6 +188,13 @@ export {
188188
title4,
189189
title5,
190190
title6,
191+
heading,
192+
heading1,
193+
heading2,
194+
heading3,
195+
heading4,
196+
heading5,
197+
heading6,
191198
bold,
192199
codeBlock,
193200
comment,

core/src/commands/title.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import { ICommand, ExecuteState, TextAreaTextApi } from './';
3-
import { title1 } from './title1';
3+
import { heading1 } from './title1';
44
import { selectLine, executeCommand } from '../utils/markdownUtils';
55

6-
export function titleExecute({
6+
export function headingExecute({
77
state,
88
api,
99
prefix,
@@ -19,8 +19,8 @@ export function titleExecute({
1919
executeCommand({ api, selectedText: state1.selectedText, selection: state.selection, prefix, suffix });
2020
}
2121

22-
export const title: ICommand = {
23-
...title1,
22+
export const heading: ICommand = {
23+
...heading1,
2424
icon: (
2525
<svg width="12" height="12" viewBox="0 0 520 520">
2626
<path
@@ -30,3 +30,10 @@ export const title: ICommand = {
3030
</svg>
3131
),
3232
};
33+
34+
/**
35+
* @deprecated Use `heading` instead.
36+
* This command is now deprecated and will be removed in future versions.
37+
* Use `title` for inserting headings.
38+
*/
39+
export const title: ICommand = heading;

core/src/commands/title1.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import React from 'react';
2-
import { titleExecute } from '../commands/title';
2+
import { headingExecute } from '../commands/title';
33
import { ICommand, ExecuteState, TextAreaTextApi } from './';
44

5-
export const title1: ICommand = {
6-
name: 'title1',
7-
keyCommand: 'title1',
5+
export const heading1: ICommand = {
6+
name: 'heading1',
7+
keyCommand: 'heading1',
88
shortcuts: 'ctrlcmd+1',
99
prefix: '# ',
1010
suffix: '',
1111
buttonProps: { 'aria-label': 'Insert Heading 1 (ctrl + 1)', title: 'Insert Heading 1 (ctrl + 1)' },
1212
icon: <div style={{ fontSize: 18, textAlign: 'left' }}>Heading 1</div>,
1313
execute: (state: ExecuteState, api: TextAreaTextApi) => {
14-
titleExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
14+
headingExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
1515
},
1616
};
17+
18+
/**
19+
* @deprecated Use `heading1` instead.
20+
* This command is now deprecated and will be removed in future versions.
21+
* Use `title1` for inserting Heading 1.
22+
*/
23+
export const title1: ICommand = heading1;

core/src/commands/title2.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import React from 'react';
2-
import { titleExecute } from '../commands/title';
2+
import { headingExecute } from '../commands/title';
33
import { ICommand, ExecuteState, TextAreaTextApi } from './';
44

5-
export const title2: ICommand = {
6-
name: 'title2',
7-
keyCommand: 'title2',
5+
export const heading2: ICommand = {
6+
name: 'heading2',
7+
keyCommand: 'heading2',
88
shortcuts: 'ctrlcmd+2',
99
prefix: '## ',
1010
suffix: '',
1111
buttonProps: { 'aria-label': 'Insert Heading 2 (ctrl + 2)', title: 'Insert Heading 2 (ctrl + 2)' },
1212
icon: <div style={{ fontSize: 16, textAlign: 'left' }}>Heading 2</div>,
1313
execute: (state: ExecuteState, api: TextAreaTextApi) => {
14-
titleExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
14+
headingExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
1515
},
1616
};
17+
18+
/**
19+
* @deprecated Use `heading2` instead.
20+
* This command is now deprecated and will be removed in future versions.
21+
* Use `title2` for inserting Heading 2.
22+
*/
23+
export const title2: ICommand = heading2;

core/src/commands/title3.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import React from 'react';
2-
import { titleExecute } from '../commands/title';
2+
import { headingExecute } from '../commands/title';
33
import { ICommand, ExecuteState, TextAreaTextApi } from './';
44

5-
export const title3: ICommand = {
6-
name: 'title3',
7-
keyCommand: 'title3',
5+
export const heading3: ICommand = {
6+
name: 'heading3',
7+
keyCommand: 'heading3',
88
shortcuts: 'ctrlcmd+3',
99
prefix: '### ',
1010
suffix: '',
1111
buttonProps: { 'aria-label': 'Insert Heading 3 (ctrl + 3)', title: 'Insert Heading 3 (ctrl + 3)' },
1212
icon: <div style={{ fontSize: 15, textAlign: 'left' }}>Heading 3</div>,
1313
execute: (state: ExecuteState, api: TextAreaTextApi) => {
14-
titleExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
14+
headingExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
1515
},
1616
};
17+
18+
/**
19+
* @deprecated Use `heading3` instead.
20+
* This command is now deprecated and will be removed in future versions.
21+
* Use `title3` for inserting Heading 3.
22+
*/
23+
export const title3: ICommand = heading3;

core/src/commands/title4.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import React from 'react';
2-
import { titleExecute } from '../commands/title';
2+
import { headingExecute } from '../commands/title';
33
import { ICommand, ExecuteState, TextAreaTextApi } from './';
44

5-
export const title4: ICommand = {
6-
name: 'title4',
7-
keyCommand: 'title4',
5+
export const heading4: ICommand = {
6+
name: 'heading4',
7+
keyCommand: 'heading4',
88
shortcuts: 'ctrlcmd+4',
99
prefix: '#### ',
1010
suffix: '',
1111
buttonProps: { 'aria-label': 'Insert Heading 4 (ctrl + 4)', title: 'Insert Heading 4 (ctrl + 4)' },
1212
icon: <div style={{ fontSize: 14, textAlign: 'left' }}>Heading 4</div>,
1313
execute: (state: ExecuteState, api: TextAreaTextApi) => {
14-
titleExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
14+
headingExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
1515
},
1616
};
17+
18+
/**
19+
* @deprecated Use `heading4` instead.
20+
* This command is now deprecated and will be removed in future versions.
21+
* Use `title4` for inserting Heading 4.
22+
*/
23+
export const title4: ICommand = heading4;

core/src/commands/title5.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import React from 'react';
2-
import { titleExecute } from '../commands/title';
2+
import { headingExecute } from '../commands/title';
33
import { ICommand, ExecuteState, TextAreaTextApi } from './';
44

5-
export const title5: ICommand = {
6-
name: 'title5',
7-
keyCommand: 'title5',
5+
export const heading5: ICommand = {
6+
name: 'heading5',
7+
keyCommand: 'heading5',
88
shortcuts: 'ctrlcmd+5',
99
prefix: '##### ',
1010
suffix: '',
1111
buttonProps: { 'aria-label': 'Insert Heading 5 (ctrl + 5)', title: 'Insert Heading 5 (ctrl + 5)' },
1212
icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Heading 5</div>,
1313
execute: (state: ExecuteState, api: TextAreaTextApi) => {
14-
titleExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
14+
headingExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
1515
},
1616
};
17+
18+
/**
19+
* @deprecated Use `heading5` instead.
20+
* This command is now deprecated and will be removed in future versions.
21+
* Use `title5` for inserting Heading 5.
22+
*/
23+
export const title5: ICommand = heading5;

core/src/commands/title6.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import React from 'react';
2-
import { titleExecute } from '../commands/title';
2+
import { headingExecute } from '../commands/title';
33
import { ICommand, ExecuteState, TextAreaTextApi } from './';
44

5-
export const title6: ICommand = {
6-
name: 'title6',
7-
keyCommand: 'title6',
5+
export const heading6: ICommand = {
6+
name: 'heading6',
7+
keyCommand: 'heading6',
88
shortcuts: 'ctrlcmd+6',
99
prefix: '###### ',
1010
suffix: '',
1111
buttonProps: { 'aria-label': 'Insert Heading 6 (ctrl + 6)', title: 'Insert Heading 6 (ctrl + 6)' },
1212
icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Heading 6</div>,
1313
execute: (state: ExecuteState, api: TextAreaTextApi) => {
14-
titleExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
14+
headingExecute({ state, api, prefix: state.command.prefix!, suffix: state.command.suffix });
1515
},
1616
};
17+
18+
/**
19+
* @deprecated Use `heading6` instead.
20+
* This command is now deprecated and will be removed in future versions.
21+
* Use `title6` for inserting Heading 6.
22+
*/
23+
export const title6: ICommand = heading6;

0 commit comments

Comments
 (0)