Skip to content

Conversation

@BartoszGrajdek
Copy link
Contributor

@BartoszGrajdek BartoszGrajdek commented Aug 21, 2024

Details

Related Issues

GH_LINK

Manual Tests

Change codeFance rule in /node_modules/expensify-common/dist/ExpensiMark.js to code below

             {
                name: 'codeFence',
                // ` is a backtick symbol we are matching on three of them before then after a new line character
                regex: /(?<![^^\r\n])(&#x60;&#x60;&#x60;(\r\n|\n))((?:\s*?(?!(?:\r\n|\n)?&#x60;&#x60;&#x60;(?!&#x60;))[\S])+\s*?(?:\r\n|\n))(&#x60;&#x60;&#x60;)/g,
                // We're using a function here to perform an additional replace on the content
                // inside the backticks because Android is not able to use <pre> tags and does
                // not respect whitespace characters at all like HTML does. We do not want to mess
                // with the new lines here since they need to be converted into <br>. And we don't
                // want to do this anywhere else since that would break HTML.
                // &nbsp; will create styling issues so use &#32;
                replacement: (_extras, _match, _g1, _g2, textWithinFences) => {
                    const group = textWithinFences.replace(/(?:(?![\n\r])\s)/g, '&#32;');
                    return `<pre>${group}</pre>`;
                },
                rawInputReplacement: (_extras, _match, _g1, newLineCharacter, textWithinFences) => {
                    const group = textWithinFences.replace(/(?:(?![\n\r])\s)/g, '&#32;').replace(/<emoji>|<\/emoji>/g, '');
                    return `<pre>${newLineCharacter}${group}</pre>`;
                },
            },

Linked PRs

}

if (node.nodeType === Node.TEXT_NODE) {
let hasAddedNewline = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the newline logic is confusing when adding codeblock after a codeblock or splitting one.
The input appears as in the new line, but it parses into the new codeblock only after manually pressing enter at the line break.

Screen.Recording.2025-06-16.at.18.08.56.mov

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the main goals of the Live Markdown Input is to preview how the message from Expensify will look after sending. In all scenarios, the code block syntax moves the content around it into separate lines (display: block). I agree that it can be a bit confusing, but we do the same thing for inline images

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe to make it more intuitive, we should require a whitespace after the codeblock closing syntax to be able to add another markdown after it. What do you think about it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels different with demo image bc the image is adding w/o additional character between blocks. I think this is the expected behaviour here as well.

Screen.Recording.2025-06-18.at.10.57.05.mov

const currentLine = target.tree.childNodes[orderIndex]?.element;
const scrollTargetElement = currentLine || node.element;

if (!isChildOfMultilineMarkdownElement(node.element)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found this multiline problem while testing, but it works same on main. IMO can be fixed as a followup.

Screen.Recording.2025-06-16.at.18.17.11.mov

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, will fix that in follow up PR :D

@Skalakid
Copy link
Contributor

Skalakid commented Jul 4, 2025

Hello, here is the PR with required changes in the expensify-common library Expensify/expensify-common#865. Once it's merged we can proceed with with merging this PR

Copy link
Collaborator

@jmusial jmusial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @tomekzaw do you want to take a look or it's ok if I merge it ? (on Monday 😄 )

@tomekzaw
Copy link
Collaborator

tomekzaw commented Aug 1, 2025

Feel free to merge if the PR is okay 😄

@jmusial jmusial merged commit 9c23e12 into main Aug 4, 2025
7 checks passed
@jmusial jmusial deleted the @BartoszGrajdek/web-parser-refactor-code-blocks branch August 4, 2025 08:49
@os-botify
Copy link
Contributor

os-botify bot commented Aug 4, 2025

🚀 Published to npm in 0.1.300 🎉

Comment on lines -33 to -37
.react-native-live-markdown-input-singleline:empty::before,
.react-native-live-markdown-input-multiline:empty::before {
pointer-events: none;
display: block; /* For Firefox */
content: attr(placeholder);
Copy link

@Pujan92 Pujan92 Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BartoszGrajdek Why do we removed this part? It seems to cause an issue of not showing the placeholder

https://expensify.slack.com/archives/C049HHMV9SM/p1755884247194659

Screenshot 2025-08-23 at 00 20 01

@mountiny
Copy link

Lets please get @Expensify/design involved whenever there are changes to how things look in the App. Was this look of the code block in composer vetted before? Apologies if that was already discussed somewhere else than this PR.

image

@dannymcclain
Copy link

Lets please get @Expensify/design involved whenever there are changes to how things look in the App. Was this look of the code block in composer vetted before? Apologies if that was already discussed somewhere else than this PR.

Yeah this composer style isn't looking right to me. I'm not against including the monospace font style & background + border styles in the composer, but if we're going to do that, we need the styles to match the end result (the sent message styles). Currently the colors look different and wrong to me. cc @dubielzyk-expensify

@mountiny
Copy link

I believe @Skalakid will update the styles of that in the App PR, so please let us know how you think it should look like Expensify/App#69158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants