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
13 changes: 12 additions & 1 deletion WebExample/__tests__/styles.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {test} from '@playwright/test';
// eslint-disable-next-line import/no-relative-packages
import * as TEST_CONST from '../../example/src/testConstants';
import {testMarkdownContentStyle} from './utils';
import {testMarkdownContentStyle, testMarkdownElementHasComputedStyle} from './utils';

test.beforeEach(async ({page}) => {
await page.goto(TEST_CONST.LOCAL_URL, {waitUntil: 'load'});
Expand Down Expand Up @@ -60,4 +60,15 @@ test.describe('markdown content styling', () => {

await testMarkdownContentStyle({testContent: 'blockquote', style: browserStyle, page});
});

test('blockquote with strikethrough', async ({page, browserName}) => {
let blockquoteStyle = 'line-through';
if (browserName === 'firefox') {
blockquoteStyle = 'line-through rgb(0, 0, 0)';
} else if (browserName === 'chromium') {
blockquoteStyle = 'line-through solid rgb(0, 0, 0)';
}

await testMarkdownElementHasComputedStyle({testContent: 'strikethrough_blockquote', propertyName: 'text-decoration', style: blockquoteStyle, page});
});
});
27 changes: 26 additions & 1 deletion WebExample/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,29 @@ const testMarkdownContentStyle = async ({testContent, style, page, dimmensions}:
}
};

export {setupInput, getCursorPosition, setCursorPosition, getElementStyle, pressCmd, getElementValue, changeMarkdownStyle, setSelection, testMarkdownContentStyle};
const testMarkdownElementHasComputedStyle = async ({testContent, propertyName, style, page}: {testContent: string; propertyName: string; style: string; page: Page}) => {
const inputLocator = await setupInput(page);

const elementHandle = inputLocator.locator('span', {hasText: testContent}).last();

let elementStyle;
if (elementHandle) {
await elementHandle.waitFor({state: 'attached'});
elementStyle = await elementHandle.evaluate((el, property) => window.getComputedStyle(el).getPropertyValue(property), propertyName);
}

expect(elementStyle).toEqual(style);
};

export {
setupInput,
getCursorPosition,
setCursorPosition,
getElementStyle,
pressCmd,
getElementValue,
changeMarkdownStyle,
setSelection,
testMarkdownContentStyle,
testMarkdownElementHasComputedStyle,
};
1 change: 1 addition & 0 deletions example/src/testConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const EXAMPLE_CONTENT = [
'https://expensify.com',
'# header1',
'> blockquote',
'~sb\n*sbb\n_sbi\n> strikethrough_blockquote\nsbi_\nsbb*\nsb~',
'`inline code`',
'```\ncodeblock\n```',
'@here',
Expand Down
4 changes: 4 additions & 0 deletions src/web/MarkdownTextInput.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@
-ms-user-select: none;
user-select: none;
}

[class^='react-native-live-markdown-input'] [data-type='strikethrough'] * {
text-decoration: inherit;
}