Skip to content
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

[Bug] Heading level specific padding stops cursor #656

Closed
alterhuman opened this issue Jan 9, 2024 · 1 comment · Fixed by #657 or #751
Closed

[Bug] Heading level specific padding stops cursor #656

alterhuman opened this issue Jan 9, 2024 · 1 comment · Fixed by #657 or #751
Assignees

Comments

@alterhuman
Copy link

Bug Description

Adding a different padding for each heading level stops the cursor from moving up using the arrow key when it is at a heading.

How to Reproduce

To reproduce, specify different padding for each heading level in the HeadingBlockComponentBuilder.

BlockComponentBuilder headingBlock(BuildContext context) {
  final baseHeadingStyle = TextStyle(
    letterSpacing: -1,
    fontWeight: FontWeight.w500,
    color: context.palette.primary,
  );

  return HeadingBlockComponentBuilder(
    configuration: BlockComponentConfiguration(
      padding: (node) {
        // No top padding for first line/paragraph
        if (node.previous == null) {
          return const EdgeInsets.only(top: 0, bottom: 8);
        }

        switch (node.attributes[HeadingBlockKeys.level]) {
          case 1:
            return const EdgeInsets.only(top: 20, bottom: 8);
          case 2:
            return const EdgeInsets.only(top: 17, bottom: 8);
          case 3:
            return const EdgeInsets.only(top: 14, bottom: 8);
          case 4:
            return const EdgeInsets.only(top: 11, bottom: 8);
          case 5:
            return const EdgeInsets.only(top: 8, bottom: 8);
          case 6:
            return const EdgeInsets.only(top: 5, bottom: 8);
          default:
            return const EdgeInsets.only(top: 5, bottom: 8);
        }
      },
    ),
    textStyleBuilder: (level) {
      switch (level) {
        case 1:
          return baseHeadingStyle.copyWith(fontSize: 22);
        case 2:
          return baseHeadingStyle.copyWith(fontSize: 19);
        case 3:
          return baseHeadingStyle.copyWith(fontSize: 17.7);
        case 4:
          return baseHeadingStyle.copyWith(fontSize: 16);
        case 5:
          return baseHeadingStyle.copyWith(fontSize: 14.5);
        case 6:
          return baseHeadingStyle.copyWith(fontSize: 13.8);
        default:
          return baseHeadingStyle.copyWith(fontSize: 13.8);
      }
    },
  );
}

Expected Behavior

The cursor should be able to move up using the arrow key.

Operating System

MacOS

AppFlowy Editor Version(s)

2.2.0

Screenshots

Screenshot 2024-01-09 at 5 46 23 AM

Unable to move my cursor to the 'Hi' line using the up arrow key.

Additional Context

It works fine if I return only a single padding.

@q200892907
Copy link
Contributor

#589 should be a problem

@LucasXu0 LucasXu0 self-assigned this Jan 9, 2024
Jei-sKappa added a commit to Jei-sKappa/appflowy-editor that referenced this issue Mar 21, 2024
Previously the `moveVertical` function only moved the cursor 'node to node' without thaking into consideration multiline nodes or some portion of a line with different fontSize (ex: a paragraph with size 16 but with a bolded word with size 32). This was caused by the PR AppFlowy-IO#657 that closes AppFlowy-IO#656 and AppFlowy-IO#589.
Jei-sKappa added a commit to Jei-sKappa/appflowy-editor that referenced this issue Mar 28, 2024
Previously the `moveVertical` function only moved the cursor 'node to node' without thaking into consideration multiline nodes or some portion of a line with different fontSize (ex: a paragraph with size 16 but with a bolded word with size 32). This was caused by the PR AppFlowy-IO#657 that closes AppFlowy-IO#656 and AppFlowy-IO#589.
Jei-sKappa added a commit to Jei-sKappa/appflowy-editor that referenced this issue Apr 13, 2024
Previously the `moveVertical` function only moved the cursor 'node to node' without thaking into consideration multiline nodes or some portion of a line with different fontSize (ex: a paragraph with size 16 but with a bolded word with size 32). This was caused by the PR AppFlowy-IO#657 that closes AppFlowy-IO#656 and AppFlowy-IO#589.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants