Repository navigation
feat(swift): port @lexical/hashtag - #35
Merged
Merged
Conversation
Adds LexicalHashtag, ported from packages/lexical-hashtag/src: HashtagNode, createHashtagNode, isHashtagNode, HashtagExtension, HashtagConfig and registerLexicalHashtag, built on LexicalText's registerLexicalTextEntity. lexical-hashtag is enforced in the parity ledger. JS matches with a regular expression with the i flag and without u, which reads UTF-16 code units and folds case with Canonicalize. The matcher runs that expression by hand over code units with the same folding, from JS's character tables. New vectors in vectors/entities check it on text in many scripts, and the documents the transforms leave when text is set at once or typed a character at a time. The TextKit views style a text node of a type other than text with the theme style of that type, as its createDOM adds that class, and the default theme gives hashtags the web playground's background. The playground registers HashtagExtension in both modes, as the web one does. The hashtag cases that waited for this package are ported: 34 in lexical-text and 6 in lexical-markdown (meta#5366). Those that also need @lexical/mark stay skipped. Amp-Thread-ID: https://ampcode.com/threads/T-01a19fce-8f8f-751a-afa3-961a37bb1a98
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Ports
@lexical/hashtagasLexicalHashtag:HashtagNode,createHashtagNode,isHashtagNode,HashtagExtension,HashtagConfigandregisterLexicalHashtag, built onLexicalText'sregisterLexicalTextEntity.lexical-hashtagisenforcedin the parity ledger.JS matches hashtags with a regular expression that has the
iflag and nouflag, so it reads UTF-16 code units and folds case with the spec'sCanonicalize. Swift's regular expressions read Unicode scalars and fold case differently. So the same expression runs by hand over code units, with JS's character tables, including the CJK ranges thatString.fromCharCodetruncates. New vectors invectors/entitiescheck the matcher on 55 texts in many scripts. They also check the documents the transforms leave when text is set at once or typed one character at a time.The TextKit views style a text node whose type is not
textwith the theme style of its type, as itscreateDOMadds that class, and the default theme gives hashtags the web playground's background. The playground'sborder-bottomis not drawn. The Swift playground registersHashtagExtensionin both modes, as the web one does.The hashtag cases that waited for this package are now ported: 34 in
lexical-textand 6 inlexical-markdown(meta#5366). The ones that also need@lexical/markstay skipped.Test plan
Before
lexical-hashtagwas not in the ledger, andlexical-texthad 58 ported and 51 skipped.After
swift format lint --strict --recursive Sources Tests Benchmarks Package.swift: cleanswift build --build-tests && swift test --skip-build: every suite passes; the known issues are the existingwithKnownIssuecases, including upstream'stest.failsfor Bug: [lexical-text] A lookbehind matcher over repeated characters drops NodeState from a character the user did not type meta/lexical#9725pnpm --filter lexical-conformance run test:Test Files 10 passed (10),Tests 24 passed (24)pnpm --filter lexical-conformance run check-ledger:lexical-text | enforced | 109 | 92 | 17 | 0,lexical-hashtag | enforced | 1 | 1 | 0 | 0,lexical-markdown | enforced | 1064 | 616 | 448 | 0npx tsc -p ./tsconfig.build.json --noEmit: cleanword#tag. Typing could not be driven on the test Mac: synthetic keystrokes drop characters in every app there, TextEdit included.