Compare commits

...

224 Commits

Author SHA1 Message Date
Tom Moor bff6a80b67 styles 2022-06-25 19:07:18 +02:00
Tom Moor 07ad87f65f fix: Don't send email notification with empty diff 2022-06-24 09:57:53 +02:00
Tom Moor dd471328db fix: Collection name missing in notification email
fix: Email styles
2022-06-24 09:50:39 +02:00
Tom Moor 04f0983e20 Bringing across still relevant work from email-diff branch 2022-06-23 10:54:11 +02:00
Tom Moor 50456c3b89 fix: Custom domain authentication, regressed in:
https://github.com/outline/outline/pull/3652
2022-06-22 21:58:05 +02:00
Tom Moor 51230a55e5 fix: Post-auth subdomain redirect 2022-06-22 19:51:37 +02:00
Tom Moor 6d4da176d1 chore: Move provisionSubdomain from Team model to teamCreator command 2022-06-22 11:09:20 +02:00
Tom Moor 88b3b50333 Enable turning off collaborative editing when self-hosted with warning 2022-06-22 09:15:14 +02:00
Tom Moor 305de71e8b chore: Block all email providers from being added as team domains (#3678) 2022-06-21 01:29:43 -07:00
Tom Moor 9cd3ec0868 chore: Simplify model save codepath, prevents text from being sent ever when collab editing enabled 2022-06-20 22:55:37 +02:00
Tom Moor 6975d76faf fix: Paste without formatting not respected
closes #3675
2022-06-20 15:58:07 +02:00
Tom Moor 4b27feff61 fix: Enable documents.update with collab editing (#3647)
* fix: Enable documents.update with collab editing

* jest cannot deal with ESM deps
2022-06-20 06:36:25 -07:00
Nan Yu e0d2b6cace feat: allow personal gmail accounts to be used to sign into teams with an existing invite (#3652)
* feat: allow personal gmail accounts to be used to sign into teams with an existing invite

* address comments

* add comment for appDomain

* address comments
2022-06-20 01:33:16 -07:00
Translate-O-Tron 188c1e409b New Crowdin updates (#3648)
* fix: New Chinese Simplified translations from Crowdin [ci skip]

* fix: New German translations from Crowdin [ci skip]

* fix: New Portuguese translations from Crowdin [ci skip]

* fix: New Persian translations from Crowdin [ci skip]

* fix: New Portuguese, Brazilian translations from Crowdin [ci skip]

* fix: New Vietnamese translations from Crowdin [ci skip]

* fix: New Chinese Traditional translations from Crowdin [ci skip]

* fix: New Turkish translations from Crowdin [ci skip]

* fix: New Swedish translations from Crowdin [ci skip]

* fix: New Russian translations from Crowdin [ci skip]

* fix: New Polish translations from Crowdin [ci skip]

* fix: New Spanish translations from Crowdin [ci skip]

* fix: New Korean translations from Crowdin [ci skip]

* fix: New Japanese translations from Crowdin [ci skip]

* fix: New Italian translations from Crowdin [ci skip]

* fix: New Danish translations from Crowdin [ci skip]

* fix: New French translations from Crowdin [ci skip]

* fix: New Dutch translations from Crowdin [ci skip]

* fix: New Indonesian translations from Crowdin [ci skip]

* fix: New Chinese Simplified translations from Crowdin [ci skip]

* fix: New Thai translations from Crowdin [ci skip]

* fix: New French translations from Crowdin [ci skip]

* fix: New Chinese Simplified translations from Crowdin [ci skip]

* fix: New Indonesian translations from Crowdin [ci skip]
2022-06-19 14:24:53 -07:00
Nan Yu 9faa5dd011 chore: minor version bump (#3654) 2022-06-12 22:57:59 -07:00
Tom Moor 1a62926909 fix: Allow soft breaks in paragraphs with Shift-Enter 2022-06-09 21:41:15 +02:00
Tom Moor c4edfb8ebc fix: Improve embed option visibility in dark mode 2022-06-09 21:38:24 +02:00
Tom Moor 8421e1f773 fix: Allow soft breaks in paragraphs with Shift-Enter
closes #3276
2022-06-09 21:24:11 +02:00
Tom Moor 118e5da345 fix: Unpublished does not appear in document history
closes #3429
2022-06-09 21:16:37 +02:00
Tom Moor 1c7c478a4a fix: Newlines should be interpreted as paragraphs when pasting
closes #3421
2022-06-09 20:58:52 +02:00
Tom Moor 32cdb3f961 fix: Do not error when moving document into alphabetically ordered collection
closes #3649
2022-06-09 20:33:44 +02:00
Tom Moor d99d84d97d fix: Email cannot be found for some Azure sign-in accounts 2022-06-09 09:22:12 +02:00
Tom Moor aed8d7a649 fix: SSR meta data for nested shared documents (#3646) 2022-06-08 01:38:34 -07:00
Tom Moor 80ad6cfec8 fix: Expired refreshToken should invalidate session, not check SSO retry task 2022-06-08 08:55:58 +02:00
Translate-O-Tron 892146a563 New Crowdin updates (#3631) 2022-06-07 13:57:44 -07:00
Tom Moor 56393f39b7 fix: Previously provisioned JWT's should be revoked on signout (#3639)
* feat: auth.delete endpoint

* test
2022-06-07 13:57:17 -07:00
Tom Moor 0de6650aa5 chore: Suppress unneccessary model warnings from Sequelize upgrade 2022-06-07 09:38:00 +02:00
Tom Moor ac551a3c44 chore: Bump workbox-webpack-plugin dependency 2022-06-06 22:06:37 +02:00
Tom Moor 14b9259a47 fix: Always strip trailing slash on canonical links 2022-06-06 22:04:12 +02:00
Tom Moor e5b524e4c2 chore: Upgrade sequelize dependency 2022-06-06 21:54:54 +02:00
Tom Moor 4bccb4c4ec chore: Bump bull-board dependencies 2022-06-06 21:18:22 +02:00
Tom Moor cdd4f0f315 fix: Add postgresql as valid database protocol 2022-06-06 12:13:03 -07:00
Tom Moor 728790e38f feat: Validate Google, Azure, OIDC SSO access (#3590)
* chore: Store expiresAt on UserAuthentications. This represents the time that the accessToken is no longer valid and should be exchanged using the refreshToken

* feat: Check and expire Google SSO

* fix: Better handling of multiple auth methods
Added more docs

* fix: Retry access validation with network errors

* Small refactor, add Azure token validation support

* doc

* test

* lint

* OIDC refresh support

* CheckSSOAccessTask -> ValidateSSOAccessTask
Added lastValidatedAt column
Skip checks if validated within 5min
Some edge cases around encrypted columns
2022-06-05 13:18:51 -07:00
Tom Moor c4c5b6289e fix: Gap and grammar in Notification settings 2022-06-05 11:47:40 +02:00
Tom Moor e337123cfd fix: Add application/x-zip-compressed as acceptable mimetype for bulk import upload
related #3632
2022-06-05 11:01:37 +02:00
Tom Moor ac07724f21 chore: Synchronizing refactor and small fixes from enterprise codebase (#3634)
* chore: Syncronizing refactor and small fixes from enterprise codebase

* fix
2022-06-05 00:59:41 -07:00
Tom Moor 28439d315d fix: Self-hosted should show signin options for all configured authentication methods (#2986) 2022-06-04 10:46:03 -07:00
Tom Moor 4eb3b61c7a fix: Lazily polyfill ResizeObserver for old iOS (#3629)
* fix: Lazily polyfill ResizeObserver for old iOS

* fix: Prevent child rendering until polyfills are loaded

* tsc
2022-06-04 09:06:07 -07:00
Translate-O-Tron 6fc608c8c1 New Crowdin updates (#3622) 2022-06-04 08:15:54 -07:00
Tom Moor 2dc930bfe2 fix: Context menus not scrollable on iOS (#3626)
closes #3588
2022-06-04 08:15:43 -07:00
Tom Moor bf233b209b fix: Alternative fix to #3583, addresses some bugs that were introduced 2022-06-03 11:03:44 +02:00
Tom Moor 1dfd1e0681 fix: Reference error visiting share link for deleted team 2022-06-03 08:58:31 +02:00
dependabot[bot] 4054afe6f9 chore(deps): bump protobufjs from 6.11.2 to 6.11.3 (#3623) 2022-06-02 23:17:50 -07:00
Tom Moor 2d7dd558a1 fix: Unable to delete user via API (#3619)
Remove requirement to pass 'confirmation' to users.delete
closes #3604
2022-06-02 12:56:27 -07:00
Tom Moor 68dd76cfa3 chore: Update documentImporter with changes from enterprise, improved Confluence compat 2022-06-02 21:42:32 +02:00
Tom Moor 9113989635 fix: Members list does not update when viewing while underlying users changes
closes #3616
2022-06-02 18:43:07 +02:00
Translate-O-Tron 293ce2ba72 New Crowdin updates (#3608) 2022-06-02 09:30:28 -07:00
Nan Yu fa1ce950e8 fix: infinite redirects when hosted subdomain is changed back and forth between two values (#3615) 2022-06-02 09:30:13 -07:00
Tom Moor 0a77733500 fix: Update canonical url when moving between pages of shared document 2022-06-01 21:27:18 +02:00
Nan Yu 41e425756d chore: refactor domain parsing to be more general (#3448)
* change the api of domain parsing to just parseDomain and getCookieDomain
* adds getBaseDomain as the method to get the domain after any official subdomains
2022-05-31 18:48:23 -07:00
Translate-O-Tron 876f788f59 New Crowdin updates (#3597)
* fix: New German translations from Crowdin [ci skip]

* fix: New German translations from Crowdin [ci skip]

* fix: New Chinese Simplified translations from Crowdin [ci skip]

* fix: New German translations from Crowdin [ci skip]
2022-05-30 10:33:47 -07:00
Lennart Lösche 0ae559f7bf Update redis port in sample env file (#3596)
* fix redis port

The wrong Redis port is specified in the sample file, we fixed that

* adjust redis port in docker-compose
2022-05-30 10:06:10 -07:00
Tom Moor da87fd422d Remove hover styles on mobile context menus 2022-05-28 10:05:17 +02:00
Tom Moor 1e84872bab fix: Only consider enabled AuthenticationProviders for Slack hooks 2022-05-28 09:36:22 +02:00
Tom Moor 4f0051ed5e fix: Right click on links in editor opens them
closes #3594
2022-05-28 09:23:18 +02:00
Tom Moor 317ed1f041 fix: More env validation improvements
closes #3593
2022-05-28 09:11:02 +02:00
Tom Moor 8a29a3523a 0.64.3 2022-05-25 06:07:02 +01:00
Tom Moor 2babf42cda fix: Headings missing in TOC on publicly shared pages
closes #3583
2022-05-24 22:11:49 +01:00
Tom Moor df14da01b0 fix: Allow docker urls for OIDC, closes #3582 2022-05-24 21:20:18 +01:00
Tom Moor 62bb13047a 0.64.2 2022-05-24 08:00:08 +01:00
Tom Moor 6413797c34 fix: Empty string not parsed as false boolean in env validation
closes #3581
2022-05-24 07:59:52 +01:00
Tom Moor ef5e3f0b29 fix: Empty environment variables should not trigger validations
Add deprecation notice for SLACK_KEY, SLACK_SECRET
closes #3578
2022-05-23 21:37:27 +01:00
Baptiste Mille-Mathias 51249fd6f7 upgrade CodeQL action to v2 (#3572)
v1 will be declared deprecated starting dec' 22
https://github.blog/changelog/2022-04-27-code-scanning-deprecation-of-codeql-action-v1/
2022-05-23 12:51:33 -07:00
Tom Moor 151c2c731a 0.64.1 2022-05-23 13:19:49 +01:00
Tom Moor 519ed1ac2c fix: Environment variables always interpreted as true,
closes #3573
2022-05-23 13:19:38 +01:00
Tom Moor f1ce28cd8f fix: Allow underscores in Postgres and Redis hostnames for docker support
closes #3574
2022-05-23 13:11:52 +01:00
Tom Moor adb56a3c31 Update LICENSE 2022-05-23 01:56:46 -07:00
Tom Moor 280e1c1d86 0.64.0 2022-05-23 09:55:20 +01:00
Baptiste Mille-Mathias 3c8b9725e1 Fix github action for stale issues (#3569) 2022-05-23 01:42:30 -07:00
Tom Moor 73de15fd5d fix: documentUpdater called without change can result in lastModifiedById being updated 2022-05-22 22:39:54 +01:00
Tom Moor a78ad8dec2 fix: Escape user defined values (regressed just now bc7052b7ca) 2022-05-22 11:10:59 +01:00
Tom Moor 45c082f137 fix: Notices dark theme 2022-05-22 09:33:30 +01:00
Tom Moor 4a9892c2e1 robots 2022-05-22 08:58:44 +01:00
Tom Moor 6d7f008af0 fix: Sidebar missing on public documents when accessing with valid team token 2022-05-22 08:51:47 +01:00
Tom Moor bc7052b7ca feat: Inject description and canonical url into public share links 2022-05-22 08:46:57 +01:00
Tom Moor c4006cef7b perf: Remove markdown serialize from editor render path (#3567)
* perf: Remove markdown serialize from editor render path

* fix: Simplify heading equality check

* perf: Add cache for slugified headings

* tsc
2022-05-21 12:50:27 -07:00
Tom Moor 2a6d6f5804 chore: Restore more flexible SMTP env email validation 2022-05-21 14:01:57 +01:00
Tom Moor bf0ff6c823 chore: Casing of logger -> Logger as it's an instantiated class 2022-05-21 13:59:23 +01:00
Tom Moor 6c8b127ff9 chore: isHosted -> isCloudHosted for clarity 2022-05-21 13:34:52 +01:00
Tom Moor f2be756cf4 feat: Improved error for community edition when database columns cannot be decrypted 2022-05-21 13:25:55 +01:00
rusakovdenis 67049a7868 fix: simplify transformation (#3548)
* fix: simplify transformation

Functions (isDragging, isOver, canDrop) always return a boolean value

* fix: type

In browserslist must be either an array or an object
2022-05-21 05:14:53 -07:00
Translate-O-Tron d9706d4735 New Crowdin updates (#3556) 2022-05-21 05:14:34 -07:00
Tom Moor ec748f9914 fix: Floating toolbar should not appear until mouseup when selecting with mouse
closes #3564
2022-05-21 12:57:29 +01:00
Tom Moor ef668c2fa0 Tweak design of notices 2022-05-21 11:06:35 +01:00
Tom Moor 594a004c0f chore: Move to GitHub action from Probot for stale issue/pr management 2022-05-21 10:05:41 +01:00
Tom Moor 468478d06d fix: Another timestamp crash 2022-05-21 10:05:41 +01:00
Tom Moor 02caf88d2a chore: AuthenticationProvider component to function 2022-05-21 10:05:41 +01:00
github-actions[bot] 50f26929a1 chore: Compressed inefficient images automatically (#3563)
Co-authored-by: tommoor <tommoor@users.noreply.github.com>
2022-05-21 01:44:17 -07:00
Tom Moor 0f93e92bc6 feat: Add 'Scribe' embed support 2022-05-21 09:28:04 +01:00
Tom Moor c08940ca3c feat: Add optional replyTo for email sending 2022-05-21 08:36:37 +01:00
Tom Moor ee8324ad73 fix: Remove additional scope requests for now 2022-05-20 23:59:33 +01:00
Tom Moor 96a32c98e7 fix: Remove email validation to allow for Name <email> format 2022-05-20 22:18:21 +01:00
Tom Moor 5c741e3d98 fix: Crash render timestamp on some languages 2022-05-20 18:58:23 +01:00
Tom Moor ba7b3fff05 fix: Emojis and embeds cannot be copied to plain text clipboard (#3561) 2022-05-20 09:47:13 -07:00
Tom Moor 90ca8655af fix: Collapsed header button unclickable when full-width document option is selected
closes #3558
2022-05-20 10:04:36 +01:00
Tom Moor 0577c73f06 fix: Links with anchors are broken when pages are renamed
closes #3553
2022-05-20 09:43:54 +01:00
Tom Moor 39e146b4e6 fix: Minor usability improves to team domain management 2022-05-19 18:28:19 +01:00
Tom Moor 34576dd008 fix: Allow COLLABORATION_URL set with websocket protocol 2022-05-19 16:34:58 +01:00
Translate-O-Tron 585a34d27e New Crowdin updates (#3535) 2022-05-19 08:05:35 -07:00
Tom Moor 3c002f82cc chore: Centralize env parsing, validation, defaults, and deprecation notices (#3487)
* chore: Centralize env parsing, defaults, deprecation

* wip

* test

* test

* tsc

* docs, more validation

* fix: Allow empty REDIS_URL (defaults to localhost)

* test

* fix: SLACK_MESSAGE_ACTIONS not bool

* fix: Add SMTP port validation
2022-05-19 08:05:11 -07:00
Corey Alexander 51001cfac1 feat: Migrate allowedDomains to a Team Level Settings (#3489)
Fixes #3412

Previously the only way to restrict the domains for a Team were with the ALLOWED_DOMAINS environment variable for self hosted instances.
This PR migrates this to be a database backed setting on the Team object. This is done through the creation of a TeamDomain model that is associated with the Team and contains the domain name

This settings is updated on the Security Tab. Here domains can be added or removed from the Team.

On the server side, we take the code paths that previously were using ALLOWED_DOMAINS and switched them to use the Team allowed domains instead
2022-05-17 20:26:29 -04:00
Tom Moor 18e0d936ef feat: Match incoming search requests using confirmed email as fallback (#3538) 2022-05-17 13:49:23 -07:00
Limezy 5658090d7e Trying to chase missing translations (#3441) 2022-05-17 13:01:00 -07:00
Tom Moor 19de348c85 fix: null ref usage, closes #3456 2022-05-16 22:58:59 +01:00
Tom Moor b8a02df7ba chore: utils.gc -> cron.daily (#3543) 2022-05-16 12:44:22 -07:00
Tom Moor 4c15f27bb2 fix: Focus submit button by default in confirmation dialogs
fix: Move collection delete to use confirmation dialog
closes #3446
2022-05-15 16:21:42 +01:00
Tom Moor b152b9f17b fix: Possible extra separator in filtered context menus
Todo: We need to combine this logic with the menus in the editor, but not today
closes #3506
2022-05-15 15:40:49 +01:00
Tom Moor 40e41b26a1 fix: Missing not found page
closes #3476
closes #3531
2022-05-15 15:10:34 +01:00
Translate-O-Tron 4c01f6268e New Crowdin updates (#3462) 2022-05-15 06:46:40 -07:00
Tom Moor 8815a58ff5 perf: Requesting less db columns when calculating collection permissions (#3498)
perf: Not looping collection documentStructure for unpublish permission calculation
2022-05-15 06:46:24 -07:00
Tom Moor 36a3ae4b01 fix: Don't show suspended users in document facepile or list of viewers (#3497) 2022-05-15 06:05:40 -07:00
Tom Moor bca66f7415 fix: Exports show as 0 bytes 2022-05-15 07:10:35 +01:00
Tom Moor 06d966ad0c fix: Spacing on login form
fix: signup query params overridden unneccessarily
closes #3516
2022-05-15 06:57:35 +01:00
Tom Moor c205ffbfe9 Merge branch 'main' of github.com:outline/outline 2022-05-11 09:30:08 +01:00
Tom Moor b75a6928cb Revert "fix: Fade out navigation when editing and mouse hasn't moved (#3256)" (#3502)
This reverts commit e0cf873a36.
2022-05-06 13:28:37 -07:00
Tom Moor 0ba792317b Merge branch 'main' of github.com:outline/outline 2022-05-06 13:01:15 -07:00
Saumya Pandey e0cf873a36 fix: Fade out navigation when editing and mouse hasn't moved (#3256)
* fix: hide header when editing

* fix: settings collab switch

* Update app/hooks/useMouseMove.ts

Co-authored-by: Tom Moor <tom.moor@gmail.com>

* fix: accept timeout parameter

* fix: don't hide observing banner

* fix: hide on focused and observing

* perf: memo

* hide References too

Co-authored-by: Tom Moor <tom.moor@gmail.com>
2022-05-07 00:17:09 +05:30
Tom Moor 1782c08195 fix: Touch lastViewedAt timestamp on document to prevent flash of order repositioning 2022-05-05 23:51:47 -07:00
Tom Moor d9e7baf072 chore: Update caniuse browser support 2022-05-05 22:29:10 -07:00
Tom Moor ec1bc801a4 fix: Write revision on document publish 2022-05-04 22:03:04 -07:00
Nan Yu 9117b7479f fix: paginated list history headings were not rendering when there was only one unique heading (#3496)
* fix: paginated list history headings were not rendering when there was only one unique heading

* minor bug
2022-05-04 21:08:50 -07:00
Tom Moor eeb8008927 chore: Refactor collection export to match import (#3483)
* chore: Refactor collection export to use FileOperations processor and task

* Tweak options
2022-05-01 21:06:07 -07:00
Tom Moor 669575fc89 fix: Account for null collection.documentStructure again 2022-05-01 09:30:47 -07:00
Felix Heilmeyer 247208e5f5 feat: make ioredis configurable via environment variables (#3365)
* feat: expose ioredis client options

* run linter

* refactor redis client init into class extension

* explicitly handle constructor errors

* rename singletons
2022-05-01 08:44:35 -07:00
Tom Moor 25dce04046 perf: Move collection sorting to frontend (#3475)
* perf: Move collection sorting to frontend, on demand, memoized

* fix: Add default
2022-05-01 08:30:16 -07:00
Tom Moor 5cd4ecd34a fix: CRDT creation touches document updated timestamp (#3482)
fix: Race condition in collaboration document persistence
2022-05-01 08:30:07 -07:00
Tom Moor bb074edb0d perf: Improve speed of Azure login (parallelize two slow API requests)
chore: Improved types around passport
2022-04-30 16:57:58 -07:00
Tom Moor a736022c39 chore: cleanup 2022-04-30 09:10:35 -07:00
Emir Boyacı 677ca10b2b chore: fix i18n type error (#3473) 2022-04-29 22:57:10 -07:00
Tom Moor 32c1d2e2f8 fix: Opensearch should mirror correct team subdomain
closes #3470
2022-04-29 22:53:39 -07:00
Tom Moor c7e4f491eb fix: Correctly escape RegExp in import tasks
closes #3460
2022-04-27 23:58:01 -07:00
Tom Moor 5f6b6e2879 Turkey -> Turkish 2022-04-27 22:46:17 -07:00
Tom Moor 7aeb9c2cd2 chore: cleanup ApiClient 2022-04-27 22:45:01 -07:00
Tom Moor 4177031d0b fix: Collection names with slashes produce invalid export output
closes #3368
2022-04-27 19:33:36 -07:00
Tom Moor 7fa0199dca fix: Applying a template should not overwrite an existing title
closes #3430
2022-04-27 19:18:45 -07:00
Tom Moor 78da5e2335 fix: Navigate to settings should not be displayed to non-admins
closes #3432
2022-04-27 19:12:38 -07:00
Tom Moor 964b4ef97d fix: Allow authorized signups to hosted-only setting 2022-04-27 19:04:06 -07:00
Tom Moor d8fed83736 chore: Add tracing around key presenters 2022-04-27 18:59:17 -07:00
Tom Moor 576497eca1 feat: Allow override default Task options on schedule 2022-04-27 18:54:54 -07:00
Tom Moor 4fd0307814 Revert: Enable web search query syntax 2022-04-26 21:34:33 -07:00
Corey Alexander 2449434fef feat: Allow Document to be fetched without Slug (#3453)
* Allow Document to be fetched without Slug

Fixes #3423

This PR refactors the `Document.findByPk` method to not require the
`slug` portion of the urlID.

Before this function accepted two different 'formats' for the ID.

 - The `uuid` ID of the Document
 - The full `urlID` which looked something like
   `some-document-1234567890`

However the `some-document` slug portion of this identifier wasn't
actually used when looking for a document.

We now allow searching by JUST the postfix of the `urlID`, in the above
example that is `1234567890`.
We do this via a new Regex pattern to match on that just looks for the
right looking id alone, without the prefix.

This codepath looks the same as when we find it by the full `urlID`
besides the different regex that we match on.

The issue #3423 mentions that this should apply to all the API
endpoints. I believe that this `findByPk` method is all that should be
needed for that change. But if this is incorrect, OR you would like more
test coverage on the API endpoints as a more 'end to end test' please
let me know!

* Change original regex to make the slug optional

This has the, I believe to be good, side-effect of making the same logic
apply to `Collection` as well. Since `Collection` was always doing the
same stripping of the slug before the lookup I believe it should be just
as safe to do there.

We don't have to touch the code in Collections but we add a test of this
behavior there as well.

* No reason to rename this now that we aren't doing two matches
2022-04-26 20:49:37 -07:00
Tom Moor 11477a1185 chore: Centralize clientside logging 2022-04-25 23:31:30 -07:00
Tom Moor 38409ff4ec fix: Enable web search query syntax 2022-04-25 21:58:24 -07:00
Tom Moor 2a11a23d5b fix: Updated design of api tokens to clarify, closes #3422 2022-04-25 21:34:36 -07:00
Tom Moor e49897ab5a fix: Account for rare case where file.name is unavailable 2022-04-25 21:13:06 -07:00
Tom Moor ceebc922cf fix: Error attempting to import .docx files, closes #3455 2022-04-25 21:07:22 -07:00
Tom Moor 7436d4c5c1 fix: Truncate stored error message for file ops
closes #3459
2022-04-25 21:00:31 -07:00
Tom Moor 5cbea1eab2 feat: Add Turkish translations
closes #3461
2022-04-25 20:07:49 -07:00
Translate-O-Tron 93f770c4d4 New Crowdin updates (#3377) 2022-04-25 17:16:23 -07:00
Tom Moor fcd4a2566a Merge branch 'main' of github.com:outline/outline 2022-04-23 18:33:25 -07:00
Tom Moor 0cdf1f791e fix: Permission select should have border 2022-04-23 18:33:14 -07:00
Gerardo Mathus 19ffff6fd2 Allow Downloads From Embeds (#3447)
* add flag to iframe

* ignore changes

* remove double space
2022-04-23 17:28:35 -07:00
Limezy 044d551b60 fix : translation strings in DocumentMeta component (2955) (#3417)
* fix issue 2955

* Linter

* Linter

* Linter

* Fix stupid mistake to run my own tests
2022-04-23 10:12:38 -07:00
github-actions[bot] 26d4040cb5 chore: Compressed inefficient images automatically (#3443)
Co-authored-by: tommoor <tommoor@users.noreply.github.com>
2022-04-23 10:12:23 -07:00
Limezy 3b62c76207 Add tldraw embed (#3439)
* Test Tldraw embed

* Correct regex

* Correct alt for image

* Resize image to 120x120
2022-04-23 10:10:33 -07:00
Tom Moor 33ce49cc33 chore: Refactor data import (#3434)
* Complete refactor of import

* feat: Notion data import (#3442)
2022-04-23 10:07:35 -07:00
Tom Moor bdcfaae025 fix: Timestamps updated on closing document 2022-04-20 10:43:18 -07:00
Tom Moor 0245451501 perf: Caught a debounced hook re-rendering continously 2022-04-20 08:44:17 -07:00
Maksim Eltyshev e162e67396 ref: Fix small typo (#3428) 2022-04-20 08:11:40 -07:00
Nan Yu 233f3af667 feat: allow admins to require invites before user accounts can be created (#3381)
* allow admins to require invites before user accounts can be created
* use new dialog component for general confirmation dialogs
2022-04-19 12:27:23 -07:00
Tom Moor 1b913054e8 chore: Move i18n generation, pre-commit hooks (#3410) 2022-04-17 13:29:08 -07:00
Tom Moor b10802a0aa fix: Document empty placeholder changes when focused 2022-04-17 11:58:46 -07:00
Tom Moor 48893f727e fix: Tabs on document references don't show active state
'Referenced by' -> 'Backlinks'
2022-04-17 11:42:55 -07:00
Tom Moor 2fb0182e16 tom/use-event-listener 2022-04-17 11:00:28 -07:00
Tom Moor e4e98286f4 fix: Embed disabled state should persist (#3407)
* Normalize code around localStorage
Persist disabled embed state

* fix: Cannot view more than 10 starred items on load

* More tidying of sidebar state
2022-04-17 10:24:40 -07:00
Tom Moor 1e1a57d246 chore: Move document embed switching to toggle 2022-04-16 21:22:45 -07:00
Tom Moor b1aba32b62 chore: Bringing across edits from enterprise codebase 2022-04-16 19:46:01 -07:00
Tom Moor 0b5e48621a fix: Show resizable border on long-hover 2022-04-16 19:22:24 -07:00
Tom Moor 5b0a45c159 fix: Entirety of document title should have text cursor 2022-04-16 18:47:59 -07:00
Tom Moor 0883a56311 feat: Additional embed integrations (#3398)
* feat: Gliffy integration

* feat: JSFiddle integration

* feat: Otter.ai integration

* Optimised images with calibre/image-actions

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-04-16 15:04:49 -07:00
Tom Moor 4c4b80ba9b fix: Collaboration debounce shared between docs (#3401)
* fix: Collaboration debounce shared between docs

* Rename, Tracing -> Metrics

* Add tracing

* tsc

* fix: Lock document row when loading document in collaboration service incase state needs writing

* fix: Incorrect service name regression
2022-04-16 14:58:17 -07:00
Tom Moor 1a8f2c3bb0 Update LICENSE 2022-04-15 17:24:14 -07:00
Tom Moor c4046b1be5 0.63.0 2022-04-15 17:23:50 -07:00
Tom Moor cf58d8e3e1 fix: Capture drop events in clickable padding below editor (#3376)
* fix: Capture drop events in clickable padding below editor

* fix: Inconsistency in drop handling
2022-04-15 09:03:25 -07:00
Tom Moor 0ecfa95efc fix: Search params are not considered on first load
closes #3378
2022-04-14 17:50:20 -07:00
Tom Moor 7f58fbe71b fix: Save title change immediately on field blur
closes #3374
2022-04-13 16:26:22 -07:00
Tom Moor 9e08717d25 feat: Two more cases of typing in code marks, closes #3375 2022-04-13 15:17:47 -07:00
Translate-O-Tron 5c7ebea14b New Crowdin updates (#3345) 2022-04-13 08:59:57 -07:00
忽如寄 9fe5148113 feat: refactor resolve ♻️ (#3358)
Change-Id: Ib229549e114db67b04f2039b80c9015f78310cc8
2022-04-13 08:59:41 -07:00
Tom Moor f23f0d57de fix: Link editor should reset when selection changes
closes #3362
2022-04-13 08:55:43 -07:00
Tom Moor d3ecab3489 fix: Lowercase email from auth providers to match any outstanding invites (#3369)
* fix: Lowercase email from auth providers to match any outstanding invites

* fix
2022-04-12 21:31:55 -07:00
Tom Moor 1de732c82a fix: CommandMenu height when filtered 2022-04-12 20:58:39 -07:00
Tom Moor abbc3bdb30 fix: Consistent menus in editor (#3363)
* Use scrollable in context menu

* fix: Remove old blockToolbar styles
2022-04-12 20:12:45 -07:00
Tom Moor 86f1645199 feat: Automatic invite reminder email (#3354)
* feat: Add user flags concept, for tracking bits on a user

* feat: Example flag usage for user invite resend abuse

* wip

* test

* fix: Set correct flag
2022-04-12 20:12:33 -07:00
Nan Yu 5520317ce1 fix: prevent the interactive gutter elements from interfering with the sidebar collapse button (#3350)
* fix: prevent the interactive gutter elements from interfering with the sidebar collapse button

* keep mobile padding the same on documents

Co-authored-by: Tom Moor <tom.moor@gmail.com>
2022-04-11 19:48:05 -07:00
Tom Moor 7f5bf6c6b3 feat: User flags (#3353)
* feat: Add user flags concept, for tracking bits on a user

* feat: Example flag usage for user invite resend abuse
2022-04-11 19:42:50 -07:00
Tom Moor 11c009bdbf fix: Don't create new document when opening browser window with cmd+n 2022-04-11 08:08:13 -07:00
Tom Moor f399c9d38c chore: More tracing cleanup 2022-04-11 08:04:13 -07:00
Tom Moor 27597727ee chore: More tracing cleanup 2022-04-10 20:11:18 -07:00
Tom Moor 31b95b5f17 fix: BaseProcessor should not be pushed onto queues 2022-04-10 20:05:59 -07:00
Tom Moor 963475d2b0 fix: Queue retry behavior (#3359)
* fix: Queue retry behavior

* Add default options for task queue
2022-04-10 17:50:42 -07:00
Nan Yu cfa71762c2 feat: adds "/" keyboard shortcut to share, focus content body on search selection (#3347)
* feat: adds "/" keyboard shortcut to focus search input on share screen; auto-focus content body on search item selection

* usekeydown instead of registerkeydown
2022-04-10 07:54:02 -07:00
Tom Moor 4de0389055 Update config.yml 2022-04-10 07:46:31 -07:00
Yggdrasil80 9390434dde feat: add arm64 docker image build (#3262)
* Add arm64 docker image build

* add arm64 docker image build

* fix: install missing docker buildx

* fix: new cimg orbs not working with this config

* fix misstake on qemu image name

* fix node:16 image not supported on arm/v5 and arm/v6

* add timeout to avoir errors

* fix docker buildx multiarch auto removing

* remove useless platforms, and keep only most used to reduce CI duration

* fix context issues

* fixed multiarch CI
2022-04-10 07:45:57 -07:00
Tom Moor b7a6a34565 fix: Flash of empty state on paginated lists (#3351)
* fix: Flash of empty state on paginated lists
fix: Typing of PaginatedList to generic

* test

* test
2022-04-09 20:31:51 -07:00
Tom Moor 9281287dba one 2022-04-09 20:25:54 -07:00
Tom Moor 48fad5cfa0 fix: Link preview and search should work on collection descriptions (#3355) 2022-04-09 19:00:56 -07:00
Tom Moor a47427de9e fix: Tweak commit message for calibre action to be semantic 2022-04-09 18:56:21 -07:00
github-actions[bot] e40f106dbb Compress Images (#3356)
Co-authored-by: tommoor <tommoor@users.noreply.github.com>
2022-04-09 18:55:52 -07:00
Tom Moor b82176bae4 fix: Replace example in github workflow config 2022-04-09 18:52:07 -07:00
Tom Moor 2d159d683b chore: Add auto image compression action 2022-04-09 18:49:34 -07:00
Tom Moor 8f23504c64 fix: Archived documents should be filtered from getChildDocumentIds when searching and loading share data (#3352)
closes #3343
2022-04-09 18:34:18 -07:00
Tom Moor ae34570648 chore: Add metrics logging for emails 2022-04-09 15:09:01 -07:00
Tom Moor 5c1888b0a4 feat: Adds menu item to resend outstanding invites (#3348)
* feat: Adds menu item to resend outstanding invites

* i18n

* snapshots
2022-04-09 11:34:27 -07:00
Nan Yu 75a868e5e8 feat: Search shared documents (#3126)
* provide a type-ahead search input on shared document pages that allow search of child document tree
* improve keyboard navigation handling of all search views
* improve coloring on dark mode list selection states
* refactor PaginatedList component to eliminate edge cases
2022-04-08 10:40:51 -07:00
Tom Moor 5fb5e69181 fix: Use of lookbehind regex crashes Safari, added lint rule to prevent future accidental regression 2022-04-08 10:16:55 -07:00
Tom Moor 58a059ae33 fix: CI should fail if yarn.lock is out of date 2022-04-08 08:49:34 -07:00
Tom Moor 1f93027c97 feat: Add date and time slash commands to block menu 2022-04-07 18:50:50 -07:00
Tom Moor 63ed015a86 fix: Loosen italic markdown matching a little
see: https://github.com/outline/outline/discussions/3336
2022-04-07 17:33:15 -07:00
Tom Moor 902cef8100 docs 2022-04-07 17:00:25 -07:00
Translate-O-Tron 6aa680a41d New Crowdin updates (#3258) 2022-04-07 16:51:23 -07:00
Tom Moor 5c24f9e1d5 chore: Email + mailer refactor (#3342)
* Huge email refactor

* fix: One rename too many

* comments
2022-04-07 16:50:04 -07:00
Tom Moor 15375bf199 fix: users.info request flood (#3334)
* feat: Add user id filter to users.list endpoint

* fix: Remove users.info request loop
2022-04-06 22:00:11 -07:00
Tom Moor 9b5df51625 chore: Add APM tracing around queues 2022-04-06 21:59:52 -07:00
Tom Moor f10cfbbd9e fix: Missing user scope in collection mailer 2022-04-06 21:35:45 -07:00
Tom Moor 4f358032eb chore: CircleCI Images (#3341)
* chore: Upgrade from deprecated images

* img

* fix: No default postgres user/pass anymore

* parallel

* config

* migrate

* split frontend/backend tests

* fix

* resource_class

* node

* node
2022-04-06 20:59:40 -07:00
Tom Moor 448f94ed04 fix: Allow admin edit/update access to all collections (#3335)
* fix: Allow admin edit/update access to all collections

* test
2022-04-06 16:49:07 -07:00
Tom Moor dbfdcd6d23 chore: Refactor worker, emails and data cleanup to task system (#3337)
* Refactor worker, all emails on task system

* fix

* lint

* fix: Remove a bunch of expect-error comments in related tests

* refactor: Move work from utils.gc into tasks

* test

* Add tracing to tasks and processors
fix: DebounceProcessor triggering on all events
Event.add -> Event.schedule
2022-04-06 16:48:28 -07:00
Tom Moor 9c766362ed fix: Hanging separators in filtered block menu 2022-04-04 22:35:28 -07:00
Tom Moor 10fff7811f fix 2022-04-04 22:01:58 -07:00
Tom Moor cefceaac3e chore: Combine z-index from editor 2022-04-04 21:50:52 -07:00
Tom Moor 0d87de9f80 fix: Hide document popover on mobile 2022-04-04 21:32:31 -07:00
Tom Moor 2e41ace386 refactor: Move depths and breakpoints out of theme 2022-04-04 21:20:38 -07:00
Tom Moor 20a69b711a fix: Some spots where navigation state was not preserved
fix: Collection in main nav pops open when moving from starred collection
2022-04-04 19:04:28 -07:00
534 changed files with 17364 additions and 8149 deletions
+109 -83
View File
@@ -1,51 +1,93 @@
version: 2.1
defaults: &defaults
working_directory: ~/outline
docker:
- image: cimg/node:14.19
- image: cimg/redis:5.0
- image: cimg/postgres:14.2
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: circle_test
resource_class: large
environment:
NODE_ENV: test
SECRET_KEY: F0E5AD933D7F6FD8F4DBB3E038C501C052DC0593C686D21ACB30AE205D2F634B
DATABASE_URL_TEST: postgres://postgres:password@localhost:5432/circle_test
DATABASE_URL: postgres://postgres:password@localhost:5432/circle_test
URL: http://localhost:3000
SMTP_FROM_EMAIL: hello@example.com
AWS_S3_UPLOAD_BUCKET_URL: https://s3.amazonaws.com
AWS_S3_UPLOAD_BUCKET_NAME: outline-circle
executors:
docker-publisher:
environment:
IMAGE_NAME: outlinewiki/outline
BASE_IMAGE_NAME: outlinewiki/outline-base
docker:
- image: circleci/buildpack-deps:stretch
jobs:
build:
working_directory: ~/outline
docker:
- image: circleci/node:14
- image: circleci/redis:latest
- image: circleci/postgres:9.6.5-alpine-ram
environment:
NODE_ENV: test
SECRET_KEY: F0E5AD933D7F6FD8F4DBB3E038C501C052DC0593C686D21ACB30AE205D2F634B
DATABASE_URL_TEST: postgres://root@localhost:5432/circle_test
DATABASE_URL: postgres://root@localhost:5432/circle_test
URL: http://localhost:3000
SMTP_FROM_EMAIL: hello@example.com
AWS_S3_UPLOAD_BUCKET_URL: https://s3.amazonaws.com
AWS_S3_UPLOAD_BUCKET_NAME: outline-circle
<<: *defaults
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: install-deps
command: yarn install --pure-lockfile
command: yarn install --frozen-lockfile
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
lint:
<<: *defaults
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: lint
command: yarn lint
types:
<<: *defaults
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: typescript
command: yarn tsc
test-app:
<<: *defaults
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: test
command: yarn test:app
test-server:
<<: *defaults
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: migrate
command: ./node_modules/.bin/sequelize db:migrate --url $DATABASE_URL_TEST
- run:
name: lint
command: yarn lint
- run:
name: typescript
command: yarn tsc
- run:
name: test
command: yarn test
command: yarn test:server
bundle-size:
<<: *defaults
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: build-webpack
command: yarn build:webpack
@@ -56,59 +98,59 @@ jobs:
- setup_remote_docker:
version: 20.10.6
- run:
name: Build Docker image
command: docker build -t $IMAGE_NAME:latest .
- run:
name: Archive Docker image
command: docker save -o image.tar $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./image.tar
publish-latest:
executor: docker-publisher
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker:
version: 20.10.6
- run:
name: Load archived Docker image
command: docker load -i /tmp/workspace/image.tar
- run:
name: Publish Docker Image to Docker Hub
name: Install Docker buildx
command: |
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
IMAGE_TAG=${CIRCLE_TAG/v/''}
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
docker push $IMAGE_NAME:latest
docker push $IMAGE_NAME:$IMAGE_TAG
publish-tag:
executor: docker-publisher
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker:
version: 20.10.6
mkdir -p ~/.docker/cli-plugins
url="https://github.com/docker/buildx/releases/download/v0.8.0/buildx-v0.8.0.linux-amd64"
curl -sSL -o ~/.docker/cli-plugins/docker-buildx $url
chmod a+x ~/.docker/cli-plugins/docker-buildx
- run:
name: Load archived Docker image
command: docker load -i /tmp/workspace/image.tar
name: Enable Docker buildx
command: export DOCKER_CLI_EXPERIMENTAL=enabled
- run:
name: Publish Docker Image to Docker Hub
name: Initialize Docker buildx
command: |
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
IMAGE_TAG=${CIRCLE_TAG/v/''}
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
docker push $IMAGE_NAME:$IMAGE_TAG
docker buildx install
docker context create docker-multiarch
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name docker-multiarch --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x docker-multiarch
docker buildx inspect --builder docker-multiarch --bootstrap
docker buildx use docker-multiarch
- run:
name: Build base image
command: docker build -f Dockerfile.base -t $BASE_IMAGE_NAME:latest --load .
- run:
name: Login to Docker Hub
command: echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
- run:
name: Publish base Docker Image to Docker Hub
command: docker push $BASE_IMAGE_NAME:latest
- run:
name: Build and push Docker image
command: docker buildx build -t $IMAGE_NAME:latest -t $IMAGE_NAME:${CIRCLE_TAG/v/''} --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x --push .
workflows:
version: 2
build-and-test:
all:
jobs:
- build:
filters:
tags:
ignore: /^v.*/
- build
- lint:
requires:
- build
- test-server:
requires:
- build
- test-app:
requires:
- build
- types:
requires:
- build
- bundle-size:
requires:
- test-app
- test-server
build-docker:
jobs:
- build-image:
@@ -117,19 +159,3 @@ workflows:
only: /^v.*/
branches:
ignore: /.*/
- publish-latest:
requires:
- build-image
filters:
tags:
only: /^v\d+\.\d+\.\d+$/
branches:
ignore: /.*/
- publish-tag:
requires:
- build-image
filters:
tags:
only: /^v\d+\.\d+\.\d+-.*$/
branches:
ignore: /.*/
+10 -6
View File
@@ -16,7 +16,15 @@ DATABASE_CONNECTION_POOL_MIN=
DATABASE_CONNECTION_POOL_MAX=
# Uncomment this to disable SSL for connecting to Postgres
# PGSSLMODE=disable
# For redis you can either specify an ioredis compatible url like this
REDIS_URL=redis://localhost:6379
# or alternatively, if you would like to provide addtional connection options,
# use a base64 encoded JSON connection option object. Refer to the ioredis documentation
# for a list of available options.
# Example: Use Redis Sentinel for high availability
# {"sentinels":[{"host":"sentinel-0","port":26379},{"host":"sentinel-1","port":26379}],"name":"mymaster"}
# REDIS_URL=ioredis://eyJzZW50aW5lbHMiOlt7Imhvc3QiOiJzZW50aW5lbC0wIiwicG9ydCI6MjYzNzl9LHsiaG9zdCI6InNlbnRpbmVsLTEiLCJwb3J0IjoyNjM3OX1dLCJuYW1lIjoibXltYXN0ZXIifQ==
# URL should point to the fully qualified, publicly accessible URL. If using a
# proxy the port in URL and PORT may be different.
@@ -57,8 +65,8 @@ AWS_S3_ACL=private
#
# When configuring the Client ID, add a redirect URL under "OAuth & Permissions":
# https://<URL>/auth/slack.callback
SLACK_KEY=get_a_key_from_slack
SLACK_SECRET=get_the_secret_of_above_key
SLACK_CLIENT_ID=get_a_key_from_slack
SLACK_CLIENT_SECRET=get_the_secret_of_above_key
# To configure Google auth, you'll need to create an OAuth Client ID at
# => https://console.cloud.google.com/apis/credentials
@@ -129,10 +137,6 @@ MAXIMUM_IMPORT_SIZE=5120000
# requests and this ends up being duplicative
DEBUG=http
# Comma separated list of domains to be allowed to signin to the wiki. If not
# set, all domains are allowed by default when using Google OAuth to signin
ALLOWED_DOMAINS=
# For a complete Slack integration with search and posting to channels the
# following configs are also needed, some more details
# => https://wiki.generaloutline.com/share/be25efd1-b3ef-4450-b8e5-c4a4fc11e02a
+2
View File
@@ -16,6 +16,7 @@
"plugin:prettier/recommended"
],
"plugins": [
"es",
"@typescript-eslint",
"eslint-plugin-import",
"eslint-plugin-node",
@@ -28,6 +29,7 @@
"curly": 2,
"no-mixed-operators": "off",
"no-useless-escape": "off",
"es/no-regexp-lookbehind-assertions": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
-22
View File
@@ -1,22 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 120
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 14
# Issues with these labels will never be considered stale
exemptLabels:
- security
- pinned
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
Hey! The issue has been automatically marked as stale because it has not had
recent activity. It will be closed soon if no further activity occurs. Please
reply here if you wish for the issue to be kept open.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
@@ -0,0 +1,56 @@
# Image Actions will run in the following scenarios:
# - on Pull Requests containing images (not including forks)
# - on pushing of images to `main` (for forks)
# - on demand (https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/)
# - at 11 PM every Sunday in anything gets missed with any of the above scenarios
# For Pull Requests, the images are added to the PR.
# For other scenarios, a new PR will be opened if any images are compressed.
name: Compress images
on:
pull_request:
paths:
- "**.jpg"
- "**.jpeg"
- "**.png"
- "**.webp"
push:
branches:
- main
paths:
- "**.jpg"
- "**.jpeg"
- "**.png"
- "**.webp"
workflow_dispatch:
schedule:
- cron: "00 20 * * 0"
jobs:
build:
name: calibreapp/image-actions
runs-on: ubuntu-latest
# Only run on main repo on and PRs that match the main repo.
if: |
github.repository == 'outline/outline' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
steps:
- name: Checkout Branch
uses: actions/checkout@v2
- name: Compress Images
id: calibre
uses: calibreapp/image-actions@main
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
# For non-Pull Requests, run in compressOnly mode and we'll PR after.
compressOnly: ${{ github.event_name != 'pull_request' }}
- name: Create Pull Request
# If it's not a Pull Request then commit any changes as a new PR.
if: |
github.event_name != 'pull_request' &&
steps.calibre.outputs.markdown != ''
uses: peter-evans/create-pull-request@v3
with:
title: "chore: Auto Compress Images"
branch-suffix: timestamp
commit-message: "chore: Compressed inefficient images automatically"
body: ${{ steps.calibre.outputs.markdown }}
+3 -3
View File
@@ -42,7 +42,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
# ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
+29
View File
@@ -0,0 +1,29 @@
name: "Close Stale PRs"
on:
workflow_dispatch:
schedule:
- cron: "30 1 * * *"
permissions:
issues: write
pull-requests: write
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v5
with:
stale-pr-message: "This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days"
stale-issue-message: "This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days"
close-pr-message: "Automatically closed due to inactivity"
close-issue-message: "Automatically closed due to inactivity"
days-before-issue-stale: 120
days-before-pr-stale: 60
days-before-close: 5
operations-per-run: 60
stale-issue-label: stale
stale-pr-label: stale
exempt-issue-labels: "security,pinned"
- name: Print outputs
run: echo ${{ join(steps.stale.outputs.*, ',') }}
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
+8 -31
View File
@@ -1,45 +1,22 @@
# syntax=docker/dockerfile:1.2
ARG APP_PATH=/opt/outline
FROM node:16-alpine AS deps-common
ARG APP_PATH
WORKDIR $APP_PATH
COPY ./package.json ./yarn.lock ./
# ---
FROM deps-common AS deps-dev
RUN yarn install --no-optional --frozen-lockfile && \
yarn cache clean
# ---
FROM deps-common AS deps-prod
RUN yarn install --production=true --frozen-lockfile && \
yarn cache clean
# ---
FROM node:16-alpine AS builder
FROM outlinewiki/outline-base as base
ARG APP_PATH
WORKDIR $APP_PATH
COPY . .
COPY --from=deps-dev $APP_PATH/node_modules ./node_modules
ARG CDN_URL
RUN yarn build
# ---
FROM node:16-alpine AS runner
FROM node:16.14.2-alpine3.15 AS runner
ARG APP_PATH
WORKDIR $APP_PATH
ENV NODE_ENV production
COPY --from=builder $APP_PATH/build ./build
COPY --from=builder $APP_PATH/server ./server
COPY --from=builder $APP_PATH/public ./public
COPY --from=builder $APP_PATH/.sequelizerc ./.sequelizerc
COPY --from=deps-prod $APP_PATH/node_modules ./node_modules
COPY --from=builder $APP_PATH/package.json ./package.json
COPY --from=base $APP_PATH/build ./build
COPY --from=base $APP_PATH/server ./server
COPY --from=base $APP_PATH/public ./public
COPY --from=base $APP_PATH/.sequelizerc ./.sequelizerc
COPY --from=base $APP_PATH/node_modules ./node_modules
COPY --from=base $APP_PATH/package.json ./package.json
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
+18
View File
@@ -0,0 +1,18 @@
ARG APP_PATH=/opt/outline
FROM node:16.14.2-alpine3.15 AS deps
ARG APP_PATH
WORKDIR $APP_PATH
COPY ./package.json ./yarn.lock ./
RUN yarn install --no-optional --frozen-lockfile --network-timeout 1000000 && \
yarn cache clean
COPY . .
ARG CDN_URL
RUN yarn build
RUN rm -rf node_modules
RUN yarn install --production=true --frozen-lockfile --network-timeout 1000000 && \
yarn cache clean
+2 -2
View File
@@ -3,7 +3,7 @@ Business Source License 1.1
Parameters
Licensor: General Outline, Inc.
Licensed Work: Outline 0.62.0
Licensed Work: Outline 0.64.0
The Licensed Work is (c) 2020 General Outline, Inc.
Additional Use Grant: You may make use of the Licensed Work, provided that
you may not use the Licensed Work for a Document
@@ -15,7 +15,7 @@ Additional Use Grant: You may make use of the Licensed Work, provided that
Licensed Work by creating teams and documents
controlled by such third parties.
Change Date: 2026-03-01
Change Date: 2026-05-23
Change License: Apache License, Version 2.0
+3 -7
View File
@@ -43,10 +43,6 @@
"value": "true",
"required": true
},
"ALLOWED_DOMAINS": {
"description": "Comma separated list of domains to be allowed (optional). If not set, all domains are allowed by default when using Google OAuth to signin. Consider putting {your app name}.herokuapp.com and any domain you are binding on in this list.",
"required": false
},
"URL": {
"description": "https://{your app name}.herokuapp.com, or the domain you are binding to",
"required": true
@@ -106,11 +102,11 @@
"value": "openid profile email",
"required": false
},
"SLACK_KEY": {
"SLACK_CLIENT_ID": {
"description": "See https://api.slack.com/apps to create a new Slack app. You must configure at least one of Slack or Google to control login.",
"required": false
},
"SLACK_SECRET": {
"SLACK_CLIENT_SECRET": {
"description": "Your Slack client secret - d2dc414f9953226bad0a356cXXXXYYYY",
"required": false
},
@@ -209,4 +205,4 @@
"required": false
}
}
}
}
+3 -8
View File
@@ -14,7 +14,7 @@ import {
} from "outline-icons";
import * as React from "react";
import getDataTransferFiles from "@shared/utils/getDataTransferFiles";
import DocumentTemplatize from "~/scenes/DocumentTemplatize";
import DocumentTemplatizeDialog from "~/components/DocumentTemplatizeDialog";
import { createAction } from "~/actions";
import { DocumentSection } from "~/actions/sections";
import history from "~/utils/history";
@@ -306,18 +306,13 @@ export const createTemplate = createAction({
if (!activeDocumentId) {
return;
}
event?.preventDefault();
event?.stopPropagation();
stores.dialogs.openModal({
title: t("Create template"),
content: (
<DocumentTemplatize
documentId={activeDocumentId}
onSubmit={stores.dialogs.closeAllModals}
/>
),
isCentered: true,
content: <DocumentTemplatizeDialog documentId={activeDocumentId} />,
});
},
});
+2
View File
@@ -91,6 +91,8 @@ export const navigateToSettings = createAction({
section: NavigationSection,
shortcut: ["g", "s"],
icon: <SettingsIcon />,
visible: ({ stores }) =>
stores.policies.abilities(stores.auth.team?.id || "").update,
perform: () => history.push(organizationSettingsPath()),
});
+12 -24
View File
@@ -10,6 +10,10 @@ import {
MenuItemWithChildren,
} from "~/types";
function resolve<T>(value: any, context: ActionContext): T {
return typeof value === "function" ? value(context) : value;
}
export function createAction(definition: Optional<Action, "id">): Action {
return {
...definition,
@@ -21,18 +25,10 @@ export function actionToMenuItem(
action: Action,
context: ActionContext
): MenuItemButton | MenuItemWithChildren {
function resolve<T>(value: any): T {
if (typeof value === "function") {
return value(context);
}
return value;
}
const resolvedIcon = resolve<React.ReactElement<any>>(action.icon);
const resolvedChildren = resolve<Action[]>(action.children);
const resolvedIcon = resolve<React.ReactElement<any>>(action.icon, context);
const resolvedChildren = resolve<Action[]>(action.children, context);
const visible = action.visible ? action.visible(context) : true;
const title = resolve<string>(action.name);
const title = resolve<string>(action.name, context);
const icon =
resolvedIcon && action.iconInContextMenu !== false
? React.cloneElement(resolvedIcon, {
@@ -69,23 +65,15 @@ export function actionToKBar(
action: Action,
context: ActionContext
): CommandBarAction[] {
function resolve<T>(value: any): T {
if (typeof value === "function") {
return value(context);
}
return value;
}
if (typeof action.visible === "function" && !action.visible(context)) {
return [];
}
const resolvedIcon = resolve<React.ReactElement<any>>(action.icon);
const resolvedChildren = resolve<Action[]>(action.children);
const resolvedSection = resolve<string>(action.section);
const resolvedName = resolve<string>(action.name);
const resolvedPlaceholder = resolve<string>(action.placeholder);
const resolvedIcon = resolve<React.ReactElement<any>>(action.icon, context);
const resolvedChildren = resolve<Action[]>(action.children, context);
const resolvedSection = resolve<string>(action.section, context);
const resolvedName = resolve<string>(action.name, context);
const resolvedPlaceholder = resolve<string>(action.placeholder, context);
const children = resolvedChildren
? flattenDeep(resolvedChildren.map((a) => actionToKBar(a, context))).filter(
(a) => !!a
-20
View File
@@ -2,9 +2,7 @@ import { observer } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Redirect } from "react-router-dom";
import { isCustomSubdomain } from "@shared/utils/domains";
import LoadingIndicator from "~/components/LoadingIndicator";
import env from "~/env";
import useStores from "~/hooks/useStores";
import { changeLanguage } from "~/utils/language";
@@ -25,29 +23,11 @@ const Authenticated = ({ children }: Props) => {
if (auth.authenticated) {
const { user, team } = auth;
const { hostname } = window.location;
if (!team || !user) {
return <LoadingIndicator />;
}
// If we're authenticated but viewing a domain that doesn't match the
// current team then kick the user to the teams correct domain.
if (team.domain) {
if (team.domain !== hostname) {
window.location.href = `${team.url}${window.location.pathname}`;
return <LoadingIndicator />;
}
} else if (
env.SUBDOMAINS_ENABLED &&
team.subdomain &&
isCustomSubdomain(hostname) &&
!hostname.startsWith(`${team.subdomain}.`)
) {
window.location.href = `${team.url}${window.location.pathname}`;
return <LoadingIndicator />;
}
return children;
}
+5 -1
View File
@@ -51,7 +51,11 @@ class AuthenticatedLayout extends React.Component<Props> {
}
};
goToNewDocument = () => {
goToNewDocument = (event: KeyboardEvent) => {
if (event.metaKey || event.altKey) {
return;
}
const { activeCollectionId } = this.props.ui;
if (!activeCollectionId) {
return;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 B

After

Width:  |  Height:  |  Size: 564 B

+2 -1
View File
@@ -1,6 +1,7 @@
import * as React from "react";
import styled from "styled-components";
import breakpoint from "styled-components-breakpoint";
import { depths } from "@shared/styles";
import env from "~/env";
import OutlineLogo from "./OutlineLogo";
@@ -38,7 +39,7 @@ const Link = styled.a`
}
${breakpoint("tablet")`
z-index: ${(props: any) => props.theme.depths.sidebar + 1};
z-index: ${depths.sidebar + 1};
position: fixed;
bottom: 0;
left: 0;
+1 -1
View File
@@ -111,7 +111,7 @@ const RealButton = styled.button<{
}
&:disabled {
background: none;
background: ${lighten(0.05, props.theme.danger)};
}
&.focus-visible {
+3 -3
View File
@@ -6,14 +6,14 @@ type Props = {
withStickyHeader?: boolean;
};
const Container = styled.div<{ withStickyHeader?: boolean }>`
const Container = styled.div<Props>`
width: 100%;
max-width: 100vw;
padding: ${(props) => (props.withStickyHeader ? "4px 12px" : "60px 12px")};
${breakpoint("tablet")`
padding: ${(props: any) =>
props.withStickyHeader ? "4px 60px 60px" : "60px"};
padding: ${(props: Props) =>
props.withStickyHeader ? "4px 44px 60px" : "60px 44px"};
`};
`;
+9 -12
View File
@@ -42,8 +42,9 @@ function Collaborators(props: Props) {
filter(
users.orderedData,
(user) =>
presentIds.includes(user.id) ||
document.collaboratorIds.includes(user.id)
(presentIds.includes(user.id) ||
document.collaboratorIds.includes(user.id)) &&
!user.isSuspended
),
(user) => presentIds.includes(user.id)
),
@@ -52,18 +53,14 @@ function Collaborators(props: Props) {
// load any users we don't yet have in memory
React.useEffect(() => {
const userIdsToFetch = uniq([
...document.collaboratorIds,
...presentIds,
]).filter((userId) => !users.get(userId));
const ids = uniq([...document.collaboratorIds, ...presentIds])
.filter((userId) => !users.get(userId))
.sort();
if (!isEqual(requestedUserIds, userIdsToFetch)) {
setRequestedUserIds(userIdsToFetch);
if (!isEqual(requestedUserIds, ids) && ids.length > 0) {
setRequestedUserIds(ids);
users.fetchPage({ ids, limit: 100 });
}
userIdsToFetch
.filter((userId) => requestedUserIds.includes(userId))
.forEach((userId) => users.fetch(userId));
}, [document, users, presentIds, document.collaboratorIds, requestedUserIds]);
const popover = usePopoverState({
@@ -3,12 +3,10 @@ import * as React from "react";
import { useTranslation, Trans } from "react-i18next";
import { useHistory } from "react-router-dom";
import Collection from "~/models/Collection";
import Button from "~/components/Button";
import Flex from "~/components/Flex";
import ConfirmationDialog from "~/components/ConfirmationDialog";
import Text from "~/components/Text";
import useCurrentTeam from "~/hooks/useCurrentTeam";
import useStores from "~/hooks/useStores";
import useToasts from "~/hooks/useToasts";
import { homePath } from "~/utils/routeHelpers";
type Props = {
@@ -16,39 +14,29 @@ type Props = {
onSubmit: () => void;
};
function CollectionDelete({ collection, onSubmit }: Props) {
const [isDeleting, setIsDeleting] = React.useState(false);
function CollectionDeleteDialog({ collection, onSubmit }: Props) {
const team = useCurrentTeam();
const { showToast } = useToasts();
const { ui } = useStores();
const history = useHistory();
const { t } = useTranslation();
const handleSubmit = React.useCallback(
async (ev: React.SyntheticEvent) => {
ev.preventDefault();
setIsDeleting(true);
try {
const redirect = collection.id === ui.activeCollectionId;
await collection.delete();
onSubmit();
if (redirect) {
history.push(homePath());
}
} catch (err) {
showToast(err.message, {
type: "error",
});
} finally {
setIsDeleting(false);
}
},
[collection, history, onSubmit, showToast, ui.activeCollectionId]
);
const handleSubmit = async () => {
const redirect = collection.id === ui.activeCollectionId;
await collection.delete();
onSubmit();
if (redirect) {
history.push(homePath());
}
};
return (
<Flex column>
<form onSubmit={handleSubmit}>
<ConfirmationDialog
onSubmit={handleSubmit}
submitText={t("Im sure Delete")}
savingText={`${t("Deleting")}`}
danger
>
<>
<Text type="secondary">
<Trans
defaults="Are you sure about that? Deleting the <em>{{collectionName}}</em> collection is permanent and cannot be restored, however documents within will be moved to the trash."
@@ -73,12 +61,9 @@ function CollectionDelete({ collection, onSubmit }: Props) {
/>
</Text>
) : null}
<Button type="submit" disabled={isDeleting} autoFocus danger>
{isDeleting ? `${t("Deleting")}` : t("Im sure Delete")}
</Button>
</form>
</Flex>
</>
</ConfirmationDialog>
);
}
export default observer(CollectionDelete);
export default observer(CollectionDeleteDialog);
+20 -17
View File
@@ -1,3 +1,4 @@
import debounce from "lodash/debounce";
import { observer } from "mobx-react";
import { transparentize } from "polished";
import * as React from "react";
@@ -9,7 +10,6 @@ import ButtonLink from "~/components/ButtonLink";
import Editor from "~/components/Editor";
import LoadingIndicator from "~/components/LoadingIndicator";
import NudeButton from "~/components/NudeButton";
import useDebouncedCallback from "~/hooks/useDebouncedCallback";
import usePolicy from "~/hooks/usePolicy";
import useStores from "~/hooks/useStores";
import useToasts from "~/hooks/useToasts";
@@ -49,21 +49,25 @@ function CollectionDescription({ collection }: Props) {
[isExpanded]
);
const handleSave = useDebouncedCallback(async (getValue) => {
try {
await collection.save({
description: getValue(),
});
setDirty(false);
} catch (err) {
showToast(
t("Sorry, an error occurred saving the collection", {
type: "error",
})
);
throw err;
}
}, 1000);
const handleSave = React.useMemo(
() =>
debounce(async (getValue) => {
try {
await collection.save({
description: getValue(),
});
setDirty(false);
} catch (err) {
showToast(
t("Sorry, an error occurred saving the collection", {
type: "error",
})
);
throw err;
}
}, 1000),
[collection, showToast, t]
);
const handleChange = React.useCallback(
(getValue) => {
@@ -107,7 +111,6 @@ function CollectionDescription({ collection }: Props) {
maxLength={1000}
embedsDisabled
readOnlyWriteCheckboxes
grow
/>
</React.Suspense>
) : (
+4 -1
View File
@@ -5,6 +5,7 @@ import * as React from "react";
import Collection from "~/models/Collection";
import { icons } from "~/components/IconPicker";
import useStores from "~/hooks/useStores";
import Logger from "~/utils/Logger";
type Props = {
collection: Collection;
@@ -36,7 +37,9 @@ function ResolvedCollectionIcon({
const Component = icons[collection.icon].component;
return <Component color={color} size={size} />;
} catch (error) {
console.warn("Failed to render custom icon " + collection.icon);
Logger.warn("Failed to render custom icon", {
icon: collection.icon,
});
}
}
+2 -1
View File
@@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next";
import { Portal } from "react-portal";
import styled from "styled-components";
import breakpoint from "styled-components-breakpoint";
import { depths } from "@shared/styles";
import CommandBarResults from "~/components/CommandBarResults";
import SearchActions from "~/components/SearchActions";
import rootActions from "~/actions/root";
@@ -90,7 +91,7 @@ const Hint = styled(Text)`
`;
const Positioner = styled(KBarPositioner)`
z-index: ${(props) => props.theme.depths.commandBar};
z-index: ${depths.commandBar};
`;
const SearchInput = styled(KBarSearch)`
+61
View File
@@ -0,0 +1,61 @@
import { observer } from "mobx-react";
import * as React from "react";
import Button from "~/components/Button";
import Flex from "~/components/Flex";
import Text from "~/components/Text";
import useStores from "~/hooks/useStores";
import useToasts from "~/hooks/useToasts";
type Props = {
/** Callback when the dialog is submitted */
onSubmit: () => Promise<void> | void;
/** Text to display on the submit button */
submitText?: string;
/** Text to display while the form is saving */
savingText?: string;
/** If true, the submit button will be a dangerous red */
danger?: boolean;
};
const ConfirmationDialog: React.FC<Props> = ({
onSubmit,
children,
submitText,
savingText,
danger,
}) => {
const [isSaving, setIsSaving] = React.useState(false);
const { dialogs } = useStores();
const { showToast } = useToasts();
const handleSubmit = React.useCallback(
async (ev: React.SyntheticEvent) => {
ev.preventDefault();
setIsSaving(true);
try {
await onSubmit();
dialogs.closeAllModals();
} catch (err) {
showToast(err.message, {
type: "error",
});
} finally {
setIsSaving(false);
}
},
[onSubmit, dialogs, showToast]
);
return (
<Flex column>
<form onSubmit={handleSubmit}>
<Text type="secondary">{children}</Text>
<Button type="submit" disabled={isSaving} danger={danger} autoFocus>
{isSaving ? savingText : submitText}
</Button>
</form>
</Flex>
);
};
export default observer(ConfirmationDialog);
+12 -11
View File
@@ -3,11 +3,10 @@ import * as React from "react";
import { MenuItem as BaseMenuItem } from "reakit/Menu";
import styled, { css } from "styled-components";
import breakpoint from "styled-components-breakpoint";
import { hover } from "~/styles";
import MenuIconWrapper from "../MenuIconWrapper";
type Props = {
onClick?: (arg0: React.SyntheticEvent) => void | Promise<void>;
onClick?: (event: React.SyntheticEvent) => void | Promise<void>;
selected?: boolean;
disabled?: boolean;
dangerous?: boolean;
@@ -132,16 +131,18 @@ export const MenuAnchorCSS = css<MenuAnchorProps>`
? "pointer-events: none;"
: `
&:${hover},
&:focus,
&.focus-visible {
color: ${props.theme.white};
background: ${props.dangerous ? props.theme.danger : props.theme.primary};
box-shadow: none;
cursor: pointer;
@media (hover: hover) {
&:hover,
&:focus,
&.focus-visible {
color: ${props.theme.white};
background: ${props.dangerous ? props.theme.danger : props.theme.primary};
box-shadow: none;
cursor: pointer;
svg {
fill: ${props.theme.white};
svg {
fill: ${props.theme.white};
}
}
}
`};
+1 -1
View File
@@ -2,7 +2,7 @@ import * as React from "react";
import { MenuSeparator } from "reakit/Menu";
import styled from "styled-components";
export default function Separator(rest: any) {
export default function Separator(rest: React.HTMLAttributes<HTMLHRElement>) {
return (
<MenuSeparator {...rest}>
{(props) => <HorizontalRule {...props} />}
+21 -23
View File
@@ -69,29 +69,27 @@ const Submenu = React.forwardRef(
);
export function filterTemplateItems(items: TMenuItem[]): TMenuItem[] {
let filtered = items.filter((item) => item.visible !== false);
// this block literally just trims unnecessary separators
filtered = filtered.reduce((acc, item, index) => {
// trim separators from start / end
if (item.type === "separator" && index === 0) {
return acc;
}
if (item.type === "separator" && index === filtered.length - 1) {
return acc;
}
// trim double separators looking ahead / behind
const prev = filtered[index - 1];
if (prev && prev.type === "separator" && item.type === "separator") {
return acc;
}
// otherwise, continue
return [...acc, item];
}, []);
return filtered;
return items
.filter((item) => item.visible !== false)
.reduce((acc, item) => {
// trim separator if the previous item was a separator
if (
item.type === "separator" &&
acc[acc.length - 1]?.type === "separator"
) {
return acc;
}
return [...acc, item];
}, [] as TMenuItem[])
.filter((item, index, arr) => {
if (
item.type === "separator" &&
(index === 0 || index === arr.length - 1)
) {
return false;
}
return true;
});
}
function Template({ items, actions, context, ...menu }: Props) {
+35 -14
View File
@@ -1,9 +1,12 @@
import { disableBodyScroll, enableBodyScroll } from "body-scroll-lock";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Portal } from "react-portal";
import { Menu } from "reakit/Menu";
import styled from "styled-components";
import styled, { DefaultTheme } from "styled-components";
import breakpoint from "styled-components-breakpoint";
import { depths } from "@shared/styles";
import Scrollable from "~/components/Scrollable";
import useMenuContext from "~/hooks/useMenuContext";
import useMenuHeight from "~/hooks/useMenuHeight";
import usePrevious from "~/hooks/usePrevious";
@@ -90,6 +93,19 @@ const ContextMenu: React.FC<Props> = ({
t,
]);
// We must manually manage scroll lock for iOS support so that the scrollable
// element can be passed into body-scroll-lock. See:
// https://github.com/ariakit/ariakit/issues/469
React.useEffect(() => {
const scrollElement = backgroundRef.current;
if (rest.visible && scrollElement) {
disableBodyScroll(scrollElement);
}
return () => {
scrollElement && enableBodyScroll(scrollElement);
};
}, [rest.visible]);
// Perf win don't render anything until the menu has been opened
if (!rest.visible && !previousVisible) {
return null;
@@ -99,7 +115,7 @@ const ContextMenu: React.FC<Props> = ({
// trigger and the bottom of the window
return (
<>
<Menu hideOnClickOutside preventBodyScroll {...rest}>
<Menu hideOnClickOutside preventBodyScroll={false} {...rest}>
{(props) => {
// kind of hacky, but this is an effective way of telling which way
// the menu will _actually_ be placed when taking into account screen
@@ -115,6 +131,7 @@ const ContextMenu: React.FC<Props> = ({
topAnchor={topAnchor}
rightAnchor={rightAnchor}
ref={backgroundRef}
hiddenScrollbars
style={
maxHeight && topAnchor
? {
@@ -148,7 +165,7 @@ export const Backdrop = styled.div`
right: 0;
bottom: 0;
background: ${(props) => props.theme.backdrop};
z-index: ${(props) => props.theme.depths.menu - 1};
z-index: ${depths.menu - 1};
${breakpoint("tablet")`
display: none;
@@ -157,10 +174,12 @@ export const Backdrop = styled.div`
export const Position = styled.div`
position: absolute;
z-index: ${(props) => props.theme.depths.menu};
z-index: ${depths.menu};
// overrides make mobile-first coding style challenging
// so we explicitly define mobile breakpoint here
/*
* overrides make mobile-first coding style challenging
* so we explicitly define mobile breakpoint here
*/
${breakpoint("mobile", "tablet")`
position: fixed !important;
transform: none !important;
@@ -171,10 +190,13 @@ export const Position = styled.div`
`};
`;
export const Background = styled.div<{
type BackgroundProps = {
topAnchor?: boolean;
rightAnchor?: boolean;
}>`
theme: DefaultTheme;
};
export const Background = styled(Scrollable)<BackgroundProps>`
animation: ${mobileContextMenu} 200ms ease;
transform-origin: 50% 100%;
max-width: 100%;
@@ -183,8 +205,6 @@ export const Background = styled.div<{
padding: 6px 0;
min-width: 180px;
min-height: 44px;
overflow: hidden;
overflow-y: auto;
max-height: 75vh;
pointer-events: all;
font-weight: normal;
@@ -194,11 +214,12 @@ export const Background = styled.div<{
}
${breakpoint("tablet")`
animation: ${(props: any) =>
animation: ${(props: BackgroundProps) =>
props.topAnchor ? fadeAndSlideDown : fadeAndSlideUp} 200ms ease;
transform-origin: ${(props: any) => (props.rightAnchor ? "75%" : "25%")} 0;
transform-origin: ${(props: BackgroundProps) =>
props.rightAnchor ? "75%" : "25%"} 0;
max-width: 276px;
background: ${(props: any) => props.theme.menuBackground};
box-shadow: ${(props: any) => props.theme.menuShadow};
background: ${(props: BackgroundProps) => props.theme.menuBackground};
box-shadow: ${(props: BackgroundProps) => props.theme.menuShadow};
`};
`;
+5 -5
View File
@@ -1,11 +1,12 @@
import copy from "copy-to-clipboard";
import * as React from "react";
import env from "~/env";
type Props = {
text: string;
children?: React.ReactElement;
onClick?: React.MouseEventHandler<HTMLButtonElement>;
onCopy: () => void;
onCopy?: () => void;
};
class CopyToClipboard extends React.PureComponent<Props> {
@@ -14,12 +15,11 @@ class CopyToClipboard extends React.PureComponent<Props> {
const elem = React.Children.only(children);
copy(text, {
debug: process.env.NODE_ENV !== "production",
debug: env.ENVIRONMENT !== "production",
format: "text/plain",
});
if (onCopy) {
onCopy();
}
onCopy?.();
if (elem && elem.props && typeof elem.props.onClick === "function") {
elem.props.onClick(ev);
+25 -7
View File
@@ -73,42 +73,61 @@ const DocumentMeta: React.FC<Props> = ({
const collection = collections.get(document.collectionId);
const lastUpdatedByCurrentUser = user.id === updatedBy.id;
const userName = updatedBy.name;
let content;
if (deletedAt) {
content = (
<span>
{t("deleted")} <Time dateTime={deletedAt} addSuffix />
{lastUpdatedByCurrentUser
? t("You deleted")
: t("{{ userName }} deleted", { userName })}{" "}
<Time dateTime={deletedAt} addSuffix />
</span>
);
} else if (archivedAt) {
content = (
<span>
{t("archived")} <Time dateTime={archivedAt} addSuffix />
{lastUpdatedByCurrentUser
? t("You archived")
: t("{{ userName }} archived", { userName })}{" "}
<Time dateTime={archivedAt} addSuffix />
</span>
);
} else if (createdAt === updatedAt) {
content = (
<span>
{t("created")} <Time dateTime={updatedAt} addSuffix />
{lastUpdatedByCurrentUser
? t("You created")
: t("{{ userName }} created", { userName })}{" "}
<Time dateTime={updatedAt} addSuffix />
</span>
);
} else if (publishedAt && (publishedAt === updatedAt || showPublished)) {
content = (
<span>
{t("published")} <Time dateTime={publishedAt} addSuffix />
{lastUpdatedByCurrentUser
? t("You published")
: t("{{ userName }} published", { userName })}{" "}
<Time dateTime={publishedAt} addSuffix />
</span>
);
} else if (isDraft) {
content = (
<span>
{t("saved")} <Time dateTime={updatedAt} addSuffix />
{lastUpdatedByCurrentUser
? t("You saved")
: t("{{ userName }} saved", { userName })}{" "}
<Time dateTime={updatedAt} addSuffix />
</span>
);
} else {
content = (
<Modified highlight={modifiedSinceViewed && !lastUpdatedByCurrentUser}>
{t("updated")} <Time dateTime={updatedAt} addSuffix />
{lastUpdatedByCurrentUser
? t("You updated")
: t("{{ userName }} updated", { userName })}{" "}
<Time dateTime={updatedAt} addSuffix />
</Modified>
);
}
@@ -143,7 +162,6 @@ const DocumentMeta: React.FC<Props> = ({
return (
<Container align="center" rtl={document.dir === "rtl"} {...rest} dir="ltr">
{lastUpdatedByCurrentUser ? t("You") : updatedBy.name}&nbsp;
{to ? <Link to={to}>{content}</Link> : content}
{showCollection && collection && (
<span>
+2 -2
View File
@@ -1,4 +1,4 @@
import { useObserver } from "mobx-react";
import { observer, useObserver } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { usePopoverState, PopoverDisclosure } from "reakit/Popover";
@@ -83,4 +83,4 @@ const Meta = styled(DocumentMeta)<{ rtl?: boolean }>`
}
`;
export default DocumentMetaWithViews;
export default observer(DocumentMetaWithViews);
+2 -1
View File
@@ -1,3 +1,4 @@
import { observer } from "mobx-react";
import { DoneIcon } from "outline-icons";
import * as React from "react";
import { useTranslation, TFunction } from "react-i18next";
@@ -60,4 +61,4 @@ const Done = styled(DoneIcon)<{ $animated: boolean }>`
transform-origin: center center;
`;
export default DocumentTasks;
export default observer(DocumentTasks);
@@ -0,0 +1,52 @@
import invariant from "invariant";
import { observer } from "mobx-react";
import * as React from "react";
import { useTranslation, Trans } from "react-i18next";
import { useHistory } from "react-router-dom";
import ConfirmationDialog from "~/components/ConfirmationDialog";
import useStores from "~/hooks/useStores";
import useToasts from "~/hooks/useToasts";
import { documentUrl } from "~/utils/routeHelpers";
type Props = {
documentId: string;
};
function DocumentTemplatizeDialog({ documentId }: Props) {
const history = useHistory();
const { showToast } = useToasts();
const { t } = useTranslation();
const { documents } = useStores();
const document = documents.get(documentId);
invariant(document, "Document must exist");
const handleSubmit = React.useCallback(async () => {
const template = await document?.templatize();
if (template) {
history.push(documentUrl(template));
showToast(t("Template created, go ahead and customize it"), {
type: "info",
});
}
}, [document, showToast, history, t]);
return (
<ConfirmationDialog
onSubmit={handleSubmit}
submitText={t("Create template")}
savingText={`${t("Creating")}`}
>
<Trans
defaults="Creating a template from <em>{{titleWithDefault}}</em> is a non-destructive action we'll make a copy of the document and turn it into a template that can be used as a starting point for new documents."
values={{
titleWithDefault: document.titleWithDefault,
}}
components={{
em: <strong />,
}}
/>
</ConfirmationDialog>
);
}
export default observer(DocumentTemplatizeDialog);
+2 -1
View File
@@ -4,6 +4,7 @@ import { observer } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import Document from "~/models/Document";
import User from "~/models/User";
import Avatar from "~/components/Avatar";
import ListItem from "~/components/List/Item";
import PaginatedList from "~/components/PaginatedList";
@@ -42,7 +43,7 @@ function DocumentViews({ document, isOpen }: Props) {
<PaginatedList
aria-label={t("Viewers")}
items={users}
renderItem={(item) => {
renderItem={(item: User) => {
const view = documentViews.find((v) => v.user.id === item.id);
const isPresent = presentIds.includes(item.id);
const isEditing = editingIds.includes(item.id);
+200 -13
View File
@@ -1,15 +1,30 @@
import { formatDistanceToNow } from "date-fns";
import { deburr, sortBy } from "lodash";
import { TextSelection } from "prosemirror-state";
import * as React from "react";
import mergeRefs from "react-merge-refs";
import { Optional } from "utility-types";
import insertFiles from "@shared/editor/commands/insertFiles";
import embeds from "@shared/editor/embeds";
import { Heading } from "@shared/editor/lib/getHeadings";
import { supportedImageMimeTypes } from "@shared/utils/files";
import getDataTransferFiles from "@shared/utils/getDataTransferFiles";
import parseDocumentSlug from "@shared/utils/parseDocumentSlug";
import { isInternalUrl } from "@shared/utils/urls";
import Document from "~/models/Document";
import ClickablePadding from "~/components/ClickablePadding";
import ErrorBoundary from "~/components/ErrorBoundary";
import HoverPreview from "~/components/HoverPreview";
import type { Props as EditorProps, Editor as SharedEditor } from "~/editor";
import useDictionary from "~/hooks/useDictionary";
import useStores from "~/hooks/useStores";
import useToasts from "~/hooks/useToasts";
import { NotFoundError } from "~/utils/errors";
import { uploadFile } from "~/utils/files";
import history from "~/utils/history";
import { isModKey } from "~/utils/keyboard";
import { isHash } from "~/utils/urls";
import DocumentBreadcrumb from "./DocumentBreadcrumb";
const LazyLoadedEditor = React.lazy(
() =>
@@ -32,14 +47,82 @@ export type Props = Optional<
shareId?: string | undefined;
embedsDisabled?: boolean;
grow?: boolean;
onHeadingsChange?: (headings: Heading[]) => void;
onSynced?: () => Promise<void>;
onPublish?: (event: React.MouseEvent) => any;
};
function Editor(props: Props, ref: React.Ref<SharedEditor>) {
const { id, shareId } = props;
function Editor(props: Props, ref: React.RefObject<SharedEditor> | null) {
const { id, shareId, onChange, onHeadingsChange } = props;
const { documents } = useStores();
const { showToast } = useToasts();
const dictionary = useDictionary();
const [
activeLinkEvent,
setActiveLinkEvent,
] = React.useState<MouseEvent | null>(null);
const previousHeadings = React.useRef<Heading[] | null>(null);
const handleLinkActive = React.useCallback((event: MouseEvent) => {
setActiveLinkEvent(event);
return false;
}, []);
const handleLinkInactive = React.useCallback(() => {
setActiveLinkEvent(null);
}, []);
const handleSearchLink = React.useCallback(
async (term: string) => {
if (isInternalUrl(term)) {
// search for exact internal document
const slug = parseDocumentSlug(term);
if (!slug) {
return [];
}
try {
const document = await documents.fetch(slug);
const time = formatDistanceToNow(Date.parse(document.updatedAt), {
addSuffix: true,
});
return [
{
title: document.title,
subtitle: `Updated ${time}`,
url: document.url,
},
];
} catch (error) {
// NotFoundError could not find document for slug
if (!(error instanceof NotFoundError)) {
throw error;
}
}
}
// default search for anything that doesn't look like a URL
const results = await documents.searchTitles(term);
return sortBy(
results.map((document: Document) => {
return {
title: document.title,
subtitle: <DocumentBreadcrumb document={document} onlyText />,
url: document.url,
};
}),
(document) =>
deburr(document.title)
.toLowerCase()
.startsWith(deburr(term).toLowerCase())
? -1
: 1
);
},
[documents]
);
const onUploadFile = React.useCallback(
async (file: File) => {
@@ -85,19 +168,123 @@ function Editor(props: Props, ref: React.Ref<SharedEditor>) {
[shareId]
);
const focusAtEnd = React.useCallback(() => {
ref?.current?.focusAtEnd();
}, [ref]);
const handleDrop = React.useCallback(
(event: React.DragEvent<HTMLDivElement>) => {
event.preventDefault();
event.stopPropagation();
const files = getDataTransferFiles(event);
const view = ref?.current?.view;
if (!view) {
return;
}
// Insert all files as attachments if any of the files are not images.
const isAttachment = files.some(
(file) => !supportedImageMimeTypes.includes(file.type)
);
// Find a valid position at the end of the document
const pos = TextSelection.near(
view.state.doc.resolve(view.state.doc.nodeSize - 2)
).from;
insertFiles(view, event, pos, files, {
uploadFile: onUploadFile,
onFileUploadStart: props.onFileUploadStart,
onFileUploadStop: props.onFileUploadStop,
onShowToast: showToast,
dictionary,
isAttachment,
});
},
[
ref,
props.onFileUploadStart,
props.onFileUploadStop,
dictionary,
onUploadFile,
showToast,
]
);
// see: https://stackoverflow.com/a/50233827/192065
const handleDragOver = React.useCallback(
(event: React.DragEvent<HTMLDivElement>) => {
event.stopPropagation();
event.preventDefault();
},
[]
);
// Calculate if headings have changed and trigger callback if so
const updateHeadings = React.useCallback(() => {
if (onHeadingsChange) {
const headings = ref?.current?.getHeadings();
if (
headings &&
headings.map((h) => h.level + h.title).join("") !==
previousHeadings.current?.map((h) => h.level + h.title).join("")
) {
previousHeadings.current = headings;
onHeadingsChange(headings);
}
}
}, [ref, onHeadingsChange]);
const handleChange = React.useCallback(
(event) => {
onChange?.(event);
updateHeadings();
},
[onChange, updateHeadings]
);
const handleRefChanged = React.useCallback(
(node: SharedEditor | null) => {
if (node && !previousHeadings.current) {
updateHeadings();
}
},
[updateHeadings]
);
return (
<ErrorBoundary reloadOnChunkMissing>
<LazyLoadedEditor
ref={ref}
uploadFile={onUploadFile}
onShowToast={showToast}
embeds={embeds}
dictionary={dictionary}
{...props}
onClickLink={onClickLink}
placeholder={props.placeholder || ""}
defaultValue={props.defaultValue || ""}
/>
<>
<LazyLoadedEditor
ref={mergeRefs([ref, handleRefChanged])}
uploadFile={onUploadFile}
onShowToast={showToast}
embeds={embeds}
dictionary={dictionary}
{...props}
onHoverLink={handleLinkActive}
onClickLink={onClickLink}
onSearchLink={handleSearchLink}
onChange={handleChange}
placeholder={props.placeholder || ""}
defaultValue={props.defaultValue || ""}
/>
{props.grow && !props.readOnly && (
<ClickablePadding
onClick={focusAtEnd}
onDrop={handleDrop}
onDragOver={handleDragOver}
grow
/>
)}
{activeLinkEvent && !shareId && (
<HoverPreview
node={activeLinkEvent.target as HTMLAnchorElement}
event={activeLinkEvent}
onClose={handleLinkInactive}
/>
)}
</>
</ErrorBoundary>
);
}
+4 -7
View File
@@ -1,4 +1,3 @@
import * as Sentry from "@sentry/react";
import { observable } from "mobx";
import { observer } from "mobx-react";
import * as React from "react";
@@ -10,7 +9,8 @@ import CenteredContent from "~/components/CenteredContent";
import PageTitle from "~/components/PageTitle";
import Text from "~/components/Text";
import env from "~/env";
import isHosted from "~/utils/isHosted";
import Logger from "~/utils/Logger";
import isCloudHosted from "~/utils/isCloudHosted";
type Props = WithTranslation & {
reloadOnChunkMissing?: boolean;
@@ -26,7 +26,6 @@ class ErrorBoundary extends React.Component<Props> {
componentDidCatch(error: Error) {
this.error = error;
console.error(error);
if (
this.props.reloadOnChunkMissing &&
@@ -40,9 +39,7 @@ class ErrorBoundary extends React.Component<Props> {
return;
}
if (env.SENTRY_DSN) {
Sentry.captureException(error);
}
Logger.error("ErrorBoundary", error);
}
handleReload = () => {
@@ -62,7 +59,7 @@ class ErrorBoundary extends React.Component<Props> {
if (this.error) {
const error = this.error;
const isReported = !!env.SENTRY_DSN && isHosted;
const isReported = !!env.SENTRY_DSN && isCloudHosted;
const isChunkError = this.error.message.match(/chunk/);
if (isChunkError) {
+10 -1
View File
@@ -5,6 +5,7 @@ import {
PublishIcon,
MoveIcon,
CheckboxIcon,
UnpublishIcon,
} from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
@@ -85,6 +86,11 @@ const EventListItem = ({ event, latest, document, ...rest }: Props) => {
meta = t("{{userName}} published", opts);
break;
case "documents.unpublish":
icon = <UnpublishIcon color="currentColor" size={16} />;
meta = t("{{userName}} unpublished", opts);
break;
case "documents.move":
icon = <MoveIcon color="currentColor" size={16} />;
meta = t("{{userName}} moved", opts);
@@ -113,7 +119,10 @@ const EventListItem = ({ event, latest, document, ...rest }: Props) => {
<Time
dateTime={event.createdAt}
tooltipDelay={500}
format="MMM do, h:mm a"
format={{
en_US: "MMM do, h:mm a",
fr_FR: "'Le 'd MMMM 'à' H:mm",
}}
relative={false}
addSuffix
onClick={handleTimeClick}
+9 -1
View File
@@ -11,11 +11,19 @@ const Flex = styled.div<{
align?: AlignValues;
justify?: JustifyValues;
shrink?: boolean;
reverse?: boolean;
gap?: number;
}>`
display: flex;
flex: ${({ auto }) => (auto ? "1 1 auto" : "initial")};
flex-direction: ${({ column }) => (column ? "column" : "row")};
flex-direction: ${({ column, reverse }) =>
reverse
? column
? "column-reverse"
: "row-reverse"
: column
? "column"
: "row"};
align-items: ${({ align }) => align};
justify-content: ${({ justify }) => justify};
flex-shrink: ${({ shrink }) => (shrink ? 1 : "initial")};
+1 -1
View File
@@ -19,7 +19,7 @@ type Props = RootStore & {
membership?: CollectionGroupMembership;
showFacepile?: boolean;
showAvatar?: boolean;
renderActions: (arg0: { openMembersModal: () => void }) => React.ReactNode;
renderActions: (params: { openMembersModal: () => void }) => React.ReactNode;
};
@observer
+4 -4
View File
@@ -1,7 +1,7 @@
import { observer } from "mobx-react";
import * as React from "react";
import { Dialog, DialogBackdrop, useDialogState } from "reakit/Dialog";
import styled from "styled-components";
import { depths } from "@shared/styles";
import Scrollable from "~/components/Scrollable";
import usePrevious from "~/hooks/usePrevious";
@@ -72,7 +72,7 @@ const Backdrop = styled.div`
right: 0;
bottom: 0;
background-color: ${(props) => props.theme.backdrop} !important;
z-index: ${(props) => props.theme.depths.modalOverlay};
z-index: ${depths.modalOverlay};
transition: opacity 200ms ease-in-out;
opacity: 0;
@@ -87,7 +87,7 @@ const Scene = styled.div`
right: 0;
bottom: 0;
margin: 12px;
z-index: ${(props) => props.theme.depths.modal};
z-index: ${depths.modal};
display: flex;
justify-content: center;
align-items: flex-start;
@@ -111,4 +111,4 @@ const Content = styled(Scrollable)`
padding: 16px;
`;
export default observer(Guide);
export default Guide;
+11 -11
View File
@@ -5,9 +5,11 @@ import { transparentize } from "polished";
import * as React from "react";
import styled from "styled-components";
import breakpoint from "styled-components-breakpoint";
import { depths } from "@shared/styles";
import Button from "~/components/Button";
import Fade from "~/components/Fade";
import Flex from "~/components/Flex";
import useEventListener from "~/hooks/useEventListener";
import useMobile from "~/hooks/useMobile";
import useStores from "~/hooks/useStores";
import { supportsPassiveListener } from "~/utils/browser";
@@ -28,19 +30,17 @@ function Header({ breadcrumb, title, actions, hasSidebar }: Props) {
const passThrough = !actions && !breadcrumb && !title;
const [isScrolled, setScrolled] = React.useState(false);
const handleScroll = React.useCallback(
throttle(() => setScrolled(window.scrollY > 75), 50),
const handleScroll = React.useMemo(
() => throttle(() => setScrolled(window.scrollY > 75), 50),
[]
);
React.useEffect(() => {
window.addEventListener(
"scroll",
handleScroll,
supportsPassiveListener ? { passive: true } : false
);
return () => window.removeEventListener("scroll", handleScroll);
}, [handleScroll]);
useEventListener(
"scroll",
handleScroll,
window,
supportsPassiveListener ? { passive: true } : { capture: false }
);
const handleClickTitle = React.useCallback(() => {
window.scrollTo({
@@ -100,7 +100,7 @@ const Actions = styled(Flex)`
const Wrapper = styled(Flex)<{ $passThrough?: boolean }>`
top: 0;
z-index: ${(props) => props.theme.depths.header};
z-index: ${depths.header};
position: sticky;
background: ${(props) => props.theme.background};
+4 -3
View File
@@ -1,3 +1,4 @@
import { escapeRegExp } from "lodash";
import * as React from "react";
import replace from "string-replace-to-array";
import styled from "styled-components";
@@ -23,7 +24,7 @@ function Highlight({
regex = highlight;
} else {
regex = new RegExp(
(highlight || "").replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"),
escapeRegExp(highlight || ""),
caseSensitive ? "g" : "gi"
);
}
@@ -41,10 +42,10 @@ function Highlight({
);
}
const Mark = styled.mark`
export const Mark = styled.mark`
background: ${(props) => props.theme.searchHighlight};
border-radius: 2px;
padding: 0 4px;
padding: 0 2px;
`;
export default Highlight;
+11 -4
View File
@@ -2,9 +2,11 @@ import { transparentize } from "polished";
import * as React from "react";
import { Portal } from "react-portal";
import styled from "styled-components";
import { depths } from "@shared/styles";
import parseDocumentSlug from "@shared/utils/parseDocumentSlug";
import { isInternalUrl } from "@shared/utils/urls";
import { isExternalUrl } from "@shared/utils/urls";
import HoverPreviewDocument from "~/components/HoverPreviewDocument";
import useMobile from "~/hooks/useMobile";
import useStores from "~/hooks/useStores";
import { fadeAndSlideDown } from "~/styles/animations";
@@ -123,8 +125,13 @@ function HoverPreviewInternal({ node, onClose }: Props) {
}
function HoverPreview({ node, ...rest }: Props) {
const isMobile = useMobile();
if (isMobile) {
return null;
}
// previews only work for internal doc links for now
if (!isInternalUrl(node.href)) {
if (isExternalUrl(node.href)) {
return null;
}
@@ -150,7 +157,7 @@ const Margin = styled.div`
const CardContent = styled.div`
overflow: hidden;
max-height: 350px;
max-height: 20em;
user-select: none;
`;
@@ -195,7 +202,7 @@ const Card = styled.div`
const Position = styled.div<{ fixed?: boolean; top?: number; left?: number }>`
margin-top: 10px;
position: ${({ fixed }) => (fixed ? "fixed" : "absolute")};
z-index: ${(props) => props.theme.depths.hoverPreview};
z-index: ${depths.hoverPreview};
display: flex;
max-height: 75%;
+11 -6
View File
@@ -38,6 +38,13 @@ const RealInput = styled.input<{ hasIcon?: boolean }>`
color: ${(props) => props.theme.placeholder};
}
&:-webkit-autofill,
&:-webkit-autofill:hover,
&:-webkit-autofill:focus {
-webkit-box-shadow: 0 0 0px 1000px ${(props) => props.theme.background}
inset;
}
&::-webkit-search-cancel-button {
-webkit-appearance: none;
}
@@ -97,7 +104,7 @@ export const LabelText = styled.div`
display: inline-block;
`;
export type Props = React.HTMLAttributes<HTMLInputElement> & {
export type Props = Omit<React.HTMLAttributes<HTMLInputElement>, "onChange"> & {
type?: "text" | "email" | "checkbox" | "search" | "textarea";
value?: string;
label?: string;
@@ -108,6 +115,7 @@ export type Props = React.HTMLAttributes<HTMLInputElement> & {
margin?: string | number;
icon?: React.ReactNode;
name?: string;
pattern?: string;
minLength?: number;
maxLength?: number;
autoFocus?: boolean;
@@ -119,6 +127,7 @@ export type Props = React.HTMLAttributes<HTMLInputElement> & {
onChange?: (
ev: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
) => unknown;
innerRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement>;
onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement>) => unknown;
onFocus?: (ev: React.SyntheticEvent) => unknown;
onBlur?: (ev: React.SyntheticEvent) => unknown;
@@ -126,7 +135,7 @@ export type Props = React.HTMLAttributes<HTMLInputElement> & {
@observer
class Input extends React.Component<Props> {
input = React.createRef<HTMLInputElement | HTMLTextAreaElement>();
input = this.props.innerRef;
@observable
focused = false;
@@ -147,10 +156,6 @@ class Input extends React.Component<Props> {
}
};
focus() {
this.input.current?.focus();
}
render() {
const {
type = "text",
+8 -2
View File
@@ -2,7 +2,7 @@ import { SearchIcon } from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { useTheme } from "styled-components";
import Input, { Props as InputProps } from "./Input";
import Input, { Props as InputProps } from "~/components/Input";
type Props = InputProps & {
placeholder?: string;
@@ -11,7 +11,10 @@ type Props = InputProps & {
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => unknown;
};
export default function InputSearch(props: Props) {
function InputSearch(
props: Props,
ref: React.RefObject<HTMLInputElement | HTMLTextAreaElement>
) {
const { t } = useTranslation();
const theme = useTheme();
const [isFocused, setIsFocused] = React.useState(false);
@@ -39,7 +42,10 @@ export default function InputSearch(props: Props) {
onBlur={handleBlur}
margin={0}
labelHidden
innerRef={ref}
{...rest}
/>
);
}
export default React.forwardRef(InputSearch);
+7 -3
View File
@@ -8,7 +8,7 @@ import useBoolean from "~/hooks/useBoolean";
import useKeyDown from "~/hooks/useKeyDown";
import { isModKey } from "~/utils/keyboard";
import { searchPath } from "~/utils/routeHelpers";
import Input from "./Input";
import Input, { Outline } from "./Input";
type Props = {
source: string;
@@ -30,7 +30,7 @@ function InputSearchPage({
collectionId,
source,
}: Props) {
const inputRef = React.useRef<Input>(null);
const inputRef = React.useRef<HTMLInputElement>(null);
const theme = useTheme();
const history = useHistory();
const { t } = useTranslation();
@@ -67,7 +67,7 @@ function InputSearchPage({
return (
<InputMaxWidth
ref={inputRef}
innerRef={inputRef}
type="search"
placeholder={placeholder || `${t("Search")}`}
value={value}
@@ -89,6 +89,10 @@ function InputSearchPage({
const InputMaxWidth = styled(Input)`
max-width: 30vw;
${Outline} {
border-radius: 16px;
}
`;
export default observer(InputSearchPage);
+2 -2
View File
@@ -10,7 +10,7 @@ import useCurrentUser from "~/hooks/useCurrentUser";
import useStores from "~/hooks/useStores";
import { detectLanguage } from "~/utils/language";
function Icon(props: any) {
function Icon({ className }: { className?: string }) {
return (
<svg
width="32"
@@ -18,7 +18,7 @@ function Icon(props: any) {
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
className={className}
>
<path
fill-rule="evenodd"
+7 -4
View File
@@ -1,7 +1,7 @@
import { observer } from "mobx-react";
import * as React from "react";
import { Helmet } from "react-helmet";
import styled from "styled-components";
import styled, { DefaultTheme } from "styled-components";
import breakpoint from "styled-components-breakpoint";
import Flex from "~/components/Flex";
import { LoadingIndicatorBar } from "~/components/LoadingIndicator";
@@ -74,11 +74,14 @@ const Container = styled(Flex)`
min-height: 100%;
`;
const Content = styled(Flex)<{
type ContentProps = {
$isResizing?: boolean;
$sidebarCollapsed?: boolean;
$hasSidebar?: boolean;
}>`
theme: DefaultTheme;
};
const Content = styled(Flex)<ContentProps>`
margin: 0;
transition: ${(props) =>
props.$isResizing ? "none" : `margin-left 100ms ease-out`};
@@ -92,7 +95,7 @@ const Content = styled(Flex)<{
`}
${breakpoint("tablet")`
${(props: any) =>
${(props: ContentProps) =>
props.$hasSidebar &&
props.$sidebarCollapsed &&
`margin-left: ${props.theme.sidebarCollapsedWidth}px;`}
+23
View File
@@ -0,0 +1,23 @@
import * as React from "react";
import { loadPolyfills } from "~/utils/polyfills";
/**
* Asyncronously load required polyfills. Should wrap the React tree.
*/
export const LazyPolyfill: React.FC = ({ children }) => {
const [isLoaded, setIsLoaded] = React.useState(false);
React.useEffect(() => {
loadPolyfills().then(() => {
setIsLoaded(true);
});
}, []);
if (!isLoaded) {
return null;
}
return <>{children}</>;
};
export default LazyPolyfill;
+1
View File
@@ -92,6 +92,7 @@ const Image = styled(Flex)`
user-select: none;
flex-shrink: 0;
align-self: center;
color: ${(props) => props.theme.text};
`;
const Heading = styled.p<{ $small?: boolean }>`
+10 -5
View File
@@ -3,19 +3,24 @@ import * as React from "react";
import styled from "styled-components";
import Fade from "~/components/Fade";
import Flex from "~/components/Flex";
import PlaceholderText from "~/components/PlaceholderText";
import PlaceholderText, {
Props as PlaceholderTextProps,
} from "~/components/PlaceholderText";
type Props = {
count?: number;
className?: string;
header?: PlaceholderTextProps;
body?: PlaceholderTextProps;
};
const ListPlaceHolder = ({ count }: Props) => {
const ListPlaceHolder = ({ count, className, header, body }: Props) => {
return (
<Fade>
{times(count || 2, (index) => (
<Item key={index} column auto>
<PlaceholderText header delay={0.2 * index} />
<PlaceholderText delay={0.2 * index} />
<Item key={index} className={className} column auto>
<PlaceholderText {...header} header delay={0.2 * index} />
<PlaceholderText {...body} delay={0.2 * index} />
</Item>
))}
</Fade>
@@ -1,5 +1,6 @@
import * as React from "react";
import styled, { keyframes } from "styled-components";
import { depths } from "@shared/styles";
const LoadingIndicatorBar = () => {
return (
@@ -17,7 +18,7 @@ const loadingFrame = keyframes`
const Container = styled.div`
position: fixed;
top: 0;
z-index: ${(props) => props.theme.depths.loadingIndicatorBar};
z-index: ${depths.loadingIndicatorBar};
width: 100%;
animation: ${loadingFrame} 4s ease-in-out infinite;
animation-delay: 250ms;
+13 -11
View File
@@ -2,7 +2,7 @@ import { format as formatDate, formatDistanceToNow } from "date-fns";
import * as React from "react";
import Tooltip from "~/components/Tooltip";
import useUserLocale from "~/hooks/useUserLocale";
import { dateLocale } from "~/utils/i18n";
import { dateLocale, locales } from "~/utils/i18n";
let callbacks: (() => void)[] = [];
@@ -26,7 +26,7 @@ type Props = {
addSuffix?: boolean;
shorten?: boolean;
relative?: boolean;
format?: string;
format?: Partial<Record<keyof typeof locales, string>>;
};
const LocaleTime: React.FC<Props> = ({
@@ -38,7 +38,13 @@ const LocaleTime: React.FC<Props> = ({
relative,
tooltipDelay,
}) => {
const userLocale = useUserLocale();
const userLocale: string = useUserLocale() || "";
const dateFormatLong = {
en_US: "MMMM do, yyyy h:mm a",
fr_FR: "'Le 'd MMMM yyyy 'à' H:mm",
};
const formatLocaleLong = dateFormatLong[userLocale] ?? "MMMM do, yyyy h:mm a";
const formatLocale = format?.[userLocale] ?? formatLocaleLong;
const [_, setMinutesMounted] = React.useState(0); // eslint-disable-line @typescript-eslint/no-unused-vars
const callback = React.useRef<() => void>();
@@ -66,17 +72,13 @@ const LocaleTime: React.FC<Props> = ({
.replace("minute", "min");
}
const tooltipContent = formatDate(
Date.parse(dateTime),
"MMMM do, yyyy h:mm a",
{
locale,
}
);
const tooltipContent = formatDate(Date.parse(dateTime), formatLocaleLong, {
locale,
});
const content =
relative !== false
? relativeContent
: formatDate(Date.parse(dateTime), format || "MMMM do, yyyy h:mm a", {
: formatDate(Date.parse(dateTime), formatLocale, {
locale,
});
+29 -11
View File
@@ -4,8 +4,9 @@ import { transparentize } from "polished";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Dialog, DialogBackdrop, useDialogState } from "reakit/Dialog";
import styled from "styled-components";
import styled, { DefaultTheme } from "styled-components";
import breakpoint from "styled-components-breakpoint";
import { depths } from "@shared/styles";
import Flex from "~/components/Flex";
import NudeButton from "~/components/NudeButton";
import Scrollable from "~/components/Scrollable";
@@ -66,6 +67,7 @@ const Modal: React.FC<Props> = ({
<Backdrop $isCentered={isCentered} {...props}>
<Dialog
{...dialog}
aria-label={typeof title === "string" ? title : undefined}
preventBodyScroll
hideOnEsc
hideOnClickOutside={!!isCentered}
@@ -74,18 +76,24 @@ const Modal: React.FC<Props> = ({
{(props) =>
isCentered && !isMobile ? (
<Small {...props}>
<Centered onClick={(ev) => ev.stopPropagation()} column>
<Centered
onClick={(ev) => ev.stopPropagation()}
column
reverse
>
<SmallContent shadow>{children}</SmallContent>
<Header>
{title && (
<Text as="span" size="large">
{title}
</Text>
)}
<NudeButton onClick={onRequestClose}>
<CloseIcon color="currentColor" />
</NudeButton>
<Text as="span" size="large">
<NudeButton onClick={onRequestClose}>
<CloseIcon color="currentColor" />
</NudeButton>
</Text>
</Header>
<SmallContent shadow>{children}</SmallContent>
</Centered>
</Small>
) : (
@@ -133,7 +141,7 @@ const Backdrop = styled(Flex)<{ $isCentered?: boolean }>`
props.$isCentered
? props.theme.modalBackdrop
: transparentize(0.25, props.theme.background)} !important;
z-index: ${(props) => props.theme.depths.modalOverlay};
z-index: ${depths.modalOverlay};
transition: opacity 50ms ease-in-out;
opacity: 0;
@@ -142,7 +150,12 @@ const Backdrop = styled(Flex)<{ $isCentered?: boolean }>`
}
`;
const Fullscreen = styled.div<{ $nested: boolean }>`
type FullscreenProps = {
$nested: boolean;
theme: DefaultTheme;
};
const Fullscreen = styled.div<FullscreenProps>`
animation: ${fadeAndScaleIn} 250ms ease;
position: absolute;
@@ -150,7 +163,7 @@ const Fullscreen = styled.div<{ $nested: boolean }>`
left: 0;
right: 0;
bottom: 0;
z-index: ${(props) => props.theme.depths.modal};
z-index: ${depths.modal};
display: flex;
justify-content: center;
align-items: flex-start;
@@ -159,7 +172,7 @@ const Fullscreen = styled.div<{ $nested: boolean }>`
outline: none;
${breakpoint("tablet")`
${(props: any) =>
${(props: FullscreenProps) =>
props.$nested &&
`
box-shadow: 0 -2px 10px ${props.theme.shadow};
@@ -240,7 +253,7 @@ const Small = styled.div`
margin: auto auto;
min-width: 350px;
max-width: 30vw;
z-index: ${(props) => props.theme.depths.modal};
z-index: ${depths.modal};
display: flex;
justify-content: center;
align-items: flex-start;
@@ -255,6 +268,11 @@ const Small = styled.div`
&[aria-expanded="true"] {
background: ${(props) => props.theme.sidebarControlHoverBackground};
}
vertical-align: middle;
}
${Header} {
align-items: start;
}
`;
+13 -4
View File
@@ -1,8 +1,15 @@
import * as React from "react";
import { NavLink, Route } from "react-router-dom";
import { match, NavLink, Route } from "react-router-dom";
type Props = React.ComponentProps<typeof NavLink> & {
children?: (match: any) => React.ReactNode;
children?: (
match:
| match<{
[x: string]: string | undefined;
}>
| boolean
| null
) => React.ReactNode;
exact?: boolean;
activeStyle?: React.CSSProperties;
to: string;
@@ -14,9 +21,11 @@ function NavLinkWithChildrenFunc(
) {
return (
<Route path={to} exact={exact}>
{({ match }) => (
{({ match, location }) => (
<NavLink {...rest} to={to} exact={exact} ref={ref}>
{children ? children(match) : null}
{children
? children(rest.isActive ? rest.isActive(match, location) : match)
: null}
</NavLink>
)}
</Route>
+2 -2
View File
@@ -6,7 +6,7 @@ import PaginatedList from "~/components/PaginatedList";
type Props = {
documents: Document[];
fetch: (options: any) => Promise<void>;
fetch: (options: any) => Promise<Document[] | undefined>;
options?: Record<string, any>;
heading?: React.ReactNode;
empty?: React.ReactNode;
@@ -40,7 +40,7 @@ const PaginatedDocumentList = React.memo<Props>(function PaginatedDocumentList({
heading={heading}
fetch={fetch}
options={options}
renderItem={(item, _index, compositeProps) => (
renderItem={(item: Document, _index, compositeProps) => (
<DocumentListItem
key={item.id}
document={item}
+2 -2
View File
@@ -8,7 +8,7 @@ import EventListItem from "./EventListItem";
type Props = {
events: Event[];
document: Document;
fetch: (options: Record<string, any> | null | undefined) => Promise<void>;
fetch: (options: Record<string, any> | undefined) => Promise<Event[]>;
options?: Record<string, any>;
heading?: React.ReactNode;
empty?: React.ReactNode;
@@ -29,7 +29,7 @@ const PaginatedEventList = React.memo<Props>(function PaginatedEventList({
heading={heading}
fetch={fetch}
options={options}
renderItem={(item, index, compositeProps) => {
renderItem={(item: Event, index, compositeProps) => {
return (
<EventListItem
key={item.id}
+100 -77
View File
@@ -13,34 +13,42 @@ import PlaceholderList from "~/components/List/Placeholder";
import withStores from "~/components/withStores";
import { dateToHeading } from "~/utils/dates";
type Props = WithTranslation &
export interface PaginatedItem {
id: string;
createdAt?: string;
updatedAt?: string;
}
type Props<T> = WithTranslation &
RootStore & {
fetch?: (options: Record<string, any> | null | undefined) => Promise<any>;
fetch?: (
options: Record<string, any> | undefined
) => Promise<T[] | undefined> | undefined;
options?: Record<string, any>;
heading?: React.ReactNode;
empty?: React.ReactNode;
items: any[];
loading?: React.ReactElement;
items?: T[];
renderItem: (
item: any,
item: T,
index: number,
composite: CompositeStateReturn
compositeProps: CompositeStateReturn
) => React.ReactNode;
renderHeading?: (name: React.ReactElement<any> | string) => React.ReactNode;
onEscape?: (ev: React.KeyboardEvent<HTMLDivElement>) => void;
};
@observer
class PaginatedList extends React.Component<Props> {
isInitiallyLoaded = this.props.items.length > 0;
@observable
isLoaded = false;
class PaginatedList<T extends PaginatedItem> extends React.Component<Props<T>> {
@observable
isFetchingMore = false;
@observable
isFetching = false;
@observable
fetchCounter = 0;
@observable
renderCount: number = DEFAULT_PAGINATION_LIMIT;
@@ -54,7 +62,7 @@ class PaginatedList extends React.Component<Props> {
this.fetchResults();
}
componentDidUpdate(prevProps: Props) {
componentDidUpdate(prevProps: Props<T>) {
if (
prevProps.fetch !== this.props.fetch ||
!isEqual(prevProps.options, this.props.options)
@@ -70,7 +78,6 @@ class PaginatedList extends React.Component<Props> {
this.renderCount = DEFAULT_PAGINATION_LIMIT;
this.isFetching = false;
this.isFetchingMore = false;
this.isLoaded = false;
};
fetchResults = async () => {
@@ -78,7 +85,9 @@ class PaginatedList extends React.Component<Props> {
return;
}
this.isFetching = true;
const counter = ++this.fetchCounter;
const limit = DEFAULT_PAGINATION_LIMIT;
const results = await this.props.fetch({
limit,
offset: this.offset,
@@ -92,9 +101,12 @@ class PaginatedList extends React.Component<Props> {
}
this.renderCount += limit;
this.isLoaded = true;
this.isFetching = false;
this.isFetchingMore = false;
// only the most recent fetch should end the loading state
if (counter >= this.fetchCounter) {
this.isFetching = false;
this.isFetchingMore = false;
}
};
@action
@@ -105,9 +117,9 @@ class PaginatedList extends React.Component<Props> {
}
// If there are already cached results that we haven't yet rendered because
// of lazy rendering then show another page.
const leftToRender = this.props.items.length - this.renderCount;
const leftToRender = (this.props.items?.length ?? 0) - this.renderCount;
if (leftToRender > 1) {
if (leftToRender > 0) {
this.renderCount += DEFAULT_PAGINATION_LIMIT;
}
@@ -120,70 +132,81 @@ class PaginatedList extends React.Component<Props> {
};
render() {
const { items, heading, auth, empty, renderHeading } = this.props;
let previousHeading = "";
const {
items = [],
heading,
auth,
empty = null,
renderHeading,
onEscape,
} = this.props;
const showLoading =
this.isFetching && !this.isFetchingMore && !this.isInitiallyLoaded;
const showEmpty = !items.length && !showLoading;
const showList =
(this.isLoaded || this.isInitiallyLoaded) && !showLoading && !showEmpty;
return (
<>
{showEmpty && empty}
{showList && (
<>
{heading}
<ArrowKeyNavigation aria-label={this.props["aria-label"]}>
{(composite: CompositeStateReturn) =>
items.slice(0, this.renderCount).map((item, index) => {
const children = this.props.renderItem(
item,
index,
composite
);
this.isFetching &&
!this.isFetchingMore &&
(!items?.length || this.fetchCounter === 0);
// If there is no renderHeading method passed then no date
// headings are rendered
if (!renderHeading) {
return children;
}
// Our models have standard date fields, updatedAt > createdAt.
// Get what a heading would look like for this item
const currentDate =
item.updatedAt || item.createdAt || previousHeading;
const currentHeading = dateToHeading(
currentDate,
this.props.t,
auth.user?.language
);
// If the heading is different to any previous heading then we
// should render it, otherwise the item can go under the previous
// heading
if (!previousHeading || currentHeading !== previousHeading) {
previousHeading = currentHeading;
return (
<React.Fragment key={item.id}>
{renderHeading(currentHeading)}
{children}
</React.Fragment>
);
}
return children;
})
}
</ArrowKeyNavigation>
{this.allowLoadMore && (
<Waypoint key={this.renderCount} onEnter={this.loadMoreResults} />
)}
</>
)}
{showLoading && (
if (showLoading) {
return (
this.props.loading || (
<DelayedMount>
<PlaceholderList count={5} />
</DelayedMount>
)
);
}
if (items?.length === 0) {
return empty;
}
return (
<>
{heading}
<ArrowKeyNavigation
aria-label={this.props["aria-label"]}
onEscape={onEscape}
>
{(composite: CompositeStateReturn) => {
let previousHeading = "";
return items.slice(0, this.renderCount).map((item, index) => {
const children = this.props.renderItem(item, index, composite);
// If there is no renderHeading method passed then no date
// headings are rendered
if (!renderHeading) {
return children;
}
// Our models have standard date fields, updatedAt > createdAt.
// Get what a heading would look like for this item
const currentDate =
item.updatedAt || item.createdAt || previousHeading;
const currentHeading = dateToHeading(
currentDate,
this.props.t,
auth.user?.language
);
// If the heading is different to any previous heading then we
// should render it, otherwise the item can go under the previous
// heading
if (!previousHeading || currentHeading !== previousHeading) {
previousHeading = currentHeading;
return (
<React.Fragment key={item.id}>
{renderHeading(currentHeading)}
{children}
</React.Fragment>
);
}
return children;
});
}}
</ArrowKeyNavigation>
{this.allowLoadMore && (
<Waypoint key={this.renderCount} onEnter={this.loadMoreResults} />
)}
</>
);
+1 -1
View File
@@ -14,7 +14,7 @@ type Props = {
collection: Collection | null | undefined;
onSuccess?: () => void;
style?: React.CSSProperties;
ref?: (arg0: React.ElementRef<"div"> | null | undefined) => void;
ref?: (element: React.ElementRef<"div"> | null | undefined) => void;
};
@observer
+1 -1
View File
@@ -4,7 +4,7 @@ import { randomInteger } from "@shared/random";
import Flex from "~/components/Flex";
import { pulsate } from "~/styles/animations";
type Props = {
export type Props = {
header?: boolean;
height?: number;
minWidth?: number;
+19 -9
View File
@@ -1,40 +1,50 @@
import * as React from "react";
import { Dialog } from "reakit/Dialog";
import { Popover as ReakitPopover } from "reakit/Popover";
import { Popover as ReakitPopover, PopoverProps } from "reakit/Popover";
import styled from "styled-components";
import breakpoint from "styled-components-breakpoint";
import { depths } from "@shared/styles";
import useMobile from "~/hooks/useMobile";
import { fadeAndScaleIn } from "~/styles/animations";
type Props = {
tabIndex?: number;
type Props = PopoverProps & {
children: React.ReactNode;
width?: number;
shrink?: boolean;
tabIndex?: number;
};
const Popover: React.FC<Props> = ({ children, width = 380, ...rest }) => {
const Popover: React.FC<Props> = ({
children,
shrink,
width = 380,
...rest
}) => {
const isMobile = useMobile();
if (isMobile) {
return (
<Dialog {...rest} modal>
<Contents>{children}</Contents>
<Contents $shrink={shrink}>{children}</Contents>
</Dialog>
);
}
return (
<ReakitPopover {...rest}>
<Contents $width={width}>{children}</Contents>
<Contents $shrink={shrink} $width={width}>
{children}
</Contents>
</ReakitPopover>
);
};
const Contents = styled.div<{ $width?: number }>`
const Contents = styled.div<{ $shrink?: boolean; $width?: number }>`
animation: ${fadeAndScaleIn} 200ms ease;
transform-origin: 75% 0;
background: ${(props) => props.theme.menuBackground};
border-radius: 6px;
padding: 12px 24px;
padding: ${(props) => (props.$shrink ? "6px 0" : "12px 24px")};
max-height: 50vh;
overflow-y: scroll;
box-shadow: ${(props) => props.theme.menuShadow};
@@ -42,7 +52,7 @@ const Contents = styled.div<{ $width?: number }>`
${breakpoint("mobile", "tablet")`
position: fixed;
z-index: ${(props: any) => props.theme.depths.menu};
z-index: ${depths.menu};
// 50 is a magic number that positions us nicely under the top bar
top: 50px;
+16 -2
View File
@@ -3,16 +3,17 @@ import * as React from "react";
import styled from "styled-components";
import useWindowSize from "~/hooks/useWindowSize";
type Props = {
type Props = React.HTMLAttributes<HTMLDivElement> & {
shadow?: boolean;
topShadow?: boolean;
bottomShadow?: boolean;
hiddenScrollbars?: boolean;
flex?: boolean;
children: React.ReactNode;
};
function Scrollable(
{ shadow, topShadow, bottomShadow, flex, ...rest }: Props,
{ shadow, topShadow, bottomShadow, hiddenScrollbars, flex, ...rest }: Props,
ref: React.RefObject<HTMLDivElement>
) {
const fallbackRef = React.useRef<HTMLDivElement>();
@@ -55,6 +56,7 @@ function Scrollable(
ref={ref || fallbackRef}
onScroll={updateShadows}
$flex={flex}
$hiddenScrollbars={hiddenScrollbars}
$topShadowVisible={topShadowVisible}
$bottomShadowVisible={bottomShadowVisible}
{...rest}
@@ -66,6 +68,7 @@ const Wrapper = styled.div<{
$flex?: boolean;
$topShadowVisible?: boolean;
$bottomShadowVisible?: boolean;
$hiddenScrollbars?: boolean;
}>`
display: ${(props) => (props.$flex ? "flex" : "block")};
flex-direction: column;
@@ -90,6 +93,17 @@ const Wrapper = styled.div<{
return "none";
}};
transition: all 100ms ease-in-out;
${(props) =>
props.$hiddenScrollbars &&
`
-ms-overflow-style: none;
overflow: -moz-scrollbars-none;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
`}
`;
export default observer(React.forwardRef(Scrollable));
+148
View File
@@ -0,0 +1,148 @@
import { observer } from "mobx-react";
import * as React from "react";
import { Link } from "react-router-dom";
import { CompositeItem } from "reakit/Composite";
import styled, { css } from "styled-components";
import breakpoint from "styled-components-breakpoint";
import Document from "~/models/Document";
import Highlight, { Mark } from "~/components/Highlight";
import { hover } from "~/styles";
type Props = {
document: Document;
highlight: string;
context: string | undefined;
showParentDocuments?: boolean;
showCollection?: boolean;
showPublished?: boolean;
shareId?: string;
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
};
const SEARCH_RESULT_REGEX = /<b\b[^>]*>(.*?)<\/b>/gi;
function replaceResultMarks(tag: string) {
// don't use SEARCH_RESULT_REGEX here as it causes
// an infinite loop to trigger a regex inside it's own callback
return tag.replace(/<b\b[^>]*>(.*?)<\/b>/gi, "$1");
}
function DocumentListItem(
props: Props,
ref: React.RefObject<HTMLAnchorElement>
) {
const { document, highlight, context, shareId, ...rest } = props;
return (
<CompositeItem
as={DocumentLink}
ref={ref}
dir={document.dir}
to={{
pathname: shareId ? `/share/${shareId}${document.url}` : document.url,
state: {
title: document.titleWithDefault,
},
}}
{...rest}
>
<Content>
<Heading dir={document.dir}>
<Title
text={document.titleWithDefault}
highlight={highlight}
dir={document.dir}
/>
</Heading>
{
<ResultContext
text={context}
highlight={highlight ? SEARCH_RESULT_REGEX : undefined}
processResult={replaceResultMarks}
/>
}
</Content>
</CompositeItem>
);
}
const Content = styled.div`
flex-grow: 1;
flex-shrink: 1;
min-width: 0;
`;
const DocumentLink = styled(Link)<{
$isStarred?: boolean;
$menuOpen?: boolean;
}>`
display: flex;
align-items: center;
padding: 6px 12px;
max-height: 50vh;
&:not(:last-child) {
margin-bottom: 4px;
}
&:focus-visible {
outline: none;
}
${breakpoint("tablet")`
width: auto;
`};
&:${hover},
&:active,
&:focus,
&:focus-within {
background: ${(props) => props.theme.listItemHoverBackground};
}
${(props) =>
props.$menuOpen &&
css`
background: ${(props) => props.theme.listItemHoverBackground};
`}
`;
const Heading = styled.h4<{ rtl?: boolean }>`
display: flex;
justify-content: ${(props) => (props.rtl ? "flex-end" : "flex-start")};
align-items: center;
height: 18px;
margin-top: 0;
margin-bottom: 0.25em;
overflow: hidden;
white-space: nowrap;
color: ${(props) => props.theme.text};
`;
const Title = styled(Highlight)`
max-width: 90%;
overflow: hidden;
text-overflow: ellipsis;
${Mark} {
padding: 0;
}
`;
const ResultContext = styled(Highlight)`
display: block;
color: ${(props) => props.theme.textTertiary};
font-size: 14px;
margin-top: -0.25em;
margin-bottom: 0.25em;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
${Mark} {
padding: 0;
}
`;
export default observer(React.forwardRef(DocumentListItem));
+227
View File
@@ -0,0 +1,227 @@
import { debounce } from "lodash";
import { observer } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { usePopoverState, PopoverDisclosure } from "reakit/Popover";
import styled from "styled-components";
import { depths } from "@shared/styles";
import Empty from "~/components/Empty";
import { Outline } from "~/components/Input";
import InputSearch from "~/components/InputSearch";
import Placeholder from "~/components/List/Placeholder";
import PaginatedList, { PaginatedItem } from "~/components/PaginatedList";
import Popover from "~/components/Popover";
import { id as bodyContentId } from "~/components/SkipNavContent";
import useKeyDown from "~/hooks/useKeyDown";
import useStores from "~/hooks/useStores";
import { SearchResult } from "~/types";
import SearchListItem from "./SearchListItem";
type Props = { shareId: string };
function SearchPopover({ shareId }: Props) {
const { t } = useTranslation();
const { documents } = useStores();
const focusRef = React.useRef<HTMLElement | null>(null);
const popover = usePopoverState({
placement: "bottom-start",
unstable_offset: [-24, 0],
modal: true,
});
const [query, setQuery] = React.useState("");
const searchResults = documents.searchResults(query);
const [cachedQuery, setCachedQuery] = React.useState(query);
const [cachedSearchResults, setCachedSearchResults] = React.useState<
PaginatedItem[] | undefined
>(searchResults);
React.useEffect(() => {
if (searchResults) {
setCachedQuery(query);
setCachedSearchResults(searchResults);
popover.show();
}
}, [searchResults, query, popover.show]);
const performSearch = React.useCallback(
async ({ query, ...options }) => {
if (query?.length > 0) {
return await documents.search(query, { shareId, ...options });
}
return undefined;
},
[documents, shareId]
);
const handleSearchInputChange = React.useMemo(
() =>
debounce(async (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.target;
setQuery(value.trim());
// covers edge case: user manually dismisses popover then
// quickly edits input resulting in no change in query
// the useEffect that normally shows the popover will miss it
if (value === cachedQuery) {
popover.show();
}
if (!value.length) {
popover.hide();
}
}, 300),
[popover, cachedQuery]
);
const searchInputRef = popover.unstable_referenceRef as React.RefObject<
HTMLInputElement
>;
const firstSearchItem = React.useRef<HTMLAnchorElement>(null);
const handleEscapeList = React.useCallback(
() => searchInputRef?.current?.focus(),
[searchInputRef]
);
const handleSearchInputFocus = React.useCallback(() => {
focusRef.current = searchInputRef.current;
}, []);
const handleKeyDown = React.useCallback(
(ev: React.KeyboardEvent<HTMLInputElement>) => {
if (ev.key === "Enter") {
if (searchResults) {
popover.show();
}
}
if (ev.key === "ArrowDown" && !ev.shiftKey) {
if (ev.currentTarget.value.length) {
if (
ev.currentTarget.value.length === ev.currentTarget.selectionStart
) {
popover.show();
}
firstSearchItem.current?.focus();
}
}
if (ev.key === "ArrowUp") {
if (popover.visible) {
popover.hide();
if (!ev.shiftKey) {
ev.preventDefault();
}
}
if (ev.currentTarget.value) {
if (ev.currentTarget.selectionEnd === 0) {
ev.currentTarget.selectionStart = 0;
ev.currentTarget.selectionEnd = ev.currentTarget.value.length;
ev.preventDefault();
}
}
}
if (ev.key === "Escape") {
if (popover.visible) {
popover.hide();
ev.preventDefault();
}
}
},
[popover, searchResults]
);
const handleSearchItemClick = React.useCallback(() => {
popover.hide();
if (searchInputRef.current) {
searchInputRef.current.value = "";
focusRef.current = document.getElementById(bodyContentId);
}
}, [popover.hide]);
useKeyDown("/", (ev) => {
if (
searchInputRef.current &&
searchInputRef.current !== document.activeElement
) {
searchInputRef.current.focus();
ev.preventDefault();
}
});
return (
<>
<PopoverDisclosure {...popover}>
{(props) => {
// props assumes the disclosure is a button, but we want a type-ahead
// so we take the aria props, and ref and ignore the event handlers
return (
<StyledInputSearch
aria-controls={props["aria-controls"]}
aria-expanded={props["aria-expanded"]}
aria-haspopup={props["aria-haspopup"]}
ref={props.ref}
onChange={handleSearchInputChange}
onFocus={handleSearchInputFocus}
onKeyDown={handleKeyDown}
/>
);
}}
</PopoverDisclosure>
<Popover
{...popover}
aria-label={t("Results")}
unstable_autoFocusOnShow={false}
unstable_finalFocusRef={focusRef}
style={{ zIndex: depths.sidebar + 1 }}
shrink
>
<PaginatedList
options={{ query, snippetMinWords: 10, snippetMaxWords: 11 }}
items={cachedSearchResults}
fetch={performSearch}
onEscape={handleEscapeList}
empty={
<NoResults>{t("No results for {{query}}", { query })}</NoResults>
}
loading={<PlaceholderList count={3} header={{ height: 20 }} />}
renderItem={(item: SearchResult, index, compositeProps) => (
<SearchListItem
key={item.document.id}
shareId={shareId}
ref={index === 0 ? firstSearchItem : undefined}
document={item.document}
context={item.context}
highlight={cachedQuery}
onClick={handleSearchItemClick}
{...compositeProps}
/>
)}
/>
</Popover>
</>
);
}
const NoResults = styled(Empty)`
padding: 0 12px;
margin: 6px 0;
`;
const PlaceholderList = styled(Placeholder)`
padding: 6px 12px;
`;
const StyledInputSearch = styled(InputSearch)`
${Outline} {
border-radius: 16px;
}
`;
export default observer(SearchPopover);
+13 -12
View File
@@ -8,7 +8,7 @@ import styled from "styled-components";
import Flex from "~/components/Flex";
import Scrollable from "~/components/Scrollable";
import useAuthorizedSettingsConfig from "~/hooks/useAuthorizedSettingsConfig";
import isHosted from "~/utils/isHosted";
import isCloudHosted from "~/utils/isCloudHosted";
import Sidebar from "./Sidebar";
import Header from "./components/Header";
import Section from "./components/Section";
@@ -39,20 +39,21 @@ function SettingsSidebar() {
<Scrollable shadow>
{Object.keys(groupedConfig).map((header) => (
<Section key={header}>
<Header>{header}</Header>
{groupedConfig[header].map((item) => (
<SidebarLink
key={item.path}
to={item.path}
icon={<item.icon color="currentColor" />}
label={item.name}
/>
))}
<Header title={header}>
{groupedConfig[header].map((item) => (
<SidebarLink
key={item.path}
to={item.path}
icon={<item.icon color="currentColor" />}
label={item.name}
/>
))}
</Header>
</Section>
))}
{!isHosted && (
{!isCloudHosted && (
<Section>
<Header>{t("Installation")}</Header>
<Header title={t("Installation")} />
<Version />
</Section>
)}
+12
View File
@@ -2,6 +2,7 @@ import { observer } from "mobx-react";
import * as React from "react";
import styled from "styled-components";
import Scrollable from "~/components/Scrollable";
import SearchPopover from "~/components/SearchPopover";
import useStores from "~/hooks/useStores";
import { NavigationNode } from "~/types";
import Sidebar from "./Sidebar";
@@ -19,6 +20,9 @@ function SharedSidebar({ rootNode, shareId }: Props) {
return (
<Sidebar>
<ScrollContainer flex>
<TopSection>
<SearchPopover shareId={shareId} />
</TopSection>
<Section>
<DocumentLink
index={0}
@@ -38,4 +42,12 @@ const ScrollContainer = styled(Scrollable)`
padding-bottom: 16px;
`;
const TopSection = styled(Section)`
// this weird looking && increases the specificity of the style rule
&& {
margin-top: 16px;
margin-bottom: 16px;
}
`;
export default observer(SharedSidebar);
+12 -10
View File
@@ -5,6 +5,7 @@ import { Portal } from "react-portal";
import { useLocation } from "react-router-dom";
import styled, { useTheme } from "styled-components";
import breakpoint from "styled-components-breakpoint";
import { depths } from "@shared/styles";
import Flex from "~/components/Flex";
import useMenuContext from "~/hooks/useMenuContext";
import usePrevious from "~/hooks/usePrevious";
@@ -64,8 +65,7 @@ const Sidebar = React.forwardRef<HTMLDivElement, Props>(
const handleStopDrag = React.useCallback(() => {
setResizing(false);
if (document.activeElement) {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'blur' does not exist on type 'Element'.
if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur();
}
@@ -224,16 +224,18 @@ const Backdrop = styled.a`
bottom: 0;
right: 0;
cursor: default;
z-index: ${(props) => props.theme.depths.sidebar - 1};
z-index: ${depths.sidebar - 1};
background: ${(props) => props.theme.backdrop};
`;
const Container = styled(Flex)<{
type ContainerProps = {
$mobileSidebarVisible: boolean;
$isAnimating: boolean;
$isSmallerThanMinimum: boolean;
$collapsed: boolean;
}>`
};
const Container = styled(Flex)<ContainerProps>`
position: fixed;
top: 0;
bottom: 0;
@@ -241,12 +243,12 @@ const Container = styled(Flex)<{
background: ${(props) => props.theme.sidebarBackground};
transition: box-shadow 100ms ease-in-out, transform 100ms ease-out,
${(props) => props.theme.backgroundTransition}
${(props: any) =>
${(props: ContainerProps) =>
props.$isAnimating ? `,width ${ANIMATION_MS}ms ease-out` : ""};
transform: translateX(
${(props) => (props.$mobileSidebarVisible ? 0 : "-100%")}
);
z-index: ${(props) => props.theme.depths.sidebar};
z-index: ${depths.sidebar};
max-width: 70%;
min-width: 280px;
@@ -262,13 +264,13 @@ const Container = styled(Flex)<{
${breakpoint("tablet")`
margin: 0;
min-width: 0;
transform: translateX(${(props: any) =>
transform: translateX(${(props: ContainerProps) =>
props.$collapsed ? "calc(-100% + 16px)" : 0});
&:hover,
&:focus-within {
transform: none;
box-shadow: ${(props: any) =>
box-shadow: ${(props: ContainerProps) =>
props.$collapsed
? "rgba(0, 0, 0, 0.2) 1px 0 4px"
: props.$isSmallerThanMinimum
@@ -285,7 +287,7 @@ const Container = styled(Flex)<{
}
&:not(:hover):not(:focus-within) > div {
opacity: ${(props: any) => (props.$collapsed ? "0" : "1")};
opacity: ${(props: ContainerProps) => (props.$collapsed ? "0" : "1")};
transition: opacity 100ms ease-in-out;
}
`};
@@ -54,7 +54,7 @@ const CollectionLink: React.FC<Props> = ({
await collection.save({
name,
});
history.push(collection.url);
history.replace(collection.url, history.location.state);
},
[collection, history]
);
@@ -37,7 +37,7 @@ function CollectionLinkChildren({
const [{ isOverReorder, isDraggingAnyDocument }, dropToReorder] = useDrop({
accept: "document",
drop: (item: DragObject) => {
if (!manualSort) {
if (!manualSort && item.collectionId === collection?.id) {
showToast(
t(
"You can't reorder documents in an alphabetically sorted collection"
@@ -22,7 +22,6 @@ function Collections() {
const [fetchError, setFetchError] = React.useState();
const { documents, collections } = useStores();
const { showToast } = useToasts();
const [expanded, setExpanded] = React.useState(true);
const isPreloaded = !!collections.orderedData.length;
const { t } = useTranslation();
const orderedCollections = collections.orderedData;
@@ -97,20 +96,18 @@ function Collections() {
if (!collections.isLoaded || fetchError) {
return (
<Flex column>
<Header>{t("Collections")}</Header>
<PlaceholderCollections />
<Header id="collections" title={t("Collections")}>
<PlaceholderCollections />
</Header>
</Flex>
);
}
return (
<Flex column>
<Header onClick={() => setExpanded((prev) => !prev)} expanded={expanded}>
{t("Collections")}
</Header>
{expanded && (
<Header id="collections" title={t("Collections")}>
<Relative>{isPreloaded ? content : <Fade>{content}</Fade>}</Relative>
)}
</Header>
</Flex>
);
}
@@ -148,7 +148,7 @@ function InnerDocumentLink(
collectionId: collection?.id || "",
}),
collect: (monitor) => ({
isDragging: !!monitor.isDragging(),
isDragging: monitor.isDragging(),
}),
canDrag: () => {
return (
@@ -213,7 +213,7 @@ function InnerDocumentLink(
}
},
collect: (monitor) => ({
isOverReparent: !!monitor.isOver({
isOverReparent: monitor.isOver({
shallow: true,
}),
canDropToReparent: monitor.canDrop(),
@@ -252,25 +252,24 @@ function InnerDocumentLink(
documents.move(item.id, collection.id, parentId, index + 1);
},
collect: (monitor) => ({
isOverReorder: !!monitor.isOver(),
isDraggingAnyDocument: !!monitor.canDrop(),
isOverReorder: monitor.isOver(),
isDraggingAnyDocument: monitor.canDrop(),
}),
});
const nodeChildren = React.useMemo(() => {
if (
collection &&
const insertDraftDocument =
activeDocument?.isDraft &&
activeDocument?.isActive &&
activeDocument?.parentDocumentId === node.id
) {
return sortNavigationNodes(
[activeDocument?.asNavigationNode, ...node.children],
collection.sort
);
}
activeDocument?.parentDocumentId === node.id;
return node.children;
return collection && insertDraftDocument
? sortNavigationNodes(
[activeDocument?.asNavigationNode, ...node.children],
collection.sort,
false
)
: node.children;
}, [
activeDocument?.isActive,
activeDocument?.isDraft,
@@ -13,7 +13,6 @@ import CollectionLinkChildren from "./CollectionLinkChildren";
import DropCursor from "./DropCursor";
import Relative from "./Relative";
import { DragObject } from "./SidebarLink";
import { useStarredContext } from "./StarredContext";
type Props = {
collection: Collection;
@@ -37,10 +36,8 @@ function DraggableCollectionLink({
}: Props) {
const locationStateStarred = useLocationStateStarred();
const { ui, collections } = useStores();
const inStarredSection = useStarredContext();
const [expanded, setExpanded] = React.useState(
collection.id === ui.activeCollectionId &&
locationStateStarred === inStarredSection
collection.id === ui.activeCollectionId && !locationStateStarred
);
const can = usePolicy(collection.id);
const belowCollectionIndex = belowCollection ? belowCollection.index : null;
@@ -88,18 +85,10 @@ function DraggableCollectionLink({
// If the current collection is active and relevant to the sidebar section we
// are in then expand it automatically
React.useEffect(() => {
if (
collection.id === ui.activeCollectionId &&
locationStateStarred === inStarredSection
) {
if (collection.id === ui.activeCollectionId && !locationStateStarred) {
setExpanded(true);
}
}, [
collection.id,
ui.activeCollectionId,
locationStateStarred,
inStarredSection,
]);
}, [collection.id, ui.activeCollectionId, locationStateStarred]);
const handleDisclosureClick = React.useCallback((ev) => {
ev.preventDefault();
+52 -12
View File
@@ -1,25 +1,65 @@
import { CollapsedIcon } from "outline-icons";
import * as React from "react";
import styled from "styled-components";
import styled, { keyframes } from "styled-components";
import usePersistedState from "~/hooks/usePersistedState";
type Props = {
onClick?: React.MouseEventHandler;
expanded?: boolean;
/** Unique header id if passed the header will become toggleable */
id?: string;
title: React.ReactNode;
};
export const Header: React.FC<Props> = ({ onClick, expanded, children }) => {
/**
* Toggleable sidebar header
*/
export const Header: React.FC<Props> = ({ id, title, children }) => {
const [firstRender, setFirstRender] = React.useState(true);
const [expanded, setExpanded] = usePersistedState(
`sidebar-header-${id}`,
true
);
React.useEffect(() => {
if (!expanded) {
setFirstRender(false);
}
}, [expanded]);
const handleClick = React.useCallback(() => {
setExpanded(!expanded);
}, [expanded, setExpanded]);
return (
<H3>
<Button onClick={onClick} disabled={!onClick}>
{children}
{onClick && (
<Disclosure expanded={expanded} color="currentColor" size={20} />
)}
</Button>
</H3>
<>
<H3>
<Button onClick={handleClick} disabled={!id}>
{title}
{id && (
<Disclosure expanded={expanded} color="currentColor" size={20} />
)}
</Button>
</H3>
{expanded && (firstRender ? children : <Fade>{children}</Fade>)}
</>
);
};
export const fadeAndSlideDown = keyframes`
from {
opacity: 0;
transform: translateY(-8px);
}
to {
opacity: 1;
transform: translateY(0px);
}
`;
const Fade = styled.span`
animation: ${fadeAndSlideDown} 100ms ease-in-out;
`;
const Button = styled.button`
display: inline-flex;
align-items: center;
@@ -4,9 +4,24 @@ const ResizeBorder = styled.div`
position: absolute;
top: 0;
bottom: 0;
right: -6px;
width: 12px;
right: -1px;
width: 2px;
cursor: col-resize;
&:hover {
transition-delay: 500ms;
transition: background 250ms ease-in-out;
background: ${(props) => props.theme.sidebarActiveBackground};
}
&:after {
content: "";
position: absolute;
top: 0;
bottom: 0;
right: -4px;
width: 10px;
}
`;
export default ResizeBorder;
@@ -16,7 +16,7 @@ export type DragObject = NavigationNode & {
type Props = Omit<NavLinkProps, "to"> & {
to?: string | Record<string, any>;
href?: string | Record<string, any>;
innerRef?: (arg0: HTMLElement | null | undefined) => void;
innerRef?: (ref: HTMLElement | null | undefined) => void;
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
onDisclosureClick?: React.MouseEventHandler<HTMLButtonElement>;
@@ -24,6 +24,7 @@ type Props = Omit<NavLinkProps, "to"> & {
label?: React.ReactNode;
menu?: React.ReactNode;
showActions?: boolean;
disabled?: boolean;
active?: boolean;
/* If set, a disclosure will be rendered to the left of any icon */
expanded?: boolean;
@@ -55,6 +56,7 @@ function SidebarLink(
className,
expanded,
onDisclosureClick,
disabled,
...rest
}: Props,
ref: React.RefObject<HTMLAnchorElement>
@@ -82,6 +84,7 @@ function SidebarLink(
<Link
$isActiveDrop={isActiveDrop}
$isDraft={isDraft}
$disabled={disabled}
activeStyle={isActiveDrop ? activeDropStyle : activeStyle}
style={active ? activeStyle : style}
onClick={onClick}
@@ -158,7 +161,11 @@ const Actions = styled(EventBoundary)<{ showActions?: boolean }>`
}
`;
const Link = styled(NavLink)<{ $isActiveDrop?: boolean; $isDraft?: boolean }>`
const Link = styled(NavLink)<{
$isActiveDrop?: boolean;
$isDraft?: boolean;
$disabled?: boolean;
}>`
display: flex;
position: relative;
text-overflow: ellipsis;
@@ -174,6 +181,13 @@ const Link = styled(NavLink)<{ $isActiveDrop?: boolean; $isDraft?: boolean }>`
cursor: pointer;
overflow: hidden;
${(props) =>
props.$disabled &&
css`
pointer-events: none;
opacity: 0.75;
`}
${(props) =>
props.$isDraft &&
css`
+39 -101
View File
@@ -16,106 +16,51 @@ import StarredContext from "./StarredContext";
import StarredLink from "./StarredLink";
const STARRED_PAGINATION_LIMIT = 10;
const STARRED = "STARRED";
function Starred() {
const [isFetching, setIsFetching] = React.useState(false);
const [fetchError, setFetchError] = React.useState();
const [expanded, setExpanded] = React.useState(true);
const [show, setShow] = React.useState("Nothing");
const [offset, setOffset] = React.useState(0);
const [upperBound, setUpperBound] = React.useState(STARRED_PAGINATION_LIMIT);
const [displayedStarsCount, setDisplayedStarsCount] = React.useState(
STARRED_PAGINATION_LIMIT
);
const { showToast } = useToasts();
const { stars } = useStores();
const { t } = useTranslation();
const fetchResults = React.useCallback(async () => {
try {
setIsFetching(true);
await stars.fetchPage({
limit: STARRED_PAGINATION_LIMIT,
offset,
});
} catch (error) {
showToast(t("Starred documents could not be loaded"), {
type: "error",
});
setFetchError(error);
} finally {
setIsFetching(false);
}
}, [stars, offset, showToast, t]);
React.useEffect(() => {
let stateInLocal;
try {
stateInLocal = localStorage.getItem(STARRED);
} catch (_) {
// no-op Safari private mode
}
if (!stateInLocal) {
localStorage.setItem(STARRED, expanded ? "true" : "false");
} else {
setExpanded(stateInLocal === "true");
}
}, [expanded]);
React.useEffect(() => {
setOffset(stars.orderedData.length);
if (stars.orderedData.length <= STARRED_PAGINATION_LIMIT) {
setShow("Nothing");
} else if (stars.orderedData.length >= upperBound) {
setShow("More");
} else if (stars.orderedData.length < upperBound) {
setShow("Less");
}
}, [stars.orderedData, upperBound]);
React.useEffect(() => {
if (offset === 0) {
fetchResults();
}
}, [fetchResults, offset]);
const handleShowMore = React.useCallback(async () => {
setUpperBound(
(previousUpperBound) => previousUpperBound + STARRED_PAGINATION_LIMIT
);
await fetchResults();
}, [fetchResults]);
const handleShowLess = React.useCallback(() => {
setUpperBound(STARRED_PAGINATION_LIMIT);
setShow("More");
}, []);
const handleExpandClick = React.useCallback(
(ev) => {
ev.preventDefault();
ev.stopPropagation();
const fetchResults = React.useCallback(
async (offset = 0) => {
try {
localStorage.setItem(STARRED, !expanded ? "true" : "false");
} catch (_) {
// no-op Safari private mode
await stars.fetchPage({
limit: STARRED_PAGINATION_LIMIT + 1,
offset,
});
} catch (error) {
showToast(t("Starred documents could not be loaded"), {
type: "error",
});
setFetchError(error);
}
setExpanded((prev) => !prev);
},
[expanded]
[stars, showToast, t]
);
React.useEffect(() => {
fetchResults();
}, [fetchResults]);
const handleShowMore = async () => {
await fetchResults(displayedStarsCount);
setDisplayedStarsCount((prev) => prev + STARRED_PAGINATION_LIMIT);
};
// Drop to reorder document
const [{ isOverReorder }, dropToReorder] = useDrop({
const [{ isOverReorder, isDraggingAnyStar }, dropToReorder] = useDrop({
accept: "star",
drop: async (item: Star) => {
item?.save({ index: fractionalIndex(null, stars.orderedData[0].index) });
},
collect: (monitor) => ({
isOverReorder: !!monitor.isOver(),
isDraggingAnyStar: monitor.getItemType() === "star",
}),
});
@@ -126,40 +71,33 @@ function Starred() {
return (
<StarredContext.Provider value={true}>
<Flex column>
<Header onClick={handleExpandClick} expanded={expanded}>
{t("Starred")}
</Header>
{expanded && (
<Header id="starred" title={t("Starred")}>
<Relative>
<DropCursor
isActiveDrop={isOverReorder}
innerRef={dropToReorder}
position="top"
/>
{stars.orderedData.slice(0, upperBound).map((star) => (
{isDraggingAnyStar && (
<DropCursor
isActiveDrop={isOverReorder}
innerRef={dropToReorder}
position="top"
/>
)}
{stars.orderedData.slice(0, displayedStarsCount).map((star) => (
<StarredLink key={star.id} star={star} />
))}
{show === "More" && !isFetching && (
{stars.orderedData.length > displayedStarsCount && (
<SidebarLink
onClick={handleShowMore}
label={`${t("Show more")}`}
disabled={stars.isFetching}
depth={0}
/>
)}
{show === "Less" && !isFetching && (
<SidebarLink
onClick={handleShowLess}
label={`${t("Show less")}`}
depth={0}
/>
)}
{(isFetching || fetchError) && !stars.orderedData.length && (
{(stars.isFetching || fetchError) && !stars.orderedData.length && (
<Flex column>
<PlaceholderCollections />
</Flex>
)}
</Relative>
)}
</Header>
</Flex>
</StarredContext.Provider>
);
@@ -1,4 +1,5 @@
import * as React from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import Badge from "~/components/Badge";
import { version } from "../../../../package.json";
@@ -6,6 +7,7 @@ import SidebarLink from "./SidebarLink";
export default function Version() {
const [releasesBehind, setReleasesBehind] = React.useState(0);
const { t } = useTranslation();
React.useEffect(() => {
async function loadReleases() {
@@ -37,10 +39,11 @@ export default function Version() {
<br />
<LilBadge>
{releasesBehind === 0
? "Up to date"
: `${releasesBehind} version${
releasesBehind === 1 ? "" : "s"
} behind`}
? t("Up to date")
: t(`{{ releasesBehind }} versions behind`, {
releasesBehind,
count: releasesBehind,
})}
</LilBadge>
</>
}
@@ -12,19 +12,19 @@ export default function useCollectionDocuments(
return [];
}
if (
const insertDraftDocument =
activeDocument?.isActive &&
activeDocument?.isDraft &&
activeDocument?.collectionId === collection.id &&
!activeDocument?.parentDocumentId
) {
return sortNavigationNodes(
[activeDocument.asNavigationNode, ...collection.documents],
collection.sort
);
}
!activeDocument?.parentDocumentId;
return collection.documents;
return insertDraftDocument
? sortNavigationNodes(
[activeDocument.asNavigationNode, ...collection.sortedDocuments],
collection.sort,
false
)
: collection.sortedDocuments;
}, [
activeDocument?.isActive,
activeDocument?.isDraft,
@@ -32,7 +32,7 @@ export default function useCollectionDocuments(
activeDocument?.parentDocumentId,
activeDocument?.asNavigationNode,
collection,
collection?.documents,
collection?.sortedDocuments,
collection?.id,
collection?.sort,
]);
+2 -1
View File
@@ -1,5 +1,6 @@
import * as React from "react";
import styled from "styled-components";
import { depths } from "@shared/styles";
import { id } from "~/components/SkipNavContent";
export default function SkipNavLink() {
@@ -25,7 +26,7 @@ const Anchor = styled.a`
background: ${(props) => props.theme.background};
color: ${(props) => props.theme.text};
outline-color: ${(props) => props.theme.primary};
z-index: ${(props) => props.theme.depths.popover};
z-index: ${depths.popover};
width: auto;
height: auto;
clip: auto;
+3 -4
View File
@@ -1,7 +1,8 @@
import { observer } from "mobx-react";
import * as React from "react";
import { ThemeProvider } from "styled-components";
import { dark, light, lightMobile, darkMobile } from "@shared/theme";
import { breakpoints } from "@shared/styles";
import { dark, light, lightMobile, darkMobile } from "@shared/styles/theme";
import useMediaQuery from "~/hooks/useMediaQuery";
import useStores from "~/hooks/useStores";
import GlobalStyles from "~/styles/globals";
@@ -11,9 +12,7 @@ const Theme: React.FC = ({ children }) => {
const resolvedTheme = ui.resolvedTheme === "dark" ? dark : light;
const resolvedMobileTheme =
ui.resolvedTheme === "dark" ? darkMobile : lightMobile;
const isMobile = useMediaQuery(
`(max-width: ${resolvedTheme.breakpoints.tablet}px)`
);
const isMobile = useMediaQuery(`(max-width: ${breakpoints.tablet}px)`);
const isPrinting = useMediaQuery("print");
const theme = isPrinting
? light
+2 -1
View File
@@ -1,6 +1,7 @@
import { observer } from "mobx-react";
import * as React from "react";
import styled from "styled-components";
import { depths } from "@shared/styles";
import Toast from "~/components/Toast";
import useStores from "~/hooks/useStores";
import { Toast as TToast } from "~/types";
@@ -27,7 +28,7 @@ const List = styled.ol`
list-style: none;
margin: 0;
padding: 0;
z-index: ${(props) => props.theme.depths.toasts};
z-index: ${depths.toasts};
`;
export default observer(Toasts);
+6 -21
View File
@@ -1,6 +1,6 @@
import * as React from "react";
import scrollIntoView from "smooth-scroll-into-view-if-needed";
import styled, { useTheme } from "styled-components";
import styled from "styled-components";
export type Props = {
selected: boolean;
@@ -22,7 +22,6 @@ function BlockMenuItem({
containerId = "block-menu-container",
}: Props) {
const Icon = icon;
const theme = useTheme();
const ref = React.useCallback(
(node) => {
@@ -50,11 +49,7 @@ function BlockMenuItem({
>
{Icon && (
<>
<Icon
color={
selected ? theme.blockToolbarIconSelected : theme.blockToolbarIcon
}
/>
<Icon color="currentColor" />
&nbsp;&nbsp;
</>
)}
@@ -85,24 +80,14 @@ const MenuItem = styled.button<{
border: none;
opacity: ${(props) => (props.disabled ? ".5" : "1")};
color: ${(props) =>
props.selected
? props.theme.blockToolbarTextSelected
: props.theme.blockToolbarText};
background: ${(props) =>
props.selected
? props.theme.blockToolbarSelectedBackground ||
props.theme.blockToolbarTrigger
: "none"};
props.selected ? props.theme.white : props.theme.textSecondary};
background: ${(props) => (props.selected ? props.theme.primary : "none")};
padding: 0 16px;
outline: none;
&:active {
color: ${(props) => props.theme.blockToolbarTextSelected};
background: ${(props) =>
props.selected
? props.theme.blockToolbarSelectedBackground ||
props.theme.blockToolbarTrigger
: props.theme.blockToolbarHoverBackground};
color: ${(props) => props.theme.white};
background: ${(props) => (props.selected ? props.theme.primary : "none")};
${Shortcut} {
color: ${(props) => props.theme.textSecondary};
+12 -10
View File
@@ -10,8 +10,10 @@ import insertFiles from "@shared/editor/commands/insertFiles";
import { CommandFactory } from "@shared/editor/lib/Extension";
import filterExcessSeparators from "@shared/editor/lib/filterExcessSeparators";
import { EmbedDescriptor, MenuItem } from "@shared/editor/types";
import { depths } from "@shared/styles";
import { supportedImageMimeTypes } from "@shared/utils/files";
import getDataTransferFiles from "@shared/utils/getDataTransferFiles";
import Scrollable from "~/components/Scrollable";
import { Dictionary } from "~/hooks/useDictionary";
import Input from "./Input";
@@ -418,7 +420,7 @@ class CommandMenu<T = MenuItem> extends React.Component<Props<T>, State> {
commands,
filterable = true,
} = this.props;
let items: (EmbedDescriptor | MenuItem)[] = this.props.items;
let items: (EmbedDescriptor | MenuItem)[] = [...this.props.items];
const embedItems: EmbedDescriptor[] = [];
for (const embed of embeds) {
@@ -487,6 +489,7 @@ class CommandMenu<T = MenuItem> extends React.Component<Props<T>, State> {
id={this.props.id || "block-menu-container"}
active={isActive}
ref={this.menuRef}
hiddenScrollbars
{...positioning}
>
{insertItem ? (
@@ -569,7 +572,7 @@ const LinkInputWrapper = styled.div`
const LinkInput = styled(Input)`
height: 36px;
width: 100%;
color: ${(props) => props.theme.blockToolbarText};
color: ${(props) => props.theme.textSecondary};
`;
const List = styled.ol`
@@ -595,22 +598,22 @@ const Empty = styled.div`
padding: 0 16px;
`;
export const Wrapper = styled.div<{
export const Wrapper = styled(Scrollable)<{
active: boolean;
top?: number;
bottom?: number;
left?: number;
isAbove: boolean;
}>`
color: ${(props) => props.theme.text};
color: ${(props) => props.theme.textSecondary};
font-family: ${(props) => props.theme.fontFamily};
position: absolute;
z-index: ${(props) => props.theme.zIndex + 100};
z-index: ${depths.editorToolbar};
${(props) => props.top !== undefined && `top: ${props.top}px`};
${(props) => props.bottom !== undefined && `bottom: ${props.bottom}px`};
left: ${(props) => props.left}px;
background-color: ${(props) => props.theme.blockToolbarBackground};
border-radius: 4px;
background: ${(props) => props.theme.menuBackground};
border-radius: 6px;
box-shadow: rgba(0, 0, 0, 0.05) 0px 0px 0px 1px,
rgba(0, 0, 0, 0.08) 0px 4px 8px, rgba(0, 0, 0, 0.08) 0px 2px 4px;
opacity: 0;
@@ -623,9 +626,8 @@ export const Wrapper = styled.div<{
pointer-events: none;
white-space: nowrap;
width: 300px;
height: auto;
max-height: 324px;
overflow: hidden;
overflow-y: auto;
* {
box-sizing: border-box;
@@ -634,7 +636,7 @@ export const Wrapper = styled.div<{
hr {
border: 0;
height: 0;
border-top: 1px solid ${(props) => props.theme.blockToolbarDivider};
border-top: 1px solid ${(props) => props.theme.divider};
}
${({ active, isAbove }) =>
+1 -1
View File
@@ -21,7 +21,7 @@ const searcher = new FuzzySearch<{
sort: true,
});
class EmojiMenu extends React.Component<
class EmojiMenu extends React.PureComponent<
Omit<
Props<Emoji>,
| "renderMenuItem"
+11 -19
View File
@@ -4,7 +4,9 @@ import { EditorView } from "prosemirror-view";
import * as React from "react";
import { Portal } from "react-portal";
import styled from "styled-components";
import { depths } from "@shared/styles";
import useComponentSize from "~/hooks/useComponentSize";
import useEventListener from "~/hooks/useEventListener";
import useMediaQuery from "~/hooks/useMediaQuery";
import useViewportHeight from "~/hooks/useViewportHeight";
@@ -163,25 +165,15 @@ const FloatingToolbar = React.forwardRef(
props,
});
React.useEffect(() => {
const handleMouseDown = () => {
if (!props.active) {
setSelectingText(true);
}
};
useEventListener("mouseup", () => {
setSelectingText(false);
});
const handleMouseUp = () => {
setSelectingText(false);
};
window.addEventListener("mousedown", handleMouseDown);
window.addEventListener("mouseup", handleMouseUp);
return () => {
window.removeEventListener("mousedown", handleMouseDown);
window.removeEventListener("mouseup", handleMouseUp);
};
}, [props.active]);
useEventListener("mousedown", () => {
if (!props.active) {
setSelectingText(true);
}
});
return (
<Portal>
@@ -208,7 +200,7 @@ const Wrapper = styled.div<{
will-change: opacity, transform;
padding: 8px 16px;
position: absolute;
z-index: ${(props) => props.theme.zIndex + 100};
z-index: ${depths.editorToolbar};
opacity: 0;
background-color: ${(props) => props.theme.toolbarBackground};
border-radius: 4px;
+1
View File
@@ -137,6 +137,7 @@ export default class LinkToolbar extends React.Component<Props> {
<FloatingToolbar ref={this.menuRef} active={active} {...rest}>
{active && (
<LinkEditor
key={`${selection.from}-${selection.to}`}
from={selection.from}
to={selection.to}
onCreateLink={onCreateLink ? this.handleOnCreateLink : undefined}
+7 -12
View File
@@ -42,7 +42,7 @@ type Props = {
function isVisible(props: Props) {
const { view } = props;
const { selection } = view.state;
const { selection, doc } = view.state;
if (isMarkActive(view.state.schema.marks.link)(view.state)) {
return true;
@@ -63,6 +63,11 @@ function isVisible(props: Props) {
return false;
}
const selectionText = doc.cut(selection.from, selection.to).textContent;
if (selection instanceof TextSelection && !selectionText) {
return false;
}
const slice = selection.content();
const fragment = slice.content;
const nodes = (fragment as any).content;
@@ -192,7 +197,6 @@ export default class SelectionToolbar extends React.Component<Props> {
const link = isMarkActive(state.schema.marks.link)(state);
const range = getMarkRange(selection.$from, state.schema.marks.link);
const isImageSelection = selection.node?.type?.name === "image";
let isTextSelection = false;
let items: MenuItem[] = [];
if (isTableSelection) {
@@ -207,7 +211,6 @@ export default class SelectionToolbar extends React.Component<Props> {
items = getDividerMenuItems(state, dictionary);
} else {
items = getFormattingMenuItems(state, isTemplate, dictionary);
isTextSelection = true;
}
// Some extensions may be disabled, remove corresponding items
@@ -226,15 +229,6 @@ export default class SelectionToolbar extends React.Component<Props> {
return null;
}
const selectionText = state.doc.cut(
state.selection.from,
state.selection.to
).textContent;
if (isTextSelection && !selectionText && !link) {
return null;
}
return (
<FloatingToolbar
view={view}
@@ -243,6 +237,7 @@ export default class SelectionToolbar extends React.Component<Props> {
>
{link && range ? (
<LinkEditor
key={`${range.from}-${range.to}`}
dictionary={dictionary}
mark={range.mark}
from={range.from}
+25 -8
View File
@@ -1,5 +1,5 @@
/* eslint-disable no-irregular-whitespace */
import { lighten } from "polished";
import { lighten, transparentize } from "polished";
import styled from "styled-components";
const EditorStyles = styled.div<{
@@ -403,7 +403,9 @@ const EditorStyles = styled.div<{
padding: 0;
&.collapsed {
transform: rotate(${(props) => (props.rtl ? "90deg" : "-90deg")});
svg {
transform: rotate(${(props) => (props.rtl ? "90deg" : "-90deg")});
}
transition-delay: 0.1s;
opacity: 1;
}
@@ -429,10 +431,12 @@ const EditorStyles = styled.div<{
.notice-block {
display: flex;
align-items: center;
background: ${(props) => props.theme.noticeInfoBackground};
background: ${(props) =>
transparentize(0.9, props.theme.noticeInfoBackground)};
border-left: 4px solid ${(props) => props.theme.noticeInfoBackground};
color: ${(props) => props.theme.noticeInfoText};
border-radius: 4px;
padding: 8px 16px;
padding: 8px 10px 8px 8px;
margin: 8px 0;
a {
@@ -462,21 +466,34 @@ const EditorStyles = styled.div<{
height: 24px;
align-self: flex-start;
margin-${(props) => (props.rtl ? "left" : "right")}: 4px;
color: ${(props) => props.theme.noticeInfoBackground};
}
.notice-block.tip {
background: ${(props) => props.theme.noticeTipBackground};
background: ${(props) =>
transparentize(0.9, props.theme.noticeTipBackground)};
border-left: 4px solid ${(props) => props.theme.noticeTipBackground};
color: ${(props) => props.theme.noticeTipText};
.icon {
color: ${(props) => props.theme.noticeTipBackground};
}
a {
color: ${(props) => props.theme.noticeTipText};
}
}
.notice-block.warning {
background: ${(props) => props.theme.noticeWarningBackground};
background: ${(props) =>
transparentize(0.9, props.theme.noticeWarningBackground)};
border-left: 4px solid ${(props) => props.theme.noticeWarningBackground};
color: ${(props) => props.theme.noticeWarningText};
.icon {
color: ${(props) => props.theme.noticeWarningBackground};
}
a {
color: ${(props) => props.theme.noticeWarningText};
}
@@ -756,8 +773,8 @@ const EditorStyles = styled.div<{
select,
button {
background: ${(props) => props.theme.blockToolbarBackground};
color: ${(props) => props.theme.blockToolbarItem};
background: ${(props) => props.theme.background};
color: ${(props) => props.theme.text};
border-width: 1px;
font-size: 13px;
display: none;
+9 -30
View File
@@ -18,7 +18,8 @@ import * as React from "react";
import { DefaultTheme, ThemeProps } from "styled-components";
import Extension, { CommandFactory } from "@shared/editor/lib/Extension";
import ExtensionManager from "@shared/editor/lib/ExtensionManager";
import headingToSlug from "@shared/editor/lib/headingToSlug";
import getHeadings from "@shared/editor/lib/getHeadings";
import getTasks from "@shared/editor/lib/getTasks";
import { MarkdownSerializer } from "@shared/editor/lib/markdown/serializer";
import Mark from "@shared/editor/marks/Mark";
import Node from "@shared/editor/nodes/Node";
@@ -28,6 +29,7 @@ import { EmbedDescriptor, EventType } from "@shared/editor/types";
import EventEmitter from "@shared/utils/events";
import Flex from "~/components/Flex";
import { Dictionary } from "~/hooks/useDictionary";
import Logger from "~/utils/Logger";
import BlockMenu from "./components/BlockMenu";
import ComponentView from "./components/ComponentView";
import EditorContext from "./components/EditorContext";
@@ -470,13 +472,13 @@ export class Editor extends React.PureComponent<
try {
const element = document.querySelector(hash);
if (element) {
element.scrollIntoView({ behavior: "smooth" });
setTimeout(() => element.scrollIntoView({ behavior: "smooth" }), 0);
}
} catch (err) {
// querySelector will throw an error if the hash begins with a number
// or contains a period. This is protected against now by safeSlugify
// however previous links may be in the wild.
console.warn(`Attempted to scroll to invalid hash: ${hash}`, err);
Logger.debug("editor", `Attempted to scroll to invalid hash: ${hash}`);
}
}
@@ -574,34 +576,11 @@ export class Editor extends React.PureComponent<
};
public getHeadings = () => {
const headings: { title: string; level: number; id: string }[] = [];
const previouslySeen = {};
return getHeadings(this.view.state.doc);
};
this.view.state.doc.forEach((node) => {
if (node.type.name === "heading") {
// calculate the optimal slug
const slug = headingToSlug(node);
let id = slug;
// check if we've already used it, and if so how many times?
// Make the new id based on that number ensuring that we have
// unique ID's even when headings are identical
if (previouslySeen[slug] > 0) {
id = headingToSlug(node, previouslySeen[slug]);
}
// record that we've seen this slug for the next loop
previouslySeen[slug] =
previouslySeen[slug] !== undefined ? previouslySeen[slug] + 1 : 1;
headings.push({
title: node.textContent,
level: node.attrs.level,
id,
});
}
});
return headings;
public getTasks = () => {
return getTasks(this.view.state.doc);
};
public render() {
+20
View File
@@ -16,6 +16,8 @@ import {
InfoIcon,
LinkIcon,
AttachmentIcon,
ClockIcon,
CalendarIcon,
} from "outline-icons";
import { MenuItem } from "@shared/editor/types";
import { Dictionary } from "~/hooks/useDictionary";
@@ -124,6 +126,24 @@ export default function blockMenuItems(dictionary: Dictionary): MenuItem[] {
keywords: "page print break line",
attrs: { markup: "***" },
},
{
name: "date",
title: dictionary.insertDate,
keywords: "clock",
icon: CalendarIcon,
},
{
name: "time",
title: dictionary.insertTime,
keywords: "clock",
icon: ClockIcon,
},
{
name: "datetime",
title: dictionary.insertDateTime,
keywords: "clock",
icon: CalendarIcon,
},
{
name: "separator",
},
+3 -3
View File
@@ -29,7 +29,7 @@ import Zapier from "~/scenes/Settings/Zapier";
import SlackIcon from "~/components/SlackIcon";
import ZapierIcon from "~/components/ZapierIcon";
import env from "~/env";
import isHosted from "~/utils/isHosted";
import isCloudHosted from "~/utils/isCloudHosted";
import useCurrentTeam from "./useCurrentTeam";
import usePolicy from "./usePolicy";
@@ -163,7 +163,7 @@ const useAuthorizedSettingsConfig = () => {
name: "Slack",
path: "/settings/integrations/slack",
component: Slack,
enabled: can.update && (!!env.SLACK_KEY || isHosted),
enabled: can.update && (!!env.SLACK_CLIENT_ID || isCloudHosted),
group: t("Integrations"),
icon: SlackIcon,
},
@@ -171,7 +171,7 @@ const useAuthorizedSettingsConfig = () => {
name: "Zapier",
path: "/settings/integrations/zapier",
component: Zapier,
enabled: can.update && isHosted,
enabled: can.update && isCloudHosted,
group: t("Integrations"),
icon: ZapierIcon,
},
+4 -5
View File
@@ -1,11 +1,11 @@
import * as React from "react";
export default function useDebouncedCallback(
callback: (arg0: any) => unknown,
export default function useDebouncedCallback<T>(
callback: (...params: T[]) => unknown,
wait: number
) {
// track args & timeout handle between calls
const argsRef = React.useRef();
const argsRef = React.useRef<T[]>();
const timeout = React.useRef<ReturnType<typeof setTimeout>>();
function cleanup() {
@@ -16,12 +16,11 @@ export default function useDebouncedCallback(
// make sure our timeout gets cleared if consuming component gets unmounted
React.useEffect(() => cleanup, []);
return function (...args: any) {
return function (...args: T[]) {
argsRef.current = args;
cleanup();
timeout.current = setTimeout(() => {
if (argsRef.current) {
// @ts-expect-error ts-migrate(2556) FIXME: Expected 1 arguments, but got 0 or more.
callback(...argsRef.current);
}
}, wait);
+3
View File
@@ -71,6 +71,9 @@ export default function useDictionary() {
tipNotice: t("Tip notice"),
warning: t("Warning"),
warningNotice: t("Warning notice"),
insertDate: t("Current date"),
insertTime: t("Current time"),
insertDateTime: t("Current date and time"),
};
}, [t]);
}
+38
View File
@@ -0,0 +1,38 @@
import * as React from "react";
/**
* Helper to remove plumbing involved with adding and removing an event listener
* in components.
*
* @param eventName The name of the event to listen to.
* @param handler The handler to call when the event is triggered.
* @param element The element to attach the event listener to.
* @param options The options to pass to the event listener.
*/
export default function useEventListener<T extends EventListener>(
eventName: string,
handler: T,
element: Window | Node = window,
options: AddEventListenerOptions = {}
) {
const savedHandler = React.useRef<T>();
const { capture, passive, once } = options;
React.useEffect(() => {
savedHandler.current = handler;
}, [handler]);
React.useEffect(() => {
const isSupported = element && element.addEventListener;
if (!isSupported) {
return;
}
const eventListener: EventListener = (event) =>
savedHandler.current?.(event);
const opts = { capture, passive, once };
element.addEventListener(eventName, eventListener, opts);
return () => element.removeEventListener(eventName, eventListener, opts);
}, [eventName, element, capture, passive, once]);
}
+2 -2
View File
@@ -1,6 +1,6 @@
import { base } from "@shared/theme";
import { breakpoints } from "@shared/styles";
import useMediaQuery from "~/hooks/useMediaQuery";
export default function useMobile(): boolean {
return useMediaQuery(`(max-width: ${base.breakpoints.tablet - 1}px)`);
return useMediaQuery(`(max-width: ${breakpoints.tablet - 1}px)`);
}
+9 -8
View File
@@ -1,5 +1,6 @@
import { throttle } from "lodash";
import * as React from "react";
import useEventListener from "./useEventListener";
/**
* Mouse position as a tuple of [x, y]
@@ -17,15 +18,15 @@ export const useMousePosition = () => {
0,
]);
const updateMousePosition = throttle((ev: MouseEvent) => {
setMousePosition([ev.clientX, ev.clientY]);
}, 200);
const updateMousePosition = React.useMemo(
() =>
throttle((ev: MouseEvent) => {
setMousePosition([ev.clientX, ev.clientY]);
}, 200),
[]
);
React.useEffect(() => {
window.addEventListener("mousemove", updateMousePosition);
return () => window.removeEventListener("mousemove", updateMousePosition);
}, []);
useEventListener("mousemove", updateMousePosition);
return mousePosition;
};
+6 -7
View File
@@ -1,4 +1,5 @@
import * as React from "react";
import useEventListener from "./useEventListener";
/**
* Hook to return page visibility state.
@@ -8,13 +9,11 @@ import * as React from "react";
export default function usePageVisibility(): boolean {
const [visible, setVisible] = React.useState(true);
React.useEffect(() => {
const handleVisibilityChange = () => setVisible(!document.hidden);
useEventListener(
"visibilitychange",
() => setVisible(!document.hidden),
document
);
document.addEventListener("visibilitychange", handleVisibilityChange);
return () => {
document.removeEventListener("visibilitychange", handleVisibilityChange);
};
}, []);
return visible;
}

Some files were not shown because too many files have changed in this diff Show More