mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) When a page starts with a number, don't treat it as an emoji
Test Plan: Added a check to the emoji test. Reviewers: georgegevoian Reviewed By: georgegevoian Subscribers: georgegevoian Differential Revision: https://phab.getgrist.com/D3951
This commit is contained in:
parent
b2743cac2d
commit
8581492912
@ -138,7 +138,9 @@ const pageInitialRegex = new RegExp(`^${emojiPart.source}(?:\\u{200D}${emojiPart
|
|||||||
// present, is omitted from the displayName, but a regular character used as the initial is kept.
|
// present, is omitted from the displayName, but a regular character used as the initial is kept.
|
||||||
function splitPageInitial(name: string): {initial: string, displayName: string, hasEmoji: boolean} {
|
function splitPageInitial(name: string): {initial: string, displayName: string, hasEmoji: boolean} {
|
||||||
const m = name.match(pageInitialRegex);
|
const m = name.match(pageInitialRegex);
|
||||||
if (m) {
|
// A common false positive is digits; those match \p{Emoji} but should not be considered emojis.
|
||||||
|
// (Other matching non-emojis include characters like '*', but those are nicer to show as emojis.)
|
||||||
|
if (m && !/^\d$/.test(m[0])) {
|
||||||
return {initial: m[0], displayName: name.slice(m[0].length).trim(), hasEmoji: true};
|
return {initial: m[0], displayName: name.slice(m[0].length).trim(), hasEmoji: true};
|
||||||
} else {
|
} else {
|
||||||
return {initial: Array.from(name)[0], displayName: name.trim(), hasEmoji: false};
|
return {initial: Array.from(name)[0], displayName: name.trim(), hasEmoji: false};
|
||||||
@ -179,6 +181,7 @@ const cssPageInitial = styled('div', `
|
|||||||
box-shadow: 0 0 0 1px var(--grist-theme-left-panel-page-emoji-outline, var(--grist-color-dark-grey));
|
box-shadow: 0 0 0 1px var(--grist-theme-left-panel-page-emoji-outline, var(--grist-color-dark-grey));
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
color: ${theme.text};
|
||||||
}
|
}
|
||||||
.${treeViewContainer.className}-close & {
|
.${treeViewContainer.className}-close & {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
|
@ -266,7 +266,7 @@ describe('Pages', function() {
|
|||||||
// It looks like our version of Chromedriver does not support sending emojis using sendKeys
|
// It looks like our version of Chromedriver does not support sending emojis using sendKeys
|
||||||
// (issue mentioned here https://stackoverflow.com/a/59139690), so we'll use executeScript to
|
// (issue mentioned here https://stackoverflow.com/a/59139690), so we'll use executeScript to
|
||||||
// rename pages.
|
// rename pages.
|
||||||
async function renamePage(origName: string, newName: string) {
|
async function renamePage(origName: string|RegExp, newName: string) {
|
||||||
await gu.openPageMenu(origName);
|
await gu.openPageMenu(origName);
|
||||||
await driver.find('.test-docpage-rename').doClick();
|
await driver.find('.test-docpage-rename').doClick();
|
||||||
const editor = await driver.find('.test-docpage-editor');
|
const editor = await driver.find('.test-docpage-editor');
|
||||||
@ -291,7 +291,11 @@ describe('Pages', function() {
|
|||||||
assert.deepEqual(await getInitialAndName(/Guest List/),
|
assert.deepEqual(await getInitialAndName(/Guest List/),
|
||||||
['👨👩👧👦', '👨👩👧Guest List']);
|
['👨👩👧👦', '👨👩👧Guest List']);
|
||||||
|
|
||||||
await gu.undo(2);
|
// Digits should not be considered emoji (even though they match /\p{Emoji}/...)
|
||||||
|
await renamePage(/Guest List/, '5Guest List');
|
||||||
|
assert.deepEqual(await getInitialAndName(/Guest List/), ['5', '5Guest List']);
|
||||||
|
|
||||||
|
await gu.undo(3);
|
||||||
assert.deepEqual(await getInitialAndName(/People/), ['P', 'People']);
|
assert.deepEqual(await getInitialAndName(/People/), ['P', 'People']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user