Support for inline uneditable/dynamic nodes

Open
#144 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
typescript
Domain
frontend

Research direction

Start by reviewing the model and SelectionRange behavior described in the issue, then trace how inline content affects offsets during deletion. The issue names no files or tests, so first clarify the desired native API and synchronization semantics for uneditable dynamic nodes; done should include agreed behavior and coverage for deletion after an inline node.

Written by the indexing model from the issue text.

Description

First off, thanks for creating Svedit, it's a really great library! I appreciate how flexible it is and the thoughtful design decisions that went into it. I've been following it for a while, it's really cool work!

I was wondering if inlining uneditable/dynamic nodes was something on your roadmap. I'm thinking of cases like @user-mentions (where usernames may change) or references to other resources that may change over time and would be inlined in a paragraph – essentially content that shouldn't be hardcoded in the document because it needs to stay in sync with external data.

I tried different approaches and managed to get pretty far with a very basic implementation, but I'm clearly going against the grain, especially because I'm trying not to change the core Svedit files so that I can easily update them as you drop new features.

The main issue is that since the content I'm inserting is dynamic, I'm inlining the node but not inserting the content in the model. This pretty much works but breaks when deleting content that follows that node, since the offsets calculated from the SelectionRange will be out of sync with the character length.

Have you already thought about this use case? Do you have any suggestions for how to approach this, or is this something you'd consider adding native support for? I'm happy to share more details about my current implementation if that would be helpful!

Dominant language
TypeScript
Stars
691
Forks
20
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from michael/svedit

All issues in michael/svedit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.