lexical_hashtag 1.3.0 copy "lexical_hashtag: ^1.3.0" to clipboard
lexical_hashtag: ^1.3.0 copied to clipboard

Hashtag nodes for lexical_core, wire-compatible with Lexical's @lexical/hashtag. Pure Dart.

lexical_hashtag

lexical_hashtag #

Hashtag nodes for lexical_core. Pure Dart.

dependencies:
  lexical_hashtag: ^1.0.0
final editor = LexicalEditor(nodes: hashtagNodes);

editor.update(() {
  $getRoot().append(
    $createParagraphNode()..append($createHashtagNode('#flutter')),
  );
}, discrete: true);
final editor = LexicalEditor(nodes: hashtagNodes);
registerHashtag(editor);   // finds `#flutter` as it is typed

Detection is a pair of transforms and both directions matter: text that becomes a tag turns into one, and a tag that stops looking like one — the # deleted, a word typed onto the end — turns back into text. A # only counts at the start of a word, so a#b and the fragment in a URL are left alone, and so is anything inside a code block.

A hashtag is a TextNode subclass with no extra fields — only its type string differs on the wire. That alone makes it non-mergeable with the text around it, which is exactly what a tag needs: it stays one addressable run instead of dissolving into the sentence on the next normalization pass.

Wire-compatible with @lexical/hashtag 0.48.x.

Hover and tap #

A hashtag is worth rendering only if it leads somewhere. Pass its type to a LexicalInteraction in lexical_flutter and hovering or tapping one reports it, with its text and its bounds for anchoring a preview:

LexicalInteraction(
  types: const {'hashtag'},
  onTap: (hit) => search(hit.text),
)

Licence #

MIT. Derived from Lexical, © Meta Platforms, Inc., also MIT. See NOTICE.

0
likes
0
points
544
downloads

Publisher

verified publisherahmadre.com

Weekly Downloads

Hashtag nodes for lexical_core, wire-compatible with Lexical's @lexical/hashtag. Pure Dart.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

lexical_core, meta

More

Packages that depend on lexical_hashtag