Giter Club home page Giter Club logo

Comments (10)

kumarajay0412 avatar kumarajay0412 commented on July 17, 2024 1

Hey @zbeyens pls look into the PR that i opened regarding above bug

from plate.

kumarajay0412 avatar kumarajay0412 commented on July 17, 2024

I think this issue is caused by isCollapsed function which is using range.isCollapsed from slate

  isCollapsed(range: Range): boolean {
    const { anchor, focus } = range
    return Point.equals(anchor, focus)
  },

the problem is arising because our anchor and focus are equal but we have different offsets which is making isCollapsed false

from plate.

felixfeng33 avatar felixfeng33 commented on July 17, 2024

Yes, for the sake of reducing the complexity of the work, we haven't considered the expanded situation temporarily.

from plate.

kumarajay0412 avatar kumarajay0412 commented on July 17, 2024

@felixfeng33 can i create a PR for this fix by adding below function

const isCollapsedInternalFunction = (range?: Range | null) => {

  // Early return for null or undefined range
  if (!range ||!range.anchor ||!range.focus) {
    return false;
  }

  // Destructure the anchor and focus properties for easier access
  const { anchor, focus } = range;
  const { anchor, focus } = range;

  // Check if both anchor and focus exist and have the same path coordinates
  if (anchor && focus && anchor.path.length > 0 && focus.path.length > 0) {
    return anchor.path[0] === focus.path[0] && anchor.path[1] === focus.path[1];
  }
};

from plate.

felixfeng33 avatar felixfeng33 commented on July 17, 2024

I think you can check the parent node props in the else statement.

from plate.

felixfeng33 avatar felixfeng33 commented on July 17, 2024

In your solution could I selection cross block?
image

from plate.

kumarajay0412 avatar kumarajay0412 commented on July 17, 2024

yes you can do cross selection in blocks as alignment is always block level

I have a question if a selection has first block center next block left what should be the overall alignment to be shown on top in mostly cases we show first block selection details can we do the same here

from plate.

felixfeng33 avatar felixfeng33 commented on July 17, 2024

It's better the overall alignment is none.

from plate.

felixfeng33 avatar felixfeng33 commented on July 17, 2024

I think we had better do some thing here since it's have more readability·
if (isCollapsed(editor.selection)) {
}else {
do some check here
}

from plate.

zbeyens avatar zbeyens commented on July 17, 2024

We should check the value of all selected blocks using getNodeEntries, and return true only if every block has the same value. One different value makes it false (like marks).

from plate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.