Unable to programmatically select a single inline element

オープン
#2,864 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
typescript
領域
frontend

調査の方向性

Start with packages/core/src/api/blockManipulation/selections/selection.ts and the editor.setSelection entry point mentioned in the issue. Trace how single inline selections are represented and why forcing a ProseMirror selection opens the formatting toolbar. Done means a single inline element can be selected through editor.setSelection and callers can control whether the formatting toolbar opens.

索引モデルが issue の本文から書いたものです。

説明

bug:P2
What’s broken?

At OpenProject, we're building an extension to have custom work package links for the BlockNote editor.
However, currently the behaviour when clicking on such an inline link is broken:

  1. The user expects after clicking on the element that when Ctrl-C and Ctrl-V are pressed, the work package link is copied
  2. The user expects after clicking on the element and pressing "del" or "backspace" that the element is removed from the document

It would be easy to solve both expectations, if we could select a single inline block. However, this is not possible at the moment via BlockNote, because it's not possible to select a single inline content.

Furthermore, when we force selection via ProseMirror, BlockNote opens a formatting toolbar. This toolbar does not make sense in our case, since you can't e.g. change font boldness or italics on our custom inline work package link.

What did you expect to happen?

What we need is:

  1. Be able to select a single inline element via editor.setSelection
  2. Be able to pass in if we want the formatting toolbar to open or not, e.g. showFormattingToolbar: true|false
Steps to reproduce
  1. Write your own extension with inline elements
  2. Try editor.setSelection on a single inline element
BlockNote version

0.51.3

Environment

No response

Additional context
Image

We would like to solve this in a clean way 🙂 At the moment we're exploring the following options:

  • Set selection via ProseMirror (solves our requirements but opens formatting toolbar)
  • Attach our own handlers which intercept copy-paste, keypress etc. when the inline element was clicked (and remove the handlers when the focus is removed)

If you see other good ways to solve our problem, we're happy about suggestions!

Contribution
  • I'd be interested in contributing a fix for this issue
Sponsor
  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖
主要言語
TypeScript
スター
10.2k
フォーク
772
平均マージ
3日 11時間
マージ済み PR(30日)
17

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TypeCellOS/BlockNote のほかの issue

TypeCellOS/BlockNote の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。