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

Move rendering responsibility fully into React #47

Open
wants to merge 61 commits into
base: main
Choose a base branch
from

Commits on Nov 17, 2023

  1. Configuration menu
    Copy the full SHA
    e98bce6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    76282b6 View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2024

  1. Introduce custom ViewDesc implementations.

    The ViewDesc classes are where prosemirror-view actually does all of
    its rendering work. We are introducing stubs of these classes that
    reproduce all of the functionality of the originals, but do not provide
    update or destroy methods, which means that they do not actually do any
    DOM manipulation.
    
    The goal is to later introduce React components that replicate the
    rendering functionality of the original ViewDesc classes.
    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    2a7d691 View commit details
    Browse the repository at this point in the history
  2. Add a React component for each ViewDesc.

    This commit adds a new React component for each ViewDesc subclass
    (NodeView, MarkView, etc.). These React components take the place of
    the update methods from prosemirror-view's original ViewDesc classes.
    
    In order to maintain React element and DOM node stability, this commit
    also introduces a more robust reactKeys plugin that accounts for text
    nodes in addition to non-text nodes.
    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    514bc5e View commit details
    Browse the repository at this point in the history
  3. Add some hooks to replace EditorView functionality

    The useBeforeInput hook replaces the DOMObserver functionality that
    we plan to remove from EditorView.
    
    usePluginViews manages plugin view updates, to ensure that they occur
    after the DOM has been updated to match the state.
    
    useSyncSelection similarly ensures that the ProseMirror selection is
    synced to the DOM after the DOM has been updated to match the state.
    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    84a36c6 View commit details
    Browse the repository at this point in the history
  4. Add a selection-only DOMObserver.

    EditorView's DOMObserver uses a Mutation Observer to detect changes to
    the contenteditable, and then attempts to deduce the intended change to
    state from that. This introduces challenges when applied to React's
    unidirection data flow model.
    
    To work around this, we use a beforeinput handler to detect changes
    before they're committed to the DOM. This means our DOMObserver only
    needs to worry about syncing the selection, so we added a custom one
    that only has that concern, but matches the API of the original
    implementation.
    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    6d3d0e0 View commit details
    Browse the repository at this point in the history
  5. Update ProseMirror component to use new systems.

    Fully integrates the new components and hooks into the ProseMirror
    component. This includes subclassing EditorView to override some of
    its properties, like the docNodeView and domObserver.
    
    This commit also adds a full test suite for the ProseMirror component's
    editing functionality.
    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    10cf9fb View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a4ac64f View commit details
    Browse the repository at this point in the history
  7. Minor README update

    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    7ee305f View commit details
    Browse the repository at this point in the history
  8. Update VS Code autofix settings

    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    c75e0f9 View commit details
    Browse the repository at this point in the history
  9. Add a ProseMirrorDoc component

    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    ee2900b View commit details
    Browse the repository at this point in the history
  10. Add ProseMirrorDoc to test helper

    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    cac04dc View commit details
    Browse the repository at this point in the history
  11. Map positions forward to maintain key stability

    Rather than attempting to map the new node positions backward to
    determine what the key used to be for that node, start with the previous
    positions and map them forward, taking care to skip any positions that
    are deleted by the transaction, and adding any new nodes that didn't
    exist in the old doc. This improves stability and correctness in more
    complex cases, such as splitting or wrapping nodes, and nested
    deletions.
    smoores-dev authored and tilgovi committed Feb 2, 2024
    Configuration menu
    Copy the full SHA
    70dc89b View commit details
    Browse the repository at this point in the history

Commits on Feb 24, 2024

  1. Configuration menu
    Copy the full SHA
    b419801 View commit details
    Browse the repository at this point in the history
  2. Always call LayoutGroup effect destroy functions.

    This resolves an issue where LayoutGroup effects were not cleaned up
    when the LayoutGroup itself was unmounted. React executes layout effect
    destroy functions from parent to child on unmount, which is opposite how
    it runs during normal render. The result was that the destroyQueue was
    never processed on unmount.
    
    Now, if the LayoutGroup is being unmounted, we call destroy functions
    immediately, without queuing.
    smoores-dev committed Feb 24, 2024
    Configuration menu
    Copy the full SHA
    da2f9f3 View commit details
    Browse the repository at this point in the history

Commits on Mar 4, 2024

  1. Always provide non-null state and view in hooks.

    This tracks a few PRs from main that update hooks like useEditorState and
    useEditorEffect to always provide non-null state and view objects.
    
    It also updates the useEditorView hook (now useEditor) to look more like
    that on main, inlining several function calls and moving most hook usage
    from the ProseMirror component into the useEditor hook.
    smoores-dev committed Mar 4, 2024
    Configuration menu
    Copy the full SHA
    9366b4e View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2024

  1. Add support for native ProseMirror widget decorations (#115)

    * Add a component for rendering ProseMirror-native widgets
    
    * Support plugin-provided custom node views
    smoores-dev authored Mar 7, 2024
    Configuration menu
    Copy the full SHA
    c6d606e View commit details
    Browse the repository at this point in the history
  2. Wrap the DocNodeView in a ChildDescriptorContext. (#116)

    When rendering nested ProseMirror editors, e.g.
    when taking control over an atom node's content,
    the nested DocNodeView would register itself as
    the child of the atom node in the view descriptor
    tree. This could cause subtle issues when, e.g.,
    ProseMirror attempts to determine whether the
    content is ltr or rtl, because it would treat the
    nested editor as the contentDOM of the atom, even
    if it was rendered in a portal into a non-
    contiguous part of the page. Presumably other
    issues could also arise from the fact that
    ProseMirror thought this node had a contentDOM
    when it actually does not.
    
    This change resolves this by simply providing a top-
    level ChildDescriptorContext, so that nested
    editors never accidentally cross the boundary up
    into their parents' view descriptor tree.
    smoores-dev authored Mar 7, 2024
    Configuration menu
    Copy the full SHA
    964fc45 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    cd22e12 View commit details
    Browse the repository at this point in the history

Commits on Mar 17, 2024

  1. Add "trailing hacks" in more scenarios. (#122)

    Browsers have very particular opinions about where they will allow
    users to place selections in contenteditable elements. ProseMirror
    manages this in part by placing <br> elements in locations that
    browsers otherwise wouldn't allow user selections.
    
    This PR brings react-prosemirror closer to matching all of the
    situations that ProseMirror itself uses these "trailing hacks". Rather
    than only in empty textblocks, we now also place trailing hacks when
    a textblock node ends with a non-text node, a widget, or a text node
    that ends with a newline.
    
    Also, Safari and Chrome both have cursor drawing/selection bugs that
    prevent users from making selections after non-contenteditable
    inline nodes in some situations. To work around this, in these
    browsers, we add an empty image element between the trailing non-
    contenteditable node and the "trailing hack", which allows users
    to place cursors there.
    smoores-dev authored Mar 17, 2024
    Configuration menu
    Copy the full SHA
    c90da83 View commit details
    Browse the repository at this point in the history

Commits on May 6, 2024

  1. Make proper use of view.someProp

    There were a few places where we incorrectly used view.someProp to
    retrieve a prop value, and then did something with the value. This will
    _always_ result in the first value being returned, even in cases where
    multiple plugins provide a value for the prop, and only some of them
    are relevant at the callsite.
    
    Instead, we now pass a function to view.someProp that only returns a
    truthy value when it has found a prop provider that provides the
    relevant value, so that we can fallback through the entire list of
    plugins.
    smoores-dev committed May 6, 2024
    Configuration menu
    Copy the full SHA
    7131045 View commit details
    Browse the repository at this point in the history

Commits on May 23, 2024

  1. Add support for multi-code-point unicode characters.

    Previously, `deleteContentBackward|Forward` inputs would delete exactly
    one code point. This created invalid strings when the last code point
    was part of a multi-code-point character.
    
    To resolve this, we now determine the length of the unicode character,
    and delete by that many code points, which matches default
    contentEditable behavior.
    smoores-dev committed May 23, 2024
    Configuration menu
    Copy the full SHA
    7d0923e View commit details
    Browse the repository at this point in the history
  2. Replace custom deletion code with getTargetRanges

    Rather than using Slate.js's more manual approach for determining how
    many code points to delete when handling a deleteContentBackward|Forward
    input type, rely on the browser's default determination via
    getTargetRanges.
    smoores-dev committed May 23, 2024
    Configuration menu
    Copy the full SHA
    7395a5b View commit details
    Browse the repository at this point in the history

Commits on Aug 9, 2024

  1. Configuration menu
    Copy the full SHA
    c32cc45 View commit details
    Browse the repository at this point in the history

Commits on Sep 4, 2024

  1. Better conversion from html attributes to react props (#130)

    * Disable react/prop-types lint rule
    
    * Flesh out conversion from html attributes to react props
    
    * Properly merge decorations/props with outputspecs
    
    * Use CSSOM to parse style attributes
    
    * Re-enable react/prop-types rule
    smoores-dev authored Sep 4, 2024
    Configuration menu
    Copy the full SHA
    ff0afd1 View commit details
    Browse the repository at this point in the history

Commits on Sep 6, 2024

  1. Configuration menu
    Copy the full SHA
    e2f94b3 View commit details
    Browse the repository at this point in the history

Commits on Sep 16, 2024

  1. Configuration menu
    Copy the full SHA
    2eecee2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ac1d16a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5c57390 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    edd1829 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    897a744 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    01c982d View commit details
    Browse the repository at this point in the history
  7. Get draw tests working

    smoores-dev committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    385f6eb View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    4c2523c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    5a9c82a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    70c5235 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    9b58c9d View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    e8a4dda View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    aa8ef57 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    c444bf6 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    b4b5c74 View commit details
    Browse the repository at this point in the history

Commits on Sep 17, 2024

  1. Configuration menu
    Copy the full SHA
    0c93e2e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e194d3e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0774922 View commit details
    Browse the repository at this point in the history
  4. committing the previous prerelease version

    and running yarn version prerelease
    saranrapjs committed Sep 17, 2024
    Configuration menu
    Copy the full SHA
    bef98f3 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    2a77f4c View commit details
    Browse the repository at this point in the history
  6. Add useStopEvent hook

    smoores-dev committed Sep 17, 2024
    Configuration menu
    Copy the full SHA
    b49651b View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2024

  1. chore: release 0.7.0-next.10

    tilgovi committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    243dea9 View commit details
    Browse the repository at this point in the history

Commits on Sep 19, 2024

  1. Configuration menu
    Copy the full SHA
    8a475d0 View commit details
    Browse the repository at this point in the history

Commits on Sep 20, 2024

  1. Configuration menu
    Copy the full SHA
    26914ac View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    880d9cf View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a11110c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9ccbe4c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    4f9b491 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b7897ad View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    ddec299 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    dad46ac View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2024

  1. Test CI

    smoores-dev committed Oct 12, 2024
    Configuration menu
    Copy the full SHA
    de20171 View commit details
    Browse the repository at this point in the history

Commits on Nov 9, 2024

  1. Support Strict mode and memoize node view components (#142)

    The primary goal of these changes is to allow a single node view component to re-render in isolation without affecting the correctness of the view descriptor tree.
    
    Previously, it was required that the entire ProseMirror component tree re-render on every document update in order to maintain the view descriptor tree. The trees are built from the leaves up in useLayoutEffects, and the tree was built from scratch on each render cycle.
    
    Now, the view descriptors are maintained in refs across renders, and mutated as needed, rather than built from scratch. This fixes an issue with strict mode (#128), since strict mode will render each component twice when it's first mounted. It also allows us to wrap each view component in React.memo, which quite dramatically improves the performance of the editor on very long documents.
    smoores-dev authored Nov 9, 2024
    Configuration menu
    Copy the full SHA
    aa1dfee View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2024

  1. Configuration menu
    Copy the full SHA
    ac622d7 View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2024

  1. chore: release 0.7.0-next.11

    tilgovi committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    ab0f6e5 View commit details
    Browse the repository at this point in the history