summernote icon indicating copy to clipboard operation
summernote copied to clipboard

Rework bullet points

Open HoffmannTom opened this issue 1 year ago • 3 comments

What does this PR do?

Working with bullet points was sometimes problematic when whitespaces were present. Copy & Paste also caused some trouble. This PR modifies the bullet point functions For this to work, the dom and range class were extended by adding some helper functions.

Where should the reviewer start?

  • best is to start with dom.js and range.js and check the additional methods.
  • bullet.js contains major changes

How should this be manually tested?

  • use the editor to create and modify lists (OL / UL)

Any background context you want to provide?

If a li-element contains formattings or additional elements (div, span), the splitNode function doesn't work well and creates some additional lines or refuses to split. This needs to be addressed in the future. The splitNode function was not modified by this PR.

What are the relevant tickets?

Screenshot (if for frontend)

Checklist

  • [x] Added relevant tests or not required
  • [X] Didn't break anything

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced DOM manipulation capabilities with improved empty node detection and traversal logic.
    • Introduced methods for setting range endpoints and retrieving child nodes in the WrappedRange class.
    • Improved handling of list and paragraph structures during indentation and toggling of lists.
  • Bug Fixes

    • Refined Instagram URL matching for better embedding functionality.
  • Tests

    • Updated tests for indentation functionality to reflect new behavior.
    • Added tests for embedding Instagram reel URLs to ensure proper handling.

HoffmannTom avatar Sep 12 '24 09:09 HoffmannTom

Walkthrough

The changes encompass enhancements across multiple files, focusing on improved DOM manipulation, range handling, list editing functionality, and Instagram URL processing. Key updates include refined empty node detection, new traversal methods, and modifications to the WrappedRange class for better range endpoint management. Additionally, the handling of list indentation and toggling has been improved, and test cases have been updated to reflect these changes, ensuring robust functionality and accurate behavior in various scenarios.

Changes

Files Change Summary
src/js/core/dom.js, src/js/core/range.js, src/js/editing/Bullet.js Enhancements to DOM manipulation, including empty node detection, traversal logic, and improved handling of lists and ranges. New utility functions and modified existing methods were introduced.
src/js/module/VideoDialog.js Updated regex for Instagram URL matching, changing capturing groups to non-capturing for efficiency and accuracy in iframe source URL construction.
test/base/module/Editor.spec.js, test/base/module/VideoDialog.spec.js Modifications to test cases to align with updated indentation logic and added tests for new Instagram reel URL handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Editor
    participant DOM
    participant Range

    User->>Editor: Indent list
    Editor->>DOM: Retrieve paragraph nodes
    DOM-->>Editor: Return nodes
    Editor->>Range: Set range endpoints
    Range-->>Editor: Confirm range
    Editor->>DOM: Update DOM structure
    DOM-->>User: Display updated list

🐇 In the garden, hopping with glee,
Changes abound, as bright as can be!
Nodes now detected, both empty and full,
With lists and ranges, our edits are cool.
So here’s to the code, so clever and neat,
A joyful leap, oh what a treat! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Sep 12 '24 09:09 coderabbitai[bot]

Hello @hackerwins sure, would be nice to tackle some issues together. When deleting lines within bulletpoint list, you get into this situation:

  • line1
    • line 2.1
    • line 2.2

You are not able to access the second line on level 1. In order to access this point, you need a <br> :

  • line1

    • line 2.1
    • line 2.2

The changes should (hopefully) fix the issue. In order to be able to place the cursor, the BR element is added. This is also the default behaviour if you just use a <div contenteditable=true> element. So this change mimicks the default browser behaviour.

HoffmannTom avatar Sep 13 '24 15:09 HoffmannTom

@HoffmannTom https://github.com/summernote/summernote/pull/4684#issuecomment-2364738438

hackerwins avatar Sep 20 '24 23:09 hackerwins