-
-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(blocks): unexpected newline appears while pasting multiply-paragr… #8154
base: master
Are you sure you want to change the base?
Conversation
…aph-blocks to code-block
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
Your org has enabled the Graphite merge queue for merging into masterAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 0e605b3. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 3 targetsSent with 💌 from NxCloud. |
…iply-paragraph-blocks-to-code-block
…iply-paragraph-blocks-to-code-block
…iply-paragraph-blocks-to-code-block
…iply-paragraph-blocks-to-code-block
@@ -232,6 +232,7 @@ export class PlainTextAdapter extends BaseAdapter<PlainText> { | |||
return null; | |||
} | |||
payload.file = payload.file.replaceAll('\r', ''); | |||
payload.file = payload.file.replace(/\n$/, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason is in the exporter side, not here. @fourdim cc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, i think so too , here is the export side in /packages/blocks/src/_common/adapters/plain-text.ts
private async _traverseSnapshot(
snapshot: BlockSnapshot
): Promise<{ mixtext: string }> {
...
walker.setEnter(o => {
const text = (o.node.props.text ?? { delta: [] }) as {
delta: DeltaInsert[];
};
switch (o.node.flavour) {
...
case 'affine:paragraph': {
buffer += text.delta.map(delta => delta.insert).join('');
buffer += '\n';
break;
}
...
but i think change here will affect a lot , so i only change the adapter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, changing this adapter will affect a lot.
It's not about adding an extra newline at the end of a file, it's about not removing the newline that should be there.
The C standard specifies that a C file should end with a newline (C11, 5.1.1.2, 2.) and that a last line without a newline yields undefined behavior (C11, J.2, 2nd item).
@@ -232,6 +232,7 @@ export class PlainTextAdapter extends BaseAdapter<PlainText> { | |||
return null; | |||
} | |||
payload.file = payload.file.replaceAll('\r', ''); | |||
payload.file = payload.file.replace(/\n$/, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, changing this adapter will affect a lot.
It's not about adding an extra newline at the end of a file, it's about not removing the newline that should be there.
The C standard specifies that a C file should end with a newline (C11, 5.1.1.2, 2.) and that a last line without a newline yields undefined behavior (C11, J.2, 2nd item).
…aph-blocks to code-block
issue
effect as follow