Skip to content

Commit 98b8079

Browse files
authored
Merge branch 'main' into feat/yfm-html-block-templates-and-preview
2 parents fccec46 + 068aeca commit 98b8079

55 files changed

Lines changed: 1171 additions & 100 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.release-please/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"packages/editor": "15.40.0",
2+
"packages/editor": "15.41.0",
33
"packages/latex-extension": "0.1.0",
44
"packages/page-constructor-extension": "0.1.0"
55
}

demo/src/components/Playground.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ export const Playground = memo<PlaygroundProps>((props) => {
269269
},
270270
yfmTable: {
271271
headerRows: true,
272+
cellBackground: true,
272273
table_ignoreSplittersInBlockCode: true,
273274
table_ignoreSplittersInBlockMath: true,
274275
table_ignoreSplittersInInlineCode: true,
@@ -437,6 +438,20 @@ export const Playground = memo<PlaygroundProps>((props) => {
437438
mdEditor.focus();
438439
}}
439440
/>
441+
<DropdownMenu.Item
442+
text="Insert"
443+
action={() => {
444+
mdEditor.insert('> insert');
445+
mdEditor.focus();
446+
}}
447+
/>
448+
<DropdownMenu.Item
449+
text="Insert(inline)"
450+
action={() => {
451+
mdEditor.insert('insert(inline)');
452+
mdEditor.focus();
453+
}}
454+
/>
440455
<DropdownMenu.Item
441456
text="Move cursor to start"
442457
action={() => {

demo/src/hocs/withLang.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {configure} from '@gravity-ui/uikit';
33
import type {Decorator} from '@storybook/react';
44

55
import '@gravity-ui/uikit/styles/styles.scss';
6+
import '@gravity-ui/markdown-editor/styles/markdown.css'; // eslint-disable-line import/order
67

78
export const withLang: Decorator = (StoryItem, context) => {
89
const lang = context.globals.lang;

demo/src/hocs/withThemeProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {ThemeProvider} from '@gravity-ui/uikit';
22
import type {Decorator} from '@storybook/react';
33

44
import '@gravity-ui/uikit/styles/styles.scss';
5+
import '@gravity-ui/markdown-editor/styles/markdown.css'; // eslint-disable-line import/order
56

67
export const withThemeProvider: Decorator = (StoryItem, context) => {
78
return (

demo/src/hocs/withToaster.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {toaster} from '@gravity-ui/uikit/toaster-singleton';
33
import type {Decorator} from '@storybook/react';
44

55
import '@gravity-ui/uikit/styles/styles.scss';
6+
import '@gravity-ui/markdown-editor/styles/markdown.css'; // eslint-disable-line import/order
67

78
export const withToaster: Decorator = (StoryItem, context) => {
89
return (

demo/src/stories/examples/yfm-table-dnd/YfmTableDnD.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const Story: StoryObj<typeof component> = {
77
mobile: false,
88
dnd: true,
99
headerRows: true,
10+
cellBackground: true,
1011
},
1112
};
1213
Story.storyName = "YFM Table D'n'D";

demo/src/stories/examples/yfm-table-dnd/YfmTableDnD.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ export type YfmTableDnDDemoProps = {
1010
mobile: boolean;
1111
dnd: boolean;
1212
headerRows: boolean;
13+
cellBackground: boolean;
1314
};
1415

1516
export const YfmTableDnDDemo = memo<YfmTableDnDDemoProps>(function YfmTableDnDDemo({
1617
mobile,
1718
dnd,
1819
headerRows,
20+
cellBackground,
1921
}) {
2022
const editor = useMarkdownEditor(
2123
{
@@ -32,11 +34,12 @@ export const YfmTableDnDDemo = memo<YfmTableDnDDemoProps>(function YfmTableDnDDe
3234
yfmTable: {
3335
dnd,
3436
headerRows,
37+
cellBackground,
3538
},
3639
},
3740
},
3841
},
39-
[mobile, dnd, headerRows],
42+
[mobile, dnd, headerRows, cellBackground],
4043
);
4144

4245
return (

demo/tests/playwright/core/editor.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ type YfmTableActionKind =
1111
| 'add-column-after'
1212
| 'add-row-before'
1313
| 'add-row-after'
14-
| 'header-toggle';
14+
| 'header-toggle'
15+
| 'row-cell-bg-open'
16+
| 'column-cell-bg-open';
1517

1618
type MarkdownEditorToolbarsLocators = Record<
1719
'main' | 'additional' | 'selection' | 'commandMenu',
@@ -142,6 +144,7 @@ class YfmNote {
142144
class YfmTable {
143145
readonly buttonPlusRowLocator;
144146
readonly buttonPlusColumnLocator;
147+
readonly cellBgPaletteLocator: Locator;
145148
private readonly tableLocator;
146149

147150
private readonly rowButtonLocator;
@@ -169,7 +172,10 @@ class YfmTable {
169172
'remove-row': page.getByTestId('g-md-yfm-table-action-remove-row'),
170173
'remove-table': page.getByTestId('g-md-yfm-table-action-remove-table'),
171174
'header-toggle': page.getByTestId('g-md-yfm-table-row-header-toggle'),
175+
'row-cell-bg-open': page.getByTestId('g-md-yfm-table-row-cell-bg'),
176+
'column-cell-bg-open': page.getByTestId('g-md-yfm-table-column-cell-bg'),
172177
};
178+
this.cellBgPaletteLocator = page.locator('.g-md-yfm-table-cell-bg-palette');
173179
}
174180

175181
getMenuLocator(type: YfmTableCellMenuType) {
@@ -225,6 +231,31 @@ class YfmTable {
225231
await firstCell.waitFor({state: 'visible'});
226232
await firstCell.click();
227233
}
234+
235+
getCellBgSwatchLocator(label: string) {
236+
return this.cellBgPaletteLocator.getByLabel(label, {exact: true});
237+
}
238+
239+
async openCellBgPalette(menuType: YfmTableCellMenuType) {
240+
const menu = this.cellMenus[menuType];
241+
await menu.waitFor({state: 'visible'});
242+
const actionKey: YfmTableActionKind =
243+
menuType === 'row' ? 'row-cell-bg-open' : 'column-cell-bg-open';
244+
await menu.locator(this.cellMenuActions[actionKey]).hover();
245+
await this.cellBgPaletteLocator.waitFor({state: 'visible'});
246+
}
247+
248+
async selectCellBg(menuType: YfmTableCellMenuType, swatchLabel: string) {
249+
await this.openCellBgPalette(menuType);
250+
await this.getCellBgSwatchLocator(swatchLabel).click();
251+
}
252+
253+
async closeMenu(menuType: YfmTableCellMenuType) {
254+
const button =
255+
menuType === 'row' ? this.rowButtonLocator.first() : this.columnButtonLocator.first();
256+
await button.click();
257+
await this.cellMenus[menuType].waitFor({state: 'hidden'});
258+
}
228259
}
229260

230261
class SearchPanel {

demo/tests/playwright/playwright/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import {beforeMount} from '@playwright/experimental-ct-react/hooks';
99

1010
import '@gravity-ui/uikit/styles/styles.scss';
11+
import '@gravity-ui/markdown-editor/styles/markdown.css'; // eslint-disable-line import/order
1112

1213
const toaster = new Toaster();
1314

0 commit comments

Comments
 (0)