Merge branch 'dev' into feat/compat/pluralkit
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Add detailed error messages to forwarding failures.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
# Add black theme
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Add /location sharing command, and a /sharemylocation command.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
added the posibility to send using per message profiles with `/usepmp`
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Add quick reply keybinds by using <kbd>ctrl</kbd>+<kbd>up</kbd> / <kbd>ctrl</kbd>+<kbd>down</kbd> you can now cycle through the message you are replying to with keybinds
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Cap unread badge numbers at `1k+`, and something extra :)
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Add room abbreviations with hover tooltips: moderators define term/definition pairs in room settings; matching terms are highlighted in messages.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
fix [accidental leaking of private nicknames](https://github.com/SableClient/Sable/issues/362) for users to be included in the message
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fixes the most recent pmp message in encrypted rooms not consistently rendering the pmp and not grouping with previous pmps.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
fixed sending sticker and attachments while having a persona selected
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Hide presence badge in members list for users without homeserver support, mimicking room profile apperance.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix broken link to Sliding Sync known issues — now points to SableClient/Sable#39 instead of the old repository.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Tighten sliding sync memory management: stop the polling loop on client dispose, persist then prune large room timelines when leaving a room, remove adaptive timeline-limit logic, and auto-unsubscribe when the local user leaves or is banned from a room.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix service worker authenticated media requests returning 401 errors after SW restart or when session data is missing/stale.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix thread drawer showing no messages when using classic sync.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Hide the redundant "Thread" indicator badge in the compose box when inside the Thread Drawer.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Reduce dead space around the root message in the thread drawer.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
# Fix confusing ui with `Client Side Embeds in Encrypted Rooms` setting
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
fix forwarding metadata by removing the `null` value
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
fix the display of jumbo emojis on messages sent with a persona
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix sidebar notification badge positioning so unread and unverified counts align consistently.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
# Add support for timestamps, playlists and youtube music links for the youtube embeds
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Added a toggle to notifications to disable full message mention highlighting.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: note
|
||||
---
|
||||
|
||||
moved the setting for filtering pronouns by language from experimental to the appearance setting
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Added a setting to Appearance that attempts to convert text in names like (it/its) into a pronoun pill, enlabed by default.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Reduced the opacity of mention highlight backgrounds to be less visually intrusive while remaining noticeable.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Use the browser's native compact number formatting for room and member counts.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
fix(sentry): scrub percent-encoded Matrix IDs and opaque base64url tokens from Sentry URLs
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
Add settings sync across devices via Matrix account data, with JSON export/import
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
default: minor
|
||||
---
|
||||
|
||||
# Update calls to have RNNoise noise suppression.
|
||||
@@ -1,4 +1,4 @@
|
||||
<!-- Please read https://github.com/ajbura/cinny/blob/dev/CONTRIBUTING.md before submitting your pull request -->
|
||||
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request -->
|
||||
|
||||
### Description
|
||||
|
||||
@@ -20,3 +20,9 @@ Fixes #
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
|
||||
### AI disclosure:
|
||||
|
||||
- [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
|
||||
- [ ] Fully AI generated (explain what all the generated code does in moderate detail).
|
||||
<!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
|
||||
@@ -46,9 +46,10 @@ updates:
|
||||
commit-message:
|
||||
prefix: chore
|
||||
groups:
|
||||
# Group all non-major updates together to reduce noise
|
||||
npm-minor-patch:
|
||||
npm-major:
|
||||
update-types:
|
||||
- major
|
||||
npm-non-major:
|
||||
update-types:
|
||||
- minor
|
||||
- patch
|
||||
# Major updates are ungrouped so they get individual review
|
||||
@@ -20,7 +20,7 @@ on:
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.TF_CLOUDFLARE_API_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TF_VAR_workers_message: ${{ github.event_name == 'pull_request' && github.event.pull_request.title || github.event.head_commit.message || github.sha }}
|
||||
TF_VAR_workers_message: ${{ github.event_name == 'pull_request' && github.event.pull_request.title || github.ref_name }}
|
||||
TF_VAR_account_id: ${{ secrets.TF_VAR_ACCOUNT_ID }}
|
||||
TF_VAR_zone_id: ${{ secrets.TF_VAR_ZONE_ID }}
|
||||
TF_HTTP_ADDRESS: ${{ secrets.TF_HTTP_ADDRESS }}
|
||||
|
||||
@@ -14,10 +14,18 @@ jobs:
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Generate bot token
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859
|
||||
with:
|
||||
app-id: ${{ secrets.APP_ID }}
|
||||
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
persist-credentials: true
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
|
||||
- uses: knope-dev/action@19617851f9f13ab2f27a05989c55efb18aca3675 # v2.1.2
|
||||
with:
|
||||
@@ -26,4 +34,4 @@ jobs:
|
||||
- name: Create Release
|
||||
run: knope release --verbose
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
@@ -1,5 +1,157 @@
|
||||
# Sable Client Changelog
|
||||
|
||||
## 1.12.3 (2026-03-24)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fixed text autocomplete issues ([#487](https://github.com/SableClient/Sable/pull/487) by @nushea)
|
||||
* Fix crash when url contains malformed/dangling uri components. ([#512](https://github.com/SableClient/Sable/pull/512) by @7w1)
|
||||
|
||||
## 1.12.2 (2026-03-24)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix standard embed links not rendering. ([#506](https://github.com/SableClient/Sable/pull/506) by @7w1)
|
||||
* Added maximum height to state events ([#491](https://github.com/SableClient/Sable/pull/491) by @nushea)
|
||||
|
||||
## 1.12.1 (2026-03-24)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Change cloudflare deploy worker message to something much shorter to avoid char limit. ([#504](https://github.com/SableClient/Sable/pull/504) by @7w1)
|
||||
|
||||
## 1.12.0 (2026-03-24)
|
||||
|
||||
### Features
|
||||
|
||||
* `Ctrl + K` search menu is now context aware and lists the current space's rooms at the top. ([#499](https://github.com/SableClient/Sable/pull/499) by @7w1)
|
||||
* Add knocking support when attempting to join a room from the directory, an address, a room mention, or space hierarchy, as well as text command support for knocking. Also improves rendering for knock notifications in rooms. ([#470](https://github.com/SableClient/Sable/pull/470) by @polyjitter)
|
||||
* Add Android/iOS PWA-specific icon variants. ([#473](https://github.com/SableClient/Sable/pull/473) by @Septicity)
|
||||
* Add support for youtube embeds. ([#497](https://github.com/SableClient/Sable/pull/497) by @thundertheidiot)
|
||||
* Add sidebar three dot menu for quick access to related settings ([#474](https://github.com/SableClient/Sable/pull/474) by @wolterkam)
|
||||
* Replies that mention the OP are now indicated by the OP username being prefixed with @ ([#465](https://github.com/SableClient/Sable/pull/465) by @mini-bomba)
|
||||
* Made pin events show a tally of the messages that are pinned. ([#462](https://github.com/SableClient/Sable/pull/462) by @nushea)
|
||||
|
||||
#### Improve multiline composer and voice recording ([#476](https://github.com/SableClient/Sable/pull/476) by @hazre)
|
||||
|
||||
- Add a multiline composer layout for longer drafts.
|
||||
- Keep the voice recorder between composer actions in multiline mode.
|
||||
- Show the recorder inside the composer on mobile while recording.
|
||||
- Prevent the composer from expanding when recording starts.
|
||||
- Make the recorder footer and waveform fit better across screen sizes.
|
||||
- Let interrupted mobile recording gestures still stop correctly.
|
||||
- Stabilize wrap detection around edge cases like narrow widths and trailing spaces.
|
||||
|
||||
### Fixes
|
||||
|
||||
* Added error messages provided by homeserver to unknown login errors. ([#496](https://github.com/SableClient/Sable/pull/496) by @7w1)
|
||||
* Ensure new updates always reload the page properly. ([#502](https://github.com/SableClient/Sable/pull/502) by @7w1)
|
||||
* Removed the blocked users moved notice from notifications setting page. ([#490](https://github.com/SableClient/Sable/pull/490) by @7w1)
|
||||
* Fix recieved encrypted message per-message profiles not triggering rerenders. ([#464](https://github.com/SableClient/Sable/pull/464) by @7w1)
|
||||
* Add `.m4a` files as a recognized audio type. ([#472](https://github.com/SableClient/Sable/pull/472) by @henk717)
|
||||
* Fix messages disappearing from rooms after reconnects and timeline resets. ([#478](https://github.com/SableClient/Sable/pull/478) by @hazre)
|
||||
* Fix Camera being enabled by default even when the client has it off pre joining in browsers that permit the video (Electron/Tauri as examples). ([#485](https://github.com/SableClient/Sable/pull/485) by @Rawrington)
|
||||
* Fix cinny-dark-theme link colors being too dark ([#469](https://github.com/SableClient/Sable/pull/469) by @Elec3137)
|
||||
* Fix "Default" menu item height in room notification switcher. ([#466](https://github.com/SableClient/Sable/pull/466) by @polyjitter)
|
||||
* fix the issue of empty displaynames of a persona, causing an empty fallback message, it will now ommit the fallback, if the name is empty or only consists of whitespace ([#495](https://github.com/SableClient/Sable/pull/495) by @dozro)
|
||||
* Fixed an Android issue where recording a voice message with headphones could leave audio stuck in low-quality mode until the app was restarted. ([#476](https://github.com/SableClient/Sable/pull/476) by @hazre)
|
||||
* Fixed voice message scrubbing/seeking on Firefox by switching the recorder from WebM (no seek index) to Ogg/Opus. ([#476](https://github.com/SableClient/Sable/pull/476) by @hazre)
|
||||
* fixes touchpad zooming behaviour ([#481](https://github.com/SableClient/Sable/pull/481) by @integralfunction)
|
||||
* Fixes width mismatch for the call chat view. ([#460](https://github.com/SableClient/Sable/pull/460) by @polyjitter)
|
||||
* Fix messages sent from sable showing wrong on other client(s) ([#468](https://github.com/SableClient/Sable/pull/468) by @nushea)
|
||||
|
||||
### Documentation
|
||||
|
||||
* Updated PR template and CONTRIBUTING.md to add AI disclosure requirement. ([#456](https://github.com/SableClient/Sable/pull/456) by @Rosy-iso)
|
||||
|
||||
## 1.11.1 (2026-03-21)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix conditional memo in reply renderer leading to crashes. ([#453](https://github.com/SableClient/Sable/pull/453) by @7w1)
|
||||
|
||||
## 1.11.0 (2026-03-21)
|
||||
|
||||
### Features
|
||||
|
||||
* Implemented improved rendering for space hierarchies in nav bar and lobby. ([#252](https://github.com/SableClient/Sable/pull/252) by @KaceCottam)
|
||||
* Added styling for replies to non-messages. ([#416](https://github.com/SableClient/Sable/pull/416) by @nushea)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix message composer clearing when edited messages are saved. ([#447](https://github.com/SableClient/Sable/pull/447) by @7w1)
|
||||
* Fix editor flowing off screen when editing large messages in compact and bubble layouts. ([#447](https://github.com/SableClient/Sable/pull/447) by @7w1)
|
||||
* Fix extra spacing in message editor. ([#447](https://github.com/SableClient/Sable/pull/447) by @7w1)
|
||||
* Fix menu items not clickable due to menu transform. ([#450](https://github.com/SableClient/Sable/pull/450) by @7w1)
|
||||
* Fix replies not rendering matrix.to links and opening them in new tabs instead of jumping to them. ([#448](https://github.com/SableClient/Sable/pull/448) by @7w1)
|
||||
* Fix per-message profile messages collapsing together when different profiles are used. ([#449](https://github.com/SableClient/Sable/pull/449) by @7w1)
|
||||
* Fix per-message profiles not updating avatar/name if edit events are recieved. ([#449](https://github.com/SableClient/Sable/pull/449) by @7w1)
|
||||
* Fix editing per-message profile messages injecting profile name into message. ([#451](https://github.com/SableClient/Sable/pull/451) by @7w1)
|
||||
* Fix per-message profiles not rendering in encrypted rooms. ([#449](https://github.com/SableClient/Sable/pull/449) by @7w1)
|
||||
* Fix thread chips not appearing on thread root messages. ([#446](https://github.com/SableClient/Sable/pull/446) by @7w1)
|
||||
* Fix up arrow to edit messages not editing messages. ([#447](https://github.com/SableClient/Sable/pull/447) by @7w1)
|
||||
|
||||
## 1.10.6 (2026-03-21)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Change default notification server. ([#443](https://github.com/SableClient/Sable/pull/443) by @7w1)
|
||||
|
||||
## 1.10.5 (2026-03-20)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Hide unread dot/highlight for rooms with notification mode set to Mute. ([#429](https://github.com/SableClient/Sable/pull/429) by @saschabuehrle)
|
||||
* Fix thread drawer flooding console with "Ignoring event" warnings when server-side thread support is enabled. ([#438](https://github.com/SableClient/Sable/pull/438) by @Just-Insane)
|
||||
|
||||
## 1.10.4 (2026-03-20)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Change default push notification server. ([#433](https://github.com/SableClient/Sable/pull/433) by @7w1)
|
||||
|
||||
## 1.10.3 (2026-03-20)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Place persona settings behind a toggle in experimental. ([#431](https://github.com/SableClient/Sable/pull/431) by @7w1)
|
||||
|
||||
## 1.10.2 (2026-03-20)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix edit button not always editing. ([#413](https://github.com/SableClient/Sable/pull/413) by @7w1)
|
||||
* Fix search/nav/links/etc not loading messages. ([#413](https://github.com/SableClient/Sable/pull/413) by @7w1)
|
||||
* Fix timeline not sticking to the bottom in non-reduced motion setting. ([#413](https://github.com/SableClient/Sable/pull/413) by @7w1)
|
||||
* Replace matrix.org with matrixrooms.info in default featured servers section. ([#413](https://github.com/SableClient/Sable/pull/413) by @7w1)
|
||||
|
||||
## 1.10.1 (2026-03-20)
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix messages overlapping in timeline. ([#411](https://github.com/SableClient/Sable/pull/411) by @7w1)
|
||||
|
||||
## 1.10.0 (2026-03-20)
|
||||
|
||||
### Features
|
||||
|
||||
* added the posibility to send using per message profiles with `/usepmp` ([#309](https://github.com/SableClient/Sable/pull/309) by @dozro)
|
||||
* Added a setting to Appearance that attempts to convert text in names like (it/its) into a pronoun pill, enlabed by default. ([#353](https://github.com/SableClient/Sable/pull/353) by @7w1)
|
||||
* Rewrite the room timeline using Virtua to fix all the scroll bugs. ([#175](https://github.com/SableClient/Sable/pull/175) by @7w1)
|
||||
* Update calls to have RNNoise noise suppression. ([#392](https://github.com/SableClient/Sable/pull/392) by @melogale)
|
||||
|
||||
### Fixes
|
||||
|
||||
* fix [accidental leaking of private nicknames](https://github.com/SableClient/Sable/issues/362) for users to be included in the message ([#365](https://github.com/SableClient/Sable/pull/365) by @dozro)
|
||||
* Hide presence badge in members list for users without homeserver support, mimicking room profile apperance. ([#354](https://github.com/SableClient/Sable/pull/354) by @7w1)
|
||||
* Tighten sliding sync memory management: stop the polling loop on client dispose, persist then prune large room timelines when leaving a room, remove adaptive timeline-limit logic, and auto-unsubscribe when the local user leaves or is banned from a room. ([#348](https://github.com/SableClient/Sable/pull/348) by @Just-Insane)
|
||||
* Fix thread drawer showing no messages when using classic sync. ([#343](https://github.com/SableClient/Sable/pull/343) by @Just-Insane)
|
||||
* Hide the redundant "Thread" indicator badge in the compose box when inside the Thread Drawer. ([#347](https://github.com/SableClient/Sable/pull/347) by @Just-Insane)
|
||||
* Reduce dead space around the root message in the thread drawer. ([#344](https://github.com/SableClient/Sable/pull/344) by @Just-Insane)
|
||||
* Added a toggle to notifications to disable full message mention highlighting. ([#355](https://github.com/SableClient/Sable/pull/355) by @7w1)
|
||||
* Add a setting to disable reply mentions by default ([#405](https://github.com/SableClient/Sable/pull/405) by @mini-bomba)
|
||||
* Reduced the opacity of mention highlight backgrounds to be less visually intrusive while remaining noticeable. ([#401](https://github.com/SableClient/Sable/pull/401) by @sachin-dul)
|
||||
|
||||
## 1.9.3 (2026-03-17)
|
||||
|
||||
### Fixes
|
||||
|
||||
@@ -53,7 +53,10 @@ We expect and appreciate authentic engagement in our community.
|
||||
|
||||
Do not post output from Large Language Models or similar generative AI as comments on GitHub, as such comments tend to be formulaic and low content.
|
||||
|
||||
If you use generative AI tools as an aid in developing code, ensure that you fully understand the proposed changes and can explain why they are the correct approach.
|
||||
If you use generative AI tools as an aid in developing code, ensure that you fully understand the proposed changes and can explain why they are the correct approach; additionally, you **must** disclose which parts of the code were:
|
||||
|
||||
- Fully generated by the AI tool.
|
||||
- Written alongside the AI tool (examples: line completion, rewriting code generated by AI).
|
||||
|
||||
Make sure you have added value based on your personal competency to your contributions. Just taking some input, feeding it to an AI and posting the result is not of value to the project. We reserve the right to rigorously reject seemingly AI generated low-value contributions.
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
"hideUsernamePasswordFields": false,
|
||||
|
||||
"pushNotificationDetails": {
|
||||
"pushNotifyUrl": "https://cinny.cc/_matrix/push/v1/notify",
|
||||
"vapidPublicKey": "BHLwykXs79AbKNiblEtZZRAgnt7o5_ieImhVJD8QZ01MVwAHnXwZzNgQEJJEU3E5CVsihoKtb7yaNe5x3vmkWkI",
|
||||
"webPushAppID": "cc.cinny.web"
|
||||
"pushNotifyUrl": "https://sygnal.sable.moe/_matrix/push/v1/notify",
|
||||
"vapidPublicKey": "BCnS4SbHjeOaqVFW4wjt5xDt_pYIL62qMzKePfYF9fl9PQU14RieIaObh7nLR_9dQf4sykZa-CTrcjkgMIE1mcg",
|
||||
"webPushAppID": "moe.sable.app.sygnal"
|
||||
},
|
||||
|
||||
"slidingSync": {
|
||||
@@ -35,7 +35,7 @@
|
||||
"#PrivSec.dev:arcticfoxes.net",
|
||||
"#disroot:aria-net.org"
|
||||
],
|
||||
"servers": ["matrix.org", "mozilla.org", "unredacted.org"]
|
||||
"servers": ["matrixrooms.info", "mozilla.org", "unredacted.org"]
|
||||
},
|
||||
|
||||
"hashRouter": {
|
||||
|
||||
@@ -35,55 +35,86 @@
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
|
||||
<link rel="apple-touch-icon" href="./public/res/svg/cinny-logo-maskable.svg" />
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="36x36"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-36x36.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="48x48"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-48x48.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="57x57"
|
||||
href="./public/res/apple/apple-touch-icon-57x57.png"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-57x57.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="60x60"
|
||||
href="./public/res/apple/apple-touch-icon-60x60.png"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-60x60.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="72x72"
|
||||
href="./public/res/apple/apple-touch-icon-72x72.png"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-72x72.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="76x76"
|
||||
href="./public/res/apple/apple-touch-icon-76x76.png"
|
||||
sizes="96x96"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-96x96.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="114x114"
|
||||
href="./public/res/apple/apple-touch-icon-114x114.png"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-114x114.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="120x120"
|
||||
href="./public/res/apple/apple-touch-icon-120x120.png"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-120x120.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="144x144"
|
||||
href="./public/res/apple/apple-touch-icon-144x144.png"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-144x144.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="152x152"
|
||||
href="./public/res/apple/apple-touch-icon-152x152.png"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-152x152.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="167x167"
|
||||
href="./public/res/apple/apple-touch-icon-167x167.png"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-167x167.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="180x180"
|
||||
href="./public/res/apple/apple-touch-icon-180x180.png"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-180x180.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="192x192"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-192x192.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="256x256"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-256x256.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="384x384"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-384x384.png"
|
||||
/>
|
||||
<link
|
||||
rel="apple-touch-icon"
|
||||
sizes="512x512"
|
||||
href="./public/res/logo-maskable/cinny-logo-maskable-512x512.png"
|
||||
/>
|
||||
</head>
|
||||
|
||||
|
||||
@@ -64,6 +64,6 @@ repo = "Sable"
|
||||
[release_notes]
|
||||
# The <!-- commit:$commit_hash --> marker is used by prepare-release.yml
|
||||
change_templates = [
|
||||
# "### $summary <!-- commit:$commit_hash -->\n\n$details",
|
||||
"### $summary <!-- commit:$commit_hash -->\n\n$details",
|
||||
"* $summary <!-- commit:$commit_hash -->",
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sable",
|
||||
"version": "1.9.3",
|
||||
"version": "1.12.3",
|
||||
"description": "An almost stable Matrix client",
|
||||
"type": "module",
|
||||
"packageManager": "[email protected]+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be",
|
||||
@@ -22,6 +22,7 @@
|
||||
"test:run": "vitest run",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"knip": "knip",
|
||||
"tunnel": "cloudflared tunnel --url http://localhost:8080",
|
||||
"knope": "knope",
|
||||
"document-change": "knope document-change",
|
||||
"postinstall": "node scripts/install-knope.js"
|
||||
@@ -34,9 +35,9 @@
|
||||
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0",
|
||||
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
||||
"@fontsource-variable/nunito": "5.2.7",
|
||||
"@sentry/react": "^10.43.0",
|
||||
"@fontsource/space-mono": "5.2.9",
|
||||
"@phosphor-icons/react": "^2.1.10",
|
||||
"@sentry/react": "^10.43.0",
|
||||
"@tanstack/react-query": "^5.90.21",
|
||||
"@tanstack/react-query-devtools": "^5.91.3",
|
||||
"@tanstack/react-virtual": "^3.13.19",
|
||||
@@ -72,7 +73,6 @@
|
||||
"linkifyjs": "^4.3.2",
|
||||
"matrix-js-sdk": "^38.4.0",
|
||||
"matrix-widget-api": "^1.16.1",
|
||||
"millify": "^6.1.0",
|
||||
"pdfjs-dist": "^5.4.624",
|
||||
"prismjs": "^1.30.0",
|
||||
"react": "^18.3.1",
|
||||
@@ -91,16 +91,17 @@
|
||||
"slate-history": "^0.113.1",
|
||||
"slate-react": "^0.123.0",
|
||||
"ua-parser-js": "^1.0.41",
|
||||
"virtua": "^0.48.8",
|
||||
"workbox-precaching": "^7.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/vite-plugin": "^1.26.0",
|
||||
"@sableclient/sable-call-embedded": "v1.1.4",
|
||||
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
||||
"@eslint/compat": "2.0.2",
|
||||
"@eslint/js": "9.39.3",
|
||||
"@rollup/plugin-inject": "^5.0.5",
|
||||
"@rollup/plugin-wasm": "^6.2.2",
|
||||
"@sableclient/sable-call-embedded": "v1.1.4",
|
||||
"@sentry/vite-plugin": "^5.1.1",
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@testing-library/react": "^16.3.2",
|
||||
@@ -119,6 +120,7 @@
|
||||
"@vitest/coverage-v8": "^4.1.0",
|
||||
"@vitest/ui": "^4.1.0",
|
||||
"buffer": "^6.0.3",
|
||||
"cloudflared": "^0.7.1",
|
||||
"eslint": "9.39.3",
|
||||
"eslint-config-airbnb-extended": "3.0.1",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
@@ -137,4 +139,4 @@
|
||||
"vitest": "^4.1.0",
|
||||
"wrangler": "^4.70.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ overrides:
|
||||
minimatch: '>=10.2.3'
|
||||
rollup: '>=4.59.0'
|
||||
serialize-javascript: '>=7.0.3'
|
||||
flatted: '>=3.4.2'
|
||||
undici: '>=7.24.0'
|
||||
|
||||
importers:
|
||||
|
||||
@@ -142,9 +144,6 @@ importers:
|
||||
matrix-widget-api:
|
||||
specifier: ^1.16.1
|
||||
version: 1.17.0
|
||||
millify:
|
||||
specifier: ^6.1.0
|
||||
version: 6.1.0
|
||||
pdfjs-dist:
|
||||
specifier: ^5.4.624
|
||||
version: 5.5.207
|
||||
@@ -199,6 +198,9 @@ importers:
|
||||
ua-parser-js:
|
||||
specifier: ^1.0.41
|
||||
version: 1.0.41
|
||||
virtua:
|
||||
specifier: ^0.48.8
|
||||
version: 0.48.8([email protected]([email protected]))([email protected])
|
||||
workbox-precaching:
|
||||
specifier: ^7.4.0
|
||||
version: 7.4.0
|
||||
@@ -278,6 +280,9 @@ importers:
|
||||
buffer:
|
||||
specifier: ^6.0.3
|
||||
version: 6.0.3
|
||||
cloudflared:
|
||||
specifier: ^0.7.1
|
||||
version: 0.7.1
|
||||
eslint:
|
||||
specifier: 9.39.3
|
||||
version: 9.39.3([email protected])
|
||||
@@ -3321,6 +3326,10 @@ packages:
|
||||
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-jJn1Gu9Tf4qnIu8tfiHZ25Hs8rNcRYSVf8zAd97wvYdOCzftm1CTs1S/RPhijjGi8gUT1p9yzfDi9zYlU/0RwA==}
|
||||
hasBin: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -3527,9 +3536,6 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-5z3uFKBWjiNR44nFcYdkcXjKMbg5KXNdciu7mhTPo9tB7NbqSNP2sSnGR+fqknZSCwKkBN+oxiiajWs4dT6ORg==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==}
|
||||
|
||||
@@ -3878,11 +3884,8 @@ packages:
|
||||
resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==}
|
||||
engines: {node: '>=16'}
|
||||
|
||||
[email protected].0:
|
||||
resolution: {integrity: sha512-kC6Bb+ooptOIvWj5B63EQWkF0FEnNjV2ZNkLMLZRDDduIiWeFF4iKnslwhiWxjAdbg4NzTNo6h0qLuvFrcx+Sw==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-IxfVbRFVlV8V/yRaGzk0UVIcsKKHMSfYw66T/u4nTwlWteQePsxe//LjudR1AMX4tZW3WFCh3Zqa/sjlqpbURQ==}
|
||||
[email protected].2:
|
||||
resolution: {integrity: sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-PN4Ya9xf9nyj/Nd9VxBNMuD7IrlRbmaG6POAQ8VLqgtc6IY/Ln1tYakow+UIq4fihYYYFM70/2oyidE6bbiPgw==}
|
||||
@@ -3957,10 +3960,6 @@ packages:
|
||||
resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==}
|
||||
engines: {node: 6.* || 8.* || >= 10.*}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -4196,10 +4195,6 @@ packages:
|
||||
resolution: {integrity: sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -4539,10 +4534,6 @@ packages:
|
||||
resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==}
|
||||
engines: {node: '>=8.6'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-H/E3J6t+DQs/F2YgfDhxUVZz/dF8JXPPKTLHL/yHCcLZLtCXJDUaqvhJXQwqOVBvbyNn4T0WjLpIHd7PAw7fBA==}
|
||||
hasBin: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==}
|
||||
engines: {node: '>=4'}
|
||||
@@ -4928,10 +4919,6 @@ packages:
|
||||
resolution: {integrity: sha512-NZQZdC5wOE/H3UT28fVGL+ikOZcEzfMGk/c3iN9UGxzWHMa1op7274oyiUVrAG4B2EuFhus8SvkaYnhvW92p9Q==}
|
||||
hasBin: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -5127,10 +5114,6 @@ packages:
|
||||
resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -5158,10 +5141,6 @@ packages:
|
||||
resolution: {integrity: sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==}
|
||||
engines: {node: '>=4'}
|
||||
@@ -5347,10 +5326,6 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-y+8YjDFzWdQlSE9N5nzKMT3g4a5UBX1HKowfdXh0uvAnTaqqwqB92Jt4UXBAeKekDs5IaDKyJFR4X1gYVCgXcw==}
|
||||
engines: {node: '>=20.18.1'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-eJdUmK/Wrx2d+mnWWmwwLRyA7OQCkLap60sk3dOK4ViZR7DKwwptwuIvFBg2HaiP9ESaEdhtpSymQPvytpmkCA==}
|
||||
engines: {node: '>=20.18.1'}
|
||||
@@ -5414,6 +5389,26 @@ packages:
|
||||
resolution: {integrity: sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==}
|
||||
hasBin: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-jpsxOw5V4B6hg44JePRLo9DL0TV7N1lBEVtPjKpAJebXyhI2s9lfiXJESaLapNtr3vtiSk/pWHiLf7B2a6UcgQ==}
|
||||
peerDependencies:
|
||||
react: '>=16.14.0'
|
||||
react-dom: '>=16.14.0'
|
||||
solid-js: '>=1.0'
|
||||
svelte: '>=5.0'
|
||||
vue: '>=3.2'
|
||||
peerDependenciesMeta:
|
||||
react:
|
||||
optional: true
|
||||
react-dom:
|
||||
optional: true
|
||||
solid-js:
|
||||
optional: true
|
||||
svelte:
|
||||
optional: true
|
||||
vue:
|
||||
optional: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==}
|
||||
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
|
||||
@@ -5655,10 +5650,6 @@ packages:
|
||||
'@cloudflare/workers-types':
|
||||
optional: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
@@ -5678,10 +5669,6 @@ packages:
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==}
|
||||
|
||||
@@ -5690,14 +5677,6 @@ packages:
|
||||
engines: {node: '>= 14.6'}
|
||||
hasBin: true
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
[email protected]:
|
||||
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
|
||||
engines: {node: '>=10'}
|
||||
@@ -8831,7 +8810,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@vitest/utils': 4.1.0
|
||||
fflate: 0.8.2
|
||||
flatted: 3.4.0
|
||||
flatted: 3.4.2
|
||||
pathe: 2.0.3
|
||||
sirv: 3.0.2
|
||||
tinyglobby: 0.2.15
|
||||
@@ -9115,6 +9094,8 @@ snapshots:
|
||||
strip-ansi: 6.0.1
|
||||
wrap-ansi: 7.0.0
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
@@ -9291,8 +9272,6 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]([email protected]):
|
||||
@@ -9810,12 +9789,10 @@ snapshots:
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
flatted: 3.4.1
|
||||
flatted: 3.4.2
|
||||
keyv: 4.5.4
|
||||
|
||||
[email protected].0: {}
|
||||
|
||||
[email protected]: {}
|
||||
[email protected].2: {}
|
||||
|
||||
[email protected]([email protected])([email protected]([email protected]))([email protected]):
|
||||
dependencies:
|
||||
@@ -9886,8 +9863,6 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
call-bind-apply-helpers: 1.0.2
|
||||
@@ -10154,8 +10129,6 @@ snapshots:
|
||||
dependencies:
|
||||
call-bound: 1.0.4
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
call-bound: 1.0.4
|
||||
@@ -10488,17 +10461,13 @@ snapshots:
|
||||
braces: 3.0.3
|
||||
picomatch: 2.3.1
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
yargs: 17.7.2
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
'@cspotcode/source-map-support': 0.8.1
|
||||
sharp: 0.34.5
|
||||
undici: 7.18.2
|
||||
undici: 7.24.3
|
||||
workerd: 1.20260310.1
|
||||
ws: 8.18.0
|
||||
youch: 4.1.0-beta.10
|
||||
@@ -10929,8 +10898,6 @@ snapshots:
|
||||
dependencies:
|
||||
jsesc: 3.1.0
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
@@ -11202,12 +11169,6 @@ snapshots:
|
||||
es-errors: 1.3.0
|
||||
internal-slot: 1.1.0
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
emoji-regex: 8.0.0
|
||||
is-fullwidth-code-point: 3.0.0
|
||||
strip-ansi: 6.0.1
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
call-bind: 1.0.8
|
||||
@@ -11264,10 +11225,6 @@ snapshots:
|
||||
is-obj: 1.0.1
|
||||
is-regexp: 1.0.0
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
ansi-regex: 5.0.1
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
@@ -11448,8 +11405,6 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
@@ -11519,6 +11474,11 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]([email protected]([email protected]))([email protected]):
|
||||
optionalDependencies:
|
||||
react: 18.3.1
|
||||
react-dom: 18.3.1([email protected])
|
||||
|
||||
[email protected](@types/[email protected])([email protected])([email protected])([email protected]):
|
||||
dependencies:
|
||||
cac: 6.7.14
|
||||
@@ -11856,37 +11816,17 @@ snapshots:
|
||||
- bufferutil
|
||||
- utf-8-validate
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
ansi-styles: 4.3.0
|
||||
string-width: 4.2.3
|
||||
strip-ansi: 6.0.1
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
optional: true
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
dependencies:
|
||||
cliui: 8.0.1
|
||||
escalade: 3.2.0
|
||||
get-caller-file: 2.0.5
|
||||
require-directory: 2.1.1
|
||||
string-width: 4.2.3
|
||||
y18n: 5.0.8
|
||||
yargs-parser: 21.1.1
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
allowBuilds:
|
||||
'@sentry/cli': true
|
||||
'@swc/core': true
|
||||
cloudflared: true
|
||||
esbuild: true
|
||||
sharp: true
|
||||
unrs-resolver: true
|
||||
@@ -13,10 +14,12 @@ minimumReleaseAgeExclude:
|
||||
overrides:
|
||||
brace-expansion: '>=1.1.12'
|
||||
esbuild: '>=0.25.0'
|
||||
flatted: '>=3.4.2'
|
||||
lodash: '>=4.17.23'
|
||||
minimatch: '>=10.2.3'
|
||||
rollup: '>=4.59.0'
|
||||
serialize-javascript: '>=7.0.3'
|
||||
undici: '>=7.24.0'
|
||||
|
||||
peerDependencyRules:
|
||||
allowedVersions:
|
||||
|
||||
@@ -11,49 +11,166 @@
|
||||
"theme_color": "#1b1a21",
|
||||
"icons": [
|
||||
{
|
||||
"src": "./public/android/android-chrome-36x36.png",
|
||||
"sizes": "36x36",
|
||||
"type": "image/png"
|
||||
"src": "./public/svg/cinny-logo-maskable.svg",
|
||||
"sizes": "any",
|
||||
"type": "image/svg+xml",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/android/android-chrome-48x48.png",
|
||||
"sizes": "48x48",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "./public/android/android-chrome-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "./public/android/android-chrome-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "./public/android/android-chrome-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "./public/android/android-chrome-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "./public/android/android-chrome-256x256.png",
|
||||
"sizes": "256x256",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "./public/android/android-chrome-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "./public/android/android-chrome-512x512.png",
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-256x256.png",
|
||||
"sizes": "256x256",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-180x180.png",
|
||||
"sizes": "180x180",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-167x167.png",
|
||||
"sizes": "167x167",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-152x152.png",
|
||||
"sizes": "152x152",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-120x120.png",
|
||||
"sizes": "120x120",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-114x114.png",
|
||||
"sizes": "114x114",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-76x76.png",
|
||||
"sizes": "76x76",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-60x60.png",
|
||||
"sizes": "60x60",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-57x57.png",
|
||||
"sizes": "57x57",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-48x48.png",
|
||||
"sizes": "48x48",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo-maskable/cinny-logo-maskable-36x36.png",
|
||||
"sizes": "36x36",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "./public/svg/cinny-logo.svg",
|
||||
"sizes": "any",
|
||||
"type": "image/svg+xml",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo/cinny-logo-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo/cinny-logo-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo/cinny-logo-256x256.png",
|
||||
"sizes": "256x256",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo/cinny-logo-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo/cinny-logo-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo/cinny-logo-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo/cinny-logo-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "./public/logo/cinny-logo-48x48.png",
|
||||
"sizes": "48x48",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 794 B |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.3 KiB |
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
width="2451.377"
|
||||
height="2451.377"
|
||||
viewBox="0 0 2451.377 2451.377"
|
||||
version="1.1"
|
||||
xml:space="preserve"
|
||||
style="clip-rule:evenodd;fill-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5"
|
||||
id="svg2"
|
||||
sodipodi:docname="apple-touch-icon.svg"
|
||||
inkscape:version="1.4.3 (0d15f75042, 2025-12-25)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="0.47932245"
|
||||
inkscape:cx="1225.6885"
|
||||
inkscape:cy="1380.0731"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1377"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" /><defs
|
||||
id="defs2" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
inkscape:label="background"
|
||||
style="clip-rule:evenodd;fill-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;display:inline"
|
||||
transform="translate(-4.9778005e-6)"><rect
|
||||
style="clip-rule:evenodd;fill-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;fill:#1a1c28;stroke-width:1.00157"
|
||||
id="rect1"
|
||||
width="2530.6555"
|
||||
height="2539.0002"
|
||||
x="-58.415791"
|
||||
y="-66.760902"
|
||||
transform="translate(4.9778005e-6)" /></g><g
|
||||
id="Layer1"
|
||||
style="display:inline"
|
||||
transform="translate(-91.78964,-37.013267)">
|
||||
|
||||
<g
|
||||
transform="matrix(4.26739,0,0,4.26739,-3874.25,-3551.54)"
|
||||
id="g2">
|
||||
<path
|
||||
d="m 1048.38,1342.19 c -121.447,14.2738 -231.68198,2.0248 -231.68198,-84.6652 0,-13.91 61.20018,-117.1054 130.63298,-169.8648 25.029,-16.21 47.575,-28.28 68.139,-42.84 38.87,-27.54 38.87,-87.474 115.01,-87.474 58.31,0 79,37.463 129.58,69.654 35.6,22.65 92.2,13.47 226.32,85.85 l 0.01,0.08 c -139.04,-51.92 -221.72,-53.49 -237.67,-50.3 -32.39,6.48 -92.02,49.61 -83.44,140.17 6.14,64.88 -39.29,124.88 -116.9,139.39 z m 105.61,-358.258 c -9.78,0 -17.72,7.939 -17.72,17.718 0,9.78 7.94,17.72 17.72,17.72 9.77,0 17.71,-7.94 17.71,-17.72 0,-9.779 -7.94,-17.718 -17.71,-17.718 z"
|
||||
style="fill:#ad9eff;fill-opacity:1"
|
||||
id="path1" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
@@ -5,10 +5,11 @@
|
||||
* Alt+N — jump to the highest-priority unread room
|
||||
* Alt+Shift+Down — cycle forward through unread rooms
|
||||
* Alt+Shift+Up — cycle backward through unread rooms
|
||||
* Ctrl+Down / Ctrl+Up: cycle through messages to reply to
|
||||
*/
|
||||
import { useCallback, useRef } from 'react';
|
||||
import { useNavigate, useLocation, matchPath } from 'react-router-dom';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { roomToParentsAtom } from '$state/room/roomToParents';
|
||||
@@ -19,6 +20,8 @@ import { getDirectRoomPath, getHomeRoomPath, getSpaceRoomPath } from '$pages/pat
|
||||
import { HOME_ROOM_PATH, DIRECT_ROOM_PATH, SPACE_ROOM_PATH } from '$pages/paths';
|
||||
import { getCanonicalAliasOrRoomId } from '$utils/matrix';
|
||||
import { announce } from '$utils/announce';
|
||||
import { roomIdToReplyDraftAtomFamily } from '$state/room/roomInputDrafts';
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
|
||||
export function GlobalKeyboardShortcuts() {
|
||||
const navigate = useNavigate();
|
||||
@@ -37,15 +40,17 @@ export function GlobalKeyboardShortcuts() {
|
||||
const roomIdOrAlias = roomMatch?.params.roomIdOrAlias
|
||||
? decodeURIComponent(roomMatch.params.roomIdOrAlias)
|
||||
: undefined;
|
||||
let currentRoomId: string | null = null;
|
||||
let currentRoom: Room | null = null;
|
||||
if (roomIdOrAlias) {
|
||||
if (roomIdOrAlias.startsWith('!')) {
|
||||
currentRoomId = roomIdOrAlias;
|
||||
currentRoom = mx.getRoom(roomIdOrAlias);
|
||||
} else {
|
||||
currentRoomId =
|
||||
mx.getRooms().find((r) => r.getCanonicalAlias() === roomIdOrAlias)?.roomId ?? null;
|
||||
currentRoom = mx.getRooms().find((r) => r.getCanonicalAlias() === roomIdOrAlias) ?? null;
|
||||
}
|
||||
}
|
||||
const replyDraftAtomFamily = roomIdToReplyDraftAtomFamily(currentRoom?.roomId ?? '');
|
||||
const replyDraft = useAtomValue(replyDraftAtomFamily);
|
||||
const setReplyDraft = useSetAtom(replyDraftAtomFamily);
|
||||
|
||||
/** Navigate to a room by ID and announce it to screen readers. */
|
||||
const navigateToRoom = useCallback(
|
||||
@@ -76,7 +81,7 @@ export function GlobalKeyboardShortcuts() {
|
||||
(evt: KeyboardEvent) => {
|
||||
if (!isKeyHotkey('alt+n', evt)) return;
|
||||
const unreadEntries = Array.from(roomToUnread.entries())
|
||||
.filter(([id, u]) => u.total > 0 && id !== currentRoomId)
|
||||
.filter(([id, u]) => u.total > 0 && id !== currentRoom?.roomId)
|
||||
.sort((a, b) => b[1].highlight - a[1].highlight || b[1].total - a[1].total);
|
||||
if (unreadEntries.length === 0) return;
|
||||
evt.preventDefault();
|
||||
@@ -84,7 +89,7 @@ export function GlobalKeyboardShortcuts() {
|
||||
const [roomId] = unreadEntries[0];
|
||||
navigateToRoom(roomId, unreadEntries.length - 1);
|
||||
},
|
||||
[roomToUnread, currentRoomId, navigateToRoom]
|
||||
[roomToUnread, currentRoom?.roomId, navigateToRoom]
|
||||
);
|
||||
|
||||
/** Alt+Shift+Down / Alt+Shift+Up: cycle through unread rooms. */
|
||||
@@ -110,8 +115,38 @@ export function GlobalKeyboardShortcuts() {
|
||||
[roomToUnread, navigateToRoom]
|
||||
);
|
||||
|
||||
/** Ctrl+Down / Ctrl+Up: cycle through messages to reply to. */
|
||||
const handleReplyKeyDown = useCallback(
|
||||
(evt: KeyboardEvent) => {
|
||||
const isDown = isKeyHotkey('mod+down', evt);
|
||||
const isUp = isKeyHotkey('mod+up', evt);
|
||||
if (currentRoom === null) return;
|
||||
if (!isDown && !isUp) return;
|
||||
|
||||
const events = currentRoom.getUnfilteredTimelineSet().getLiveTimeline().getEvents();
|
||||
|
||||
// when no message is currently targeted, just target the first one
|
||||
if (replyDraft?.eventId === undefined) {
|
||||
const latestEvent = events.at(-1);
|
||||
if (latestEvent === undefined) return;
|
||||
const eventId = latestEvent.event.event_id;
|
||||
if (eventId === undefined) return;
|
||||
setReplyDraft({ userId: currentRoom.myUserId, eventId, body: '' });
|
||||
return;
|
||||
}
|
||||
const currentReplyIndex = events.findIndex((e) => e.event.event_id === replyDraft.eventId);
|
||||
if (currentReplyIndex === events.length - 1 && isDown) return; // you cant go further down than that idiot
|
||||
const newTargetEvent = isUp ? events[currentReplyIndex - 1] : events[currentReplyIndex + 1];
|
||||
const eventId = newTargetEvent.event.event_id;
|
||||
if (eventId === undefined) return;
|
||||
setReplyDraft({ userId: currentRoom.myUserId, eventId, body: '' });
|
||||
},
|
||||
[currentRoom, replyDraft, setReplyDraft]
|
||||
);
|
||||
|
||||
useKeyDown(window, handleNextUnreadKeyDown);
|
||||
useKeyDown(window, handleUnreadNavKeyDown);
|
||||
useKeyDown(window, handleReplyKeyDown);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
UnsupportedContent,
|
||||
VideoContent,
|
||||
} from './message';
|
||||
import { UrlPreviewCard, UrlPreviewHolder } from './url-preview';
|
||||
import { UrlPreviewCard, UrlPreviewHolder, ClientPreview, youtubeUrl } from './url-preview';
|
||||
import { Image, MediaControl, PersistedVolumeVideo } from './media';
|
||||
import { ImageViewer } from './image-viewer';
|
||||
import { PdfViewer } from './Pdf-viewer';
|
||||
@@ -43,6 +43,7 @@ type RenderMessageContentProps = {
|
||||
getContent: <T>() => T;
|
||||
mediaAutoLoad?: boolean;
|
||||
urlPreview?: boolean;
|
||||
clientUrlPreview?: boolean;
|
||||
highlightRegex?: RegExp;
|
||||
htmlReactParserOptions: HTMLReactParserOptions;
|
||||
linkifyOpts: Opts;
|
||||
@@ -68,6 +69,7 @@ function RenderMessageContentInternal({
|
||||
getContent,
|
||||
mediaAutoLoad,
|
||||
urlPreview,
|
||||
clientUrlPreview,
|
||||
highlightRegex,
|
||||
htmlReactParserOptions,
|
||||
linkifyOpts,
|
||||
@@ -112,13 +114,22 @@ function RenderMessageContentInternal({
|
||||
|
||||
return (
|
||||
<UrlPreviewHolder>
|
||||
{toRender.map(({ url, type }) => (
|
||||
<UrlPreviewCard key={url} url={url} ts={ts} mediaType={type} />
|
||||
))}
|
||||
{toRender.map(({ url, type }) => {
|
||||
if (type) {
|
||||
return <UrlPreviewCard key={url} url={url} ts={ts} mediaType={type} />;
|
||||
}
|
||||
if (clientUrlPreview && youtubeUrl(url)) {
|
||||
return <ClientPreview url={url} />;
|
||||
}
|
||||
if (urlPreview) {
|
||||
return <UrlPreviewCard key={url} url={url} ts={ts} mediaType={type} />;
|
||||
}
|
||||
return null;
|
||||
})}
|
||||
</UrlPreviewHolder>
|
||||
);
|
||||
},
|
||||
[ts]
|
||||
[ts, clientUrlPreview, urlPreview]
|
||||
);
|
||||
|
||||
const renderCaption = () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Box, config, Icon, Menu, MenuItem, PopOut, RectCords, Text } from 'folds';
|
||||
import { Box, config, Icon, Menu, MenuItem, PopOut, RectCords, Text, toRem } from 'folds';
|
||||
import { MouseEventHandler, ReactNode, useMemo, useState } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
@@ -93,6 +93,7 @@ export function RoomNotificationModeSwitcher({
|
||||
size="300"
|
||||
variant="Surface"
|
||||
aria-pressed={mode === value}
|
||||
style={mode === RoomNotificationMode.Unset ? { height: toRem(48) } : undefined}
|
||||
radii="300"
|
||||
disabled={changing}
|
||||
onClick={() => handleSelect(mode)}
|
||||
|
||||
@@ -13,6 +13,28 @@ export const Editor = style([
|
||||
},
|
||||
]);
|
||||
|
||||
export const EditorRow = style({
|
||||
gridTemplateColumns: 'auto 1fr auto',
|
||||
alignItems: 'center',
|
||||
});
|
||||
|
||||
export const EditorRowMultiline = style({
|
||||
gridTemplateColumns: 'auto 1fr',
|
||||
gridTemplateAreas: `
|
||||
"before textarea"
|
||||
"before after"
|
||||
`,
|
||||
alignItems: 'start',
|
||||
});
|
||||
|
||||
export const EditorRowMultilineWithResponsiveAfter = style({
|
||||
gridTemplateColumns: 'auto 1fr auto',
|
||||
gridTemplateAreas: `
|
||||
"before textarea textarea"
|
||||
"before responsive-after after"
|
||||
`,
|
||||
});
|
||||
|
||||
export const EditorOptions = style([
|
||||
DefaultReset,
|
||||
{
|
||||
@@ -20,14 +42,30 @@ export const EditorOptions = style([
|
||||
},
|
||||
]);
|
||||
|
||||
export const EditorTextareaScroll = style({});
|
||||
export const EditorOptionsMultiline = style({
|
||||
gridArea: 'before',
|
||||
alignSelf: 'end',
|
||||
});
|
||||
|
||||
export const EditorOptionsAfterMultiline = style({
|
||||
gridArea: 'after',
|
||||
justifySelf: 'end',
|
||||
});
|
||||
|
||||
export const EditorTextareaScroll = style({
|
||||
minWidth: 0,
|
||||
});
|
||||
|
||||
export const EditorTextareaScrollMultiline = style({
|
||||
gridArea: 'textarea',
|
||||
});
|
||||
|
||||
export const EditorTextarea = style([
|
||||
DefaultReset,
|
||||
{
|
||||
flexGrow: 1,
|
||||
height: '100%',
|
||||
padding: `${toRem(13)} ${toRem(1)}`,
|
||||
height: 'auto',
|
||||
padding: `${toRem(13)} 0 0`,
|
||||
selectors: {
|
||||
[`${EditorTextareaScroll}:first-child &`]: {
|
||||
paddingLeft: toRem(13),
|
||||
@@ -42,6 +80,15 @@ export const EditorTextarea = style([
|
||||
},
|
||||
]);
|
||||
|
||||
export const EditorResponsiveAfterMultiline = style([
|
||||
EditorOptions,
|
||||
{
|
||||
gridArea: 'responsive-after',
|
||||
minWidth: 0,
|
||||
alignSelf: 'stretch',
|
||||
},
|
||||
]);
|
||||
|
||||
export const EditorPlaceholderContainer = style([
|
||||
DefaultReset,
|
||||
{
|
||||
@@ -57,6 +104,11 @@ export const EditorPlaceholderTextVisual = style([
|
||||
display: 'block',
|
||||
paddingTop: toRem(13),
|
||||
paddingLeft: toRem(1),
|
||||
selectors: {
|
||||
[`${EditorTextareaScroll}:first-child &`]: {
|
||||
paddingLeft: toRem(13),
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -0,0 +1,543 @@
|
||||
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
|
||||
import { useState } from 'react';
|
||||
import { Transforms } from 'slate';
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
||||
import { useEditor, CustomEditor } from './Editor';
|
||||
import { BlockType } from './types';
|
||||
import * as css from './Editor.css';
|
||||
|
||||
let shouldWrapToggleHarness = false;
|
||||
let measurementCacheScrollHeightReads = 0;
|
||||
|
||||
function EditorHarness() {
|
||||
const editor = useEditor();
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
Transforms.insertNodes(editor, {
|
||||
type: BlockType.Paragraph,
|
||||
children: [{ text: 'Second line' }],
|
||||
});
|
||||
}}
|
||||
>
|
||||
Make multiline
|
||||
</button>
|
||||
<CustomEditor
|
||||
editableName="EditorHarness"
|
||||
editor={editor}
|
||||
before={<button type="button">Attach</button>}
|
||||
after={<button type="button">Send</button>}
|
||||
responsiveAfter={<div data-testid="recorder">Recorder</div>}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ToggleRecorderHarness() {
|
||||
const editor = useEditor();
|
||||
const [showRecorder, setShowRecorder] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
Transforms.insertText(editor, 'Some text that still fits before recording');
|
||||
}}
|
||||
>
|
||||
Add text
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
shouldWrapToggleHarness = true;
|
||||
setShowRecorder(true);
|
||||
}}
|
||||
>
|
||||
Start recorder
|
||||
</button>
|
||||
<CustomEditor
|
||||
editableName="ToggleRecorderHarness"
|
||||
editor={editor}
|
||||
before={<button type="button">Attach</button>}
|
||||
after={<button type="button">Send</button>}
|
||||
responsiveAfter={
|
||||
showRecorder ? <div data-testid="toggle-recorder">Recorder</div> : undefined
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ForcedFooterHarness() {
|
||||
const editor = useEditor();
|
||||
|
||||
return (
|
||||
<CustomEditor
|
||||
editableName="ForcedFooterHarness"
|
||||
editor={editor}
|
||||
before={<button type="button">Attach</button>}
|
||||
after={<button type="button">Send</button>}
|
||||
responsiveAfter={<div data-testid="forced-footer-recorder">Recorder</div>}
|
||||
forceMultilineLayout
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function PasteWrapHarness() {
|
||||
const editor = useEditor();
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
Transforms.insertText(editor, 'sadasdasdsadasdasdsadasdasd');
|
||||
}}
|
||||
>
|
||||
Paste wrapped text
|
||||
</button>
|
||||
<CustomEditor editableName="PasteWrapHarness" editor={editor} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function NearThresholdWrapHarness() {
|
||||
const editor = useEditor();
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
Transforms.insertText(editor, 'near-threshold wrap text');
|
||||
}}
|
||||
>
|
||||
Paste near-threshold wrap
|
||||
</button>
|
||||
<CustomEditor editableName="NearThresholdWrapHarness" editor={editor} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TrailingSpacesWrapHarness() {
|
||||
const editor = useEditor();
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
Transforms.insertText(editor, 'trailing spaces ');
|
||||
}}
|
||||
>
|
||||
Paste trailing spaces
|
||||
</button>
|
||||
<CustomEditor editableName="TrailingSpacesWrapHarness" editor={editor} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function PasteNoWrapHarness() {
|
||||
const editor = useEditor();
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
Transforms.insertText(editor, 'short pasted text');
|
||||
}}
|
||||
>
|
||||
Paste short text
|
||||
</button>
|
||||
<CustomEditor editableName="PasteNoWrapHarness" editor={editor} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function MeasurementCacheHarness() {
|
||||
const editor = useEditor();
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
Transforms.insertText(editor, 'sadasdasdsadasdasdsadasdasd');
|
||||
}}
|
||||
>
|
||||
Add cached text
|
||||
</button>
|
||||
<CustomEditor editableName="MeasurementCacheHarness" editor={editor} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const createResizeObserverStub = (
|
||||
observedElements: Set<Element>,
|
||||
onCreate: (callback: ResizeObserverCallback) => void
|
||||
) =>
|
||||
function ResizeObserverStub(callback: ResizeObserverCallback) {
|
||||
onCreate(callback);
|
||||
|
||||
return {
|
||||
observe(target: Element) {
|
||||
observedElements.add(target);
|
||||
},
|
||||
unobserve(target: Element) {
|
||||
observedElements.delete(target);
|
||||
},
|
||||
disconnect() {
|
||||
observedElements.clear();
|
||||
},
|
||||
};
|
||||
} as unknown as typeof ResizeObserver;
|
||||
|
||||
const nativeScrollHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'scrollHeight');
|
||||
const nativeOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth');
|
||||
const nativeClientWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'clientWidth');
|
||||
const nativeRequestAnimationFrame = window.requestAnimationFrame;
|
||||
const nativeCancelAnimationFrame = window.cancelAnimationFrame;
|
||||
const nativeGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
|
||||
const nativeGlobalCancelAnimationFrame = globalThis.cancelAnimationFrame;
|
||||
const nativeResizeObserver = globalThis.ResizeObserver;
|
||||
|
||||
beforeEach(() => {
|
||||
shouldWrapToggleHarness = false;
|
||||
measurementCacheScrollHeightReads = 0;
|
||||
|
||||
Object.defineProperty(HTMLElement.prototype, 'scrollHeight', {
|
||||
configurable: true,
|
||||
get() {
|
||||
if (this instanceof HTMLElement) {
|
||||
const measurerName = this.getAttribute('data-editor-measurer');
|
||||
const measuredText = this.textContent ?? '';
|
||||
const hasMeasuredText = measuredText.length > 0;
|
||||
const isSingleLineProbe = measuredText === 'M';
|
||||
|
||||
if (measurerName === 'ToggleRecorderHarness') {
|
||||
if (!hasMeasuredText || isSingleLineProbe) return 20;
|
||||
return shouldWrapToggleHarness ? 40 : 20;
|
||||
}
|
||||
|
||||
if (measurerName === 'PasteWrapHarness') {
|
||||
if (isSingleLineProbe) return 20;
|
||||
return hasMeasuredText ? 40 : 20;
|
||||
}
|
||||
|
||||
if (measurerName === 'NearThresholdWrapHarness') {
|
||||
if (!hasMeasuredText || isSingleLineProbe) return 20;
|
||||
return this.style.width === '319px' ? 29 : 20;
|
||||
}
|
||||
|
||||
if (measurerName === 'TrailingSpacesWrapHarness') {
|
||||
if (!hasMeasuredText || isSingleLineProbe) return 20;
|
||||
return measuredText.endsWith('\u200B') ? 29 : 20;
|
||||
}
|
||||
|
||||
if (measurerName === 'PasteNoWrapHarness') {
|
||||
if (!hasMeasuredText || isSingleLineProbe) return 20;
|
||||
return 20;
|
||||
}
|
||||
|
||||
if (measurerName === 'MeasurementCacheHarness') {
|
||||
if (!hasMeasuredText || isSingleLineProbe) return 20;
|
||||
measurementCacheScrollHeightReads += 1;
|
||||
return 40;
|
||||
}
|
||||
}
|
||||
|
||||
return nativeScrollHeight?.get?.call(this) ?? 0;
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
|
||||
configurable: true,
|
||||
get() {
|
||||
if (this instanceof HTMLElement && this.classList.contains(css.EditorRow)) {
|
||||
return 320;
|
||||
}
|
||||
return nativeOffsetWidth?.get?.call(this) ?? 0;
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
|
||||
configurable: true,
|
||||
get() {
|
||||
if (this instanceof HTMLElement && this.classList.contains(css.EditorTextareaScroll)) {
|
||||
if (this.querySelector('[data-editable-name="NearThresholdWrapHarness"]')) {
|
||||
return 319;
|
||||
}
|
||||
|
||||
return 320;
|
||||
}
|
||||
|
||||
return nativeClientWidth?.get?.call(this) ?? 0;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
shouldWrapToggleHarness = false;
|
||||
measurementCacheScrollHeightReads = 0;
|
||||
window.requestAnimationFrame = nativeRequestAnimationFrame;
|
||||
window.cancelAnimationFrame = nativeCancelAnimationFrame;
|
||||
globalThis.requestAnimationFrame = nativeGlobalRequestAnimationFrame;
|
||||
globalThis.cancelAnimationFrame = nativeGlobalCancelAnimationFrame;
|
||||
globalThis.ResizeObserver = nativeResizeObserver;
|
||||
if (nativeScrollHeight) {
|
||||
Object.defineProperty(HTMLElement.prototype, 'scrollHeight', nativeScrollHeight);
|
||||
} else {
|
||||
Reflect.deleteProperty(HTMLElement.prototype, 'scrollHeight');
|
||||
}
|
||||
|
||||
if (nativeOffsetWidth) {
|
||||
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', nativeOffsetWidth);
|
||||
} else {
|
||||
Reflect.deleteProperty(HTMLElement.prototype, 'offsetWidth');
|
||||
}
|
||||
|
||||
if (nativeClientWidth) {
|
||||
Object.defineProperty(HTMLElement.prototype, 'clientWidth', nativeClientWidth);
|
||||
} else {
|
||||
Reflect.deleteProperty(HTMLElement.prototype, 'clientWidth');
|
||||
}
|
||||
});
|
||||
|
||||
describe('CustomEditor', () => {
|
||||
it('moves responsive after content into the multiline footer without keeping the textarea max height', async () => {
|
||||
render(<EditorHarness />);
|
||||
const editable = document.querySelector('[data-editable-name="EditorHarness"]');
|
||||
const scroll = editable?.parentElement as HTMLElement | null;
|
||||
const editorRoot = scroll?.parentElement?.parentElement as HTMLElement | null;
|
||||
const measurer = document.querySelector('[data-editor-measurer="EditorHarness"]');
|
||||
|
||||
expect(scroll).not.toBeNull();
|
||||
expect(editorRoot).not.toBeNull();
|
||||
expect(editorRoot?.contains(measurer)).toBe(true);
|
||||
expect(measurer?.parentElement).not.toBe(document.body);
|
||||
expect(scroll?.style.maxHeight).toBe('50vh');
|
||||
expect(screen.getByText('Attach')).toBeVisible();
|
||||
expect(screen.getByText('Send')).toBeVisible();
|
||||
expect(screen.getByTestId('recorder').parentElement).toHaveClass(css.EditorOptions);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Make multiline' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('recorder').parentElement).toHaveClass(
|
||||
css.EditorResponsiveAfterMultiline
|
||||
);
|
||||
expect(scroll?.style.maxHeight).toBe('');
|
||||
});
|
||||
|
||||
expect(screen.getByText('Attach')).toBeVisible();
|
||||
expect(screen.getByText('Send')).toBeVisible();
|
||||
});
|
||||
|
||||
it('recomputes multiline layout when inline responsive content makes existing text wrap', async () => {
|
||||
render(<ToggleRecorderHarness />);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Add text' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Start recorder' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('toggle-recorder').parentElement).toHaveClass(
|
||||
css.EditorResponsiveAfterMultiline
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('supports forcing multiline layout so responsive content moves into the footer immediately', () => {
|
||||
render(<ForcedFooterHarness />);
|
||||
|
||||
expect(screen.getByTestId('forced-footer-recorder').parentElement).toHaveClass(
|
||||
css.EditorResponsiveAfterMultiline
|
||||
);
|
||||
});
|
||||
|
||||
it('detects pasted text that exceeds the single-line width after the deferred layout measurement', async () => {
|
||||
render(<PasteWrapHarness />);
|
||||
const editable = document.querySelector('[data-editable-name="PasteWrapHarness"]');
|
||||
const scroll = editable?.parentElement as HTMLElement | null;
|
||||
|
||||
expect(scroll).not.toBeNull();
|
||||
expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Paste wrapped text' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(scroll).toHaveClass(css.EditorTextareaScrollMultiline);
|
||||
});
|
||||
});
|
||||
|
||||
it('does not oscillate back to single-line when multiline layout slightly increases the available width', async () => {
|
||||
const queuedFrames = new Map<number, FrameRequestCallback>();
|
||||
let nextFrameId = 1;
|
||||
let resizeObserverCallback: ResizeObserverCallback | undefined;
|
||||
const observedElements = new Set<Element>();
|
||||
const flushQueuedFrames = () => {
|
||||
const pendingFrames = Array.from(queuedFrames.entries());
|
||||
queuedFrames.clear();
|
||||
pendingFrames.forEach(([, callback]) => {
|
||||
callback(performance.now());
|
||||
});
|
||||
};
|
||||
|
||||
const requestAnimationFrameStub = ((callback: FrameRequestCallback) => {
|
||||
const frameId = nextFrameId;
|
||||
nextFrameId += 1;
|
||||
queuedFrames.set(frameId, callback);
|
||||
return frameId;
|
||||
}) as typeof window.requestAnimationFrame;
|
||||
const cancelAnimationFrameStub = ((frameId: number) => {
|
||||
queuedFrames.delete(frameId);
|
||||
}) as typeof window.cancelAnimationFrame;
|
||||
|
||||
window.requestAnimationFrame = requestAnimationFrameStub;
|
||||
window.cancelAnimationFrame = cancelAnimationFrameStub;
|
||||
globalThis.requestAnimationFrame = requestAnimationFrameStub;
|
||||
globalThis.cancelAnimationFrame = cancelAnimationFrameStub;
|
||||
globalThis.ResizeObserver = createResizeObserverStub(observedElements, (callback) => {
|
||||
resizeObserverCallback = callback;
|
||||
});
|
||||
|
||||
render(<NearThresholdWrapHarness />);
|
||||
const editable = document.querySelector('[data-editable-name="NearThresholdWrapHarness"]');
|
||||
const scroll = editable?.parentElement as HTMLElement | null;
|
||||
|
||||
expect(scroll).not.toBeNull();
|
||||
expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Paste near-threshold wrap' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(scroll).toHaveClass(css.EditorTextareaScrollMultiline);
|
||||
});
|
||||
expect(resizeObserverCallback).toBeDefined();
|
||||
|
||||
act(() => {
|
||||
resizeObserverCallback?.(
|
||||
Array.from(observedElements).map((target) => ({ target }) as ResizeObserverEntry),
|
||||
{} as ResizeObserver
|
||||
);
|
||||
});
|
||||
|
||||
act(() => {
|
||||
flushQueuedFrames();
|
||||
});
|
||||
|
||||
expect(scroll).toHaveClass(css.EditorTextareaScrollMultiline);
|
||||
});
|
||||
|
||||
it('counts trailing spaces toward the single-line wrap threshold', async () => {
|
||||
render(<TrailingSpacesWrapHarness />);
|
||||
const editable = document.querySelector('[data-editable-name="TrailingSpacesWrapHarness"]');
|
||||
const scroll = editable?.parentElement as HTMLElement | null;
|
||||
|
||||
expect(scroll).not.toBeNull();
|
||||
expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline);
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Paste trailing spaces' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(scroll).toHaveClass(css.EditorTextareaScrollMultiline);
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps fitting pasted text in single-line mode without deferring to the next frame', () => {
|
||||
const queuedFrames = new Map<number, FrameRequestCallback>();
|
||||
let nextFrameId = 1;
|
||||
|
||||
const requestAnimationFrameStub = ((callback: FrameRequestCallback) => {
|
||||
const frameId = nextFrameId;
|
||||
nextFrameId += 1;
|
||||
queuedFrames.set(frameId, callback);
|
||||
return frameId;
|
||||
}) as typeof window.requestAnimationFrame;
|
||||
const cancelAnimationFrameStub = ((frameId: number) => {
|
||||
queuedFrames.delete(frameId);
|
||||
}) as typeof window.cancelAnimationFrame;
|
||||
window.requestAnimationFrame = requestAnimationFrameStub;
|
||||
window.cancelAnimationFrame = cancelAnimationFrameStub;
|
||||
globalThis.requestAnimationFrame = requestAnimationFrameStub;
|
||||
globalThis.cancelAnimationFrame = cancelAnimationFrameStub;
|
||||
|
||||
render(<PasteNoWrapHarness />);
|
||||
const editable = document.querySelector('[data-editable-name="PasteNoWrapHarness"]');
|
||||
const scroll = editable?.parentElement as HTMLElement | null;
|
||||
|
||||
expect(scroll).not.toBeNull();
|
||||
expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline);
|
||||
|
||||
act(() => {
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Paste short text' }));
|
||||
});
|
||||
|
||||
expect(queuedFrames.size).toBe(0);
|
||||
expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline);
|
||||
});
|
||||
|
||||
it('reuses the cached measurement when resize observer fires without changing the single-line width', async () => {
|
||||
const queuedFrames = new Map<number, FrameRequestCallback>();
|
||||
let nextFrameId = 1;
|
||||
let resizeObserverCallback: ResizeObserverCallback | undefined;
|
||||
const observedElements = new Set<Element>();
|
||||
const flushQueuedFrames = () => {
|
||||
let safetyCounter = 0;
|
||||
while (queuedFrames.size > 0 && safetyCounter < 10) {
|
||||
const pendingFrames = Array.from(queuedFrames.entries());
|
||||
queuedFrames.clear();
|
||||
pendingFrames.forEach(([, callback]) => {
|
||||
callback(performance.now());
|
||||
});
|
||||
safetyCounter += 1;
|
||||
}
|
||||
};
|
||||
|
||||
const requestAnimationFrameStub = ((callback: FrameRequestCallback) => {
|
||||
const frameId = nextFrameId;
|
||||
nextFrameId += 1;
|
||||
queuedFrames.set(frameId, callback);
|
||||
return frameId;
|
||||
}) as typeof window.requestAnimationFrame;
|
||||
const cancelAnimationFrameStub = ((frameId: number) => {
|
||||
queuedFrames.delete(frameId);
|
||||
}) as typeof window.cancelAnimationFrame;
|
||||
|
||||
window.requestAnimationFrame = requestAnimationFrameStub;
|
||||
window.cancelAnimationFrame = cancelAnimationFrameStub;
|
||||
globalThis.requestAnimationFrame = requestAnimationFrameStub;
|
||||
globalThis.cancelAnimationFrame = cancelAnimationFrameStub;
|
||||
globalThis.ResizeObserver = createResizeObserverStub(observedElements, (callback) => {
|
||||
resizeObserverCallback = callback;
|
||||
});
|
||||
|
||||
render(<MeasurementCacheHarness />);
|
||||
|
||||
act(() => {
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Add cached text' }));
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(measurementCacheScrollHeightReads).toBe(1);
|
||||
});
|
||||
expect(resizeObserverCallback).toBeDefined();
|
||||
|
||||
act(() => {
|
||||
resizeObserverCallback?.(
|
||||
Array.from(observedElements).map((target) => ({ target }) as ResizeObserverEntry),
|
||||
{} as ResizeObserver
|
||||
);
|
||||
});
|
||||
|
||||
act(() => {
|
||||
flushQueuedFrames();
|
||||
});
|
||||
|
||||
expect(measurementCacheScrollHeightReads).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -5,10 +5,13 @@ import {
|
||||
ReactNode,
|
||||
forwardRef,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { Box, Scroll, Text } from 'folds';
|
||||
import { Descendant, Editor, createEditor } from 'slate';
|
||||
import { Descendant, Editor, Node, createEditor } from 'slate';
|
||||
import {
|
||||
Slate,
|
||||
Editable,
|
||||
@@ -53,12 +56,28 @@ export const useEditor = (): Editor => {
|
||||
};
|
||||
|
||||
export type EditorChangeHandler = (value: Descendant[]) => void;
|
||||
const MAX_MULTILINE_MEASURE_RETRIES = 2;
|
||||
const MULTILINE_HEIGHT_EPSILON = 1;
|
||||
const TRAILING_SPACE_SENTINEL = '\u200B';
|
||||
|
||||
const normalizeMeasurementText = (text: string): string =>
|
||||
/[ \t]+$/.test(text) ? `${text}${TRAILING_SPACE_SENTINEL}` : text;
|
||||
|
||||
type MultilineMeasurementCache = {
|
||||
result: boolean;
|
||||
singleLineWidth: number;
|
||||
styleKey: string;
|
||||
text: string;
|
||||
};
|
||||
|
||||
type CustomEditorProps = {
|
||||
editableName?: string;
|
||||
top?: ReactNode;
|
||||
bottom?: ReactNode;
|
||||
before?: ReactNode;
|
||||
after?: ReactNode;
|
||||
responsiveAfter?: ReactNode;
|
||||
forceMultilineLayout?: boolean;
|
||||
maxHeight?: string;
|
||||
editor: Editor;
|
||||
placeholder?: string;
|
||||
@@ -77,6 +96,8 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
||||
bottom,
|
||||
before,
|
||||
after,
|
||||
responsiveAfter,
|
||||
forceMultilineLayout = false,
|
||||
maxHeight = '50vh',
|
||||
editor,
|
||||
placeholder,
|
||||
@@ -97,6 +118,265 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
||||
const [slateInitialValue] = useState<CustomElement[]>(() => [
|
||||
{ type: BlockType.Paragraph, children: [{ text: '' }] },
|
||||
]);
|
||||
const rootRef = useRef<HTMLDivElement | null>(null);
|
||||
const editableRef = useRef<HTMLDivElement>(null);
|
||||
const rowRef = useRef<HTMLDivElement>(null);
|
||||
const beforeRef = useRef<HTMLDivElement>(null);
|
||||
const afterRef = useRef<HTMLDivElement>(null);
|
||||
const textMeasurerRef = useRef<HTMLDivElement | null>(null);
|
||||
const measurementCacheRef = useRef<MultilineMeasurementCache | null>(null);
|
||||
const multilineMeasureFrameRef = useRef<number | null>(null);
|
||||
const multilineMeasureRetryRef = useRef(0);
|
||||
const singleLineWidthOffsetRef = useRef(0);
|
||||
const latestValueRef = useRef<Descendant[]>(editor.children);
|
||||
const isMultilineRef = useRef(false);
|
||||
const [isMultiline, setIsMultiline] = useState(false);
|
||||
const [measurementVersion, setMeasurementVersion] = useState(0);
|
||||
const hasBefore = Boolean(before);
|
||||
const hasAfter = Boolean(after);
|
||||
const hasResponsiveAfter = Boolean(responsiveAfter);
|
||||
const layoutIsMultiline = isMultiline || forceMultilineLayout;
|
||||
const showResponsiveAfterInFooter = hasResponsiveAfter && layoutIsMultiline;
|
||||
const showResponsiveAfterInline = hasResponsiveAfter && !showResponsiveAfterInFooter;
|
||||
|
||||
const setRootRef = useCallback(
|
||||
(node: HTMLDivElement | null) => {
|
||||
rootRef.current = node;
|
||||
if (typeof ref === 'function') {
|
||||
ref(node);
|
||||
} else if (ref) {
|
||||
Reflect.set(ref, 'current', node);
|
||||
}
|
||||
},
|
||||
[ref]
|
||||
);
|
||||
|
||||
const updateMultilineLayout = useCallback(
|
||||
(value: Descendant[] = editor.children) => {
|
||||
const hasMultipleBlocks = value.length > 1;
|
||||
const text = value.map((node) => Node.string(node)).join('');
|
||||
const hasExplicitNewlines = text.includes('\n');
|
||||
|
||||
const editable = editableRef.current;
|
||||
const row = rowRef.current;
|
||||
const textMeasurer = textMeasurerRef.current;
|
||||
if (editable && row && textMeasurer) {
|
||||
const scroll = editable.parentElement as HTMLDivElement | null;
|
||||
const computedStyle = getComputedStyle(editable);
|
||||
const beforeWidth = beforeRef.current?.offsetWidth ?? 0;
|
||||
const afterWidth = afterRef.current?.offsetWidth ?? 0;
|
||||
const rowSingleLineWidth = row.offsetWidth - beforeWidth - afterWidth;
|
||||
const isRenderedSingleLine = !layoutIsMultiline;
|
||||
|
||||
if (isRenderedSingleLine && scroll) {
|
||||
// Scroll.clientWidth is the width the editable actually gets after padding and
|
||||
// scrollbar math. Cache that delta while we are rendered single-line so later
|
||||
// hidden measurements can compare against the same usable width.
|
||||
const renderedSingleLineWidth = scroll.clientWidth;
|
||||
if (renderedSingleLineWidth > 0) {
|
||||
singleLineWidthOffsetRef.current = Math.max(
|
||||
0,
|
||||
rowSingleLineWidth - renderedSingleLineWidth
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const singleLineWidth = Math.max(
|
||||
0,
|
||||
rowSingleLineWidth - singleLineWidthOffsetRef.current
|
||||
);
|
||||
|
||||
if (
|
||||
text.length > 0 &&
|
||||
singleLineWidth <= 0 &&
|
||||
multilineMeasureRetryRef.current < MAX_MULTILINE_MEASURE_RETRIES
|
||||
) {
|
||||
multilineMeasureRetryRef.current += 1;
|
||||
if (multilineMeasureFrameRef.current !== null) {
|
||||
cancelAnimationFrame(multilineMeasureFrameRef.current);
|
||||
}
|
||||
multilineMeasureFrameRef.current = requestAnimationFrame(() => {
|
||||
multilineMeasureFrameRef.current = null;
|
||||
updateMultilineLayout();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
multilineMeasureRetryRef.current = 0;
|
||||
let nextMultiline = hasMultipleBlocks || hasExplicitNewlines;
|
||||
if (!nextMultiline && text.length > 0) {
|
||||
const styleKey = [
|
||||
computedStyle.font,
|
||||
computedStyle.lineHeight,
|
||||
computedStyle.letterSpacing,
|
||||
computedStyle.fontKerning,
|
||||
computedStyle.fontFeatureSettings,
|
||||
computedStyle.fontVariationSettings,
|
||||
computedStyle.textTransform,
|
||||
computedStyle.textIndent,
|
||||
computedStyle.tabSize,
|
||||
].join('|');
|
||||
const cachedMeasurement = measurementCacheRef.current;
|
||||
|
||||
if (
|
||||
cachedMeasurement?.text === text &&
|
||||
cachedMeasurement.singleLineWidth === singleLineWidth &&
|
||||
cachedMeasurement.styleKey === styleKey
|
||||
) {
|
||||
nextMultiline = cachedMeasurement.result;
|
||||
} else {
|
||||
textMeasurer.style.font = computedStyle.font;
|
||||
textMeasurer.style.lineHeight = computedStyle.lineHeight;
|
||||
textMeasurer.style.letterSpacing = computedStyle.letterSpacing;
|
||||
textMeasurer.style.fontKerning = computedStyle.fontKerning;
|
||||
textMeasurer.style.fontFeatureSettings = computedStyle.fontFeatureSettings;
|
||||
textMeasurer.style.fontVariationSettings = computedStyle.fontVariationSettings;
|
||||
textMeasurer.style.textTransform = computedStyle.textTransform;
|
||||
textMeasurer.style.textIndent = computedStyle.textIndent;
|
||||
textMeasurer.style.tabSize = computedStyle.tabSize;
|
||||
// Measure against a hidden clone instead of the live editable so we can ask
|
||||
// "would this wrap at single-line width?" without the current layout feeding
|
||||
// back into the answer.
|
||||
const measureHeight = (content: string, width: string): number => {
|
||||
textMeasurer.style.width = width;
|
||||
textMeasurer.textContent = normalizeMeasurementText(content);
|
||||
return textMeasurer.scrollHeight;
|
||||
};
|
||||
const singleLineHeight = measureHeight('M', 'max-content');
|
||||
const measuredHeight = measureHeight(text, `${Math.max(singleLineWidth, 0)}px`);
|
||||
nextMultiline = measuredHeight > singleLineHeight + MULTILINE_HEIGHT_EPSILON;
|
||||
measurementCacheRef.current = {
|
||||
result: nextMultiline,
|
||||
singleLineWidth,
|
||||
styleKey,
|
||||
text,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
measurementCacheRef.current = null;
|
||||
}
|
||||
|
||||
isMultilineRef.current = nextMultiline;
|
||||
setIsMultiline(nextMultiline);
|
||||
} else {
|
||||
const nextMultiline = hasMultipleBlocks || hasExplicitNewlines;
|
||||
isMultilineRef.current = nextMultiline;
|
||||
setIsMultiline(nextMultiline);
|
||||
}
|
||||
},
|
||||
[editor, layoutIsMultiline]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const root = rootRef.current;
|
||||
if (!root) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const measurerHost = document.createElement('div');
|
||||
const textMeasurer = document.createElement('div');
|
||||
measurerHost.setAttribute('aria-hidden', 'true');
|
||||
textMeasurer.setAttribute('aria-hidden', 'true');
|
||||
if (editableName) {
|
||||
textMeasurer.dataset.editorMeasurer = editableName;
|
||||
}
|
||||
Object.assign(measurerHost.style, {
|
||||
position: 'absolute',
|
||||
inset: '0',
|
||||
width: '0',
|
||||
height: '0',
|
||||
overflow: 'hidden',
|
||||
pointerEvents: 'none',
|
||||
visibility: 'hidden',
|
||||
zIndex: '-1',
|
||||
});
|
||||
Object.assign(textMeasurer.style, {
|
||||
padding: '0',
|
||||
border: '0',
|
||||
margin: '0',
|
||||
whiteSpace: 'pre-wrap',
|
||||
overflowWrap: 'break-word',
|
||||
wordBreak: 'break-word',
|
||||
boxSizing: 'border-box',
|
||||
});
|
||||
measurerHost.appendChild(textMeasurer);
|
||||
root.appendChild(measurerHost);
|
||||
textMeasurerRef.current = textMeasurer;
|
||||
|
||||
return () => {
|
||||
measurementCacheRef.current = null;
|
||||
textMeasurerRef.current = null;
|
||||
measurerHost.remove();
|
||||
};
|
||||
}, [editableName]);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (multilineMeasureFrameRef.current !== null) {
|
||||
cancelAnimationFrame(multilineMeasureFrameRef.current);
|
||||
}
|
||||
measurementCacheRef.current = null;
|
||||
multilineMeasureRetryRef.current = 0;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const queueMultilineMeasurement = useCallback(
|
||||
(resetRetry = true) => {
|
||||
if (multilineMeasureFrameRef.current !== null) {
|
||||
cancelAnimationFrame(multilineMeasureFrameRef.current);
|
||||
}
|
||||
if (resetRetry) {
|
||||
multilineMeasureRetryRef.current = 0;
|
||||
}
|
||||
multilineMeasureFrameRef.current = requestAnimationFrame(() => {
|
||||
multilineMeasureFrameRef.current = null;
|
||||
updateMultilineLayout();
|
||||
});
|
||||
},
|
||||
[updateMultilineLayout]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof ResizeObserver === 'undefined') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const observer = new ResizeObserver(() => {
|
||||
queueMultilineMeasurement();
|
||||
});
|
||||
const observedElements = [rowRef.current, beforeRef.current, afterRef.current].filter(
|
||||
(element): element is HTMLDivElement => element !== null
|
||||
);
|
||||
|
||||
observedElements.forEach((element) => observer.observe(element));
|
||||
|
||||
return () => observer.disconnect();
|
||||
}, [
|
||||
queueMultilineMeasurement,
|
||||
updateMultilineLayout,
|
||||
hasBefore,
|
||||
hasAfter,
|
||||
showResponsiveAfterInline,
|
||||
]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
updateMultilineLayout(latestValueRef.current);
|
||||
}, [measurementVersion, updateMultilineLayout]);
|
||||
|
||||
const handleChange = useCallback(
|
||||
(value: Descendant[]) => {
|
||||
latestValueRef.current = value;
|
||||
measurementCacheRef.current = null;
|
||||
if (multilineMeasureFrameRef.current !== null) {
|
||||
cancelAnimationFrame(multilineMeasureFrameRef.current);
|
||||
multilineMeasureFrameRef.current = null;
|
||||
}
|
||||
setMeasurementVersion((version) => version + 1);
|
||||
onChange?.(value);
|
||||
},
|
||||
[onChange]
|
||||
);
|
||||
|
||||
const renderElement = useCallback(
|
||||
(props: RenderElementProps) => <RenderElement {...props} />,
|
||||
@@ -133,24 +413,36 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={`${css.Editor} ${className || ''}`} ref={ref}>
|
||||
<Slate editor={editor} initialValue={slateInitialValue} onChange={onChange}>
|
||||
<div className={`${css.Editor} ${className || ''}`} ref={setRootRef}>
|
||||
<Slate editor={editor} initialValue={slateInitialValue} onChange={handleChange}>
|
||||
{top}
|
||||
<Box alignItems="Start">
|
||||
{before && (
|
||||
<Box className={css.EditorOptions} alignItems="Center" gap="100" shrink="No">
|
||||
<Box
|
||||
ref={rowRef}
|
||||
className={`${css.EditorRow} ${layoutIsMultiline ? css.EditorRowMultiline : ''} ${showResponsiveAfterInFooter ? css.EditorRowMultilineWithResponsiveAfter : ''}`}
|
||||
alignItems="Start"
|
||||
style={{ display: after ? 'grid' : 'flex' }}
|
||||
>
|
||||
{hasBefore && (
|
||||
<Box
|
||||
ref={beforeRef}
|
||||
className={`${css.EditorOptions} ${layoutIsMultiline ? css.EditorOptionsMultiline : ''}`}
|
||||
alignItems="Center"
|
||||
gap="100"
|
||||
shrink="No"
|
||||
>
|
||||
{before}
|
||||
</Box>
|
||||
)}
|
||||
<Scroll
|
||||
className={css.EditorTextareaScroll}
|
||||
className={`${css.EditorTextareaScroll} ${layoutIsMultiline ? css.EditorTextareaScrollMultiline : ''}`}
|
||||
variant={variant}
|
||||
style={{ maxHeight }}
|
||||
style={{ maxHeight: showResponsiveAfterInFooter ? undefined : maxHeight }}
|
||||
size="300"
|
||||
visibility="Always"
|
||||
hideTrack
|
||||
>
|
||||
<Editable
|
||||
ref={editableRef}
|
||||
data-editable-name={editableName}
|
||||
className={css.EditorTextarea}
|
||||
placeholder={placeholder}
|
||||
@@ -168,11 +460,28 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
||||
}}
|
||||
/>
|
||||
</Scroll>
|
||||
{after && (
|
||||
<Box className={css.EditorOptions} alignItems="Center" gap="100" shrink="No">
|
||||
{(hasAfter || showResponsiveAfterInline) && (
|
||||
<Box
|
||||
ref={afterRef}
|
||||
className={`${css.EditorOptions} ${layoutIsMultiline ? css.EditorOptionsMultiline : ''} ${layoutIsMultiline ? css.EditorOptionsAfterMultiline : ''}`}
|
||||
alignItems="Center"
|
||||
gap="100"
|
||||
shrink="No"
|
||||
>
|
||||
{showResponsiveAfterInline && responsiveAfter}
|
||||
{after}
|
||||
</Box>
|
||||
)}
|
||||
{showResponsiveAfterInFooter && (
|
||||
<Box
|
||||
className={css.EditorResponsiveAfterMultiline}
|
||||
alignItems="Center"
|
||||
justifyContent="End"
|
||||
gap="100"
|
||||
>
|
||||
{responsiveAfter}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
{bottom}
|
||||
</Slate>
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
import { type ReactNode } from 'react';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { render, act } from '@testing-library/react';
|
||||
import {
|
||||
AutocompleteMenu,
|
||||
AUTOCOMPLETE_NAVIGATE_EVENT,
|
||||
type AutocompleteNavigateDetail,
|
||||
} from './AutocompleteMenu';
|
||||
|
||||
// ── Mocks ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
vi.mock('focus-trap-react', () => ({
|
||||
default: ({ children }: { children: ReactNode }) => <>{children}</>,
|
||||
}));
|
||||
|
||||
vi.mock('folds', () => ({
|
||||
Header: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
Menu: ({ children }: { children: ReactNode }) => <div>{children}</div>,
|
||||
Scroll: ({ children, onKeyDown }: { children: ReactNode; onKeyDown?: unknown }) => (
|
||||
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
||||
<div onKeyDown={onKeyDown as React.KeyboardEventHandler}>{children}</div>
|
||||
),
|
||||
config: { space: { S200: '8px' } },
|
||||
Icons: {},
|
||||
}));
|
||||
|
||||
vi.mock('$utils/keyboard', () => ({
|
||||
preventScrollWithArrowKey: vi.fn(),
|
||||
stopPropagation: vi.fn(() => true),
|
||||
}));
|
||||
|
||||
vi.mock('$hooks/useAlive', () => ({
|
||||
useAlive: () => () => true,
|
||||
}));
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
function dispatchNavigate(container: HTMLElement, direction: 1 | -1) {
|
||||
const menu = container.querySelector('[data-autocomplete-menu]');
|
||||
if (!menu) throw new Error('data-autocomplete-menu element not found');
|
||||
menu.dispatchEvent(
|
||||
new CustomEvent<AutocompleteNavigateDetail>(AUTOCOMPLETE_NAVIGATE_EVENT, {
|
||||
bubbles: true,
|
||||
detail: { direction },
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function renderMenu(children: ReactNode) {
|
||||
return render(
|
||||
<AutocompleteMenu headerContent={<span>header</span>} requestClose={() => {}}>
|
||||
{children}
|
||||
</AutocompleteMenu>
|
||||
);
|
||||
}
|
||||
|
||||
// ── Tests ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
describe('AutocompleteMenu — data-selected stamping', () => {
|
||||
it('stamps the first button with data-selected="true" on initial render', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
<button type="button">Item 2</button>
|
||||
</>
|
||||
);
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('true');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('false');
|
||||
expect(buttons[2].getAttribute('data-selected')).toBe('false');
|
||||
});
|
||||
|
||||
it('stamps buttons when children load after initial render (async results)', async () => {
|
||||
// Start with no children (empty search, buttons not yet present)
|
||||
const { container, rerender } = renderMenu(null);
|
||||
|
||||
// Simulate async search results arriving
|
||||
await act(async () => {
|
||||
rerender(
|
||||
<AutocompleteMenu headerContent={<span>header</span>} requestClose={() => {}}>
|
||||
<button type="button">Result A</button>
|
||||
<button type="button">Result B</button>
|
||||
</AutocompleteMenu>
|
||||
);
|
||||
});
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons).toHaveLength(2);
|
||||
// First button must be marked selected — this was the bug: with the old
|
||||
// [selectedIndex] dep array the effect didn't re-run when buttons appeared.
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('true');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('false');
|
||||
});
|
||||
|
||||
it('resets selection to the first button when the item list changes', async () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
</>
|
||||
);
|
||||
|
||||
// Navigate to the second item
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
|
||||
const before = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(before[1].getAttribute('data-selected')).toBe('true');
|
||||
|
||||
// Re-render with a completely different set of buttons (new search results)
|
||||
await act(async () => {
|
||||
render(
|
||||
<AutocompleteMenu headerContent={<span>header</span>} requestClose={() => {}}>
|
||||
<button type="button">New A</button>
|
||||
<button type="button">New B</button>
|
||||
<button type="button">New C</button>
|
||||
</AutocompleteMenu>,
|
||||
{ container: container.firstElementChild?.parentElement ?? document.body }
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('AutocompleteMenu — keyboard navigation', () => {
|
||||
it('moves selection forward with direction +1', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
<button type="button">Item 2</button>
|
||||
</>
|
||||
);
|
||||
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('false');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('true');
|
||||
expect(buttons[2].getAttribute('data-selected')).toBe('false');
|
||||
});
|
||||
|
||||
it('moves selection backward with direction -1', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
<button type="button">Item 2</button>
|
||||
</>
|
||||
);
|
||||
|
||||
// Go to last item first
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
|
||||
act(() => dispatchNavigate(container, -1));
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('false');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('true');
|
||||
expect(buttons[2].getAttribute('data-selected')).toBe('false');
|
||||
});
|
||||
|
||||
it('clamps selection at the first item when navigating backward at index 0', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
</>
|
||||
);
|
||||
|
||||
act(() => dispatchNavigate(container, -1));
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('true');
|
||||
});
|
||||
|
||||
it('clamps selection at the last item when navigating forward past the end', () => {
|
||||
const { container } = renderMenu(
|
||||
<>
|
||||
<button type="button">Item 0</button>
|
||||
<button type="button">Item 1</button>
|
||||
</>
|
||||
);
|
||||
|
||||
act(() => dispatchNavigate(container, 1));
|
||||
act(() => dispatchNavigate(container, 1)); // attempt to go past the end
|
||||
|
||||
const buttons = container.querySelectorAll<HTMLButtonElement>('button');
|
||||
expect(buttons[0].getAttribute('data-selected')).toBe('false');
|
||||
expect(buttons[1].getAttribute('data-selected')).toBe('true');
|
||||
});
|
||||
});
|
||||
@@ -1,25 +1,29 @@
|
||||
import { ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||
import { ReactNode, useEffect, useRef, useState } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
import { Header, Menu, Scroll, config } from 'folds';
|
||||
|
||||
import { preventScrollWithArrowKey, stopPropagation } from '$utils/keyboard';
|
||||
import { useAlive } from '$hooks/useAlive';
|
||||
import { Editor } from 'slate';
|
||||
import { ReactEditor } from 'slate-react';
|
||||
import * as css from './AutocompleteMenu.css';
|
||||
import { BaseAutocompleteMenu } from './BaseAutocompleteMenu';
|
||||
|
||||
export const AUTOCOMPLETE_NAVIGATE_EVENT = 'autocomplete-navigate';
|
||||
export type AutocompleteNavigateDetail = { direction: 1 | -1 };
|
||||
|
||||
type AutocompleteMenuProps = {
|
||||
requestClose: () => void;
|
||||
headerContent: ReactNode;
|
||||
children: ReactNode;
|
||||
editor: Editor;
|
||||
};
|
||||
export function AutocompleteMenu({ headerContent, requestClose, children }: AutocompleteMenuProps) {
|
||||
export function AutocompleteMenu({
|
||||
headerContent,
|
||||
requestClose,
|
||||
children,
|
||||
editor,
|
||||
}: AutocompleteMenuProps) {
|
||||
const alive = useAlive();
|
||||
const itemsRef = useRef<HTMLDivElement>(null);
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const prevButtonCountRef = useRef(-1);
|
||||
|
||||
const handleDeactivate = () => {
|
||||
if (alive()) {
|
||||
@@ -27,69 +31,42 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto
|
||||
requestClose();
|
||||
}
|
||||
};
|
||||
|
||||
// Sync data-selected to DOM; reset to index 0 when the item list changes.
|
||||
// No dep array — runs after every render so newly-loaded buttons are stamped
|
||||
// immediately (buttons arrive async when search results load).
|
||||
// setSelectedIndex is a stable React setter; the conditional call never
|
||||
// triggers an infinite update chain (it only fires when button count changes).
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
useLayoutEffect(() => {
|
||||
const buttons = Array.from(
|
||||
itemsRef.current?.querySelectorAll<HTMLButtonElement>('button') ?? []
|
||||
);
|
||||
const count = buttons.length;
|
||||
|
||||
let idx = selectedIndex;
|
||||
if (count !== prevButtonCountRef.current) {
|
||||
prevButtonCountRef.current = count;
|
||||
idx = 0;
|
||||
if (selectedIndex !== 0) setSelectedIndex(0);
|
||||
}
|
||||
|
||||
const safeIdx = Math.max(0, Math.min(idx, count - 1));
|
||||
buttons.forEach((btn, i) => {
|
||||
btn.setAttribute('data-selected', String(i === safeIdx));
|
||||
});
|
||||
});
|
||||
|
||||
// Listen for navigation events dispatched by the editor key handler
|
||||
useEffect(() => {
|
||||
const container = itemsRef.current?.closest('[data-autocomplete-menu]');
|
||||
if (!container) return undefined;
|
||||
const handler = (e: Event) => {
|
||||
const { direction } = (e as CustomEvent<AutocompleteNavigateDetail>).detail;
|
||||
setSelectedIndex((prev) => {
|
||||
const buttons = itemsRef.current?.querySelectorAll('button') ?? [];
|
||||
return Math.max(0, Math.min(prev + direction, buttons.length - 1));
|
||||
});
|
||||
};
|
||||
container.addEventListener(AUTOCOMPLETE_NAVIGATE_EVENT, handler);
|
||||
return () => container.removeEventListener(AUTOCOMPLETE_NAVIGATE_EVENT, handler);
|
||||
}, []);
|
||||
const [isActive, setIsActive] = useState(true);
|
||||
useEffect(() => ReactEditor.focus(editor), [editor, isActive]);
|
||||
function handleInput(evt: any) {
|
||||
if (!evt) return;
|
||||
if (
|
||||
isKeyHotkey('arrowdown', evt) ||
|
||||
isKeyHotkey('arrowup', evt) ||
|
||||
isKeyHotkey('tab', evt) ||
|
||||
isKeyHotkey('esc', evt) ||
|
||||
isKeyHotkey('Enter', evt)
|
||||
)
|
||||
return;
|
||||
setIsActive(false);
|
||||
}
|
||||
|
||||
return (
|
||||
<BaseAutocompleteMenu>
|
||||
<FocusTrap
|
||||
active={isActive}
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onPostDeactivate: handleDeactivate,
|
||||
returnFocusOnDeactivate: false,
|
||||
clickOutsideDeactivates: true,
|
||||
allowOutsideClick: true,
|
||||
isKeyForward: (evt: KeyboardEvent) => isKeyHotkey('arrowdown', evt),
|
||||
isKeyBackward: (evt: KeyboardEvent) => isKeyHotkey('arrowup', evt),
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Menu className={css.AutocompleteMenu}>
|
||||
<Menu className={css.AutocompleteMenu} onKeyDown={(evt) => handleInput(evt)}>
|
||||
<Header className={css.AutocompleteMenuHeader} size="400">
|
||||
{headerContent}
|
||||
</Header>
|
||||
<Scroll style={{ flexGrow: 1 }} onKeyDown={preventScrollWithArrowKey}>
|
||||
<div
|
||||
ref={itemsRef}
|
||||
className={css.AutocompleteMenuItems}
|
||||
style={{ padding: config.space.S200 }}
|
||||
>
|
||||
<div ref={itemsRef} style={{ padding: config.space.S200 }}>
|
||||
{children}
|
||||
</div>
|
||||
</Scroll>
|
||||
|
||||
@@ -106,6 +106,7 @@ export function EmoticonAutocomplete({
|
||||
<AutocompleteMenu
|
||||
headerContent={<Text size="L400">{title ?? 'Emojis'}</Text>}
|
||||
requestClose={requestClose}
|
||||
editor={editor}
|
||||
>
|
||||
{autoCompleteEmoticon.map((emoticon) => {
|
||||
const isCustomEmoji = 'url' in emoticon;
|
||||
|
||||
@@ -135,7 +135,11 @@ export function RoomMentionAutocomplete({
|
||||
});
|
||||
|
||||
return (
|
||||
<AutocompleteMenu headerContent={<Text size="L400">Rooms</Text>} requestClose={requestClose}>
|
||||
<AutocompleteMenu
|
||||
headerContent={<Text size="L400">Rooms</Text>}
|
||||
requestClose={requestClose}
|
||||
editor={editor}
|
||||
>
|
||||
{autoCompleteRoomIds.length === 0 ? (
|
||||
<UnknownRoomMentionItem query={query} handleAutocomplete={handleAutocomplete} />
|
||||
) : (
|
||||
|
||||
@@ -143,7 +143,11 @@ export function UserMentionAutocomplete({
|
||||
});
|
||||
|
||||
return (
|
||||
<AutocompleteMenu headerContent={<Text size="L400">Mentions</Text>} requestClose={requestClose}>
|
||||
<AutocompleteMenu
|
||||
headerContent={<Text size="L400">Mentions</Text>}
|
||||
requestClose={requestClose}
|
||||
editor={editor}
|
||||
>
|
||||
{query.text === 'room' && (
|
||||
<UnknownMentionItem
|
||||
userId={roomAliasOrId}
|
||||
|
||||
@@ -25,8 +25,15 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
||||
};
|
||||
|
||||
const handleWheel = (e: WheelEvent) => {
|
||||
if (e.deltaY < 0) zoomIn();
|
||||
else zoomOut();
|
||||
const { deltaY } = e;
|
||||
// Mouse wheel scrolls only by integer delta values, therefore
|
||||
// If deltaY is an integer, then it's a mouse wheel action
|
||||
if (Number.isInteger(deltaY)) {
|
||||
if (deltaY < 0) {
|
||||
zoomIn();
|
||||
} else zoomOut();
|
||||
}
|
||||
// If it's not an integer, then it's a touchpad action, do nothing and let the browser handle the zooming
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
import { useCallback, useEffect, FormEventHandler } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import {
|
||||
Dialog,
|
||||
Overlay,
|
||||
OverlayCenter,
|
||||
OverlayBackdrop,
|
||||
Header,
|
||||
config,
|
||||
Box,
|
||||
Text,
|
||||
IconButton,
|
||||
Icon,
|
||||
Icons,
|
||||
Input,
|
||||
color,
|
||||
Button,
|
||||
Spinner,
|
||||
} from 'folds';
|
||||
import { MatrixError } from '$types/matrix-sdk';
|
||||
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
|
||||
const debugLog = createDebugLogger('KnockRoomPrompt');
|
||||
|
||||
type KnockRoomProps = {
|
||||
roomId: string;
|
||||
via?: string | string[];
|
||||
onDone: () => void;
|
||||
onCancel: () => void;
|
||||
};
|
||||
export function KnockRoomPrompt({ roomId, via, onDone, onCancel }: KnockRoomProps) {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const [knockState, knockRoom] = useAsyncCallback<undefined, MatrixError, [string?]>(
|
||||
useCallback(
|
||||
async (reason?: string) => {
|
||||
debugLog.info('ui', 'Knock room button clicked', { roomId });
|
||||
mx.knockRoom(roomId, { viaServers: via || undefined, reason });
|
||||
},
|
||||
[mx, roomId, via]
|
||||
)
|
||||
);
|
||||
|
||||
const handleKnock: FormEventHandler<HTMLFormElement> = (evt) => {
|
||||
evt.preventDefault();
|
||||
const target = evt.target as HTMLFormElement;
|
||||
const reasonInput = (target?.reasonInput as HTMLInputElement) || undefined;
|
||||
const reason = reasonInput?.value.trim() || undefined;
|
||||
knockRoom(reason);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (knockState.status === AsyncStatus.Success) {
|
||||
debugLog.info('ui', 'Successfully knocked on room', { roomId });
|
||||
onDone();
|
||||
}
|
||||
}, [knockState, onDone, roomId]);
|
||||
|
||||
return (
|
||||
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||
<OverlayCenter>
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: onCancel,
|
||||
clickOutsideDeactivates: true,
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Knock On Room</Text>
|
||||
</Box>
|
||||
<IconButton size="300" onClick={onCancel} radii="300">
|
||||
<Icon src={Icons.Cross} />
|
||||
</IconButton>
|
||||
</Header>
|
||||
<Box
|
||||
as="form"
|
||||
onSubmit={handleKnock}
|
||||
style={{ padding: config.space.S400 }}
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<Box direction="Column" gap="200">
|
||||
<Text priority="400">
|
||||
Request to join this room. You can optionally leave a reason for the moderators.
|
||||
</Text>
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">
|
||||
Reason{' '}
|
||||
<Text as="span" size="T200">
|
||||
(Optional)
|
||||
</Text>
|
||||
</Text>
|
||||
<Input name="reasonInput" variant="Background" />
|
||||
{knockState.status === AsyncStatus.Error && (
|
||||
<Text style={{ color: color.Critical.Main }} size="T300">
|
||||
Failed to knock! {knockState.error.message}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="Primary"
|
||||
before={
|
||||
knockState.status === AsyncStatus.Loading ? (
|
||||
<Spinner fill="Solid" variant="Primary" size="200" />
|
||||
) : undefined
|
||||
}
|
||||
aria-disabled={
|
||||
knockState.status === AsyncStatus.Loading ||
|
||||
knockState.status === AsyncStatus.Success
|
||||
}
|
||||
>
|
||||
<Text size="B400">
|
||||
{knockState.status === AsyncStatus.Loading ? 'Knocking...' : 'Knock'}
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Dialog>
|
||||
</FocusTrap>
|
||||
</OverlayCenter>
|
||||
</Overlay>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './KnockRoomPrompt';
|
||||
@@ -121,6 +121,12 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
|
||||
|
||||
const isJumbo = useMemo(() => {
|
||||
if (!trimmedBody || trimmedBody.length >= 500) return false;
|
||||
if (
|
||||
(unwrappedPerMessageProfileMessage ?? safeCustomBody)?.match(
|
||||
/^(<img[^>]*data-mx-emoticon[^>]*\/>){1,20}$/i
|
||||
)
|
||||
)
|
||||
return true;
|
||||
if (!JUMBO_EMOJI_REG.test(trimmedBody)) return false;
|
||||
|
||||
if (trimmedBody.includes(':')) {
|
||||
@@ -129,7 +135,7 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
|
||||
}
|
||||
|
||||
return true;
|
||||
}, [trimmedBody, safeCustomBody]);
|
||||
}, [unwrappedPerMessageProfileMessage, trimmedBody, safeCustomBody]);
|
||||
|
||||
if (!body && !customBody) return <BrokenContent body={customBody ?? body} />;
|
||||
|
||||
@@ -139,7 +145,11 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
|
||||
if ((content['com.beeper.per_message_profile'] as PerMessageProfileBeeperFormat)?.has_fallback) {
|
||||
// unwrap per-message profile fallback if present
|
||||
return (
|
||||
<MessageTextBody preWrap={typeof customBody !== 'string'} style={style}>
|
||||
<MessageTextBody
|
||||
preWrap={typeof customBody !== 'string'}
|
||||
style={style}
|
||||
jumboEmoji={isJumbo ? jumboEmojiSize : 'none'}
|
||||
>
|
||||
{renderBody({
|
||||
body: trimmedBody,
|
||||
customBody: unwrappedPerMessageProfileMessage,
|
||||
|
||||
@@ -1,10 +1,94 @@
|
||||
import { MouseEventHandler, useEffect, useState } from 'react';
|
||||
import parse, { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import Linkify from 'linkify-react';
|
||||
import { Opts } from 'linkifyjs';
|
||||
import { PopOut, RectCords, Text, Tooltip, TooltipProvider, toRem } from 'folds';
|
||||
import { sanitizeCustomHtml } from '$utils/sanitize';
|
||||
import { highlightText, scaleSystemEmoji } from '$plugins/react-custom-html-parser';
|
||||
import { useRoomAbbreviationsContext } from '$hooks/useRoomAbbreviations';
|
||||
import { splitByAbbreviations } from '$utils/abbreviations';
|
||||
import { MessageEmptyContent } from './content';
|
||||
|
||||
type AbbreviationTermProps = {
|
||||
text: string;
|
||||
definition: string;
|
||||
};
|
||||
function AbbreviationTerm({ text, definition }: AbbreviationTermProps) {
|
||||
const [anchor, setAnchor] = useState<RectCords | undefined>();
|
||||
|
||||
const handleClick: MouseEventHandler<HTMLElement> = (e) => {
|
||||
e.stopPropagation();
|
||||
setAnchor((prev) => (prev ? undefined : e.currentTarget.getBoundingClientRect()));
|
||||
};
|
||||
|
||||
// On mobile, tapping an abbreviation pins the tooltip open.
|
||||
// Tapping anywhere else (outside the abbr) dismisses it.
|
||||
useEffect(() => {
|
||||
if (!anchor) return undefined;
|
||||
const dismiss = () => setAnchor(undefined);
|
||||
document.addEventListener('click', dismiss, { once: true });
|
||||
return () => document.removeEventListener('click', dismiss);
|
||||
}, [anchor]);
|
||||
|
||||
const tooltipContent = (
|
||||
<Tooltip style={{ maxWidth: toRem(250) }}>
|
||||
<Text size="T200">{definition}</Text>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<TooltipProvider position="Top" tooltip={tooltipContent}>
|
||||
{(triggerRef) => (
|
||||
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
||||
<abbr
|
||||
ref={triggerRef as React.Ref<HTMLElement>}
|
||||
onClick={handleClick}
|
||||
style={{ textDecoration: 'underline dotted', cursor: 'help' }}
|
||||
>
|
||||
{text}
|
||||
</abbr>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
{anchor && (
|
||||
<PopOut anchor={anchor} position="Top" align="Center" content={tooltipContent}>
|
||||
{null}
|
||||
</PopOut>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a `replaceTextNode` callback for use with {@link getReactCustomHtmlParser}.
|
||||
* Returns `undefined` when there are no abbreviations to apply (avoids creating
|
||||
* extra closures in the common case).
|
||||
*/
|
||||
export function buildAbbrReplaceTextNode(
|
||||
abbrMap: Map<string, string>
|
||||
): ((text: string) => JSX.Element | undefined) | undefined {
|
||||
if (abbrMap.size === 0) return undefined;
|
||||
return function replaceTextNode(text: string) {
|
||||
const segments = splitByAbbreviations(text, abbrMap);
|
||||
if (!segments.some((s) => s.termKey !== undefined)) return undefined;
|
||||
return (
|
||||
<>
|
||||
{segments.map((seg) =>
|
||||
seg.termKey !== undefined ? (
|
||||
<AbbreviationTerm
|
||||
key={seg.id}
|
||||
text={seg.text}
|
||||
definition={abbrMap.get(seg.termKey) ?? ''}
|
||||
/>
|
||||
) : (
|
||||
seg.text
|
||||
)
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
type RenderBodyProps = {
|
||||
body: string;
|
||||
customBody?: string;
|
||||
@@ -20,12 +104,37 @@ export function RenderBody({
|
||||
htmlReactParserOptions,
|
||||
linkifyOpts,
|
||||
}: Readonly<RenderBodyProps>) {
|
||||
const abbrMap = useRoomAbbreviationsContext();
|
||||
|
||||
if (customBody) {
|
||||
if (customBody === '') return <MessageEmptyContent />;
|
||||
return parse(sanitizeCustomHtml(customBody), htmlReactParserOptions);
|
||||
}
|
||||
if (body === '') return <MessageEmptyContent />;
|
||||
|
||||
if (abbrMap.size > 0) {
|
||||
const segments = splitByAbbreviations(body, abbrMap);
|
||||
if (segments.some((s) => s.termKey !== undefined)) {
|
||||
return (
|
||||
<>
|
||||
{segments.map((seg) => {
|
||||
if (seg.termKey !== undefined) {
|
||||
const definition = abbrMap.get(seg.termKey) ?? '';
|
||||
return <AbbreviationTerm key={seg.id} text={seg.text} definition={definition} />;
|
||||
}
|
||||
return (
|
||||
<Linkify key={seg.id} options={linkifyOpts}>
|
||||
{highlightRegex
|
||||
? highlightText(highlightRegex, scaleSystemEmoji(seg.text))
|
||||
: scaleSystemEmoji(seg.text)}
|
||||
</Linkify>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Linkify options={linkifyOpts}>
|
||||
{highlightRegex
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Box, Chip, Icon, Icons, Text, as, color, toRem } from 'folds';
|
||||
import { EventTimelineSet, Room } from '$types/matrix-sdk';
|
||||
import { Box, Chip, Icon, IconSrc, Icons, Text, as, color, toRem } from 'folds';
|
||||
import { EventTimelineSet, IMentions, Room, SessionMembershipData } from '$types/matrix-sdk';
|
||||
import { MouseEventHandler, ReactNode, useCallback, useMemo } from 'react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import classNames from 'classnames';
|
||||
@@ -12,6 +12,9 @@ import {
|
||||
getReactCustomHtmlParser,
|
||||
scaleSystemEmoji,
|
||||
LINKIFY_OPTS,
|
||||
makeMentionCustomProps,
|
||||
factoryRenderLinkifyWithMention,
|
||||
renderMatrixMention,
|
||||
} from '$plugins/react-custom-html-parser';
|
||||
import { useRoomEvent } from '$hooks/useRoomEvent';
|
||||
import { useSableCosmetics } from '$hooks/useSableCosmetics';
|
||||
@@ -19,6 +22,11 @@ import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { useIgnoredUsers } from '$hooks/useIgnoredUsers';
|
||||
import { nicknamesAtom } from '$state/nicknames';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { useMemberEventParser } from '$hooks/useMemberEventParser';
|
||||
import { StateEvent, MessageEvent } from '$types/matrix/room';
|
||||
import { useMentionClickHandler } from '$hooks/useMentionClickHandler';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import * as customHtmlCss from '$styles/CustomHtml.css';
|
||||
import {
|
||||
MessageBadEncryptedContent,
|
||||
MessageBlockedContent,
|
||||
@@ -31,9 +39,12 @@ import { LinePlaceholder } from './placeholder';
|
||||
type ReplyLayoutProps = {
|
||||
userColor?: string;
|
||||
username?: ReactNode;
|
||||
icon?: IconSrc;
|
||||
mentioned: boolean;
|
||||
replyIcon?: JSX.Element;
|
||||
};
|
||||
export const ReplyLayout = as<'div', ReplyLayoutProps>(
|
||||
({ username, userColor, className, children, ...props }, ref) => (
|
||||
({ username, userColor, icon, className, mentioned, children, replyIcon, ...props }, ref) => (
|
||||
<Box
|
||||
className={classNames(css.Reply, className)}
|
||||
alignItems="Center"
|
||||
@@ -41,8 +52,12 @@ export const ReplyLayout = as<'div', ReplyLayoutProps>(
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
<Box style={{ color: userColor }} alignItems="Center" shrink="No">
|
||||
{replyIcon || <Icon size="100" src={Icons.ReplyArrow} />}
|
||||
</Box>
|
||||
{!!icon && <Icon style={{ opacity: 0.6 }} size="50" src={icon} />}
|
||||
<Box style={{ color: userColor, maxWidth: toRem(200) }} alignItems="Center" shrink="No">
|
||||
<Icon size="100" src={Icons.ReplyArrow} />
|
||||
{mentioned && <Icon size="100" src={Icons.Mention} />}
|
||||
{username}
|
||||
</Box>
|
||||
<Box grow="Yes" className={css.ReplyContent}>
|
||||
@@ -71,11 +86,16 @@ type ReplyProps = {
|
||||
timelineSet?: EventTimelineSet;
|
||||
replyEventId: string;
|
||||
threadRootId?: string;
|
||||
mentions?: IMentions;
|
||||
onClick?: MouseEventHandler;
|
||||
replyIcon?: JSX.Element;
|
||||
};
|
||||
|
||||
export const Reply = as<'div', ReplyProps>(
|
||||
({ room, timelineSet, replyEventId, threadRootId, onClick, ...props }, ref) => {
|
||||
(
|
||||
{ room, timelineSet, replyEventId, threadRootId, mentions, onClick, replyIcon, ...props },
|
||||
ref
|
||||
) => {
|
||||
const placeholderWidth = useMemo(() => randomNumberBetween(40, 400), []);
|
||||
const getFromLocalTimeline = useCallback(
|
||||
() => timelineSet?.findEventById(replyEventId),
|
||||
@@ -88,21 +108,23 @@ export const Reply = as<'div', ReplyProps>(
|
||||
|
||||
const { body, formatted_body: formattedBody, format } = replyEvent?.getContent() ?? {};
|
||||
const sender = replyEvent?.getSender();
|
||||
const eventType = replyEvent?.getType();
|
||||
|
||||
const ignoredUsers = useIgnoredUsers();
|
||||
const isBlockedSender = !!sender && ignoredUsers.includes(sender);
|
||||
const { t } = useTranslation();
|
||||
const isRedacted = replyEvent?.isRedacted() === true;
|
||||
|
||||
const parseMemberEvent = useMemberEventParser();
|
||||
|
||||
const { color: usernameColor, font: usernameFont } = useSableCosmetics(sender ?? '', room);
|
||||
const nicknames = useAtomValue(nicknamesAtom);
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
|
||||
const fallbackBody = replyEvent?.isRedacted() ? (
|
||||
<MessageDeletedContent />
|
||||
) : (
|
||||
<MessageFailedContent />
|
||||
);
|
||||
const fallbackBody = isRedacted ? <MessageDeletedContent /> : <MessageFailedContent />;
|
||||
|
||||
const badEncryption = replyEvent?.getContent().msgtype === 'm.bad.encrypted';
|
||||
const mentionClickHandler = useMentionClickHandler(room.roomId);
|
||||
|
||||
// An encrypted event that hasn't been decrypted yet (keys pending) has an
|
||||
// empty result from getClearContent(). Treat it as still-loading rather
|
||||
@@ -116,6 +138,24 @@ export const Reply = as<'div', ReplyProps>(
|
||||
!replyEvent.getClearContent();
|
||||
|
||||
let bodyJSX: ReactNode = fallbackBody;
|
||||
let image: IconSrc | undefined;
|
||||
let mentioned = sender != null && (mentions?.user_ids?.includes(sender) ?? false);
|
||||
|
||||
const replyLinkifyOpts = useMemo(
|
||||
() => ({
|
||||
...LINKIFY_OPTS,
|
||||
render: factoryRenderLinkifyWithMention((href) =>
|
||||
renderMatrixMention(
|
||||
mx,
|
||||
room.roomId,
|
||||
href,
|
||||
makeMentionCustomProps(mentionClickHandler),
|
||||
nicknames
|
||||
)
|
||||
),
|
||||
}),
|
||||
[mx, room.roomId, mentionClickHandler, nicknames]
|
||||
);
|
||||
|
||||
if (format === 'org.matrix.custom.html' && formattedBody) {
|
||||
const strippedHtml = trimReplyFromFormattedBody(formattedBody)
|
||||
@@ -126,16 +166,70 @@ export const Reply = as<'div', ReplyProps>(
|
||||
.replaceAll(/<\/?(ul|ol|li|blockquote|h[1-6]|pre|div)[^>]*>/gi, '')
|
||||
.replaceAll(/(?:\r\n|\r|\n)/g, ' ');
|
||||
const parserOpts = getReactCustomHtmlParser(mx, room.roomId, {
|
||||
linkifyOpts: LINKIFY_OPTS,
|
||||
linkifyOpts: replyLinkifyOpts,
|
||||
useAuthentication,
|
||||
nicknames,
|
||||
handleMentionClick: mentionClickHandler,
|
||||
});
|
||||
bodyJSX = parse(strippedHtml, parserOpts) as JSX.Element;
|
||||
} else if (body) {
|
||||
const strippedBody = trimReplyFromBody(body).replaceAll(/(?:\r\n|\r|\n)/g, ' ');
|
||||
bodyJSX = scaleSystemEmoji(strippedBody);
|
||||
} else if (eventType === StateEvent.RoomMember && !!replyEvent) {
|
||||
const parsedMemberEvent = parseMemberEvent(replyEvent);
|
||||
image = parsedMemberEvent.icon;
|
||||
mentioned = false;
|
||||
bodyJSX = (
|
||||
<Box direction="Row" style={{ columnGap: toRem(6) }}>
|
||||
{' '}
|
||||
{parsedMemberEvent.body}{' '}
|
||||
</Box>
|
||||
);
|
||||
} else if (eventType === StateEvent.RoomName) {
|
||||
image = Icons.Hash;
|
||||
bodyJSX = t('Organisms.RoomCommon.changed_room_name');
|
||||
} else if (eventType === StateEvent.RoomTopic) {
|
||||
image = Icons.Hash;
|
||||
bodyJSX = ' changed room topic';
|
||||
} else if (eventType === StateEvent.RoomAvatar) {
|
||||
image = Icons.Hash;
|
||||
bodyJSX = ' changed room avatar';
|
||||
} else if (eventType === StateEvent.GroupCallMemberPrefix && !!replyEvent) {
|
||||
const callJoined = replyEvent.getContent<SessionMembershipData>().application;
|
||||
image = callJoined ? Icons.Phone : Icons.PhoneDown;
|
||||
bodyJSX = callJoined ? ' joined the call' : ' ended the call';
|
||||
} else if (eventType === StateEvent.RoomPinnedEvents && replyEvent) {
|
||||
const { pinned } = replyEvent.getContent();
|
||||
const prevPinned = replyEvent.getPrevContent().pinned;
|
||||
const pinsAdded =
|
||||
prevPinned && pinned && pinned.filter((x: string) => !prevPinned.includes(x));
|
||||
const pinsRemoved =
|
||||
prevPinned && pinned && prevPinned.filter((x: string) => !pinned.includes(x));
|
||||
image = Icons.Pin;
|
||||
bodyJSX = (
|
||||
<>
|
||||
{(pinsAdded?.length > 0 &&
|
||||
`pinned ${pinsAdded.length} message${pinsAdded.length > 1 ? 's' : ''}`) ||
|
||||
''}
|
||||
{(pinsAdded?.length > 0 && pinsRemoved?.length > 0 && `and`) || ''}
|
||||
{(pinsRemoved?.length > 0 &&
|
||||
`unpinned ${pinsRemoved.length} message${pinsRemoved.length > 1 ? 's' : ''}`) ||
|
||||
''}
|
||||
{(!pinsAdded || pinsAdded.length <= 0) &&
|
||||
(!pinsRemoved || pinsRemoved.length <= 0) &&
|
||||
`has not changed the pins`}
|
||||
</>
|
||||
);
|
||||
} else if (Object.values(MessageEvent).every((v) => v !== eventType && !!eventType)) {
|
||||
image = Icons.Code;
|
||||
bodyJSX = (
|
||||
<>
|
||||
{' sent '}
|
||||
<code className={customHtmlCss.Code}>{eventType}</code>
|
||||
{' state event'}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Box direction="Row" gap="200" alignItems="Center" {...props} ref={ref}>
|
||||
{threadRootId && (
|
||||
@@ -144,8 +238,12 @@ export const Reply = as<'div', ReplyProps>(
|
||||
<ReplyLayout
|
||||
as="button"
|
||||
userColor={usernameColor}
|
||||
icon={image}
|
||||
replyIcon={replyIcon}
|
||||
mentioned={mentioned}
|
||||
username={
|
||||
sender && (
|
||||
sender &&
|
||||
eventType !== StateEvent.RoomMember && (
|
||||
<Text size="T300" truncate style={{ fontFamily: usernameFont }}>
|
||||
<b>{getMemberDisplayName(room, sender, nicknames) ?? getMxIdLocalPart(sender)}</b>
|
||||
</Text>
|
||||
@@ -163,13 +261,15 @@ export const Reply = as<'div', ReplyProps>(
|
||||
})()}
|
||||
</Text>
|
||||
) : (
|
||||
<LinePlaceholder
|
||||
style={{
|
||||
backgroundColor: color.SurfaceVariant.ContainerActive,
|
||||
width: toRem(placeholderWidth),
|
||||
maxWidth: '100%',
|
||||
}}
|
||||
/>
|
||||
(isRedacted && <MessageDeletedContent />) || (
|
||||
<LinePlaceholder
|
||||
style={{
|
||||
backgroundColor: color.SurfaceVariant.ContainerActive,
|
||||
width: toRem(placeholderWidth),
|
||||
maxWidth: '100%',
|
||||
}}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</ReplyLayout>
|
||||
{replyEvent === null && (
|
||||
|
||||
@@ -93,9 +93,9 @@ type ForwardMeta = {
|
||||
|
||||
// see https://github.com/hummlbach/matrix-doc/blob/acea0854a1c9489599295a858b068ce02a6b2b20/proposals/2723-add-forward-info.md
|
||||
type MSC2723ForwardMeta = {
|
||||
event_id: string;
|
||||
room_id: string;
|
||||
sender: string | null; // we won't set this field
|
||||
event_id?: string;
|
||||
room_id?: string;
|
||||
sender?: string; // we won't set this field
|
||||
origin_server_ts: number;
|
||||
};
|
||||
|
||||
@@ -109,7 +109,7 @@ export function MessageForwardInternal({
|
||||
const [isTargetSelected, setIsTargetSelected] = useState(false);
|
||||
const [isForwardSuccess, setIsForwardSuccess] = useState(false);
|
||||
const [isForwarding, setIsForwarding] = useState(false);
|
||||
const [isForwardError, setIsForwardError] = useState(false);
|
||||
const [forwardError, setForwardError] = useState<string | null>(null);
|
||||
const [targetRoomId, setTargetRoomId] = useState<string | null>(null);
|
||||
|
||||
// detect if it's a public room or not
|
||||
@@ -205,9 +205,9 @@ export function MessageForwardInternal({
|
||||
newBodyPlain = originalBody.length > 0 ? `${bodyModifText}\n\n${quotedBody}` : bodyModifText;
|
||||
|
||||
const safeHtml =
|
||||
originalFormattedBody !== undefined
|
||||
? sanitizeCustomHtml(originalFormattedBody)
|
||||
: sanitizeCustomHtml(originalBody).replaceAll('\n', '<br>');
|
||||
originalFormattedBody === undefined
|
||||
? sanitizeCustomHtml(originalBody).replaceAll('\n', '<br>')
|
||||
: sanitizeCustomHtml(originalFormattedBody);
|
||||
|
||||
newBodyHtml =
|
||||
`<div data-forward-marker>` +
|
||||
@@ -241,6 +241,9 @@ export function MessageForwardInternal({
|
||||
original_timestamp: mEvent.getTs(),
|
||||
original_event_private: true,
|
||||
} satisfies ForwardMeta,
|
||||
'com.famedly.app.forwarded': {
|
||||
origin_server_ts: mEvent.getTs(),
|
||||
} satisfies MSC2723ForwardMeta,
|
||||
};
|
||||
} else {
|
||||
content = {
|
||||
@@ -261,7 +264,6 @@ export function MessageForwardInternal({
|
||||
'com.famedly.app.forwarded': {
|
||||
event_id: eventId,
|
||||
room_id: room.roomId,
|
||||
sender: null, // we won't set this field, as a design decision to avoid potential privacy issues and since the sender can be inferred from the event_id and room_id if needed
|
||||
origin_server_ts: mEvent.getTs(),
|
||||
} satisfies MSC2723ForwardMeta,
|
||||
};
|
||||
@@ -285,15 +287,16 @@ export function MessageForwardInternal({
|
||||
setIsForwardSuccess(true);
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
debugLog.error('ui', 'Message forward failed', {
|
||||
sourceRoomId: room.roomId,
|
||||
targetRoomId: targetRoom.roomId,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
error: message,
|
||||
});
|
||||
Sentry.metrics.count('sable.message.forward.error', 1);
|
||||
setIsForwarding(false);
|
||||
setIsForwardSuccess(false);
|
||||
setIsForwardError(true);
|
||||
setForwardError(message);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -348,9 +351,9 @@ export function MessageForwardInternal({
|
||||
<Text>Forward to {getRoom(targetRoomId)?.name}</Text>
|
||||
</Button>
|
||||
)}
|
||||
{isForwardError && (
|
||||
{forwardError && (
|
||||
<Text size="T300" color="Critical600" style={{ margin: config.space.S300 }}>
|
||||
Failed to forward message. Please try again.
|
||||
Failed to forward: {forwardError}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ReactNode, useCallback, useRef, useState } from 'react';
|
||||
import { MatrixError, Room } from '$types/matrix-sdk';
|
||||
import { JoinRule, MatrixError, Room } from '$types/matrix-sdk';
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
@@ -21,7 +21,6 @@ import classNames from 'classnames';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix';
|
||||
import { nameInitials } from '$utils/common';
|
||||
import { millify } from '$plugins/millify';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { onEnterOrSpace, stopPropagation } from '$utils/keyboard';
|
||||
@@ -31,7 +30,9 @@ import { useElementSizeObserver } from '$hooks/useElementSizeObserver';
|
||||
import { getRoomAvatarUrl, getStateEvent } from '$utils/room';
|
||||
import { useStateEventCallback } from '$hooks/useStateEventCallback';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { KnockRoomPrompt } from '$components/knock-room-prompt';
|
||||
import { RoomAvatar } from '$components/room-avatar';
|
||||
import { formatCompactNumber } from '$utils/formatCompactNumber';
|
||||
import * as css from './style.css';
|
||||
|
||||
type GridColumnCount = '1' | '2' | '3';
|
||||
@@ -143,6 +144,7 @@ type RoomCardProps = {
|
||||
topic?: string;
|
||||
memberCount?: number;
|
||||
roomType?: string;
|
||||
joinRule?: JoinRule;
|
||||
viaServers?: string[];
|
||||
onView?: (roomId: string) => void;
|
||||
renderTopicViewer: (name: string, topic: string, requestClose: () => void) => ReactNode;
|
||||
@@ -158,6 +160,7 @@ export const RoomCard = as<'div', RoomCardProps>(
|
||||
topic,
|
||||
memberCount,
|
||||
roomType,
|
||||
joinRule,
|
||||
viaServers,
|
||||
onView,
|
||||
renderTopicViewer,
|
||||
@@ -172,7 +175,7 @@ export const RoomCard = as<'div', RoomCardProps>(
|
||||
const [topicEvent, setTopicEvent] = useState(() =>
|
||||
joinedRoom ? getStateEvent(joinedRoom, StateEvent.RoomTopic) : undefined
|
||||
);
|
||||
|
||||
const [knocking, setKnocking] = useState(false);
|
||||
const fallbackName = getMxIdLocalPart(roomIdOrAlias) ?? roomIdOrAlias;
|
||||
const fallbackTopic = roomIdOrAlias;
|
||||
|
||||
@@ -256,7 +259,7 @@ export const RoomCard = as<'div', RoomCardProps>(
|
||||
{typeof joinedMemberCount === 'number' && (
|
||||
<Box gap="100">
|
||||
<Icon size="50" src={Icons.User} />
|
||||
<Text size="T200">{`${millify(joinedMemberCount)} Members`}</Text>
|
||||
<Text size="T200">{`${formatCompactNumber(joinedMemberCount)} Members`}</Text>
|
||||
</Box>
|
||||
)}
|
||||
{typeof joinedRoomId === 'string' && (
|
||||
@@ -271,19 +274,38 @@ export const RoomCard = as<'div', RoomCardProps>(
|
||||
</Text>
|
||||
</Button>
|
||||
)}
|
||||
{typeof joinedRoomId !== 'string' && joinState.status !== AsyncStatus.Error && (
|
||||
<Button
|
||||
onClick={join}
|
||||
variant="Secondary"
|
||||
size="300"
|
||||
disabled={joining}
|
||||
before={joining && <Spinner size="50" variant="Secondary" fill="Soft" />}
|
||||
>
|
||||
<Text size="B300" truncate>
|
||||
{joining ? 'Joining' : 'Join'}
|
||||
</Text>
|
||||
</Button>
|
||||
)}
|
||||
{typeof joinedRoomId !== 'string' &&
|
||||
joinState.status !== AsyncStatus.Error &&
|
||||
(joinRule === JoinRule.Knock ? (
|
||||
<>
|
||||
<Button onClick={() => setKnocking(true)} variant="Secondary" size="300">
|
||||
<Text size="B300" truncate>
|
||||
Knock
|
||||
</Text>
|
||||
</Button>
|
||||
|
||||
{knocking && (
|
||||
<KnockRoomPrompt
|
||||
roomId={roomIdOrAlias}
|
||||
via={viaServers}
|
||||
onDone={() => setKnocking(false)}
|
||||
onCancel={() => setKnocking(false)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Button
|
||||
onClick={join}
|
||||
variant="Secondary"
|
||||
size="300"
|
||||
disabled={joining}
|
||||
before={joining && <Spinner size="50" variant="Secondary" fill="Soft" />}
|
||||
>
|
||||
<Text size="B300" truncate>
|
||||
{joining ? 'Joining' : 'Join'}
|
||||
</Text>
|
||||
</Button>
|
||||
))}
|
||||
{typeof joinedRoomId !== 'string' && joinState.status === AsyncStatus.Error && (
|
||||
<Box gap="200">
|
||||
<Button
|
||||
|
||||