mirror of
https://github.com/penpot/penpot.git
synced 2026-01-16 10:20:02 -05:00
Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4effd375a9 | ||
|
|
4e753dc474 | ||
|
|
fbf63b98c3 | ||
|
|
3df557b370 | ||
|
|
35f3125fff | ||
|
|
f22aa606ce | ||
|
|
9d288486d7 | ||
|
|
ea5521485a | ||
|
|
f768ffbdad | ||
|
|
4f0d3660de | ||
|
|
7ccb742ef3 | ||
|
|
7bc29c22ed | ||
|
|
1d550eaa18 | ||
|
|
b71ec4bfe0 | ||
|
|
827bbf6a7f | ||
|
|
2db0cc0cbf | ||
|
|
42ef01b339 | ||
|
|
fdaef2be69 | ||
|
|
ae3213f5d4 | ||
|
|
6dfd05fdd1 | ||
|
|
51107c3fc9 | ||
|
|
b6863efb3a | ||
|
|
799bceb8b7 | ||
|
|
9e573128c1 | ||
|
|
1f05511add | ||
|
|
eeee52a738 | ||
|
|
7f53860296 | ||
|
|
16d0077393 | ||
|
|
622fed2f0d | ||
|
|
d22ade3289 | ||
|
|
7febf330ac | ||
|
|
75a50ac1ac | ||
|
|
e62567d09e | ||
|
|
8d80eebeb1 | ||
|
|
ee9a42238d | ||
|
|
758c76d661 | ||
|
|
1dec46cbfa | ||
|
|
ae25d704c1 | ||
|
|
e05f8c0329 | ||
|
|
ce62e11626 | ||
|
|
9f04c2fc1d | ||
|
|
05a405a82d | ||
|
|
3c8c21c378 | ||
|
|
2dbeb884a5 | ||
|
|
931d72b41f | ||
|
|
2e3cdd872c | ||
|
|
55a13c3139 | ||
|
|
f63d1c87e3 | ||
|
|
abbfd44534 | ||
|
|
f772724f9a | ||
|
|
f3abd0f190 | ||
|
|
5d4042c861 | ||
|
|
1fbcec98fb | ||
|
|
abef9f3cf7 | ||
|
|
6f1958f9f2 | ||
|
|
6b2ce86d5f | ||
|
|
0cfd70da2e | ||
|
|
4167faf39d | ||
|
|
90e6e8c5eb | ||
|
|
b40b1fa2e4 | ||
|
|
bb1ec109d8 | ||
|
|
4c21468850 | ||
|
|
40c300fa1a | ||
|
|
77a47e4b2b |
81
CHANGES.md
81
CHANGES.md
@@ -8,23 +8,47 @@
|
||||
|
||||
### :heart: Community contributions (Thank you!)
|
||||
|
||||
- Clarify message when inviting existing team members to make it more user-friendly and clear which invitations will be sent. [Taiga #11441](https://tree.taiga.io/project/penpot/issue/11441) by [@iprithvitharun](https://github.com/iprithvitharun)
|
||||
- Update email change confirmation message for clarity and correct grammar. [GitHub #6786](https://github.com/penpot/penpot/issues/6786) by [@iprithvitharun](https://github.com/iprithvitharun)
|
||||
|
||||
### :sparkles: New features & Enhancements
|
||||
|
||||
- Add visual indicator for new comments in the workspace [Taiga #11328](https://tree.taiga.io/project/penpot/issue/11328)
|
||||
- On components overrides, separate the content of the text from the rest of properties [Taiga #7434](https://tree.taiga.io/project/penpot/us/7434)
|
||||
- Improve dashboard's sidebar [Taiga #10700](https://tree.taiga.io/project/penpot/us/10700)
|
||||
- Change "Save color" button to primary button [Taiga #9410](https://tree.taiga.io/project/penpot/issue/9410)
|
||||
- Support for exif rotated images [GitHub #6767](https://github.com/penpot/penpot/issues/6767)
|
||||
- Display Blend Mode and Layer Opacity properties in the Inspect tab [Taiga #11283](https://tree.taiga.io/project/penpot/issue/11283)
|
||||
- Provide CSS `mix-blend-mode` property in code editor when present on shape [Taiga #11282](https://tree.taiga.io/project/penpot/issue/11282)
|
||||
- Add the option to import tokens in a .zip file. [Taiga #11378](https://tree.taiga.io/project/penpot/us/11378)
|
||||
- New typography token type - font size token [Taiga #10938](https://tree.taiga.io/project/penpot/us/10938)
|
||||
- Hide bounding box while editing visual effects [Taiga #11576](https://tree.taiga.io/project/penpot/issue/11576)
|
||||
- Improved text layer resizing: Allow double-click on text bounding box to set auto-width/auto-height [Taiga #11577](https://tree.taiga.io/project/penpot/issue/11577)
|
||||
- Improve text layer auto-resize: auto-width switches to auto-height on horizontal resize, and only switches to fixed on vertical resize [Taiga #11578](https://tree.taiga.io/project/penpot/issue/11578)
|
||||
- Highlight first font in font selector search. Apply only on Enter or click. [Taiga #11579](https://tree.taiga.io/project/penpot/issue/11579)
|
||||
- Add the ability to show login dialog on profile settings [Github #6871](https://github.com/penpot/penpot/pull/6871)
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Copying font size does not copy the unit [Taiga #11143](https://tree.taiga.io/project/penpot/issue/11143)
|
||||
- Fix text-decoration line-through that displays a wrong property value [Taiga #11145](https://tree.taiga.io/project/penpot/issue/11145)
|
||||
- Fix display error message on register form [Taiga #11444](https://tree.taiga.io/project/penpot/issue/11444)
|
||||
- Fix toggle focus mode did not restore viewport and selection upon exit [GitHub #6280](https://github.com/penpot/penpot/issues/6820)
|
||||
- Fix problem when creating a layout from an existing layout [Taiga #11554](https://tree.taiga.io/project/penpot/issue/11554)
|
||||
- Fix title button from Title Case to Capitalize [Taiga #11476](https://tree.taiga.io/project/penpot/issue/11476)
|
||||
- Fix touchpad swipe leading to navigating back/forth [GitHub #4246](https://github.com/penpot/penpot/issues/4246)
|
||||
- Keep color data when copying from info tab into CSS [Taiga #11144](https://tree.taiga.io/project/penpot/issue/11144)
|
||||
- Update HSL values to modern syntax as defined in W3C CSS Color Module Level 4 [Taiga #11144](https://tree.taiga.io/project/penpot/issue/11144)
|
||||
- Fix main component receives focus and is selected when using 'Show Main Component' [Taiga #11402](https://tree.taiga.io/project/penpot/issue/11402)
|
||||
- Fix duplicating pages with mainInstance shapes nested inside groups [Taiga #10774](https://tree.taiga.io/project/penpot/issue/10774)
|
||||
- Fix ESC key not closing Add/Manage Libraries modal [Taiga #11523](https://tree.taiga.io/project/penpot/issue/11523)
|
||||
- Fix copying a shadow color from info tab [Taiga #11211](https://tree.taiga.io/project/penpot/issue/11211)
|
||||
|
||||
## 2.8.1 (Unreleased)
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix unexpected exception on processing old texts [Github #6889](https://github.com/penpot/penpot/pull/6889)
|
||||
|
||||
## 2.8.0
|
||||
|
||||
@@ -46,6 +70,7 @@ in future versions. Therefore, **migration from Redis to ValKey is recommended f
|
||||
on-premises instances** that want to keep up to date.
|
||||
|
||||
### :heart: Community contributions (Thank you!)
|
||||
|
||||
- Add Serbian language [GitHub #5002](https://github.com/penpot/penpot/issues/5002) by [crnobog69](https://github.com/crnobog69)
|
||||
|
||||
### :sparkles: New features & Enhancements
|
||||
@@ -101,7 +126,6 @@ on-premises instances** that want to keep up to date.
|
||||
- Fix copy in error message [GitHub #6615](https://github.com/penpot/penpot/pull/6615)
|
||||
- Fix url on invitation link [Taiga #11284](https://tree.taiga.io/project/penpot/issue/11284)
|
||||
|
||||
|
||||
## 2.7.1
|
||||
|
||||
### :bug: Bugs fixed
|
||||
@@ -109,7 +133,6 @@ on-premises instances** that want to keep up to date.
|
||||
- Fix incorrect handling of strokes with images on importing files
|
||||
- Fix tokens disappearing after manual additions [Taiga #11063](https://tree.taiga.io/project/penpot/issue/11063)
|
||||
|
||||
|
||||
## 2.7.0
|
||||
|
||||
### :rocket: Epics and highlights
|
||||
@@ -241,7 +264,6 @@ on-premises instances** that want to keep up to date.
|
||||
- Add character limitation to asset inputs [Taiga #10669](https://tree.taiga.io/project/penpot/issue/10669)
|
||||
- Fix Storybook link 'list of all available icons' wrong path [Taiga #10705](https://tree.taiga.io/project/penpot/issue/10705)
|
||||
|
||||
|
||||
## 2.5.4
|
||||
|
||||
### :heart: Community contributions (Thank you!)
|
||||
@@ -286,7 +308,7 @@ on-premises instances** that want to keep up to date.
|
||||
|
||||
### :boom: Breaking changes & Deprecations
|
||||
|
||||
Although this is not a breaking change, we believe it’s important to highlight it in this
|
||||
Although this is not a breaking change, we believe it's important to highlight it in this
|
||||
section:
|
||||
|
||||
This release includes a fix for an internal bug in Penpot that caused incorrect handling
|
||||
@@ -294,9 +316,9 @@ of media assets (e.g., fill images). The issue has been resolved since version 2
|
||||
no new incorrect references will be generated. However, existing files may still contain
|
||||
incorrect references.
|
||||
|
||||
To address this, we’ve provided a script to correct these references in existing files.
|
||||
To address this, we've provided a script to correct these references in existing files.
|
||||
|
||||
While having incorrect references generally doesn’t result in visible issues, there are
|
||||
While having incorrect references generally doesn't result in visible issues, there are
|
||||
rare cases where it can cause problems. For example, if a component library (containing
|
||||
images) is deleted, and that library is being used in other files, running the FileGC task
|
||||
(responsible for freeing up space and performing logical deletions) could leave those
|
||||
@@ -371,7 +393,6 @@ is a number of cores)
|
||||
- Fix missing methods reference on API Docs
|
||||
- Fix memory usage issue on file-gc asynchronous task (related to snapshots feature)
|
||||
|
||||
|
||||
## 2.4.1
|
||||
|
||||
### :bug: Bugs fixed
|
||||
@@ -379,7 +400,6 @@ is a number of cores)
|
||||
- Fix error when importing files with touched components [Taiga #9625](https://tree.taiga.io/project/penpot/issue/9625)
|
||||
- Fix problem when changing color libraries [Plugins #184](https://github.com/penpot/penpot-plugins/issues/184)
|
||||
|
||||
|
||||
## 2.4.0
|
||||
|
||||
### :rocket: Epics and highlights
|
||||
@@ -433,7 +453,6 @@ is a number of cores)
|
||||
|
||||
- Add initial documentation for Kubernetes
|
||||
|
||||
|
||||
## 2.3.1
|
||||
|
||||
### :bug: Bugs fixed
|
||||
@@ -441,7 +460,6 @@ is a number of cores)
|
||||
- Fix unexpected issue on interaction between plugins sandbox and
|
||||
internal impl of promise
|
||||
|
||||
|
||||
## 2.3.0
|
||||
|
||||
### :rocket: Epics and highlights
|
||||
@@ -467,7 +485,6 @@ is a number of cores)
|
||||
|
||||
You can enable it with the `enable-feature-text-editor-v2` configuration flag.
|
||||
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix problem with constraints buttons [Taiga #8465](https://tree.taiga.io/project/penpot/issue/8465)
|
||||
@@ -507,8 +524,8 @@ is a number of cores)
|
||||
### :boom: Breaking changes & Deprecations
|
||||
|
||||
- Removed "merge assets" option when exporting ".svg + .json" files. After the components changes the option wasn't
|
||||
working properly and we're planning to change the format soon. We think it's better to deprecate the option for the
|
||||
time being.
|
||||
working properly and we're planning to change the format soon. We think it's better to deprecate the option for the
|
||||
time being.
|
||||
|
||||
### :heart: Community contributions (Thank you!)
|
||||
|
||||
@@ -524,7 +541,7 @@ time being.
|
||||
freeing up space in the database. It can be enabled with the
|
||||
`enable-enable-tiered-file-data-storage` flag.
|
||||
|
||||
*(On-Premise feature, EXPERIMENTAL).*
|
||||
_(On-Premise feature, EXPERIMENTAL)._
|
||||
|
||||
- **JSON Interoperability for HTTP API** [Taiga #8372](https://tree.taiga.io/project/penpot/us/8372)
|
||||
|
||||
@@ -567,7 +584,7 @@ time being.
|
||||
|
||||
- **Design System**
|
||||
|
||||
We implemented and subbed in new components from our Design System: `loader*` ([Taiga #8355](https://tree.taiga.io/project/penpot/task/8355)) and `tab-switcher*` ([Taiga #8518](https://tree.taiga.io/project/penpot/task/8518)).
|
||||
We implemented and subbed in new components from our Design System: `loader*` ([Taiga #8355](https://tree.taiga.io/project/penpot/task/8355)) and `tab-switcher*` ([Taiga #8518](https://tree.taiga.io/project/penpot/task/8518)).
|
||||
|
||||
- **Storybook** [Taiga #6329](https://tree.taiga.io/project/penpot/us/6329)
|
||||
|
||||
@@ -622,11 +639,11 @@ time being.
|
||||
|
||||
### :sparkles: New features
|
||||
|
||||
- Consolidate templates new order and naming [Taiga #8392](https://tree.taiga.io/project/penpot/task/8392)
|
||||
- Consolidate templates new order and naming [Taiga #8392](https://tree.taiga.io/project/penpot/task/8392)
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix the “search” label in translations [Taiga #8402](https://tree.taiga.io/project/penpot/issue/8402)
|
||||
- Fix the "search" label in translations [Taiga #8402](https://tree.taiga.io/project/penpot/issue/8402)
|
||||
- Fix pencil loader [Taiga #8348](https://tree.taiga.io/project/penpot/issue/8348)
|
||||
- Fix several issues on the OIDC.
|
||||
- Fix regression on the `email-verification` flag [Taiga #8398](https://tree.taiga.io/project/penpot/issue/8398)
|
||||
@@ -706,22 +723,21 @@ time being.
|
||||
- Fix color palette sorting [Taiga #7458](https://tree.taiga.io/project/penpot/issue/7458)
|
||||
- Fix style scoping problem with imported SVG [Taiga #7671](https://tree.taiga.io/project/penpot/issue/7671)
|
||||
|
||||
|
||||
## 2.0.1
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix different issues related to components v2 migrations including [Github #4443](https://github.com/penpot/penpot/issues/4443)
|
||||
|
||||
|
||||
## 2.0.0 - I Just Can't Get Enough
|
||||
|
||||
### :rocket: Epics and highlights
|
||||
|
||||
- Grid CSS layout [Taiga #4915](https://tree.taiga.io/project/penpot/epic/4915)
|
||||
- UI redesign [Taiga #4958](https://tree.taiga.io/project/penpot/epic/4958)
|
||||
- New components System [Taiga #2662](https://tree.taiga.io/project/penpot/epic/2662)
|
||||
- Swap components [Taiga #1331](https://tree.taiga.io/project/penpot/us/1331)
|
||||
- Images as fill [Taiga #2983](https://tree.taiga.io/project/penpot/us/2983)
|
||||
- Images as fill [Taiga #2983](https://tree.taiga.io/project/penpot/us/2983)
|
||||
- HTML code generation [Taiga #5277](https://tree.taiga.io/project/penpot/us/5277)
|
||||
- Light and dark themes [Taiga #2287](https://tree.taiga.io/project/penpot/us/2287)
|
||||
|
||||
@@ -730,9 +746,9 @@ time being.
|
||||
- New strokes default to inside border [Taiga #6847](https://tree.taiga.io/project/penpot/issue/6847)
|
||||
- Change default z ordering on layers in flex layout. The previous behavior was inconsistent with how HTML works and we changed it to be more consistent. Previous layers that overlapped could be hidden, the fastest way to fix this is changing the z-index property but a better way is to change the order of your layers.
|
||||
|
||||
|
||||
### :heart: Community contributions (Thank you!)
|
||||
- New Hausa, Yoruba and Igbo translations and update translation files (by All For Tech Empowerment Foundation) [Taiga #6950](https://tree.taiga.io/project/penpot/us/6950), [Taiga #6534](https://tree.taiga.io/project/penpot/us/6534)
|
||||
|
||||
- New Hausa, Yoruba and Igbo translations and update translation files (by All For Tech Empowerment Foundation) [Taiga #6950](https://tree.taiga.io/project/penpot/us/6950), [Taiga #6534](https://tree.taiga.io/project/penpot/us/6534)
|
||||
- Hide bounding-box when editing shape (by @VasilevsVV) [#3930](https://github.com/penpot/penpot/pull/3930)
|
||||
- CTRL + "+" to zoom into canvas instead of browser (by @audriu) [#3848](https://github.com/penpot/penpot/pull/3848)
|
||||
- Add dev deps.edn in the project root (by @PEZ) [#3794](https://github.com/penpot/penpot/pull/3794)
|
||||
@@ -741,6 +757,7 @@ time being.
|
||||
- Typo (by StephanEggermont) [#157](https://github.com/penpot/penpot-docs/pull/157)
|
||||
|
||||
### :sparkles: New features
|
||||
|
||||
- Send comments with Ctrl+Enter / Cmd + Enter [Taiga #6085](https://tree.taiga.io/project/penpot/issue/6085)
|
||||
- Select through stroke only rectangle [Taiga #5484](https://tree.taiga.io/project/penpot/issue/5484)
|
||||
- Stroke default position [Taiga #6847](https://tree.taiga.io/project/penpot/issue/6847)
|
||||
@@ -808,6 +825,7 @@ time being.
|
||||
- [REDESIGN] Onboarding slides [Taiga #6678](https://tree.taiga.io/project/penpot/us/6678)
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix pixelated thumbnails [Github #3681](https://github.com/penpot/penpot/issues/3681), [Github #3661](https://github.com/penpot/penpot/issues/3661)
|
||||
- Fix problem with not applying colors to boards [Github #3941](https://github.com/penpot/penpot/issues/3941)
|
||||
- Fix problem with path editor undoing changes [Github #3998](https://github.com/penpot/penpot/issues/3998)
|
||||
@@ -816,7 +834,7 @@ time being.
|
||||
- Selecting from Color Palette does not work for board when there is no existing fill [Taiga #6464](https://tree.taiga.io/project/penpot/issue/6464)
|
||||
- Color thumbnails are consistently rounded in the inspect code mode [Taiga #5886](https://tree.taiga.io/project/penpot/issue/5886)
|
||||
- Adding vector path points before first point of existing open path not working [Taiga #6593](https://tree.taiga.io/project/penpot/issue/6593)
|
||||
- Some image formats include the extension when importing [Taiga #5485](https://tree.taiga.io/project/penpot/issue/5485)
|
||||
- Some image formats include the extension when importing [Taiga #5485](https://tree.taiga.io/project/penpot/issue/5485)
|
||||
- Gradient color tool doesn't work properly with flipped items [Taiga #6485](https://tree.taiga.io/project/penpot/issue/6485)
|
||||
- [TEXT] Align options are not shown when several text are selected [Taiga #5948](https://tree.taiga.io/project/penpot/issue/5948)
|
||||
- [VIEW MODE] Comments not working properly on multiple pages [Taiga #6281](https://tree.taiga.io/project/penpot/issue/6281)
|
||||
@@ -860,7 +878,7 @@ time being.
|
||||
|
||||
### :sparkles: New features
|
||||
|
||||
- Improve selected colors [Taiga #5805]( https://tree.taiga.io/project/penpot/us/5805)
|
||||
- Improve selected colors [Taiga #5805](https://tree.taiga.io/project/penpot/us/5805)
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
@@ -895,7 +913,6 @@ time being.
|
||||
- Fix deleted pages comments shown in right sidebar [Taiga #5648](https://tree.taiga.io/project/penpot/us/5648)
|
||||
- Fix tooltip on toggle visibility and toggle lock buttons [Taiga #5141](https://tree.taiga.io/project/penpot/issue/5141)
|
||||
|
||||
|
||||
## 1.19.1
|
||||
|
||||
### :bug: Bugs fixed
|
||||
@@ -1009,7 +1026,6 @@ time being.
|
||||
|
||||
- Update google fonts catalog (at 2023/07/06) [Taiga #5592](https://tree.taiga.io/project/penpot/issue/5592)
|
||||
|
||||
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
||||
- Update Typography palette order (by @akshay-gupta7) [Github #3156](https://github.com/penpot/penpot/pull/3156)
|
||||
@@ -1163,12 +1179,14 @@ time being.
|
||||
- Fix problem with opacity in imported SVG's [Taiga #4923](https://tree.taiga.io/project/penpot/issue/4923)
|
||||
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
||||
- To @ondrejkonec: for contributing to the code with:
|
||||
- Refactor CSS variables [Github #2948](https://github.com/penpot/penpot/pull/2948)
|
||||
|
||||
## 1.17.3
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix copy and paste very nested inside itself [Taiga #4848](https://tree.taiga.io/project/penpot/issue/4848)
|
||||
- Fix custom fonts not rendered correctly [Taiga #4874](https://tree.taiga.io/project/penpot/issue/4874)
|
||||
- Fix problem with shadows and blur on multiple selection
|
||||
@@ -1201,6 +1219,7 @@ time being.
|
||||
## 1.17.1
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix components groups items show the component name in list mode [Taiga #4770](https://tree.taiga.io/project/penpot/issue/4770)
|
||||
- Fix typing CMD+Z on MacOS turns the cursor into a Zoom cursor [Taiga #4778](https://tree.taiga.io/project/penpot/issue/4778)
|
||||
- Fix white space on small screens [Taiga #4774](https://tree.taiga.io/project/penpot/issue/4774)
|
||||
@@ -1315,7 +1334,7 @@ time being.
|
||||
|
||||
### :boom: Breaking changes & Deprecations
|
||||
|
||||
- Removed the support for v2 internal file data blob format. This
|
||||
- Removed the support for v2 internal file data blob format. This
|
||||
version has never been documented nor set as default value so
|
||||
technically this is not a breaking change because we are removing
|
||||
a "private API".
|
||||
@@ -1420,7 +1439,6 @@ time being.
|
||||
- Fix when ungrouping, the items previously grouped should ALWAYS remain selected [Taiga #4064](https://tree.taiga.io/project/penpot/issue/4064)
|
||||
- Change shortcut for "Clear undo" [#2219](https://github.com/penpot/penpot/issues/2219)
|
||||
|
||||
|
||||
## 1.15.2-beta
|
||||
|
||||
### :bug: Bugs fixed
|
||||
@@ -1504,6 +1522,7 @@ time being.
|
||||
- Fix bringing complete file data when launching the export dialog [Taiga #4006](https://tree.taiga.io/project/penpot/issue/4006)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
||||
## 1.14.2-beta
|
||||
@@ -1544,10 +1563,10 @@ time being.
|
||||
- Prototype connection should be under the rules [Taiga #3384](https://tree.taiga.io/project/penpot/issue/3384)
|
||||
- Fix problem with empty text boxes events [Taiga #3627](https://tree.taiga.io/project/penpot/issue/3627)
|
||||
|
||||
|
||||
## 1.13.5-beta
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix orientation artboard preset not working with differently sized artboards [Taiga #3548](https://tree.taiga.io/project/penpot/issue/3548)
|
||||
- Fix background on export arboards [Taiga #1991](https://tree.taiga.io/project/penpot/issue/1991)
|
||||
|
||||
@@ -1691,6 +1710,7 @@ time being.
|
||||
- Fix problem when resizing a group with texts with auto-width/height [#3171](https://tree.taiga.io/project/penpot/issue/3171)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
||||
## 1.12.4-beta
|
||||
@@ -1708,7 +1728,7 @@ time being.
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix issue with shift+select to deselect shapes [Taiga #3154](https://tree.taiga.io/project/penpot/issue/3154)
|
||||
- Fix issue with drag-select shapes [Taiga #3165](https://tree.taiga.io/project/penpot/issue/3165)
|
||||
- Fix issue with drag-select shapes [Taiga #3165](https://tree.taiga.io/project/penpot/issue/3165)
|
||||
- Fix issue on password persistence after registration process on private instances
|
||||
|
||||
## 1.12.2-beta
|
||||
@@ -1726,7 +1746,6 @@ time being.
|
||||
- Fix length of names in sidebar [Taiga #2962](https://tree.taiga.io/project/penpot/issue/2962)
|
||||
- Fix issues on loki integration
|
||||
|
||||
|
||||
## 1.12.0-beta
|
||||
|
||||
### :boom: Breaking changes
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
||||
<div
|
||||
style="font-family:Source Sans Pro, sans-serif;font-size:16px;line-height:150%;text-align:left;color:#000000;">
|
||||
Click to the link below to confirm the change:</div>
|
||||
Click the link below to confirm the change.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -217,8 +217,7 @@
|
||||
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
|
||||
<div
|
||||
style="font-family:Source Sans Pro, sans-serif;font-size:16px;line-height:150%;text-align:left;color:#000000;">
|
||||
If you received this email by mistake, please consider changing your password for security
|
||||
reasons.</div>
|
||||
If you did not request this change, consider changing your password for security reasons.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -2,12 +2,11 @@ Hello {{name|abbreviate:25}}!
|
||||
|
||||
We received a request to change your current email to {{ pending-email }}.
|
||||
|
||||
Click to the link below to confirm the change:
|
||||
Click the link below to confirm the change.
|
||||
|
||||
{{ public-uri }}/#/auth/verify-token?token={{token}}
|
||||
|
||||
If you received this email by mistake, please consider changing your password
|
||||
for security reasons.
|
||||
If you did not request this change, consider changing your password for security reasons.
|
||||
|
||||
Enjoy!
|
||||
The Penpot team.
|
||||
|
||||
@@ -17,38 +17,6 @@ Debug Main Page
|
||||
<desc><a href="/dbg/error">CLICK HERE TO SEE THE ERROR REPORTS</a> </desc>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Download file data:</legend>
|
||||
<desc>Given an FILE-ID, downloads the file data as file. The file data is encoded using transit.</desc>
|
||||
<form method="get" action="/dbg/file/data">
|
||||
<div class="row">
|
||||
<input type="text" style="width:300px" name="file-id" placeholder="file-id" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="submit" name="download" value="Download" />
|
||||
<input type="submit" name="clone" value="Clone" />
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Upload File Data:</legend>
|
||||
<desc>Create a new file on your draft projects using the file downloaded from the previous section.</desc>
|
||||
<form method="post" enctype="multipart/form-data" action="/dbg/file/data">
|
||||
<div class="row">
|
||||
<input type="file" name="file" value="" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Import with same id?</label>
|
||||
<input type="checkbox" name="reuseid" />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<input type="submit" value="Upload" />
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Profile Management</legend>
|
||||
<form method="post" action="/dbg/actions/resend-email-verification">
|
||||
@@ -81,6 +49,50 @@ Debug Main Page
|
||||
|
||||
</section>
|
||||
|
||||
<section class="widget">
|
||||
|
||||
<fieldset>
|
||||
<legend>Download RAW file data:</legend>
|
||||
<desc>Given an FILE-ID, downloads the file AS-IS (no validation
|
||||
checks, just exports the file data and related objects in raw)
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
<b>WARNING: this operation does not performs any checks</b>
|
||||
</desc>
|
||||
<form method="get" action="/dbg/actions/file-raw-export-import">
|
||||
<div class="row">
|
||||
<input type="text" style="width:300px" name="file-id" placeholder="file-id" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="submit" name="download" value="Download" />
|
||||
<input type="submit" name="clone" value="Clone" />
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Upload File Data:</legend>
|
||||
<desc>Create a new file on your draft projects using the file downloaded from the previous section.
|
||||
<br/>
|
||||
<br/>
|
||||
<b>WARNING: this operation does not performs any checks</b>
|
||||
</desc>
|
||||
<form method="post" enctype="multipart/form-data" action="/dbg/actions/file-raw-export-import">
|
||||
<div class="row">
|
||||
<input type="file" name="file" value="" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Import with same id?</label>
|
||||
<input type="checkbox" name="reuseid" />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<input type="submit" value="Upload" />
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
</section>
|
||||
<section class="widget">
|
||||
<fieldset>
|
||||
<legend>Export binfile:</legend>
|
||||
@@ -88,7 +100,7 @@ Debug Main Page
|
||||
the related libraries in a single custom formatted binary
|
||||
file.</desc>
|
||||
|
||||
<form method="get" action="/dbg/file/export">
|
||||
<form method="get" action="/dbg/actions/file-export">
|
||||
<div class="row set-of-inputs">
|
||||
<input type="text" style="width:300px" name="file-ids" placeholder="file-id" />
|
||||
<input type="text" style="width:300px" name="file-ids" placeholder="file-id" />
|
||||
@@ -116,7 +128,7 @@ Debug Main Page
|
||||
<legend>Import binfile:</legend>
|
||||
<desc>Import penpot file in binary format.</desc>
|
||||
|
||||
<form method="post" enctype="multipart/form-data" action="/dbg/file/import">
|
||||
<form method="post" enctype="multipart/form-data" action="/dbg/actions/file-import">
|
||||
<div class="row">
|
||||
<input type="file" name="file" value="" />
|
||||
</div>
|
||||
@@ -130,79 +142,27 @@ Debug Main Page
|
||||
|
||||
<section class="widget">
|
||||
<fieldset>
|
||||
<legend>Reset file version</legend>
|
||||
<desc>Allows reset file data version to a specific number/</desc>
|
||||
|
||||
<form method="post" action="/dbg/actions/reset-file-version">
|
||||
<div class="row">
|
||||
<input type="text" style="width:300px" name="file-id" placeholder="file-id" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="number" style="width:100px" name="version" placeholder="version" value="32" />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label for="force-version">Are you sure?</label>
|
||||
<input id="force-version" type="checkbox" name="force" />
|
||||
<br />
|
||||
<small>
|
||||
This is a just a security double check for prevent non intentional submits.
|
||||
</small>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<input type="submit" value="Submit" />
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
</section>
|
||||
|
||||
<section class="widget">
|
||||
<h2>Feature Flags</h2>
|
||||
<fieldset>
|
||||
<legend>Enable</legend>
|
||||
<legend>Feature Flags for Team</legend>
|
||||
<desc>Add a feature flag to a team</desc>
|
||||
<form method="post" action="/dbg/actions/add-team-feature">
|
||||
<form method="post" action="/dbg/actions/handle-team-features">
|
||||
<div class="row">
|
||||
<input type="text" style="width:300px" name="team-id" placeholder="team-id" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="text" style="width:100px" name="feature" placeholder="feature" value="" />
|
||||
<select type="text" style="width:100px" name="feature">
|
||||
{% for feature in supported-features %}
|
||||
<option value="{{feature}}">{{feature}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label for="check-feature">Skip feature check</label>
|
||||
<input id="check-feature" type="checkbox" name="skip-check" />
|
||||
<br />
|
||||
<small>
|
||||
Do not check if the feature is supported
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label for="force-version">Are you sure?</label>
|
||||
<input id="force-version" type="checkbox" name="force" />
|
||||
<br />
|
||||
<small>
|
||||
This is a just a security double check for prevent non intentional submits.
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<input type="submit" value="Submit" />
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Disable</legend>
|
||||
<desc>Remove a feature flag from a team</desc>
|
||||
<form method="post" action="/dbg/actions/remove-team-feature">
|
||||
<div class="row">
|
||||
<input type="text" style="width:300px" name="team-id" placeholder="team-id" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="text" style="width:100px" name="feature" placeholder="feature" value="" />
|
||||
<select style="width:100px" name="action">
|
||||
<option value="">Action...</option>
|
||||
<option value="show">Show</option>
|
||||
<option value="enable">Enable</option>
|
||||
<option value="disable">Disable</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
@@ -7,7 +7,9 @@ penpot - error list
|
||||
{% block content %}
|
||||
<nav>
|
||||
<div class="title">
|
||||
<h1>Error reports (last 200)</h1>
|
||||
<h1>Error reports (last 200)
|
||||
<a href="/dbg">[GO BACK]</a>
|
||||
</h1>
|
||||
</div>
|
||||
</nav>
|
||||
<main class="horizontal-list">
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
(defn decode-file
|
||||
"A general purpose file decoding function that resolves all external
|
||||
pointers, run migrations and return plain vanilla file map"
|
||||
[cfg {:keys [id] :as file}]
|
||||
[cfg {:keys [id] :as file} & {:keys [migrate?] :or {migrate? true}}]
|
||||
(binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg id)]
|
||||
(let [file (->> file
|
||||
(feat.fmigr/resolve-applied-migrations cfg)
|
||||
@@ -168,7 +168,7 @@
|
||||
(update :data feat.fdata/process-pointers deref)
|
||||
(update :data feat.fdata/process-objects (partial into {}))
|
||||
(update :data assoc :id id)
|
||||
(fmg/migrate-file libs)))))
|
||||
(cond-> migrate? (fmg/migrate-file libs))))))
|
||||
|
||||
(defn get-file
|
||||
"Get file, resolve all features and apply migrations.
|
||||
|
||||
@@ -37,3 +37,9 @@
|
||||
{::db/return-keys false
|
||||
::sql/on-conflict-do-nothing true})
|
||||
(db/get-update-count))))
|
||||
|
||||
(defn reset-migrations!
|
||||
"Replace file migrations"
|
||||
[conn {:keys [id] :as file}]
|
||||
(db/delete! conn :file-migration {:file-id id})
|
||||
(upsert-migrations! conn file))
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
[app.common.features :as cfeat]
|
||||
[app.common.logging :as l]
|
||||
[app.common.pprint :as pp]
|
||||
[app.common.transit :as t]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.features.file-migrations :as feat.fmig]
|
||||
[app.http.session :as session]
|
||||
[app.rpc.commands.auth :as auth]
|
||||
[app.rpc.commands.files-create :refer [create-file]]
|
||||
@@ -50,26 +52,26 @@
|
||||
{::yres/status 200
|
||||
::yres/headers {"content-type" "text/html"}
|
||||
::yres/body (-> (io/resource "app/templates/debug.tmpl")
|
||||
(tmpl/render {:version (:full cf/version)}))})
|
||||
(tmpl/render {:version (:full cf/version)
|
||||
:supported-features cfeat/supported-features}))})
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; FILE CHANGES
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn prepare-response
|
||||
[body]
|
||||
(let [headers {"content-type" "application/transit+json"}]
|
||||
{::yres/status 200
|
||||
::yres/body body
|
||||
::yres/headers headers}))
|
||||
(defn- get-resolved-file
|
||||
[cfg file-id]
|
||||
(some-> (bfc/get-file cfg file-id :migrate? false)
|
||||
(update :data blob/encode)))
|
||||
|
||||
(defn prepare-download-response
|
||||
[body filename]
|
||||
(let [headers {"content-disposition" (str "attachment; filename=" filename)
|
||||
"content-type" "application/octet-stream"}]
|
||||
{::yres/status 200
|
||||
::yres/body body
|
||||
::yres/headers headers}))
|
||||
(defn prepare-download
|
||||
[file filename]
|
||||
{::yres/status 200
|
||||
::yres/headers
|
||||
{"content-disposition" (str "attachment; filename=" filename ".json")
|
||||
"content-type" "application/octet-stream"}
|
||||
::yres/body
|
||||
(t/encode file {:type :json-verbose})})
|
||||
|
||||
(def sql:retrieve-range-of-changes
|
||||
"select revn, changes from file_change where file_id=? and revn >= ? and revn <= ? order by revn")
|
||||
@@ -77,45 +79,51 @@
|
||||
(def sql:retrieve-single-change
|
||||
"select revn, changes, data from file_change where file_id=? and revn = ?")
|
||||
|
||||
(defn- retrieve-file-data
|
||||
[{:keys [::db/pool]} {:keys [params ::session/profile-id] :as request}]
|
||||
(defn- download-file-data
|
||||
[cfg {:keys [params ::session/profile-id] :as request}]
|
||||
(let [file-id (some-> params :file-id parse-uuid)
|
||||
revn (some-> params :revn parse-long)
|
||||
filename (str file-id)]
|
||||
|
||||
(when-not file-id
|
||||
(ex/raise :type :validation
|
||||
:code :missing-arguments))
|
||||
|
||||
(let [data (if (integer? revn)
|
||||
(some-> (db/exec-one! pool [sql:retrieve-single-change file-id revn]) :data)
|
||||
(some-> (db/get-by-id pool :file file-id) :data))]
|
||||
|
||||
(when-not data
|
||||
(ex/raise :type :not-found
|
||||
:code :enpty-data
|
||||
:hint "empty response"))
|
||||
(if-let [file (get-resolved-file cfg file-id)]
|
||||
(cond
|
||||
(contains? params :download)
|
||||
(prepare-download-response data filename)
|
||||
(prepare-download file filename)
|
||||
|
||||
(contains? params :clone)
|
||||
(let [profile (profile/get-profile pool profile-id)
|
||||
project-id (:default-project-id profile)]
|
||||
(db/tx-run! cfg
|
||||
(fn [{:keys [::db/conn] :as cfg}]
|
||||
(let [profile (profile/get-profile conn profile-id)
|
||||
project-id (:default-project-id profile)
|
||||
file (-> (create-file cfg {:id (uuid/next)
|
||||
:name (str "Cloned: " (:name file))
|
||||
:features (:features file)
|
||||
:project-id project-id
|
||||
:profile-id profile-id})
|
||||
(assoc :data (:data file))
|
||||
(assoc :migrations (:migrations file)))]
|
||||
|
||||
(db/run! pool (fn [{:keys [::db/conn] :as cfg}]
|
||||
(create-file cfg {:id file-id
|
||||
:name (str "Cloned file: " filename)
|
||||
:project-id project-id
|
||||
:profile-id profile-id})
|
||||
(db/update! conn :file
|
||||
{:data data}
|
||||
{:id file-id})
|
||||
{::yres/status 201
|
||||
::yres/body "OK CREATED"})))
|
||||
(feat.fmig/reset-migrations! conn file)
|
||||
(db/update! conn :file
|
||||
{:data (:data file)}
|
||||
{:id (:id file)}
|
||||
{::db/return-keys false})
|
||||
|
||||
|
||||
{::yres/status 201
|
||||
::yres/body "OK CLONED"})))
|
||||
|
||||
:else
|
||||
(prepare-response (blob/decode data))))))
|
||||
(ex/raise :type :validation
|
||||
:code :invalid-params
|
||||
:hint "invalid button"))
|
||||
|
||||
(ex/raise :type :not-found
|
||||
:code :enpty-data
|
||||
:hint "empty response"))))
|
||||
|
||||
(defn- is-file-exists?
|
||||
[pool id]
|
||||
@@ -123,81 +131,61 @@
|
||||
(-> (db/exec-one! pool [sql id]) :exists)))
|
||||
|
||||
(defn- upload-file-data
|
||||
[{:keys [::db/pool]} {:keys [::session/profile-id params] :as request}]
|
||||
[{:keys [::db/pool] :as cfg} {:keys [::session/profile-id params] :as request}]
|
||||
(let [profile (profile/get-profile pool profile-id)
|
||||
project-id (:default-project-id profile)
|
||||
data (some-> params :file :path io/read*)]
|
||||
file (some-> params :file :path io/read* t/decode)]
|
||||
|
||||
(if (and data project-id)
|
||||
(let [fname (str "Imported file *: " (dt/now))
|
||||
(if (and file project-id)
|
||||
(let [fname (str "Imported: " (:name file) "(" (dt/now) ")")
|
||||
reuse-id? (contains? params :reuseid)
|
||||
file-id (or (and reuse-id? (ex/ignoring (-> params :file :filename parse-uuid)))
|
||||
(uuid/next))]
|
||||
|
||||
(if (and reuse-id? file-id
|
||||
(is-file-exists? pool file-id))
|
||||
(do
|
||||
(db/update! pool :file
|
||||
{:data data
|
||||
:deleted-at nil}
|
||||
{:id file-id})
|
||||
{::yres/status 200
|
||||
::yres/body "OK UPDATED"})
|
||||
(db/tx-run! cfg
|
||||
(fn [{:keys [::db/conn] :as cfg}]
|
||||
(db/update! conn :file
|
||||
{:data (:data file)
|
||||
:features (into-array (:features file))
|
||||
:deleted-at nil}
|
||||
{:id file-id}
|
||||
{::db/return-keys false})
|
||||
(feat.fmig/reset-migrations! conn file)
|
||||
{::yres/status 200
|
||||
::yres/body "OK UPDATED"}))
|
||||
|
||||
(db/tx-run! cfg
|
||||
(fn [{:keys [::db/conn] :as cfg}]
|
||||
(let [file (-> (create-file cfg {:id file-id
|
||||
:name fname
|
||||
:features (:features file)
|
||||
:project-id project-id
|
||||
:profile-id profile-id})
|
||||
(assoc :data (:data file))
|
||||
(assoc :migrations (:migrations file)))]
|
||||
|
||||
(db/run! pool (fn [{:keys [::db/conn] :as cfg}]
|
||||
(create-file cfg {:id file-id
|
||||
:name fname
|
||||
:project-id project-id
|
||||
:profile-id profile-id})
|
||||
(db/update! conn :file
|
||||
{:data data}
|
||||
{:id file-id})
|
||||
{:data (:data file)}
|
||||
{:id file-id}
|
||||
{::db/return-keys false})
|
||||
(feat.fmig/reset-migrations! conn file)
|
||||
{::yres/status 201
|
||||
::yres/body "OK CREATED"}))))
|
||||
::yres/body "OK CREATED"})))))
|
||||
|
||||
{::yres/status 500
|
||||
::yres/body "ERROR"})))
|
||||
(ex/raise :type :validation
|
||||
:code :invalid-params
|
||||
:hint "invalid file uploaded"))))
|
||||
|
||||
(defn file-data-handler
|
||||
(defn raw-export-import-handler
|
||||
[cfg request]
|
||||
(case (yreq/method request)
|
||||
:get (retrieve-file-data cfg request)
|
||||
:get (download-file-data cfg request)
|
||||
:post (upload-file-data cfg request)
|
||||
(ex/raise :type :http
|
||||
:code :method-not-found)))
|
||||
|
||||
(defn file-changes-handler
|
||||
[{:keys [::db/pool]} {:keys [params] :as request}]
|
||||
(letfn [(retrieve-changes [file-id revn]
|
||||
(if (str/includes? revn ":")
|
||||
(let [[start end] (->> (str/split revn #":")
|
||||
(map str/trim)
|
||||
(map parse-long))]
|
||||
(some->> (db/exec! pool [sql:retrieve-range-of-changes file-id start end])
|
||||
(map :changes)
|
||||
(map blob/decode)
|
||||
(mapcat identity)
|
||||
(vec)))
|
||||
|
||||
(if-let [revn (parse-long revn)]
|
||||
(let [item (db/exec-one! pool [sql:retrieve-single-change file-id revn])]
|
||||
(some-> item :changes blob/decode vec))
|
||||
(ex/raise :type :validation :code :invalid-arguments))))]
|
||||
|
||||
(let [file-id (some-> params :id parse-uuid)
|
||||
revn (or (some-> params :revn parse-long) "latest")
|
||||
filename (str file-id)]
|
||||
|
||||
(when (or (not file-id) (not revn))
|
||||
(ex/raise :type :validation
|
||||
:code :invalid-arguments
|
||||
:hint "missing arguments"))
|
||||
|
||||
(let [data (retrieve-changes file-id revn)]
|
||||
(if (contains? params :download)
|
||||
(prepare-download-response data filename)
|
||||
(prepare-response data))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ERROR BROWSER
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -430,49 +418,49 @@
|
||||
::yres/body "OK"}))
|
||||
|
||||
|
||||
(defn- add-team-feature
|
||||
[{:keys [params] :as request}]
|
||||
(let [team-id (some-> params :team-id d/parse-uuid)
|
||||
feature (some-> params :feature str)
|
||||
(defn- handle-team-features
|
||||
[cfg {:keys [params] :as request}]
|
||||
(let [team-id (some-> params :team-id d/parse-uuid)
|
||||
feature (some-> params :feature str)
|
||||
action (some-> params :action)
|
||||
skip-check (contains? params :skip-check)]
|
||||
|
||||
(when-not (contains? params :force)
|
||||
(ex/raise :type :validation
|
||||
:code :missing-force
|
||||
:hint "missing force checkbox"))
|
||||
|
||||
(when (nil? team-id)
|
||||
(ex/raise :type :validation
|
||||
:code :invalid-team-id
|
||||
:hint "provided invalid team id"))
|
||||
|
||||
(srepl/enable-team-feature! team-id feature :skip-check skip-check)
|
||||
(if (= action "show")
|
||||
(let [team (db/run! cfg teams/get-team-info {:id team-id})]
|
||||
{::yres/status 200
|
||||
::yres/headers {"content-type" "text/plain"}
|
||||
::yres/body (apply str "Team features:\n"
|
||||
(->> (:features team)
|
||||
(map (fn [feature]
|
||||
(str "- " feature "\n")))))})
|
||||
|
||||
{::yres/status 200
|
||||
::yres/headers {"content-type" "text/plain"}
|
||||
::yres/body "OK"}))
|
||||
(do
|
||||
(when-not (contains? params :force)
|
||||
(ex/raise :type :validation
|
||||
:code :missing-force
|
||||
:hint "missing force checkbox"))
|
||||
|
||||
(defn- remove-team-feature
|
||||
[{:keys [params] :as request}]
|
||||
(let [team-id (some-> params :team-id d/parse-uuid)
|
||||
feature (some-> params :feature str)
|
||||
skip-check (contains? params :skip-check)]
|
||||
(cond
|
||||
(= action "enable")
|
||||
(srepl/enable-team-feature! team-id feature :skip-check skip-check)
|
||||
|
||||
(when-not (contains? params :force)
|
||||
(ex/raise :type :validation
|
||||
:code :missing-force
|
||||
:hint "missing force checkbox"))
|
||||
(= action "disable")
|
||||
(srepl/disable-team-feature! team-id feature :skip-check skip-check)
|
||||
|
||||
(when (nil? team-id)
|
||||
(ex/raise :type :validation
|
||||
:code :invalid-team-id
|
||||
:hint "provided invalid team id"))
|
||||
:else
|
||||
(ex/raise :type :validation
|
||||
:code :invalid-action
|
||||
:hint (str "invalid action: " action)))
|
||||
|
||||
(srepl/disable-team-feature! team-id feature :skip-check skip-check)
|
||||
|
||||
{::yres/status 200
|
||||
::yres/headers {"content-type" "text/plain"}
|
||||
::yres/body "OK"}))
|
||||
{::yres/status 200
|
||||
::yres/headers {"content-type" "text/plain"}
|
||||
::yres/body "OK"}))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; OTHER SMALL VIEWS/HANDLERS
|
||||
@@ -525,6 +513,25 @@
|
||||
(ex/raise :type :authentication
|
||||
:code :only-admins-allowed)))))})
|
||||
|
||||
(def errors
|
||||
(letfn [(handle-error [cause]
|
||||
(when-let [data (ex-data cause)]
|
||||
(when (= :validation (:type data))
|
||||
(str "Error: " (or (:hint data) (ex-message cause)) "\n"))))]
|
||||
{:name ::errors
|
||||
:compile
|
||||
(fn [& _params]
|
||||
(fn [handler]
|
||||
(fn [request]
|
||||
(try
|
||||
(handler request)
|
||||
(catch Throwable cause
|
||||
(let [body (or (handle-error cause)
|
||||
(ex/format-throwable cause))]
|
||||
{::yres/status 400
|
||||
::yres/headers {"content-type" "text/plain"}
|
||||
::yres/body body}))))))}))
|
||||
|
||||
(defmethod ig/assert-key ::routes
|
||||
[_ params]
|
||||
(assert (db/pool? (::db/pool params)) "expected a valid database pool")
|
||||
@@ -540,15 +547,14 @@
|
||||
["/changelog" {:handler (partial changelog-handler cfg)}]
|
||||
["/error/:id" {:handler (partial error-handler cfg)}]
|
||||
["/error" {:handler (partial error-list-handler cfg)}]
|
||||
["/actions/resend-email-verification"
|
||||
{:handler (partial resend-email-notification cfg)}]
|
||||
["/actions/reset-file-version"
|
||||
{:handler (partial reset-file-version cfg)}]
|
||||
["/actions/add-team-feature"
|
||||
{:handler (partial add-team-feature)}]
|
||||
["/actions/remove-team-feature"
|
||||
{:handler (partial remove-team-feature)}]
|
||||
["/file/export" {:handler (partial export-handler cfg)}]
|
||||
["/file/import" {:handler (partial import-handler cfg)}]
|
||||
["/file/data" {:handler (partial file-data-handler cfg)}]
|
||||
["/file/changes" {:handler (partial file-changes-handler cfg)}]]])
|
||||
["/actions" {:middleware [[errors]]}
|
||||
["/resend-email-verification"
|
||||
{:handler (partial resend-email-notification cfg)}]
|
||||
["/reset-file-version"
|
||||
{:handler (partial reset-file-version cfg)}]
|
||||
["/handle-team-features"
|
||||
{:handler (partial handle-team-features cfg)}]
|
||||
["/file-export" {:handler (partial export-handler cfg)}]
|
||||
["/file-import" {:handler (partial import-handler cfg)}]
|
||||
["/file-raw-export-import" {:handler (partial raw-export-import-handler cfg)}]]]])
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
(ns app.rpc.commands.files-create
|
||||
(:require
|
||||
[app.binfile.common :as bfc]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.features :as cfeat]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.types.file :as ctf]
|
||||
@@ -41,9 +40,7 @@
|
||||
:or {is-shared false revn 0 create-page true}
|
||||
:as params}]
|
||||
|
||||
(dm/assert!
|
||||
"expected a valid connection"
|
||||
(db/connection? conn))
|
||||
(assert (db/connection? conn) "expected a valid connection")
|
||||
|
||||
(binding [pmap/*tracked* (pmap/create-tracked)
|
||||
cfeat/*current* features]
|
||||
|
||||
@@ -78,9 +78,10 @@
|
||||
|
||||
(defn decode-row
|
||||
[{:keys [features subscription] :as row}]
|
||||
(cond-> row
|
||||
(some? features) (assoc :features (db/decode-pgarray features #{}))
|
||||
(some? subscription) (assoc :subscription (db/decode-transit-pgobject subscription))))
|
||||
(when row
|
||||
(cond-> row
|
||||
(some? features) (assoc :features (db/decode-pgarray features #{}))
|
||||
(some? subscription) (assoc :subscription (db/decode-transit-pgobject subscription)))))
|
||||
|
||||
;; FIXME: move
|
||||
|
||||
@@ -461,11 +462,12 @@
|
||||
|
||||
;; --- COMMAND QUERY: get-team-info
|
||||
|
||||
(defn- get-team-info
|
||||
(defn get-team-info
|
||||
[{:keys [::db/conn] :as cfg} {:keys [id] :as params}]
|
||||
(db/get* conn :team
|
||||
{:id id}
|
||||
{::sql/columns [:id :is-default]}))
|
||||
(-> (db/get* conn :team
|
||||
{:id id}
|
||||
{::sql/columns [:id :is-default :features]})
|
||||
(decode-row)))
|
||||
|
||||
(sv/defmethod ::get-team-info
|
||||
"Retrieve minimal team info by its ID."
|
||||
|
||||
@@ -205,9 +205,8 @@
|
||||
[:trial-start [:maybe ::sm/timestamp]]
|
||||
[:cancel-at [:maybe ::sm/timestamp]]
|
||||
[:canceled-at [:maybe ::sm/timestamp]]
|
||||
|
||||
[:current-period-end ::sm/timestamp]
|
||||
[:current-period-start ::sm/timestamp]
|
||||
[:current-period-end [:maybe ::sm/timestamp]]
|
||||
[:current-period-start [:maybe ::sm/timestamp]]
|
||||
[:cancel-at-period-end :boolean]
|
||||
|
||||
[:cancellation-details
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
rounded-s (d/format-number (* 100 s) precision)
|
||||
rounded-l (d/format-number (* 100 l) precision)
|
||||
rounded-a (d/format-number a precision)]
|
||||
(str/concat "" rounded-h ", " rounded-s "%, " rounded-l "%, " rounded-a)))
|
||||
(str/concat "" rounded-h " " rounded-s "% " rounded-l "% / " rounded-a)))
|
||||
|
||||
(defn format-rgba
|
||||
[[r g b a]]
|
||||
|
||||
@@ -9,17 +9,16 @@
|
||||
data resources."
|
||||
(:refer-clojure :exclude [read-string hash-map merge name update-vals
|
||||
parse-double group-by iteration concat mapcat
|
||||
parse-uuid max min regexp?])
|
||||
parse-uuid max min regexp? array?])
|
||||
#?(:cljs
|
||||
(:require-macros [app.common.data]))
|
||||
|
||||
(:require
|
||||
#?(:cljs [cljs.core :as c]
|
||||
:clj [clojure.core :as c])
|
||||
#?(:cljs [cljs.reader :as r]
|
||||
:clj [clojure.edn :as r])
|
||||
#?(:cljs [goog.array :as garray])
|
||||
[app.common.math :as mth]
|
||||
[clojure.core :as c]
|
||||
[clojure.set :as set]
|
||||
[cuerdas.core :as str]
|
||||
[linked.map :as lkm]
|
||||
@@ -167,6 +166,15 @@
|
||||
;; Data Structures Access & Manipulation
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn array?
|
||||
[o]
|
||||
#?(:cljs
|
||||
(c/array? o)
|
||||
:clj
|
||||
(if (some? o)
|
||||
(.isArray (class o))
|
||||
false)))
|
||||
|
||||
(defn not-empty?
|
||||
[coll]
|
||||
(boolean (seq coll)))
|
||||
|
||||
@@ -650,26 +650,12 @@
|
||||
(check-component component file)
|
||||
(deref *errors*)))
|
||||
|
||||
(def ^:private valid-fdata?
|
||||
"Structural validation of file data using defined schema"
|
||||
(sm/lazy-validator ::ctf/data))
|
||||
|
||||
(def ^:private get-fdata-explain
|
||||
"Get schema explain data for file data"
|
||||
(sm/lazy-explainer ::ctf/data))
|
||||
|
||||
(defn validate-file-schema!
|
||||
"Validates the file itself, without external dependencies, it
|
||||
performs the schema checking and some semantical validation of the
|
||||
content."
|
||||
[{:keys [id data] :as file}]
|
||||
(when-not (valid-fdata? data)
|
||||
(ex/raise :type :validation
|
||||
:code :schema-validation
|
||||
:hint (str/ffmt "invalid file data structure found on file '%'" id)
|
||||
:file-id id
|
||||
::sm/explain (get-fdata-explain data)))
|
||||
file)
|
||||
[file]
|
||||
(update file :data ctf/check-file-data))
|
||||
|
||||
(defn validate-file!
|
||||
"Validate full referential integrity and semantic coherence on file data.
|
||||
@@ -683,7 +669,6 @@
|
||||
:file-id (:id file)
|
||||
:details errors)))
|
||||
|
||||
|
||||
(declare compare-slots)
|
||||
|
||||
;; Optional check to look for missing swap slots.
|
||||
|
||||
@@ -1665,27 +1665,62 @@
|
||||
:shapes all-parents})]))))
|
||||
|
||||
|
||||
(defn- text-partial-change-value
|
||||
[touched-content untouched-content touched]
|
||||
(cond
|
||||
(touched :text-content-structure-same-attrs)
|
||||
(if (touched :text-content-attribute)
|
||||
;; Both structure and attrs has been touched, keep the
|
||||
(defn- text-change-value
|
||||
[touched-content ;; The :content of the copy text before updating
|
||||
untouched-content ;; The :content of the main component
|
||||
touched]
|
||||
|
||||
(let [main-comps-diff (cttx/get-diff-type touched-content untouched-content)
|
||||
diff-structure? (contains? main-comps-diff :text-content-structure)
|
||||
|
||||
touched-attrs (cttx/get-first-paragraph-text-attrs touched-content)
|
||||
;; Have touched content an uniform style?
|
||||
thed-unif-style? (cttx/equal-attrs? touched-content touched-attrs)
|
||||
|
||||
untouched-attrs (cttx/get-first-paragraph-text-attrs untouched-content)
|
||||
;; Have untouched content an uniform style?
|
||||
untched-unif-style? (cttx/equal-attrs? untouched-content untouched-attrs)]
|
||||
(cond
|
||||
;; Both text and attrs has been touched, keep the
|
||||
;; touched-content
|
||||
(and (touched :text-content-text) (touched :text-content-attribute))
|
||||
touched-content
|
||||
;; Keep the touched-content structure and texts, update
|
||||
;; its attrs to make them like the untouched-content
|
||||
(cttx/copy-attrs-keys touched-content (cttx/get-first-paragraph-text-attrs untouched-content)))
|
||||
|
||||
(touched :text-content-text)
|
||||
;; Keep the texts touched in touched-content, so copy the
|
||||
;; texts from touched-content into untouched-content
|
||||
(cttx/copy-text-keys touched-content untouched-content)
|
||||
(touched :text-content-structure)
|
||||
;; Special case for adding or removing paragraphs:
|
||||
;; If the structure has been touched, but the attrs don't,
|
||||
;; and both have uniform attributes, we keep the touched-content structure and
|
||||
;; texts, updating its attrs to make them like the untouched-content
|
||||
(if (and (not (touched :text-content-attribute)) thed-unif-style? untched-unif-style?)
|
||||
(cttx/copy-attrs-keys touched-content untouched-attrs)
|
||||
;; In other case, we keep the touched content
|
||||
touched-content)
|
||||
|
||||
(touched :text-content-text)
|
||||
;; Keep the texts touched in touched-content, so copy the
|
||||
;; texts from touched-content into untouched-content
|
||||
(cttx/copy-text-keys touched-content untouched-content)
|
||||
|
||||
(touched :text-content-attribute)
|
||||
;; The untouched content has a different structure, but the touched content had't
|
||||
;; touched the structure
|
||||
(if diff-structure?
|
||||
;; If both have uniform attributes, we keep the untouched-content structure and
|
||||
;; texts, updating its attrs to make them like the touched-content
|
||||
(if (and thed-unif-style? untched-unif-style?)
|
||||
(cttx/copy-attrs-keys untouched-content touched-attrs)
|
||||
;; In other case, we keep the touched content
|
||||
touched-content)
|
||||
|
||||
;; Keep the attrs touched in touched-content, so copy the
|
||||
;; texts from untouched-content into touched-content
|
||||
(cttx/copy-text-keys untouched-content touched-content))
|
||||
|
||||
|
||||
;; Nothing is touched
|
||||
:else
|
||||
untouched-content)))
|
||||
|
||||
(touched :text-content-attribute)
|
||||
;; Keep the attrs touched in touched-content, so copy the
|
||||
;; texts from untouched-content into touched-content
|
||||
(cttx/copy-text-keys untouched-content touched-content)))
|
||||
|
||||
(defn- add-update-attr-operations
|
||||
[attr dest-shape roperations uoperations attr-val]
|
||||
@@ -1700,33 +1735,6 @@
|
||||
[(conj roperations roperation)
|
||||
(conj uoperations uoperation)]))
|
||||
|
||||
(defn- is-text-partial-change?
|
||||
"Check if the attr update is a text partial change"
|
||||
[untouched-shape touched-shape]
|
||||
(let [touched (get touched-shape :touched #{})
|
||||
partial-text-keys [:text-content-attribute :text-content-text]
|
||||
active-keys (filter touched partial-text-keys)
|
||||
untouched-content (:content untouched-shape)
|
||||
untouched-attrs (cttx/get-first-paragraph-text-attrs untouched-content)
|
||||
eq-untouched-attrs? (cttx/equal-attrs? untouched-content untouched-attrs)]
|
||||
(and
|
||||
(or
|
||||
;; One and only one of the keys is pressent
|
||||
(= 1 (count active-keys))
|
||||
(and
|
||||
(not (touched :text-content-attribute))
|
||||
(touched :text-content-structure-same-attrs)))
|
||||
|
||||
(or
|
||||
;; Both has the same structure
|
||||
(cttx/equal-structure? untouched-content (:content touched-shape))
|
||||
|
||||
;; The origin and destiny have different structures, but each have the same attrs
|
||||
;; for all the items on its content tree
|
||||
(and
|
||||
eq-untouched-attrs?
|
||||
(touched :text-content-structure-same-attrs))))))
|
||||
|
||||
(defn- update-attrs
|
||||
"The main function that implements the attribute sync algorithm. Copy
|
||||
attributes that have changed in the origin shape to the dest shape.
|
||||
@@ -1783,13 +1791,13 @@
|
||||
;; and attrs (bold, font, etc) are in the same attr :content.
|
||||
;; If only one of them is touched, we want to adress this case and
|
||||
;; only update the untouched one
|
||||
text-partial-change?
|
||||
(when (and
|
||||
omit-touched?
|
||||
(cfh/text-shape? origin-shape)
|
||||
(= :content attr)
|
||||
(touched attr-group))
|
||||
(is-text-partial-change? origin-shape dest-shape))
|
||||
text-content-change?
|
||||
(and
|
||||
omit-touched?
|
||||
(cfh/text-shape? origin-shape)
|
||||
(= :content attr)
|
||||
(touched attr-group))
|
||||
|
||||
|
||||
skip-operations?
|
||||
(or (= (get origin-shape attr) (get dest-shape attr))
|
||||
@@ -1798,7 +1806,7 @@
|
||||
;; When it is a text-partial-change, we should generate operations
|
||||
;; even when omit-touched? is true, but updating only the text or
|
||||
;; the attributes, omiting the other part
|
||||
(not text-partial-change?)))
|
||||
(not text-content-change?)))
|
||||
|
||||
attr-val (when-not skip-operations?
|
||||
(cond
|
||||
@@ -1807,18 +1815,23 @@
|
||||
reset-pos-data?
|
||||
nil
|
||||
|
||||
text-partial-change?
|
||||
(text-partial-change-value (:content dest-shape)
|
||||
(:content origin-shape)
|
||||
touched)
|
||||
text-content-change?
|
||||
(text-change-value (:content dest-shape)
|
||||
(:content origin-shape)
|
||||
touched)
|
||||
|
||||
:else
|
||||
(get origin-shape attr)))
|
||||
|
||||
;; If the final attr-value is the actual value, skip
|
||||
skip-operations? (or skip-operations?
|
||||
(= attr-val (get dest-shape attr)))
|
||||
|
||||
|
||||
;; On a text-partial-change, we want to force a position-data reset
|
||||
;; so it's calculated again
|
||||
[roperations uoperations]
|
||||
(if text-partial-change?
|
||||
(if (and text-content-change? (not skip-operations?))
|
||||
(add-update-attr-operations :position-data dest-shape roperations uoperations nil)
|
||||
[roperations uoperations])
|
||||
|
||||
@@ -1830,6 +1843,93 @@
|
||||
roperations'
|
||||
uoperations')))))))
|
||||
|
||||
|
||||
(defn- switch-text-change-value
|
||||
[prev-content ;; The :content of the text before the switch
|
||||
current-content ;; The :content of the text after the switch (a clean copy)
|
||||
ref-content touched] ;; The :content of the referenced text on the main component
|
||||
;; before the switch
|
||||
(let [;; We need the differences between the contents on the main
|
||||
;; components. current-content is the content of a clean copy,
|
||||
;; so for all effects its the same as the content on its main
|
||||
main-comps-diff (cttx/get-diff-type ref-content current-content)
|
||||
can-keep-text? (not (contains? main-comps-diff :text-content-text))
|
||||
can-keep-attr? (not (contains? main-comps-diff :text-content-attribute))
|
||||
main-diff-structure? (contains? main-comps-diff :text-content-structure)
|
||||
|
||||
current-attrs (cttx/get-first-paragraph-text-attrs current-content)
|
||||
;; Have current content an uniform style?
|
||||
curr-unif-style? (cttx/equal-attrs? current-content current-attrs)
|
||||
prev-attrs (cttx/get-first-paragraph-text-attrs prev-content)
|
||||
;; Have prev content an uniform style?
|
||||
prev-unif-style? (cttx/equal-attrs? prev-content prev-attrs)
|
||||
ref-attrs (cttx/get-first-paragraph-text-attrs ref-content)
|
||||
;; Have ref content an uniform style?
|
||||
ref-unif-style? (cttx/equal-attrs? ref-content ref-attrs)]
|
||||
(cond
|
||||
;; When the main components have a difference in structure
|
||||
;; (different number of paragraph or text entries)
|
||||
main-diff-structure?
|
||||
;; Special case for adding or removing paragraphs:
|
||||
;; If the structure has changed between ref-content and current-content,
|
||||
;; but each one have uniform attributes, and the attrs on the main
|
||||
;; components were equal, we keep the touched-content structure and
|
||||
;; texts, updating its attrs to make them like the current-content
|
||||
(if (and curr-unif-style?
|
||||
ref-unif-style?
|
||||
prev-unif-style?
|
||||
(= ref-attrs current-attrs))
|
||||
(cttx/copy-attrs-keys current-content prev-attrs)
|
||||
;; In any other case of structure change, we discard all
|
||||
;; the overrides and keep the content of the current-shape
|
||||
current-content)
|
||||
|
||||
;; When the main components are equal, we keep the updated
|
||||
;; content from previous-shape as is
|
||||
(and can-keep-text? can-keep-attr?)
|
||||
prev-content
|
||||
|
||||
;; When we can't keep anything, we discard all the
|
||||
;; overrides and keep the content of the current-shape
|
||||
(and (not can-keep-text?) (not can-keep-attr?))
|
||||
current-content
|
||||
|
||||
;; Special case for added or removed paragraphs:
|
||||
;; If the structure has changed on current-content, but it has uniform attributes
|
||||
;; and the previous-content also has uniform attributes, and we can keep the changes
|
||||
;; on the text, we keep the touched-content structure and texts, updating
|
||||
;; its attrs to make them like the current-content
|
||||
(and (touched :text-content-structure)
|
||||
curr-unif-style?
|
||||
prev-unif-style?)
|
||||
(if can-keep-text?
|
||||
(cttx/copy-attrs-keys prev-content current-attrs)
|
||||
(cttx/copy-attrs-keys current-content prev-attrs))
|
||||
|
||||
;; In any other case of structure change, we discard all
|
||||
;; the overrides and keep the content of the current-shape
|
||||
(touched :text-content-structure)
|
||||
current-content
|
||||
|
||||
;; When there is a change on :text-content-text,
|
||||
;; and and we can keep it, we copy the texts from
|
||||
;; previous-shape over the attrs of current-shape
|
||||
(and
|
||||
(touched :text-content-text) can-keep-text?)
|
||||
(cttx/copy-text-keys prev-content current-content)
|
||||
|
||||
;; When there is a change on :text-content-attribute,
|
||||
;; and we can keep it, we copy the texts from current-shape
|
||||
;; over the attrs of previous-shape
|
||||
(and
|
||||
(touched :text-content-attribute) can-keep-attr?)
|
||||
(cttx/copy-text-keys current-content prev-content)
|
||||
|
||||
;; In any other case, we discard all the overrides
|
||||
;; and keep the content of the current-shape
|
||||
:else
|
||||
current-content)))
|
||||
|
||||
(defn update-attrs-on-switch
|
||||
"Copy attributes that have changed in the shape previous to the switch
|
||||
to the current shape (post switch). Used only on variants switch"
|
||||
@@ -1883,14 +1983,13 @@
|
||||
;; and attrs (bold, font, etc) are in the same attr :content.
|
||||
;; If only one of them is touched, we want to adress this case and
|
||||
;; only update the untouched one
|
||||
text-partial-change?
|
||||
(when (and
|
||||
(not skip-operations?)
|
||||
(cfh/text-shape? current-shape)
|
||||
(cfh/text-shape? previous-shape)
|
||||
(= :content attr)
|
||||
(touched attr-group))
|
||||
(is-text-partial-change? current-shape previous-shape))
|
||||
text-change?
|
||||
(and
|
||||
(not skip-operations?)
|
||||
(cfh/text-shape? current-shape)
|
||||
(cfh/text-shape? previous-shape)
|
||||
(= :content attr)
|
||||
(touched attr-group))
|
||||
|
||||
;; position-data is a special case because can be affected by :geometry-group and :content-group
|
||||
;; so, if the position-data changes but the geometry is touched we need to reset the position-data
|
||||
@@ -1902,20 +2001,34 @@
|
||||
(not= (:position-data previous-shape) (:position-data current-shape))
|
||||
(touched :geometry-group))
|
||||
|
||||
attr-val (when-not skip-operations?
|
||||
(cond
|
||||
;; If position data changes and the geometry group is touched
|
||||
;; we need to put to nil so we can regenerate it
|
||||
reset-pos-data?
|
||||
nil
|
||||
attr-val
|
||||
(when-not skip-operations?
|
||||
(cond
|
||||
;; If position data changes and the geometry group is touched
|
||||
;; we need to put to nil so we can regenerate it
|
||||
reset-pos-data?
|
||||
nil
|
||||
|
||||
text-partial-change?
|
||||
(text-partial-change-value (:content previous-shape)
|
||||
(:content current-shape)
|
||||
touched)
|
||||
text-change?
|
||||
(switch-text-change-value (:content previous-shape)
|
||||
(:content current-shape)
|
||||
(:content origin-ref-shape)
|
||||
touched)
|
||||
|
||||
:else
|
||||
(get previous-shape attr)))
|
||||
:else
|
||||
(get previous-shape attr)))
|
||||
|
||||
;; If the final attr-value is the actual value, skip
|
||||
skip-operations? (or skip-operations?
|
||||
(= attr-val (get current-shape attr)))
|
||||
|
||||
|
||||
;; On a text-change, we want to force a position-data reset
|
||||
;; so it's calculated again
|
||||
[roperations uoperations]
|
||||
(if (and (not skip-operations?) text-change?)
|
||||
(add-update-attr-operations :position-data current-shape roperations uoperations nil)
|
||||
[roperations uoperations])
|
||||
|
||||
[roperations' uoperations']
|
||||
(if skip-operations?
|
||||
|
||||
@@ -8,11 +8,14 @@
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.files.changes-builder :as pcb]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.logic.libraries :as cll]
|
||||
[app.common.logic.shapes :as cls]
|
||||
[app.common.logic.variants :as clv]
|
||||
[app.common.test-helpers.components :as thc]
|
||||
[app.common.test-helpers.files :as thf]
|
||||
[app.common.test-helpers.ids-map :as thi]
|
||||
[app.common.test-helpers.shapes :as ths]
|
||||
[app.common.text :as txt]
|
||||
[app.common.types.container :as ctn]
|
||||
@@ -275,26 +278,36 @@
|
||||
|
||||
(defn swap-component
|
||||
"Swap the specified shape by the component specified by component-tag"
|
||||
[file shape component-tag & {:keys [page-label propagate-fn]}]
|
||||
[file shape component-tag & {:keys [page-label propagate-fn keep-touched? new-shape-label]}]
|
||||
(let [page (if page-label
|
||||
(thf/get-page file page-label)
|
||||
(thf/current-page file))
|
||||
libraries {(:id file) file}
|
||||
|
||||
[_ _all-parents changes]
|
||||
orig-shapes (when keep-touched? (cfh/get-children-with-self (:objects page) (:id shape)))
|
||||
|
||||
[new-shape _all-parents changes]
|
||||
(cll/generate-component-swap (pcb/empty-changes)
|
||||
(:objects page)
|
||||
shape
|
||||
(:data file)
|
||||
page
|
||||
{(:id file) file}
|
||||
libraries
|
||||
(-> (thc/get-component file component-tag)
|
||||
:id)
|
||||
0
|
||||
nil
|
||||
{}
|
||||
false)
|
||||
(true? keep-touched?))
|
||||
|
||||
changes (if keep-touched?
|
||||
(clv/generate-keep-touched changes new-shape shape orig-shapes page libraries (:data file))
|
||||
changes)
|
||||
|
||||
|
||||
file' (thf/apply-changes file changes)]
|
||||
(when new-shape-label
|
||||
(thi/set-id! new-shape-label (:id new-shape)))
|
||||
(if propagate-fn
|
||||
(propagate-fn file')
|
||||
file')))
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
(:require
|
||||
[app.common.test-helpers.components :as thc]
|
||||
[app.common.test-helpers.ids-map :as thi]
|
||||
[app.common.test-helpers.shapes :as ths]))
|
||||
[app.common.test-helpers.shapes :as ths]
|
||||
[app.common.text :as txt]
|
||||
[app.common.types.shape :as cts]))
|
||||
|
||||
(defn add-variant
|
||||
[file variant-label component1-label root1-label component2-label root2-label
|
||||
@@ -37,3 +39,48 @@
|
||||
(thc/update-component component1-label {:variant-id variant-id :variant-properties [{:name "Property1" :value "p1v1"} {:name "Property2" :value "p2v1"}]})
|
||||
(thc/make-component component2-label root2-label)
|
||||
(thc/update-component component2-label {:variant-id variant-id :variant-properties [{:name "Property1" :value "p1v2"} {:name "Property2" :value "p2v2"}]}))))
|
||||
|
||||
(defn add-variant-with-child
|
||||
[file variant-label component1-label root1-label component2-label root2-label child1-label child2-label
|
||||
& {:keys [child1-params child2-params]}]
|
||||
(let [file (ths/add-sample-shape file variant-label :type :frame :is-variant-container true)
|
||||
variant-id (thi/id variant-label)]
|
||||
(-> file
|
||||
(ths/add-sample-shape root2-label :type :frame :parent-label variant-label :variant-id variant-id :variant-name "Value2")
|
||||
(ths/add-sample-shape root1-label :type :frame :parent-label variant-label :variant-id variant-id :variant-name "Value1")
|
||||
(ths/add-sample-shape child1-label (assoc child1-params :parent-label root1-label))
|
||||
(ths/add-sample-shape child2-label (assoc child2-params :parent-label root2-label))
|
||||
(thc/make-component component1-label root1-label)
|
||||
(thc/update-component component1-label {:variant-id variant-id :variant-properties [{:name "Property1" :value "Value1"}]})
|
||||
(thc/make-component component2-label root2-label)
|
||||
(thc/update-component component2-label {:variant-id variant-id :variant-properties [{:name "Property1" :value "Value2"}]}))))
|
||||
|
||||
|
||||
(defn add-variant-with-text
|
||||
[file variant-label component1-label root1-label component2-label root2-label child1-label child2-label text1 text2
|
||||
& {:keys [text1-params text2-params]}]
|
||||
(let [text1 (-> (cts/setup-shape {:type :text :x 0 :y 0 :grow-type :auto-width})
|
||||
(txt/change-text text1)
|
||||
(assoc :position-data nil
|
||||
:parent-label root1-label))
|
||||
text2 (-> (cts/setup-shape {:type :text :x 0 :y 0 :grow-type :auto-width})
|
||||
(txt/change-text text2)
|
||||
(assoc :position-data nil
|
||||
:parent-label root2-label))
|
||||
|
||||
file (ths/add-sample-shape file variant-label :type :frame :is-variant-container true)
|
||||
variant-id (thi/id variant-label)]
|
||||
(-> file
|
||||
|
||||
(ths/add-sample-shape root2-label :type :frame :parent-label variant-label :variant-id variant-id :variant-name "Value2")
|
||||
(ths/add-sample-shape root1-label :type :frame :parent-label variant-label :variant-id variant-id :variant-name "Value1")
|
||||
(ths/add-sample-shape child1-label
|
||||
(merge text1
|
||||
text1-params))
|
||||
(ths/add-sample-shape child2-label
|
||||
(merge text2
|
||||
text2-params))
|
||||
(thc/make-component component1-label root1-label)
|
||||
(thc/update-component component1-label {:variant-id variant-id :variant-properties [{:name "Property1" :value "Value1"}]})
|
||||
(thc/make-component component2-label root2-label)
|
||||
(thc/update-component component2-label {:variant-id variant-id :variant-properties [{:name "Property1" :value "Value2"}]}))))
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
[app.common.types.component :as ctk]
|
||||
[app.common.types.components-list :as ctkl]
|
||||
[app.common.types.pages-list :as ctpl]
|
||||
[app.common.types.plugins :as ctpg]
|
||||
[app.common.types.plugins :refer [schema:plugin-data]]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.common.types.text :as cttx]
|
||||
@@ -30,21 +30,22 @@
|
||||
(def valid-container-types
|
||||
#{:page :component})
|
||||
|
||||
(sm/register!
|
||||
^{::sm/type ::container}
|
||||
[:map
|
||||
[:id ::sm/uuid]
|
||||
[:type {:optional true}
|
||||
[::sm/one-of valid-container-types]]
|
||||
[:name :string]
|
||||
[:path {:optional true} [:maybe :string]]
|
||||
[:modified-at {:optional true} ::sm/inst]
|
||||
[:objects {:optional true}
|
||||
[:map-of {:gen/max 10} ::sm/uuid :map]]
|
||||
[:plugin-data {:optional true} ::ctpg/plugin-data]])
|
||||
(def schema:container
|
||||
(sm/register!
|
||||
^{::sm/type ::container}
|
||||
[:map
|
||||
[:id ::sm/uuid]
|
||||
[:type {:optional true}
|
||||
[::sm/one-of valid-container-types]]
|
||||
[:name :string]
|
||||
[:path {:optional true} [:maybe :string]]
|
||||
[:modified-at {:optional true} ::sm/inst]
|
||||
[:objects {:optional true}
|
||||
[:map-of {:gen/max 10} ::sm/uuid :map]]
|
||||
[:plugin-data {:optional true} schema:plugin-data]]))
|
||||
|
||||
(def check-container
|
||||
(sm/check-fn ::container))
|
||||
(sm/check-fn schema:container))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; HELPERS
|
||||
@@ -294,8 +295,8 @@
|
||||
([page component library-data position]
|
||||
(make-component-instance page component library-data position {}))
|
||||
([page component library-data position
|
||||
{:keys [main-instance? force-id force-frame-id keep-ids?]
|
||||
:or {main-instance? false force-id nil force-frame-id nil keep-ids? false}}]
|
||||
{:keys [main-instance? force-id force-frame-id keep-ids? force-parent-id]
|
||||
:or {main-instance? false force-id nil force-frame-id nil keep-ids? false force-parent-id nil}}]
|
||||
(let [component-page (ctpl/get-page library-data (:main-instance-page component))
|
||||
|
||||
component-shape (-> (get-shape component-page (:main-instance-id component))
|
||||
@@ -303,7 +304,6 @@
|
||||
(assoc :frame-id uuid/zero)
|
||||
(remove-swap-keep-attrs))
|
||||
|
||||
|
||||
orig-pos (gpt/point (:x component-shape) (:y component-shape))
|
||||
delta (gpt/subtract position orig-pos)
|
||||
|
||||
@@ -368,7 +368,7 @@
|
||||
|
||||
[new-shape new-shapes _]
|
||||
(ctst/clone-shape component-shape
|
||||
frame-id
|
||||
(or force-parent-id frame-id)
|
||||
(:objects component-page)
|
||||
:update-new-shape update-new-shape
|
||||
:force-id force-id
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
[app.common.types.container :as ctn]
|
||||
[app.common.types.page :as ctp]
|
||||
[app.common.types.pages-list :as ctpl]
|
||||
[app.common.types.plugins :as ctpg]
|
||||
[app.common.types.plugins :refer [schema:plugin-data]]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
[app.common.types.tokens-lib :as ctl]
|
||||
[app.common.types.tokens-lib :refer [schema:tokens-lib]]
|
||||
[app.common.types.typographies-list :as ctyl]
|
||||
[app.common.types.typography :as cty]
|
||||
[app.common.uuid :as uuid]
|
||||
@@ -61,13 +61,13 @@
|
||||
[:map-of {:gen/max 5} ::sm/uuid ctc/schema:library-color])
|
||||
|
||||
(def schema:components
|
||||
[:map-of {:gen/max 5} ::sm/uuid ::ctn/container])
|
||||
[:map-of {:gen/max 5} ::sm/uuid ctn/schema:container])
|
||||
|
||||
(def schema:typographies
|
||||
[:map-of {:gen/max 2} ::sm/uuid ::cty/typography])
|
||||
[:map-of {:gen/max 2} ::sm/uuid cty/schema:typography])
|
||||
|
||||
(def schema:pages-index
|
||||
[:map-of {:gen/max 5} ::sm/uuid ::ctp/page])
|
||||
[:map-of {:gen/max 5} ::sm/uuid ctp/schema:page])
|
||||
|
||||
(def schema:options
|
||||
[:map {:title "FileOptions"}
|
||||
@@ -82,8 +82,8 @@
|
||||
[:colors {:optional true} schema:colors]
|
||||
[:components {:optional true} schema:components]
|
||||
[:typographies {:optional true} schema:typographies]
|
||||
[:plugin-data {:optional true} ::ctpg/plugin-data]
|
||||
[:tokens-lib {:optional true} ::ctl/tokens-lib]])
|
||||
[:plugin-data {:optional true} schema:plugin-data]
|
||||
[:tokens-lib {:optional true} schema:tokens-lib]])
|
||||
|
||||
(def schema:file
|
||||
"A schema for validate a file data structure; data is optional
|
||||
|
||||
@@ -53,10 +53,10 @@
|
||||
[:name :string]
|
||||
[:index {:optional true} ::sm/int]
|
||||
[:objects schema:objects]
|
||||
[:default-grids {:optional true} ::ctg/default-grids]
|
||||
[:default-grids {:optional true} ctg/schema:default-grids]
|
||||
[:flows {:optional true} schema:flows]
|
||||
[:guides {:optional true} schema:guides]
|
||||
[:plugin-data {:optional true} ::ctpg/plugin-data]
|
||||
[:plugin-data {:optional true} ctpg/schema:plugin-data]
|
||||
[:background {:optional true} ctc/schema:hex-color]
|
||||
|
||||
[:comment-thread-positions {:optional true}
|
||||
|
||||
@@ -83,21 +83,12 @@
|
||||
compare them, and returns a set with the type of differences.
|
||||
The possibilities are
|
||||
:text-content-text
|
||||
:text-content-attribute,
|
||||
:text-content-structure
|
||||
:text-content-structure-same-attrs."
|
||||
:text-content-attribute
|
||||
:text-content-structure"
|
||||
[a b]
|
||||
(let [diff-type (compare-text-content a b
|
||||
{:text-cb (fn [acc] (conj acc :text-content-text))
|
||||
:attribute-cb (fn [acc _] (conj acc :text-content-attribute))})]
|
||||
(if-not (contains? diff-type :text-content-structure)
|
||||
diff-type
|
||||
(let [;; get attrs of the first paragraph of the first paragraph-set
|
||||
attrs (get-first-paragraph-text-attrs a)]
|
||||
(if (and (equal-attrs? a attrs)
|
||||
(equal-attrs? b attrs))
|
||||
#{:text-content-structure :text-content-structure-same-attrs}
|
||||
diff-type)))))
|
||||
(compare-text-content a b
|
||||
{:text-cb (fn [acc] (conj acc :text-content-text))
|
||||
:attribute-cb (fn [acc _] (conj acc :text-content-attribute))}))
|
||||
|
||||
(defn get-diff-attrs
|
||||
"Given two content text structures, conformed by maps and vectors,
|
||||
@@ -127,7 +118,8 @@
|
||||
entries"
|
||||
[a b]
|
||||
(cond
|
||||
(not= (type a) (type b))
|
||||
(and (not= (type a) (type b))
|
||||
(not (and (map? a) (map? b)))) ;; Sometimes they are both maps but of different subtypes
|
||||
false
|
||||
|
||||
(map? a)
|
||||
|
||||
@@ -135,6 +135,8 @@
|
||||
|
||||
(def typography-keys (set/union font-size-keys letter-spacing-keys))
|
||||
|
||||
;; TODO: Created to extract the font-size feature from the typography feature flag.
|
||||
;; Delete this once the typography feature flag is removed.
|
||||
(def ff-typography-keys (set/difference typography-keys font-size-keys))
|
||||
|
||||
(def ^:private schema:number
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
(:require
|
||||
#?(:cljs [goog.color :as gcolors])
|
||||
[app.common.colors :as colors]
|
||||
[app.common.data :as d]
|
||||
[clojure.test :as t]))
|
||||
|
||||
(t/deftest valid-hex-color
|
||||
@@ -52,8 +51,8 @@
|
||||
(t/is (= [1 2 3] (colors/hex->rgb "#010203"))))
|
||||
|
||||
(t/deftest format-hsla
|
||||
(t/is (= "210, 50%, 0.78%, 1" (colors/format-hsla [210.0 0.5 0.00784313725490196 1])))
|
||||
(t/is (= "220, 5%, 30%, 0.8" (colors/format-hsla [220.0 0.05 0.3 0.8]))))
|
||||
(t/is (= "210 50% 0.78% / 1" (colors/format-hsla [210.0 0.5 0.00784313725490196 1])))
|
||||
(t/is (= "220 5% 30% / 0.8" (colors/format-hsla [220.0 0.05 0.3 0.8]))))
|
||||
|
||||
(t/deftest format-rgba
|
||||
(t/is (= "210, 199, 12, 0.08" (colors/format-rgba [210 199 12 0.08])))
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
file' (thf/apply-changes file changes)
|
||||
copy-child' (ths/get-shape file' :copy-child)]
|
||||
(t/is (= #{:content-group :text-content-structure :text-content-structure-same-attrs} (:touched copy-child')))))
|
||||
(t/is (= #{:content-group :text-content-structure} (:touched copy-child')))))
|
||||
|
||||
(t/deftest test-text-copy-changed-structure-diff-attrs
|
||||
(let [;; ==== Setup
|
||||
|
||||
1125
common/test/common_tests/logic/variants_switch_test.cljc
Normal file
1125
common/test/common_tests/logic/variants_switch_test.cljc
Normal file
File diff suppressed because it is too large
Load Diff
@@ -39,7 +39,7 @@
|
||||
(t/is (= #{:text-content-attribute} diff-attr))
|
||||
(t/is (= #{:text-content-text :text-content-attribute} diff-both))
|
||||
(t/is (= #{:text-content-structure} diff-structure))
|
||||
(t/is (= #{:text-content-structure :text-content-structure-same-attrs} diff-structure-same-attrs))))
|
||||
(t/is (= #{:text-content-structure} diff-structure-same-attrs))))
|
||||
|
||||
|
||||
(t/deftest test-get-diff-attrs
|
||||
|
||||
91
docker/imagemagick/Dockerfile
Normal file
91
docker/imagemagick/Dockerfile
Normal file
@@ -0,0 +1,91 @@
|
||||
FROM ubuntu:24.04
|
||||
LABEL maintainer="Penpot <docker@penpot.app>"
|
||||
|
||||
ENV LANG='C.UTF-8' \
|
||||
LC_ALL='C.UTF-8' \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
TZ=Etc/UTC
|
||||
|
||||
ARG IMAGEMAGICK_VERSION=7.1.1-47
|
||||
|
||||
RUN set -e; \
|
||||
apt-get -qq update; \
|
||||
apt-get -qq upgrade; \
|
||||
apt-get -qqy --no-install-recommends install \
|
||||
autoconf \
|
||||
binutils \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
curl \
|
||||
libfftw3-dev \
|
||||
libheif-dev \
|
||||
libjpeg-dev \
|
||||
liblcms2-dev \
|
||||
libltdl-dev \
|
||||
liblzma-dev \
|
||||
libopenexr-dev \
|
||||
libpng-dev \
|
||||
librsvg2-dev \
|
||||
libtiff-dev \
|
||||
libtool \
|
||||
libwebp-dev \
|
||||
libzip-dev \
|
||||
libzstd-dev \
|
||||
pkg-config \
|
||||
; \
|
||||
curl -LfsSo /tmp/magick.tar.gz https://github.com/ImageMagick/ImageMagick/archive/refs/tags/${IMAGEMAGICK_VERSION}.tar.gz; \
|
||||
mkdir -p /tmp/magick; \
|
||||
cd /tmp/magick; \
|
||||
tar -xf /tmp/magick.tar.gz --strip-components=1; \
|
||||
./configure --prefix=/opt/imagick; \
|
||||
make -j 2; \
|
||||
make install; \
|
||||
rm -rf /opt/imagick/lib/libMagick++*; \
|
||||
rm -rf /opt/imagick/include; \
|
||||
rm -rf /opt/imagick/share; \
|
||||
apt-get -qqy --autoremove purge \
|
||||
autoconf \
|
||||
binutils \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
curl \
|
||||
libfftw3-dev \
|
||||
libheif-dev \
|
||||
libjpeg-dev \
|
||||
liblcms2-dev \
|
||||
libltdl-dev \
|
||||
liblzma-dev \
|
||||
libopenexr-dev \
|
||||
libpng-dev \
|
||||
librsvg2-dev \
|
||||
libtiff-dev \
|
||||
libtool\
|
||||
libwebp-dev \
|
||||
libzip-dev \
|
||||
libzstd-dev \
|
||||
pkg-config \
|
||||
;\
|
||||
apt-get -qqy --no-install-recommends install \
|
||||
libfontconfig1 \
|
||||
libfreetype6 \
|
||||
libglib2.0-0 \
|
||||
libgomp1 \
|
||||
libheif1 \
|
||||
libjpeg-turbo8 \
|
||||
liblcms2-2 \
|
||||
libopenexr-3-1-30 \
|
||||
libopenjp2-7 \
|
||||
libpng16-16 \
|
||||
librsvg2-2 \
|
||||
libtiff6 \
|
||||
libwebp7 \
|
||||
libwebpdemux2 \
|
||||
libwebpmux3 \
|
||||
libxml2 \
|
||||
libzip4t64 \
|
||||
libzstd1 \
|
||||
;\
|
||||
apt-get -qqy clean; \
|
||||
rm -rf /var/lib/apt/lists/*;
|
||||
|
||||
ENTRYPOINT ["/opt/imagick/bin/magick"]
|
||||
@@ -6,37 +6,18 @@ ENV LANG='C.UTF-8' \
|
||||
JAVA_HOME="/opt/jdk" \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
NODE_VERSION=v22.16.0 \
|
||||
IMAGEMAGICK_VERSION=7.1.1-47 \
|
||||
TZ=Etc/UTC
|
||||
|
||||
RUN set -ex; \
|
||||
apt-get -qq update; \
|
||||
apt-get -qq upgrade; \
|
||||
apt-get -qqy --no-install-recommends install \
|
||||
curl \
|
||||
ca-certificates \
|
||||
binutils \
|
||||
build-essential autoconf libtool pkg-config \
|
||||
libltdl-dev \
|
||||
libpng-dev libjpeg-dev libtiff-dev libwebp-dev libopenexr-dev libfftw3-dev \
|
||||
libzip-dev \
|
||||
liblcms2-dev liblzma-dev libzstd-dev \
|
||||
libheif-dev librsvg2-dev \
|
||||
ca-certificates \
|
||||
curl \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN set -eux; \
|
||||
curl -LfsSo /tmp/magick.tar.gz https://github.com/ImageMagick/ImageMagick/archive/refs/tags/${IMAGEMAGICK_VERSION}.tar.gz; \
|
||||
mkdir -p /tmp/magick; \
|
||||
cd /tmp/magick; \
|
||||
tar -xf /tmp/magick.tar.gz --strip-components=1; \
|
||||
./configure --prefix=/opt/imagick; \
|
||||
make -j 2; \
|
||||
make install; \
|
||||
rm -rf /opt/imagick/lib/libMagick++*; \
|
||||
rm -rf /opt/imagick/include; \
|
||||
rm -rf /opt/imagick/share;
|
||||
|
||||
RUN set -eux; \
|
||||
ARCH="$(dpkg --print-architecture)"; \
|
||||
case "${ARCH}" in \
|
||||
@@ -105,33 +86,33 @@ RUN set -ex; \
|
||||
apt-get -qq update; \
|
||||
apt-get -qq upgrade; \
|
||||
apt-get -qqy --no-install-recommends install \
|
||||
tzdata \
|
||||
ca-certificates \
|
||||
fontconfig \
|
||||
woff-tools \
|
||||
woff2 \
|
||||
fontforge \
|
||||
python3 \
|
||||
python3-tabulate \
|
||||
fontforge \
|
||||
tzdata \
|
||||
woff-tools \
|
||||
woff2 \
|
||||
\
|
||||
libpng16-16 \
|
||||
libfontconfig1 \
|
||||
libfreetype6 \
|
||||
libglib2.0-0 \
|
||||
libgomp1 \
|
||||
libheif1 \
|
||||
libjpeg-turbo8 \
|
||||
liblcms2-2 \
|
||||
libopenexr-3-1-30 \
|
||||
libopenjp2-7 \
|
||||
libpng16-16 \
|
||||
librsvg2-2 \
|
||||
libtiff6 \
|
||||
libwebp7 \
|
||||
libopenexr-3-1-30 \
|
||||
libfreetype6 \
|
||||
libfontconfig1 \
|
||||
libglib2.0-0 \
|
||||
libxml2 \
|
||||
liblcms2-2 \
|
||||
libheif1 \
|
||||
libopenjp2-7 \
|
||||
libzstd1 \
|
||||
librsvg2-2 \
|
||||
libgomp1 \
|
||||
libwebpmux3 \
|
||||
libwebpdemux2 \
|
||||
libwebpmux3 \
|
||||
libxml2 \
|
||||
libzip4t64 \
|
||||
libzstd1 \
|
||||
; \
|
||||
find tmp/usr/share/zoneinfo/* -type d ! -name 'Etc' |xargs rm -rf; \
|
||||
rm -rf /var/lib /var/cache; \
|
||||
@@ -144,7 +125,7 @@ RUN set -ex; \
|
||||
|
||||
COPY --from=build /opt/jre /opt/jre
|
||||
COPY --from=build /opt/node /opt/node
|
||||
COPY --from=build /opt/imagick /opt/imagick
|
||||
COPY --from=penpotapp/imagemagick:7.1.1-47 /opt/imagick /opt/imagick
|
||||
COPY --chown=penpot:penpot ./bundle-backend/ /opt/penpot/backend/
|
||||
|
||||
USER penpot:penpot
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
|
||||
DOCKER_CLI_EXPERIMENTAL=enabled
|
||||
IMAGE=${1:-backend}
|
||||
|
||||
OUTPUT="type=registry"
|
||||
|
||||
if [ "--local" = "$2" ]; then
|
||||
OUTPUT="type=docker"
|
||||
fi
|
||||
|
||||
ORG=${PENPOT_DOCKER_NAMESPACE:-penpotapp};
|
||||
PLATFORM=${PENPOT_BUILD_PLATFORM:-linux/amd64};
|
||||
|
||||
IMAGE=${PENPOT_BUILD_IMAGE:-backend}
|
||||
PLATFORM=${PENPOT_BUILD_PLATFORM:-linux/amd64};
|
||||
PLATFORM=${PENPOT_BUILD_PLATFORM:-linux/amd64,linux/arm64};
|
||||
VERSION=${PENPOT_BUILD_VERSION:-latest}
|
||||
|
||||
DOCKER_IMAGE="$ORG/$IMAGE";
|
||||
OPTIONS="-t $DOCKER_IMAGE:$VERSION";
|
||||
|
||||
@@ -20,7 +23,7 @@ for element in "${TAGS[@]}"; do
|
||||
done
|
||||
|
||||
docker buildx inspect penpot > /dev/null 2>&1;
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all > /dev/null;
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
docker buildx create --name=penpot --use
|
||||
@@ -32,4 +35,5 @@ fi
|
||||
|
||||
unset IFS;
|
||||
|
||||
docker buildx build --platform ${PLATFORM// /,} $OPTIONS -f Dockerfile.$IMAGE "$@" .;
|
||||
shift;
|
||||
docker buildx build --output $OUTPUT --platform ${PLATFORM// /,} $OPTIONS -f Dockerfile.$IMAGE .;
|
||||
|
||||
@@ -28,5 +28,6 @@ Use Docker if you already know the tool, if need full control of the process or
|
||||
and do not want to depend on any external provider, or need to do any special customization.
|
||||
</p>
|
||||
|
||||
Or you can try <a href="#unofficial-self-host-options">other options</a>,
|
||||
offered by Penpot community.
|
||||
Or you can try [other options][1], offered by Penpot community.
|
||||
|
||||
[1]: /technical-guide/getting-started/unofficial-options/
|
||||
|
||||
@@ -97,6 +97,11 @@ file itself, which you can use as a basis for creating your own settings.
|
||||
You can also consult the list of parameters on the
|
||||
<a href="https://artifacthub.io/packages/helm/penpot/penpot#parameters" target="_blank">ArtifactHub page of the project</a>.
|
||||
|
||||
### Using OpenShift?
|
||||
If you are deploying Penpot on OpenShift, we recommend following the specific guidelines provided in our Penpot-helm documentation:
|
||||
<a href="https://artifacthub.io/packages/helm/penpot/penpot#-openshift-requirements" target="_blank">`Installing the chart with OpenShift requirements`</a>
|
||||
|
||||
Make sure to review the section **OpenShift Requirements** for important security and compatibility considerations.
|
||||
|
||||
## Upgrade Penpot
|
||||
|
||||
|
||||
2950
frontend/playwright/data/render-wasm/get-file-text-decoration.json
Normal file
2950
frontend/playwright/data/render-wasm/get-file-text-decoration.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -121,7 +121,6 @@ test("Renders a file with styled texts", async ({ page }) => {
|
||||
await expect(workspace.canvas).toHaveScreenshot();
|
||||
});
|
||||
|
||||
|
||||
test("Renders a file with texts with images", async ({ page }) => {
|
||||
const workspace = new WasmWorkspacePage(page);
|
||||
await workspace.setupEmptyFile();
|
||||
@@ -145,6 +144,28 @@ test("Renders a file with texts with images", async ({ page }) => {
|
||||
await expect(workspace.canvas).toHaveScreenshot();
|
||||
});
|
||||
|
||||
test("Renders a file with text decoration", async ({ page }) => {
|
||||
const workspace = new WasmWorkspacePage(page);
|
||||
await workspace.setupEmptyFile();
|
||||
await workspace.mockFileMediaAsset(
|
||||
[
|
||||
"d6c33e7b-7b64-80f3-8006-78509a3a2d21",
|
||||
],
|
||||
"render-wasm/assets/pattern.png",
|
||||
);
|
||||
await mockGetEmojiFont(workspace);
|
||||
await mockGetJapaneseFont(workspace);
|
||||
|
||||
await workspace.mockGetFile("render-wasm/get-file-text-decoration.json");
|
||||
|
||||
await workspace.goToWorkspace({
|
||||
id: "d6c33e7b-7b64-80f3-8006-785098582f1d",
|
||||
pageId: "d6c33e7b-7b64-80f3-8006-785098582f1e",
|
||||
});
|
||||
await workspace.waitForFirstRender();
|
||||
await expect(workspace.canvas).toHaveScreenshot();
|
||||
});
|
||||
|
||||
test("Renders a file with multiple emoji", async ({ page }) => {
|
||||
const workspace = new WasmWorkspacePage(page);
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
@@ -245,4 +245,4 @@
|
||||
|
||||
(defn event
|
||||
[props]
|
||||
(ptk/data-event ::events props))
|
||||
(ptk/data-event ::event props))
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
[app.main.data.workspace :as-alias dw]
|
||||
[app.main.data.workspace.groups :as dwg]
|
||||
[app.main.data.workspace.notifications :as-alias dwn]
|
||||
[app.main.data.workspace.pages :as-alias dwpg]
|
||||
[app.main.data.workspace.selection :as dws]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.specialized-panel :as dwsp]
|
||||
@@ -700,7 +701,7 @@
|
||||
(fn [page-id shape-id]
|
||||
(rx/merge
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::dw/initialize-page))
|
||||
(rx/filter (ptk/type? ::dwpg/initialize-page))
|
||||
(rx/take 1)
|
||||
(rx/observe-on :async)
|
||||
(rx/mapcat (fn [_] (select-and-zoom shape-id))))
|
||||
|
||||
@@ -847,3 +847,25 @@
|
||||
(if undo-transation?
|
||||
(rx/of (dwu/commit-undo-transaction undo-id))
|
||||
(rx/empty))))))))
|
||||
|
||||
;; Pure function to determine next grow-type for text layers
|
||||
(defn next-grow-type [current-grow-type resize-direction]
|
||||
(cond
|
||||
(= current-grow-type :fixed)
|
||||
:fixed
|
||||
|
||||
(and (= resize-direction :horizontal)
|
||||
(= current-grow-type :auto-width))
|
||||
:auto-height
|
||||
|
||||
(and (= resize-direction :horizontal)
|
||||
(= current-grow-type :auto-height))
|
||||
:auto-height
|
||||
|
||||
(and (= resize-direction :vertical)
|
||||
(or (= current-grow-type :auto-width)
|
||||
(= current-grow-type :auto-height)))
|
||||
:fixed
|
||||
|
||||
:else
|
||||
current-grow-type))
|
||||
|
||||
@@ -174,12 +174,15 @@
|
||||
add-component-copy
|
||||
(fn [objs id shape]
|
||||
(let [component (ctkl/get-component fdata (:component-id shape))
|
||||
parent-id (when (not= (:parent-id shape) uuid/zero) (:parent-id shape))
|
||||
[new-shape new-shapes]
|
||||
(ctn/make-component-instance page
|
||||
component
|
||||
fdata
|
||||
(gpt/point (:x shape) (:y shape))
|
||||
{:keep-ids? true :force-frame-id (:frame-id shape)})
|
||||
{:keep-ids? true
|
||||
:force-frame-id (:frame-id shape)
|
||||
:force-parent-id parent-id})
|
||||
children (into {} (map (fn [shape] [(:id shape) shape]) new-shapes))
|
||||
objs (assoc objs id new-shape)]
|
||||
(merge objs children)))
|
||||
@@ -201,10 +204,8 @@
|
||||
(assoc :id id)
|
||||
(assoc :objects
|
||||
objects))
|
||||
|
||||
changes (-> (pcb/empty-changes it)
|
||||
(pcb/add-page id page))]
|
||||
|
||||
(rx/of (dch/commit-changes changes))))))
|
||||
|
||||
(s/def ::rename-page
|
||||
|
||||
@@ -479,7 +479,7 @@
|
||||
;; We don't have the fills attribute. It's an old text without color
|
||||
;; so need to be black
|
||||
(and (nil? (:fills node)) (empty? color-attrs))
|
||||
(update :fills conj txt/default-text-attrs)
|
||||
(assoc :fills (:fills txt/default-text-attrs))
|
||||
|
||||
;; Remove duplicates from the fills
|
||||
:always
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
(ntf/show {:content (tr "workspace.tokens.unknown-token-type-message")
|
||||
:detail (->> (for [[token-type tokens] type->tokens]
|
||||
(tr "workspace.tokens.unknown-token-type-section" token-type (count tokens)))
|
||||
(str/join "\n"))
|
||||
(str/join "<br>"))
|
||||
:type :toast
|
||||
:level :info})))
|
||||
|
||||
|
||||
@@ -218,16 +218,23 @@
|
||||
(gpt/add resize-origin displacement)
|
||||
resize-origin)
|
||||
|
||||
;; Determine resize direction for grow-type logic
|
||||
resize-direction (cond
|
||||
(or (= handler :left) (= handler :right)) :horizontal
|
||||
(or (= handler :top) (= handler :bottom)) :vertical
|
||||
:else nil)
|
||||
|
||||
;; Calculate new grow-type for text layers
|
||||
new-grow-type (when (cfh/text-shape? shape)
|
||||
(dwm/next-grow-type (dm/get-prop shape :grow-type) resize-direction))
|
||||
|
||||
;; When the horizontal/vertical scale a flex children with auto/fill
|
||||
;; we change it too fixed
|
||||
change-width?
|
||||
(not (mth/close? (dm/get-prop scalev :x) 1))
|
||||
|
||||
change-height?
|
||||
(not (mth/close? (dm/get-prop scalev :y) 1))
|
||||
|
||||
auto-width-text? (and (cfh/text-shape? shape) (= :auto-width (dm/get-prop shape :grow-type)))
|
||||
auto-height-text? (and (cfh/text-shape? shape) (= :auto-height (dm/get-prop shape :grow-type)))]
|
||||
(not (mth/close? (dm/get-prop scalev :y) 1))]
|
||||
|
||||
(cond-> (ctm/empty)
|
||||
(some? displacement)
|
||||
@@ -242,11 +249,9 @@
|
||||
^boolean change-height?
|
||||
(ctm/change-property :layout-item-v-sizing :fix)
|
||||
|
||||
(and auto-width-text? (or change-width? change-height?))
|
||||
(ctm/change-property :grow-type :fixed)
|
||||
|
||||
(and auto-height-text? change-height?)
|
||||
(ctm/change-property :grow-type :fixed)
|
||||
;; Set grow-type if it should change
|
||||
(and new-grow-type (not= new-grow-type (dm/get-prop shape :grow-type)))
|
||||
(ctm/change-property :grow-type new-grow-type)
|
||||
|
||||
^boolean scale-text
|
||||
(ctm/scale-content (dm/get-prop scalev :x)))))
|
||||
|
||||
@@ -102,23 +102,27 @@
|
||||
(print-trace! error)
|
||||
(print-data! error))))
|
||||
|
||||
;; We receive a explicit authentication error;
|
||||
;; If the uri is for workspace, dashboard or view assign the
|
||||
;; exception for the 'Oops' page. Otherwise this explicitly clears
|
||||
;; all profile data and redirect the user to the login page. This is
|
||||
;; here and not in app.main.errors because of circular dependency.
|
||||
;; We receive a explicit authentication error; If the uri is for
|
||||
;; workspace, dashboard, viewer or settings, then assign the exception
|
||||
;; for show the error page. Otherwise this explicitly clears all
|
||||
;; profile data and redirect the user to the login page. This is here
|
||||
;; and not in app.main.errors because of circular dependency.
|
||||
(defmethod ptk/handle-error :authentication
|
||||
[e]
|
||||
(let [msg (tr "errors.auth.unable-to-login")
|
||||
uri (.-href glob/location)
|
||||
show-oops? (or (str/includes? uri "workspace")
|
||||
(str/includes? uri "dashboard")
|
||||
(str/includes? uri "view"))]
|
||||
(if show-oops?
|
||||
(st/async-emit! (rt/assign-exception e))
|
||||
[error]
|
||||
(let [message (tr "errors.auth.unable-to-login")
|
||||
uri (rt/get-current-href)
|
||||
|
||||
show-error?
|
||||
(or (str/includes? uri "workspace")
|
||||
(str/includes? uri "dashboard")
|
||||
(str/includes? uri "view")
|
||||
(str/includes? uri "settings"))]
|
||||
|
||||
(if show-error?
|
||||
(st/async-emit! (rt/assign-exception error))
|
||||
(do
|
||||
(st/emit! (da/logout))
|
||||
(ts/schedule 500 #(st/emit! (ntf/warn msg)))))))
|
||||
(ts/schedule 500 #(st/emit! (ntf/warn message)))))))
|
||||
|
||||
;; Error that happens on an active business model validation does not
|
||||
;; passes an validation (example: profile can't leave a team). From
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
[app.main.ui.onboarding.team-choice :refer [onboarding-team-modal]]
|
||||
[app.main.ui.releases :refer [release-notes-modal]]
|
||||
[app.main.ui.static :as static]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[app.util.theme :as theme]
|
||||
[beicon.v2.core :as rx]
|
||||
@@ -362,6 +363,8 @@
|
||||
;; initialize themes
|
||||
(theme/use-initialize profile)
|
||||
|
||||
(dom/prevent-browser-gesture-navigation!)
|
||||
|
||||
[:& (mf/provider ctx/current-route) {:value route}
|
||||
[:& (mf/provider ctx/current-profile) {:value profile}
|
||||
(if edata
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
[:> cta-power-up*
|
||||
{:top-title (tr "subscription.dashboard.power-up.your-subscription")
|
||||
:top-description (tr "subscription.dashboard.power-up.professional.top-title")
|
||||
:bottom-description (tr "subscription.dashboard.power-up.professional.bottom-description", subscription-href)
|
||||
:bottom-description (tr "subscription.dashboard.power-up.professional.bottom", subscription-href)
|
||||
:has-dropdown true}]
|
||||
|
||||
"unlimited"
|
||||
@@ -75,7 +75,7 @@
|
||||
[:> cta-power-up*
|
||||
{:top-title (tr "subscription.dashboard.power-up.your-subscription")
|
||||
:top-description (tr "subscription.dashboard.power-up.unlimited-plan")
|
||||
:bottom-description (tr "subscription.dashboard.power-up.unlimited.bottom-description", subscription-href)
|
||||
:bottom-description (tr "subscription.dashboard.power-up.unlimited.bottom", subscription-href)
|
||||
:has-dropdown true}])
|
||||
|
||||
"enterprise"
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.dom.normalize-wheel :as nw]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[app.util.keyboard :as kbd]
|
||||
[app.util.storage :as storage]
|
||||
@@ -171,41 +172,48 @@
|
||||
(mf/defc templates-section*
|
||||
{::mf/props :obj}
|
||||
[{:keys [default-project-id profile project-id team-id]}]
|
||||
(let [templates (mf/deref builtin-templates)
|
||||
templates (mf/with-memo [templates]
|
||||
(filterv #(and
|
||||
(not= (:id %) "welcome")
|
||||
(not= (:id %) "tutorial-for-beginners")) templates))
|
||||
(let [templates (mf/deref builtin-templates)
|
||||
templates (mf/with-memo [templates]
|
||||
(filterv #(and
|
||||
(not= (:id %) "welcome")
|
||||
(not= (:id %) "tutorial-for-beginners")) templates))
|
||||
|
||||
route (mf/deref refs/route)
|
||||
route-name (get-in route [:data :name])
|
||||
section (if (= route-name :dashboard-files)
|
||||
(if (= project-id default-project-id)
|
||||
"dashboard-drafts"
|
||||
"dashboard-project")
|
||||
(name route-name))
|
||||
route (mf/deref refs/route)
|
||||
route-name (get-in route [:data :name])
|
||||
section (if (= route-name :dashboard-files)
|
||||
(if (= project-id default-project-id)
|
||||
"dashboard-drafts"
|
||||
"dashboard-project")
|
||||
(name route-name))
|
||||
|
||||
collapsed* (mf/use-state
|
||||
#(get storage/global ::collapsed))
|
||||
collapsed (deref collapsed*)
|
||||
collapsed* (mf/use-state
|
||||
#(get storage/global ::collapsed))
|
||||
collapsed (deref collapsed*)
|
||||
|
||||
|
||||
|
||||
can-move (mf/use-state {:left false :right true})
|
||||
can-move (mf/use-state {:left false :right true})
|
||||
|
||||
total (count templates)
|
||||
total (count templates)
|
||||
|
||||
;; We need space for total plus the libraries&templates link
|
||||
content-ref (mf/use-ref)
|
||||
|
||||
move-left (fn [] (dom/scroll-by! (mf/ref-val content-ref) -300 0))
|
||||
move-right (fn [] (dom/scroll-by! (mf/ref-val content-ref) 300 0))
|
||||
content-ref (mf/use-ref)
|
||||
|
||||
on-toggle-collapse
|
||||
(mf/use-fn
|
||||
(fn [_event]
|
||||
(swap! collapsed* not)))
|
||||
|
||||
on-wheel
|
||||
(mf/use-fn
|
||||
(fn [^js event]
|
||||
(let [event* (nw/normalize-wheel event)
|
||||
deltaY (.-spinY event*)
|
||||
deltaX (.-spinX event*)
|
||||
node (mf/ref-val content-ref)]
|
||||
(when (> (abs deltaY) (abs deltaX))
|
||||
(.scrollBy node #js {:left (* 300 deltaY) :mode "smooth"})))))
|
||||
|
||||
on-scroll
|
||||
(mf/use-fn
|
||||
(fn [e]
|
||||
@@ -219,16 +227,10 @@
|
||||
:right (> scroll-available client-width)}))))
|
||||
|
||||
on-move-left
|
||||
(mf/use-fn #(move-left))
|
||||
|
||||
on-move-left-key-down
|
||||
(mf/use-fn #(move-left))
|
||||
(mf/use-fn #(dom/scroll-by! (mf/ref-val content-ref) -300 0))
|
||||
|
||||
on-move-right
|
||||
(mf/use-fn #(move-right))
|
||||
|
||||
on-move-right-key-down
|
||||
(mf/use-fn #(move-right))
|
||||
(mf/use-fn #(dom/scroll-by! (mf/ref-val content-ref) 300 0))
|
||||
|
||||
on-import-template
|
||||
(mf/use-fn
|
||||
@@ -236,7 +238,7 @@
|
||||
(fn [template _event]
|
||||
(import-template! template team-id project-id default-project-id section)))]
|
||||
|
||||
(mf/with-effect [content-ref templates]
|
||||
(mf/with-effect [templates]
|
||||
(let [content (mf/ref-val content-ref)]
|
||||
(when (and (some? content) (some? templates))
|
||||
(dom/scroll-to content #js {:behavior "instant" :left 0 :top 0})
|
||||
@@ -258,6 +260,7 @@
|
||||
|
||||
[:div {:class (stl/css :content)
|
||||
:on-scroll on-scroll
|
||||
:on-wheel on-wheel
|
||||
:ref content-ref}
|
||||
|
||||
(for [index (range (count templates))]
|
||||
@@ -279,13 +282,13 @@
|
||||
[:button {:class (stl/css :move-button :move-left)
|
||||
:tab-index (if ^boolean collapsed "-1" "0")
|
||||
:on-click on-move-left
|
||||
:on-key-down on-move-left-key-down}
|
||||
:on-key-down on-move-left}
|
||||
arrow-icon])
|
||||
|
||||
(when (:right @can-move)
|
||||
[:button {:class (stl/css :move-button :move-right)
|
||||
:tab-index (if collapsed "-1" "0")
|
||||
:on-click on-move-right
|
||||
:aria-label (tr "labels.next")
|
||||
:on-key-down on-move-right-key-down}
|
||||
:on-key-down on-move-right
|
||||
:aria-label (tr "labels.next")}
|
||||
arrow-icon])]))
|
||||
|
||||
@@ -71,4 +71,5 @@
|
||||
[:div {:on-click on-toggle-detail}
|
||||
(tr "workspace.notification-pill.detail")]]
|
||||
(when show-detail
|
||||
[:div {:class (stl/css :error-detail-content)} detail])])]))
|
||||
[:div {:class (stl/css :error-detail-content)
|
||||
:dangerouslySetInnerHTML #js {:__html detail}}])])]))
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
[app.main.ui.components.title-bar :refer [inspect-title-bar*]]
|
||||
[app.main.ui.inspect.attributes.common :refer [color-row]]
|
||||
[app.util.code-gen.style-css :as css]
|
||||
[app.util.code-gen.style-css-formats :refer [format-color]]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
@@ -22,8 +23,18 @@
|
||||
(defn- shadow-copy-data [shadow]
|
||||
(css/shadow->css shadow))
|
||||
|
||||
(defn- copy-color-data
|
||||
"Converts a fill object to CSS color string in the specified format."
|
||||
[color format]
|
||||
(format-color color {:format format}))
|
||||
|
||||
(mf/defc shadow-block [{:keys [shadow]}]
|
||||
(let [color-format (mf/use-state :hex)]
|
||||
(let [color-format (mf/use-state :hex)
|
||||
color-format* (deref color-format)
|
||||
on-change-format
|
||||
(mf/use-fn
|
||||
(fn [format]
|
||||
(reset! color-format format)))]
|
||||
[:div {:class (stl/css :attributes-shadow-block)}
|
||||
[:div {:class (stl/css :shadow-row)}
|
||||
[:div {:class (stl/css :global/attr-label)} (->> shadow :style d/name (str "workspace.options.shadow-options.") (tr))]
|
||||
@@ -42,7 +53,8 @@
|
||||
|
||||
[:& color-row {:color (:color shadow)
|
||||
:format @color-format
|
||||
:on-change-format #(reset! color-format %)}]]))
|
||||
:copy-data (copy-color-data (:color shadow) color-format*)
|
||||
:on-change-format on-change-format}]]))
|
||||
|
||||
(mf/defc shadow-panel [{:keys [shapes]}]
|
||||
(let [shapes (->> shapes (filter has-shadow?))]
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.text :as txt]
|
||||
[app.common.types.color :as types.color]
|
||||
[app.common.types.color :as ctc]
|
||||
[app.main.fonts :as fonts]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
@@ -18,6 +18,8 @@
|
||||
[app.main.ui.components.title-bar :refer [inspect-title-bar*]]
|
||||
[app.main.ui.formats :as fmt]
|
||||
[app.main.ui.inspect.attributes.common :refer [color-row]]
|
||||
[app.util.code-gen.style-css-formats :refer [format-color]]
|
||||
[app.util.color :as uc]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[cuerdas.core :as str]
|
||||
[okulary.core :as l]
|
||||
@@ -41,6 +43,21 @@
|
||||
(map #(dm/str (d/name %) ": " (get style %) ";"))
|
||||
(str/join "\n")))
|
||||
|
||||
(defn- format-gradient-css
|
||||
"Converts a gradient object to a CSS string."
|
||||
[gradient]
|
||||
(str "background-image: " (uc/gradient->css gradient) ";"
|
||||
"background-clip: text;"
|
||||
"color: transparent;"))
|
||||
|
||||
(defn- copy-color-data
|
||||
"Converts a fill object to CSS color string in the specified format."
|
||||
[fill format]
|
||||
(let [color (ctc/fill->color fill)]
|
||||
(if-let [gradient (:gradient color)]
|
||||
(format-gradient-css gradient)
|
||||
(format-color color {:format format}))))
|
||||
|
||||
(mf/defc typography-block
|
||||
[{:keys [text style]}]
|
||||
(let [typography-library-ref
|
||||
@@ -57,7 +74,8 @@
|
||||
file-library-workspace (get (mf/deref refs/files) (:typography-ref-file style))
|
||||
typography-external-lib (get-in file-library-workspace [:data :typographies (:typography-ref-id style)])
|
||||
|
||||
color-format (mf/use-state :hex)
|
||||
color-format! (mf/use-state :hex)
|
||||
color-format* (deref color-format!)
|
||||
|
||||
typography (or (get (or typography-library file-typographies-viewer file-typographies-workspace) (:typography-ref-id style)) typography-external-lib)]
|
||||
|
||||
@@ -65,10 +83,10 @@
|
||||
(when (:fills style)
|
||||
(for [[idx fill] (map-indexed vector (:fills style))]
|
||||
[:& color-row {:key idx
|
||||
:format @color-format
|
||||
:color (types.color/fill->color fill)
|
||||
:copy-data (copy-style-data fill :fill-color :fill-color-gradient)
|
||||
:on-change-format #(reset! color-format %)}]))
|
||||
:format color-format*
|
||||
:color (ctc/fill->color fill)
|
||||
:copy-data (copy-color-data fill color-format*)
|
||||
:on-change-format #(reset! color-format! %)}]))
|
||||
|
||||
(when (:typography-ref-id style)
|
||||
[:div {:class (stl/css :text-row)}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.main.data.team :as dtm]
|
||||
[app.main.errors :as errors]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.router :as rt]
|
||||
[app.main.store :as st]
|
||||
@@ -130,7 +131,10 @@
|
||||
(assoc query-params :team-id (:default-team-id profile))))))
|
||||
|
||||
:else
|
||||
(st/emit! (rt/assign-exception {:type :not-found})))))))))
|
||||
(st/emit! (rt/assign-exception {:type :not-found}))))
|
||||
|
||||
(fn [cause]
|
||||
(errors/on-error cause)))))))
|
||||
|
||||
(defn init-routes
|
||||
[]
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
(mf/with-effect [profile]
|
||||
(when (nil? profile)
|
||||
(st/emit! (rt/nav :auth-login))))
|
||||
(st/emit! (rt/assign-exception {:type :authentication}))))
|
||||
|
||||
[:*
|
||||
[:> modal-container*]
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.schema :as sm]
|
||||
[app.main.data.auth :as da]
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.profile :as du]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.router :as rt]
|
||||
@@ -61,7 +61,7 @@
|
||||
(mf/defc subscribe-management-dialog
|
||||
{::mf/register modal/components
|
||||
::mf/register-as :management-dialog}
|
||||
[{:keys [subscription-type teams subscribe-to-trial]}]
|
||||
[{:keys [subscription-type current-subscription teams subscribe-to-trial]}]
|
||||
|
||||
(let [subscription-name (if subscribe-to-trial
|
||||
(if (= subscription-type "unlimited")
|
||||
@@ -96,7 +96,7 @@
|
||||
handle-accept-dialog (mf/use-fn
|
||||
(fn []
|
||||
(st/emit! (ptk/event ::ev/event {::ev/name "open-subscription-management"
|
||||
::ev/origin "profile"
|
||||
::ev/origin "settings"
|
||||
:section "subscription-management-modal"}))
|
||||
(let [current-href (rt/get-current-href)
|
||||
returnUrl (js/encodeURIComponent current-href)
|
||||
@@ -126,12 +126,15 @@
|
||||
(tr "subscription.settings.management.dialog.no-teams")])
|
||||
|
||||
(when (and
|
||||
(or (= subscription-type "professional") (= subscription-type "unlimited"))
|
||||
(or (and (= subscription-type "professional") (contains? #{"unlimited" "enterprise"} (:type current-subscription)))
|
||||
(and (= subscription-type "unlimited") (= (:type current-subscription) "enterprise")))
|
||||
(not (contains? #{"unpaid" "canceled"} (:status current-subscription)))
|
||||
(not subscribe-to-trial))
|
||||
[:div {:class (stl/css :modal-text)}
|
||||
(tr "subscription.settings.management.dialog.downgrade")])
|
||||
|
||||
(if (and (= subscription-type "unlimited") subscribe-to-trial)
|
||||
(if (and (= subscription-type "unlimited")
|
||||
(or subscribe-to-trial (contains? #{"unpaid" "canceled"} (:status current-subscription))))
|
||||
[:& fm/form {:on-submit subscribe-to-unlimited
|
||||
:class (stl/css :seats-form)
|
||||
:form form}
|
||||
@@ -160,7 +163,7 @@
|
||||
:on-click handle-close-dialog}]
|
||||
|
||||
[:> fm/submit-button*
|
||||
{:label (tr "subscription.settings.start-trial")
|
||||
{:label (if subscribe-to-trial (tr "subscription.settings.start-trial") (tr "labels.continue"))
|
||||
:class (stl/css :primary-button)}]]]]
|
||||
|
||||
[:div {:class (stl/css :modal-footer)}
|
||||
@@ -212,43 +215,73 @@
|
||||
|
||||
(mf/defc subscription-page*
|
||||
[{:keys [profile]}]
|
||||
(let [route (mf/deref refs/route)
|
||||
params (:params route)
|
||||
params-subscription (:subscription (:query params))
|
||||
show-trial-subscription-modal (or (= params-subscription "subscription-to-penpot-unlimited")
|
||||
(= params-subscription "subscription-to-penpot-enterprise"))
|
||||
show-subscription-success-modal (or (= params-subscription "subscribed-to-penpot-unlimited")
|
||||
(= params-subscription "subscribed-to-penpot-enterprise"))
|
||||
subscription (:subscription (:props profile))
|
||||
subscription-type (get-subscription-type subscription)
|
||||
subscription-is-trial (= (:status subscription) "trialing")
|
||||
teams* (mf/use-state nil)
|
||||
teams (deref teams*)
|
||||
locale (mf/deref i18n/locale)
|
||||
penpot-member (dt/format-date-locale-short (:created-at profile) {:locale locale})
|
||||
subscription-member (dt/format-date-locale-short (:start-date subscription) {:locale locale})
|
||||
go-to-pricing-page (mf/use-fn
|
||||
(fn []
|
||||
(st/emit! (ptk/event ::ev/event {::ev/name "explore-pricing-click" ::ev/origin "settings" :section "subscription"}))
|
||||
(dom/open-new-window "https://penpot.app/pricing")))
|
||||
go-to-payments (mf/use-fn
|
||||
(fn []
|
||||
(st/emit! (ptk/event ::ev/event {::ev/name "open-subscription-management"
|
||||
::ev/origin "profile"
|
||||
:section "subscription"}))
|
||||
(let [current-href (rt/get-current-href)
|
||||
returnUrl (js/encodeURIComponent current-href)
|
||||
href (dm/str "payments/subscriptions/show?returnUrl=" returnUrl)]
|
||||
(st/emit! (rt/nav-raw :href href)))))
|
||||
open-subscription-modal (mf/use-fn
|
||||
(mf/deps teams)
|
||||
(fn [subscription-type]
|
||||
(st/emit! (ptk/event ::ev/event {::ev/name "open-subscription-modal"
|
||||
::ev/origin "settings:in-app"}))
|
||||
(st/emit!
|
||||
(modal/show :management-dialog
|
||||
{:subscription-type subscription-type
|
||||
:teams teams :subscribe-to-trial (not subscription)}))))]
|
||||
(let [route (mf/deref refs/route)
|
||||
authenticated? (da/is-authenticated? profile)
|
||||
|
||||
teams* (mf/use-state nil)
|
||||
teams (deref teams*)
|
||||
|
||||
locale (mf/deref i18n/locale)
|
||||
|
||||
params-subscription
|
||||
(-> route :params :query :subscription)
|
||||
|
||||
show-trial-subscription-modal?
|
||||
(or (= params-subscription "subscription-to-penpot-unlimited")
|
||||
(= params-subscription "subscription-to-penpot-enterprise"))
|
||||
|
||||
show-subscription-success-modal?
|
||||
(or (= params-subscription "subscribed-to-penpot-unlimited")
|
||||
(= params-subscription "subscribed-to-penpot-enterprise"))
|
||||
|
||||
success-modal-is-trial?
|
||||
(-> route :params :query :trial)
|
||||
|
||||
subscription
|
||||
(-> profile :props :subscription)
|
||||
|
||||
subscription-type
|
||||
(get-subscription-type subscription)
|
||||
|
||||
subscription-is-trial?
|
||||
(= (:status subscription) "trialing")
|
||||
|
||||
member-since
|
||||
(dt/format-date-locale-short (:created-at profile) {:locale locale})
|
||||
|
||||
subscribed-since
|
||||
(dt/format-date-locale-short (:start-date subscription) {:locale locale})
|
||||
|
||||
go-to-pricing-page
|
||||
(mf/use-fn
|
||||
(fn []
|
||||
(st/emit! (ev/event {::ev/name "explore-pricing-click"
|
||||
::ev/origin "settings"
|
||||
:section "subscription"}))
|
||||
(dom/open-new-window "https://penpot.app/pricing")))
|
||||
|
||||
go-to-payments
|
||||
(mf/use-fn
|
||||
(fn []
|
||||
(st/emit! (ev/event {::ev/name "open-subscription-management"
|
||||
::ev/origin "settings"
|
||||
:section "subscription"}))
|
||||
(let [current-href (rt/get-current-href)
|
||||
returnUrl (js/encodeURIComponent current-href)
|
||||
href (dm/str "payments/subscriptions/show?returnUrl=" returnUrl)]
|
||||
(st/emit! (rt/nav-raw :href href)))))
|
||||
|
||||
open-subscription-modal
|
||||
(mf/use-fn
|
||||
(mf/deps teams)
|
||||
(fn [subscription-type current-subscription]
|
||||
(st/emit! (ev/event {::ev/name "open-subscription-modal"
|
||||
::ev/origin "settings:in-app"}))
|
||||
(st/emit!
|
||||
(modal/show :management-dialog
|
||||
{:subscription-type subscription-type
|
||||
:current-subscription current-subscription
|
||||
:teams teams :subscribe-to-trial (not subscription)}))))]
|
||||
|
||||
(mf/with-effect []
|
||||
(->> (rp/cmd! :get-owned-teams)
|
||||
@@ -258,33 +291,34 @@
|
||||
(mf/with-effect []
|
||||
(dom/set-html-title (tr "subscription.labels")))
|
||||
|
||||
(mf/with-effect [show-trial-subscription-modal subscription]
|
||||
(when show-trial-subscription-modal
|
||||
(st/emit!
|
||||
(ptk/event ::ev/event {::ev/name "open-subscription-modal"
|
||||
::ev/origin "settings:from-pricing-page"})
|
||||
(modal/show :management-dialog
|
||||
{:subscription-type (if (= params-subscription "subscription-to-penpot-unlimited")
|
||||
"unlimited"
|
||||
"enterprise")
|
||||
:teams teams
|
||||
:subscribe-to-trial (not subscription)})
|
||||
(rt/nav :settings-subscription {} {::rt/replace true}))))
|
||||
(mf/with-effect [authenticated? show-subscription-success-modal? show-trial-subscription-modal? success-modal-is-trial? subscription]
|
||||
(when ^boolean authenticated?
|
||||
(cond
|
||||
^boolean show-trial-subscription-modal?
|
||||
|
||||
(mf/with-effect [show-subscription-success-modal subscription]
|
||||
(when show-subscription-success-modal
|
||||
(st/emit!
|
||||
(modal/show :subscription-success
|
||||
{:subscription-name (if (= params-subscription "subscribed-to-penpot-unlimited")
|
||||
(tr "subscription.settings.unlimited-trial")
|
||||
(tr "subscription.settings.enterprise-trial"))})
|
||||
(du/update-profile-props {:subscription
|
||||
(-> subscription
|
||||
(assoc :type (if (= params-subscription "subscribed-to-penpot-unlimited")
|
||||
"unlimited"
|
||||
"enterprise"))
|
||||
(assoc :status "trialing"))})
|
||||
(rt/nav :settings-subscription {} {::rt/replace true}))))
|
||||
(st/emit!
|
||||
(ptk/event ::ev/event {::ev/name "open-subscription-modal"
|
||||
::ev/origin "settings:from-pricing-page"})
|
||||
(modal/show :management-dialog
|
||||
{:subscription-type (if (= params-subscription "subscription-to-penpot-unlimited")
|
||||
"unlimited"
|
||||
"enterprise")
|
||||
:current-subscription subscription
|
||||
:teams teams
|
||||
:subscribe-to-trial (not subscription)})
|
||||
(rt/nav :settings-subscription {} {::rt/replace true}))
|
||||
|
||||
^boolean show-subscription-success-modal?
|
||||
(st/emit!
|
||||
(modal/show :subscription-success
|
||||
{:subscription-name (if (= params-subscription "subscribed-to-penpot-unlimited")
|
||||
(if (= success-modal-is-trial? "true")
|
||||
(tr "subscription.settings.unlimited-trial")
|
||||
(tr "subscription.settings.unlimited"))
|
||||
(if (= success-modal-is-trial? "true")
|
||||
(tr "subscription.settings.enterprise-trial")
|
||||
(tr "subscription.settings.enterprise")))})
|
||||
(rt/nav :settings-subscription {} {::rt/replace true})))))
|
||||
|
||||
[:section {:class (stl/css :dashboard-section)}
|
||||
[:div {:class (stl/css :dashboard-content)}
|
||||
@@ -298,16 +332,16 @@
|
||||
[:> plan-card* {:card-title (tr "subscription.settings.professional")
|
||||
:benefits [(tr "subscription.settings.professional.projects-files"),
|
||||
(tr "subscription.settings.professional.teams-editors"),
|
||||
(tr "subscription.settings.professional.storage")]}]
|
||||
(tr "subscription.settings.professional.storage-autosave")]}]
|
||||
|
||||
"unlimited"
|
||||
(if subscription-is-trial
|
||||
(if subscription-is-trial?
|
||||
[:> plan-card* {:card-title (tr "subscription.settings.unlimited-trial")
|
||||
:card-title-icon i/character-u
|
||||
:benefits-title (tr "subscription.settings.benefits.all-professional-benefits")
|
||||
:benefits [(tr "subscription.settings.unlimited.teams"),
|
||||
(tr "subscription.settings.unlimited.bill"),
|
||||
(tr "subscription.settings.unlimited.storage")]
|
||||
(tr "subscription.settings.unlimited.storage-autosave")]
|
||||
:cta-text (tr "subscription.settings.manage-your-subscription")
|
||||
:cta-link go-to-payments
|
||||
:cta-text-trial (tr "subscription.settings.add-payment-to-continue")
|
||||
@@ -319,38 +353,41 @@
|
||||
:benefits-title (tr "subscription.settings.benefits.all-unlimited-benefits")
|
||||
:benefits [(tr "subscription.settings.unlimited.teams"),
|
||||
(tr "subscription.settings.unlimited.bill"),
|
||||
(tr "subscription.settings.unlimited.storage")]
|
||||
(tr "subscription.settings.unlimited.storage-autosave")]
|
||||
:cta-text (tr "subscription.settings.manage-your-subscription")
|
||||
:cta-link go-to-payments
|
||||
:editors (-> profile :props :subscription :quantity)}])
|
||||
|
||||
"enterprise"
|
||||
(if subscription-is-trial
|
||||
(if subscription-is-trial?
|
||||
[:> plan-card* {:card-title (tr "subscription.settings.enterprise-trial")
|
||||
:card-title-icon i/character-e
|
||||
:benefits-title (tr "subscription.settings.benefits.all-professional-benefits")
|
||||
:benefits [(tr "subscription.settings.enterprise.support"),
|
||||
(tr "subscription.settings.enterprise.security"),
|
||||
(tr "subscription.settings.enterprise.logs")]
|
||||
:benefits [(tr "subscription.settings.enterprise.security"),
|
||||
(tr "subscription.settings.enterprise.capped-bill"),
|
||||
(tr "subscription.settings.enterprise.unlimited-storage")]
|
||||
:cta-text (tr "subscription.settings.manage-your-subscription")
|
||||
:cta-link go-to-payments}]
|
||||
[:> plan-card* {:card-title (tr "subscription.settings.enterprise")
|
||||
:card-title-icon i/character-e
|
||||
:benefits-title (tr "subscription.settings.benefits.all-professional-benefits")
|
||||
:benefits [(tr "subscription.settings.enterprise.support"),
|
||||
(tr "subscription.settings.enterprise.security"),
|
||||
(tr "subscription.settings.enterprise.logs")]
|
||||
:benefits [(tr "subscription.settings.enterprise.security"),
|
||||
(tr "subscription.settings.enterprise.capped-bill"),
|
||||
(tr "subscription.settings.enterprise.unlimited-storage")]
|
||||
:cta-text (tr "subscription.settings.manage-your-subscription")
|
||||
:cta-link go-to-payments}]))
|
||||
|
||||
[:div {:class (stl/css :membership-container)}
|
||||
(when subscription-member [:div {:class (stl/css :membership)}
|
||||
[:span {:class (stl/css :subscription-member)} i/crown]
|
||||
[:span {:class (stl/css :membership-date)} (tr "subscription.settings.support-us-since" subscription-member)]])
|
||||
(when (and subscribed-since (not= subscription-type "professional"))
|
||||
[:div {:class (stl/css :membership)}
|
||||
[:span {:class (stl/css :subscription-member)} i/crown]
|
||||
[:span {:class (stl/css :membership-date)}
|
||||
(tr "subscription.settings.support-us-since" subscribed-since)]])
|
||||
|
||||
[:div {:class (stl/css :membership)}
|
||||
[:span {:class (stl/css :penpot-member)} i/user]
|
||||
[:span {:class (stl/css :membership-date)} (tr "subscription.settings.member-since" penpot-member)]]]]
|
||||
[:span {:class (stl/css :membership-date)}
|
||||
(tr "subscription.settings.member-since" member-since)]]]]
|
||||
|
||||
[:div {:class (stl/css :other-subscriptions)}
|
||||
[:h3 {:class (stl/css :plan-section-title)} (tr "subscription.settings.other-plans")]
|
||||
@@ -360,7 +397,7 @@
|
||||
:price-period (tr "subscription.settings.price-editor-month")
|
||||
:benefits [(tr "subscription.settings.professional.projects-files"),
|
||||
(tr "subscription.settings.professional.teams-editors"),
|
||||
(tr "subscription.settings.professional.storage")]
|
||||
(tr "subscription.settings.professional.storage-autosave")]
|
||||
:cta-text (tr "subscription.settings.subscribe")
|
||||
:cta-link #(open-subscription-modal "professional")
|
||||
:cta-text-with-icon (tr "subscription.settings.more-information")
|
||||
@@ -374,9 +411,9 @@
|
||||
:benefits-title (tr "subscription.settings.benefits.all-professional-benefits")
|
||||
:benefits [(tr "subscription.settings.unlimited.teams"),
|
||||
(tr "subscription.settings.unlimited.bill"),
|
||||
(tr "subscription.settings.unlimited.storage")]
|
||||
(tr "subscription.settings.unlimited.storage-autosave")]
|
||||
:cta-text (if subscription (tr "subscription.settings.subscribe") (tr "subscription.settings.try-it-free"))
|
||||
:cta-link #(open-subscription-modal "unlimited")
|
||||
:cta-link #(open-subscription-modal "unlimited" subscription-type)
|
||||
:cta-text-with-icon (tr "subscription.settings.more-information")
|
||||
:cta-link-with-icon go-to-pricing-page}])
|
||||
|
||||
@@ -385,10 +422,10 @@
|
||||
:card-title-icon i/character-e
|
||||
:price-value "$950"
|
||||
:price-period (tr "subscription.settings.price-organization-month")
|
||||
:benefits-title (tr "subscription.settings.benefits.all-professional-benefits")
|
||||
:benefits [(tr "subscription.settings.enterprise.support"),
|
||||
(tr "subscription.settings.enterprise.security"),
|
||||
(tr "subscription.settings.enterprise.logs")]
|
||||
:benefits-title (tr "subscription.settings.benefits.all-unlimited-benefits")
|
||||
:benefits [(tr "subscription.settings.enterprise.security"),
|
||||
(tr "subscription.settings.enterprise.capped-bill"),
|
||||
(tr "subscription.settings.enterprise.unlimited-storage")]
|
||||
:cta-text (if subscription (tr "subscription.settings.subscribe") (tr "subscription.settings.try-it-free"))
|
||||
:cta-link #(open-subscription-modal "enterprise")
|
||||
:cta-text-with-icon (tr "subscription.settings.more-information")
|
||||
|
||||
@@ -69,9 +69,8 @@
|
||||
[:div {:class (stl/css :main-message)} (tr "errors.invite-invalid")]
|
||||
[:div {:class (stl/css :desc-message)} (tr "errors.invite-invalid.info")]])
|
||||
|
||||
(mf/defc login-dialog
|
||||
{::mf/props :obj}
|
||||
[{:keys [show-dialog]}]
|
||||
(mf/defc login-dialog*
|
||||
[]
|
||||
(let [current-section (mf/use-state :login)
|
||||
user-email (mf/use-state "")
|
||||
register-token (mf/use-state "")
|
||||
@@ -94,9 +93,7 @@
|
||||
|
||||
success-login
|
||||
(mf/use-fn
|
||||
(fn []
|
||||
(reset! show-dialog false)
|
||||
(st/emit! (rt/reload true))))
|
||||
#(st/emit! (rt/reload true)))
|
||||
|
||||
success-register
|
||||
(mf/use-fn
|
||||
@@ -117,7 +114,7 @@
|
||||
(reset! current-section :recovery-email-sent)))
|
||||
|
||||
on-nav-root
|
||||
(mf/use-fn #(st/emit! (rt/nav-root)))]
|
||||
(mf/use-fn #(st/emit! (rt/nav :auth-login {})))]
|
||||
|
||||
[:div {:class (stl/css :overlay)}
|
||||
[:div {:class (stl/css :dialog-login)}
|
||||
@@ -203,11 +200,9 @@
|
||||
[:button {:on-click on-click} button-text]]]]))
|
||||
|
||||
(mf/defc request-access*
|
||||
[{:keys [file-id team-id is-default is-workspace]}]
|
||||
(let [profile (mf/deref refs/profile)
|
||||
requested* (mf/use-state {:sent false :already-requested false})
|
||||
[{:keys [file-id team-id is-default is-workspace profile]}]
|
||||
(let [requested* (mf/use-state {:sent false :already-requested false})
|
||||
requested (deref requested*)
|
||||
show-dialog (mf/use-state true)
|
||||
|
||||
on-close
|
||||
(mf/use-fn
|
||||
@@ -237,90 +232,47 @@
|
||||
(st/emit! (dcm/create-team-access-request
|
||||
(with-meta params mdata))))))]
|
||||
|
||||
[:*
|
||||
(if (some? file-id)
|
||||
(if is-workspace
|
||||
[:div {:class (stl/css :workspace)}
|
||||
[:div {:class (stl/css :workspace-left)}
|
||||
i/logo-icon
|
||||
[:div
|
||||
[:div {:class (stl/css :project-name)} (tr "not-found.no-permission.project-name")]
|
||||
[:div {:class (stl/css :file-name)} (tr "not-found.no-permission.penpot-file")]]]
|
||||
[:div {:class (stl/css :workspace-right)}]]
|
||||
(cond
|
||||
is-default
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.project")
|
||||
:button-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
|
||||
[:div {:class (stl/css :viewer)}
|
||||
;; FIXME: the viewer header was never designed to be reused
|
||||
;; from other parts of the application, and this code looks
|
||||
;; like a fast workaround reusing it as-is without a proper
|
||||
;; component adaptation for be able to use it easily it on
|
||||
;; viewer context or static error page context
|
||||
[:& viewer.header/header {:project
|
||||
{:name (tr "not-found.no-permission.project-name")}
|
||||
:index 0
|
||||
:file {:name (tr "not-found.no-permission.penpot-file")}
|
||||
:page nil
|
||||
:frame nil
|
||||
:permissions {:is-logged true}
|
||||
:zoom 1
|
||||
:section :interactions
|
||||
:shown-thumbnails false
|
||||
:interactions-mode nil}]])
|
||||
(and (some? file-id) (:already-requested requested))
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.already-requested.file")
|
||||
:content [(tr "not-found.no-permission.already-requested.or-others.file")]
|
||||
:button-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
|
||||
[:div {:class (stl/css :dashboard)}
|
||||
[:div {:class (stl/css :dashboard-sidebar)}
|
||||
[:> sidebar*
|
||||
{:team nil
|
||||
:projects []
|
||||
:project (:default-project-id profile)
|
||||
:profile profile
|
||||
:section :dashboard-projects
|
||||
:search-term ""}]]])
|
||||
(:already-requested requested)
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.already-requested.project")
|
||||
:content [(tr "not-found.no-permission.already-requested.or-others.project")]
|
||||
:button-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
|
||||
(when @show-dialog
|
||||
(cond
|
||||
(nil? profile)
|
||||
[:& login-dialog {:show-dialog show-dialog}]
|
||||
(:sent requested)
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.done.success")
|
||||
:content [(tr "not-found.no-permission.done.remember")]
|
||||
:button-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
|
||||
is-default
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.project")
|
||||
:button-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
(some? file-id)
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.file")
|
||||
:content [(tr "not-found.no-permission.you-can-ask.file")
|
||||
(tr "not-found.no-permission.if-approves")]
|
||||
:button-text (tr "not-found.no-permission.ask")
|
||||
:on-button-click on-request-access
|
||||
:cancel-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
|
||||
(and (some? file-id) (:already-requested requested))
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.already-requested.file")
|
||||
:content [(tr "not-found.no-permission.already-requested.or-others.file")]
|
||||
:button-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
|
||||
(:already-requested requested)
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.already-requested.project")
|
||||
:content [(tr "not-found.no-permission.already-requested.or-others.project")]
|
||||
:button-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
|
||||
(:sent requested)
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.done.success")
|
||||
:content [(tr "not-found.no-permission.done.remember")]
|
||||
:button-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
|
||||
(some? file-id)
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.file")
|
||||
:content [(tr "not-found.no-permission.you-can-ask.file")
|
||||
(tr "not-found.no-permission.if-approves")]
|
||||
:button-text (tr "not-found.no-permission.ask")
|
||||
:on-button-click on-request-access
|
||||
:cancel-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]
|
||||
|
||||
(some? team-id)
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.project")
|
||||
:content [(tr "not-found.no-permission.you-can-ask.project")
|
||||
(tr "not-found.no-permission.if-approves")]
|
||||
:button-text (tr "not-found.no-permission.ask")
|
||||
:on-button-click on-request-access
|
||||
:cancel-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}]))]))
|
||||
(some? team-id)
|
||||
[:& request-dialog {:title (tr "not-found.no-permission.project")
|
||||
:content [(tr "not-found.no-permission.you-can-ask.project")
|
||||
(tr "not-found.no-permission.if-approves")]
|
||||
:button-text (tr "not-found.no-permission.ask")
|
||||
:on-button-click on-request-access
|
||||
:cancel-text (tr "not-found.no-permission.go-dashboard")
|
||||
:on-close on-close}])))
|
||||
|
||||
(mf/defc not-found*
|
||||
[]
|
||||
@@ -484,29 +436,77 @@
|
||||
|
||||
[:> internal-error* props])))
|
||||
|
||||
(mf/defc context-wrapper*
|
||||
[{:keys [is-workspace is-dashboard is-viewer profile children]}]
|
||||
[:*
|
||||
(cond
|
||||
is-workspace
|
||||
[:div {:class (stl/css :workspace)}
|
||||
[:div {:class (stl/css :workspace-left)}
|
||||
i/logo-icon
|
||||
[:div
|
||||
[:div {:class (stl/css :project-name)} (tr "not-found.no-permission.project-name")]
|
||||
[:div {:class (stl/css :file-name)} (tr "not-found.no-permission.penpot-file")]]]
|
||||
[:div {:class (stl/css :workspace-right)}]]
|
||||
|
||||
is-viewer
|
||||
[:div {:class (stl/css :viewer)}
|
||||
;; FIXME: the viewer header was never designed to be reused
|
||||
;; from other parts of the application, and this code looks
|
||||
;; like a fast workaround reusing it as-is without a proper
|
||||
;; component adaptation for be able to use it easily it on
|
||||
;; viewer context or static error page context
|
||||
[:& viewer.header/header {:project
|
||||
{:name (tr "not-found.no-permission.project-name")}
|
||||
:index 0
|
||||
:file {:name (tr "not-found.no-permission.penpot-file")}
|
||||
:page nil
|
||||
:frame nil
|
||||
:permissions {:is-logged true}
|
||||
:zoom 1
|
||||
:section :interactions
|
||||
:shown-thumbnails false
|
||||
:interactions-mode nil}]]
|
||||
|
||||
is-dashboard
|
||||
[:div {:class (stl/css :dashboard)}
|
||||
[:div {:class (stl/css :dashboard-sidebar)}
|
||||
[:> sidebar*
|
||||
{:team nil
|
||||
:projects []
|
||||
:project (:default-project-id profile)
|
||||
:profile profile
|
||||
:section :dashboard-projects
|
||||
:search-term ""}]]])
|
||||
|
||||
children])
|
||||
|
||||
(mf/defc exception-page*
|
||||
{::mf/props :obj}
|
||||
[{:keys [data route] :as props}]
|
||||
|
||||
(let [type (:type data)
|
||||
path (:path route)
|
||||
(let [type (:type data)
|
||||
path (:path route)
|
||||
|
||||
params (:query-params route)
|
||||
params (:query-params route)
|
||||
|
||||
workspace? (str/includes? path "workspace")
|
||||
dashboard? (str/includes? path "dashboard")
|
||||
view? (str/includes? path "view")
|
||||
workspace? (str/includes? path "workspace")
|
||||
dashboard? (str/includes? path "dashboard")
|
||||
view? (str/includes? path "view")
|
||||
|
||||
;; We store the request access info int this state
|
||||
info* (mf/use-state nil)
|
||||
info (deref info*)
|
||||
info* (mf/use-state nil)
|
||||
info (deref info*)
|
||||
|
||||
loaded? (get info :loaded false)
|
||||
loaded? (get info :loaded false)
|
||||
profile (mf/deref refs/profile)
|
||||
|
||||
auth-error?
|
||||
(= type :authentication)
|
||||
|
||||
request-access?
|
||||
(and
|
||||
(or (= type :not-found)
|
||||
(= type :authentication))
|
||||
(or (= type :not-found) auth-error?)
|
||||
(or workspace? dashboard? view?)
|
||||
(or (:file-id info)
|
||||
(:team-id info)))]
|
||||
@@ -517,11 +517,25 @@
|
||||
(rx/subs! (partial reset! info*)
|
||||
(partial reset! info* {:loaded true})))))
|
||||
|
||||
(when loaded?
|
||||
(if request-access?
|
||||
[:> request-access* {:file-id (:file-id info)
|
||||
:team-id (:team-id info)
|
||||
:is-default (:team-default info)
|
||||
:is-workspace workspace?}]
|
||||
[:> exception-section* props]))))
|
||||
|
||||
(if auth-error?
|
||||
[:> context-wrapper*
|
||||
{:is-workspace workspace?
|
||||
:is-dashboard dashboard?
|
||||
:is-viewer view?
|
||||
:profile profile}
|
||||
[:> login-dialog* {}]]
|
||||
|
||||
(when loaded?
|
||||
(if request-access?
|
||||
[:> context-wrapper* {:is-workspace workspace?
|
||||
:is-dashboard dashboard?
|
||||
:is-viewer view?
|
||||
:profile profile}
|
||||
[:> request-access* {:file-id (:file-id info)
|
||||
:team-id (:team-id info)
|
||||
:is-default (:team-default info)
|
||||
:is-workspace workspace?}]]
|
||||
|
||||
[:> exception-section* props])))))
|
||||
|
||||
|
||||
@@ -593,8 +593,7 @@
|
||||
close-dialog
|
||||
(mf/use-fn
|
||||
(fn [_]
|
||||
(modal/hide!)
|
||||
(modal/disallow-click-outside!)))
|
||||
(modal/hide!)))
|
||||
|
||||
selected-tab*
|
||||
(mf/use-state #(d/nilv starting-tab "libraries"))
|
||||
|
||||
@@ -129,8 +129,7 @@
|
||||
(mf/use-fn
|
||||
(mf/deps file-id)
|
||||
(fn []
|
||||
(modal/show! :libraries-dialog {:file-id file-id})
|
||||
(modal/allow-click-outside!)))
|
||||
(modal/show! :libraries-dialog {:file-id file-id})))
|
||||
|
||||
on-open-menu
|
||||
(mf/use-fn #(swap! filters* update :open-menu not))
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
(:require-macros [app.main.style :as stl])
|
||||
(:require
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace :as udw]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.numeric-input :refer [numeric-input*]]
|
||||
@@ -49,20 +50,23 @@
|
||||
|
||||
handle-add
|
||||
(mf/use-fn
|
||||
(mf/deps change!)
|
||||
(mf/deps change! ids)
|
||||
(fn []
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(change! #(assoc % :blur (create-blur)))))
|
||||
|
||||
handle-delete
|
||||
(mf/use-fn
|
||||
(mf/deps change!)
|
||||
(mf/deps change! ids)
|
||||
(fn []
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(change! #(dissoc % :blur))))
|
||||
|
||||
handle-change
|
||||
(mf/use-fn
|
||||
(mf/deps change!)
|
||||
(mf/deps change! ids)
|
||||
(fn [value]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(change! #(cond-> %
|
||||
(not (contains? % :blur))
|
||||
(assoc :blur (create-blur))
|
||||
@@ -72,8 +76,9 @@
|
||||
|
||||
handle-toggle-visibility
|
||||
(mf/use-fn
|
||||
(mf/deps change!)
|
||||
(mf/deps change! ids)
|
||||
(fn []
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(change! #(update-in % [:blur :hidden] not))))]
|
||||
|
||||
[:div {:class (stl/css :element-set)}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
[app.common.types.fill :as types.fill]
|
||||
[app.common.types.shape.attrs :refer [default-color]]
|
||||
[app.config :as cfg]
|
||||
[app.main.data.workspace :as udw]
|
||||
[app.main.data.workspace.colors :as dc]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.title-bar :refer [title-bar]]
|
||||
@@ -114,6 +115,7 @@
|
||||
(mf/deps ids multiple? empty-fills?)
|
||||
(fn [_]
|
||||
(when can-add-fills?
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/add-fill ids {:color default-color
|
||||
:opacity 1}))
|
||||
(when (or multiple? empty-fills?)
|
||||
@@ -124,6 +126,7 @@
|
||||
(mf/deps ids)
|
||||
(fn [color index]
|
||||
(let [color (select-keys color ctc/color-attrs)]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/change-fill ids color index)))))
|
||||
|
||||
on-reorder
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
(wasm.api/use-shape (:id shape))
|
||||
(wasm.api/set-shape-blend-mode value)))
|
||||
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dw/set-preview-blend-mode ids value))))
|
||||
|
||||
handle-blend-mode-leave
|
||||
@@ -101,33 +102,38 @@
|
||||
|
||||
handle-opacity-change
|
||||
(mf/use-fn
|
||||
(mf/deps on-change)
|
||||
(mf/deps on-change ids)
|
||||
(fn [value]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(let [value (/ value 100)]
|
||||
(on-change :opacity value))))
|
||||
|
||||
handle-set-hidden
|
||||
(mf/use-fn
|
||||
(mf/deps on-change)
|
||||
(mf/deps on-change ids)
|
||||
(fn [_]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(on-change :hidden true)))
|
||||
|
||||
handle-set-visible
|
||||
(mf/use-fn
|
||||
(mf/deps on-change)
|
||||
(mf/deps on-change ids)
|
||||
(fn [_]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(on-change :hidden false)))
|
||||
|
||||
handle-set-blocked
|
||||
(mf/use-fn
|
||||
(mf/deps on-change)
|
||||
(mf/deps on-change ids)
|
||||
(fn [_]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(on-change :blocked true)))
|
||||
|
||||
handle-set-unblocked
|
||||
(mf/use-fn
|
||||
(mf/deps on-change)
|
||||
(mf/deps on-change ids)
|
||||
(fn [_]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(on-change :blocked false)))
|
||||
|
||||
options
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.types.shape.shadow :as ctss]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.colors :as dc]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
@@ -80,31 +81,56 @@
|
||||
(mf/use-fn (mf/deps index) #(on-remove index))
|
||||
|
||||
on-update-offset-x
|
||||
(mf/use-fn (mf/deps index) #(on-update index :offset-x %))
|
||||
(mf/use-fn
|
||||
(mf/deps index)
|
||||
(fn [value]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking [shadow-id]))
|
||||
(on-update index :offset-x value)))
|
||||
|
||||
on-update-offset-y
|
||||
(mf/use-fn (mf/deps index) #(on-update index :offset-y %))
|
||||
(mf/use-fn
|
||||
(mf/deps index)
|
||||
(fn [value]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking [shadow-id]))
|
||||
(on-update index :offset-y value)))
|
||||
|
||||
on-update-spread
|
||||
(mf/use-fn (mf/deps index) #(on-update index :spread %))
|
||||
(mf/use-fn
|
||||
(mf/deps index)
|
||||
(fn [value]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking [shadow-id]))
|
||||
(on-update index :spread value)))
|
||||
|
||||
on-update-blur
|
||||
(mf/use-fn (mf/deps index) #(on-update index :blur %))
|
||||
(mf/use-fn
|
||||
(mf/deps index)
|
||||
(fn [value]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking [shadow-id]))
|
||||
(on-update index :blur value)))
|
||||
|
||||
on-update-color
|
||||
(mf/use-fn
|
||||
(mf/deps index on-update)
|
||||
(fn [color]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking [shadow-id]))
|
||||
(on-update index :color color)))
|
||||
|
||||
on-detach-color
|
||||
(mf/use-fn (mf/deps index) #(on-detach-color index))
|
||||
|
||||
on-style-change
|
||||
(mf/use-fn (mf/deps index) #(on-update index :style (keyword %)))
|
||||
(mf/use-fn
|
||||
(mf/deps index)
|
||||
(fn [value]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking [shadow-id]))
|
||||
(on-update index :style (keyword value))))
|
||||
|
||||
on-toggle-visibility
|
||||
(mf/use-fn (mf/deps index) #(on-toggle-visibility index))
|
||||
(mf/use-fn
|
||||
(mf/deps index)
|
||||
(fn []
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking [shadow-id]))
|
||||
(on-toggle-visibility index)))
|
||||
|
||||
on-toggle-open
|
||||
(mf/use-fn
|
||||
@@ -242,18 +268,21 @@
|
||||
(mf/use-fn
|
||||
(fn []
|
||||
(let [ids (mf/ref-val ids-ref)]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dwsh/update-shapes ids #(dissoc % :shadow))))))
|
||||
|
||||
handle-reorder
|
||||
(mf/use-fn
|
||||
(fn [new-index index]
|
||||
(let [ids (mf/ref-val ids-ref)]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/reorder-shadows ids index new-index)))))
|
||||
|
||||
on-add-shadow
|
||||
(mf/use-fn
|
||||
(fn []
|
||||
(let [ids (mf/ref-val ids-ref)]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/add-shadow ids (create-shadow))))))
|
||||
|
||||
on-detach-color
|
||||
@@ -261,18 +290,22 @@
|
||||
(fn [index]
|
||||
(let [ids (mf/ref-val ids-ref)
|
||||
f #(update-in % [:shadow index :color] dissoc :id :file-id :ref-id :ref-file)]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dwsh/update-shapes ids f)))))
|
||||
|
||||
on-toggle-visibility
|
||||
(mf/use-fn
|
||||
(fn [index]
|
||||
(let [ids (mf/ref-val ids-ref)]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dwsh/update-shapes ids #(update-in % [:shadow index :hidden] not))))))
|
||||
|
||||
on-remove
|
||||
(mf/use-fn
|
||||
(mf/deps ids)
|
||||
(fn [index]
|
||||
(let [ids (mf/ref-val ids-ref)]
|
||||
(st/emit! (dw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dwsh/update-shapes ids #(update % :shadow remove-shadow-by-index index))))))
|
||||
|
||||
on-update
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
[app.common.colors :as clr]
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.main.data.workspace :as udw]
|
||||
[app.main.data.workspace.colors :as dc]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.title-bar :refer [title-bar]]
|
||||
@@ -56,6 +57,7 @@
|
||||
(mf/use-fn
|
||||
(mf/deps ids)
|
||||
(fn [index color]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/change-stroke-color ids color index))))
|
||||
|
||||
|
||||
@@ -63,18 +65,21 @@
|
||||
(mf/use-fn
|
||||
(mf/deps ids)
|
||||
(fn [index]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/remove-stroke ids index))))
|
||||
|
||||
handle-remove-all
|
||||
(mf/use-fn
|
||||
(mf/deps ids)
|
||||
(fn [_]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/remove-all-strokes ids))))
|
||||
|
||||
on-color-detach
|
||||
(mf/use-fn
|
||||
(mf/deps ids)
|
||||
(fn [index color]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(let [color (-> color
|
||||
(dissoc :ref-id :ref-file))]
|
||||
(st/emit! (dc/change-stroke-color ids color index)))))
|
||||
@@ -84,22 +89,26 @@
|
||||
(mf/deps ids)
|
||||
(fn [new-index]
|
||||
(fn [index]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/reorder-strokes ids index new-index)))))
|
||||
|
||||
on-stroke-style-change
|
||||
(mf/use-fn
|
||||
(mf/deps ids)
|
||||
(fn [index value]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/change-stroke-attrs ids {:stroke-style value} index))))
|
||||
|
||||
on-stroke-alignment-change
|
||||
(fn [index value]
|
||||
(when-not (str/empty? value)
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/change-stroke-attrs ids {:stroke-alignment value} index))))
|
||||
|
||||
on-stroke-width-change
|
||||
(fn [index value]
|
||||
(when-not (str/empty? value)
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/change-stroke-attrs ids {:stroke-width value} index))))
|
||||
|
||||
open-caps-select
|
||||
@@ -128,10 +137,12 @@
|
||||
|
||||
on-stroke-cap-start-change
|
||||
(fn [index value]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/change-stroke-attrs ids {:stroke-cap-start value} index)))
|
||||
|
||||
on-stroke-cap-end-change
|
||||
(fn [index value]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/change-stroke-attrs ids {:stroke-cap-end value} index)))
|
||||
|
||||
on-stroke-cap-switch
|
||||
@@ -140,10 +151,12 @@
|
||||
stroke-cap-end (get-in values [:strokes index :stroke-cap-end])]
|
||||
(when (and (not= stroke-cap-start :multiple)
|
||||
(not= stroke-cap-end :multiple))
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/change-stroke-attrs ids {:stroke-cap-start stroke-cap-end
|
||||
:stroke-cap-end stroke-cap-start} index)))))
|
||||
on-add-stroke
|
||||
(fn [_]
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (dc/add-stroke ids {:stroke-alignment :inner
|
||||
:stroke-style :solid
|
||||
:stroke-color clr/black
|
||||
|
||||
@@ -112,7 +112,6 @@
|
||||
recent-fonts (mf/with-memo [state recent-fonts]
|
||||
(filter-fonts state recent-fonts))
|
||||
|
||||
|
||||
full-size? (boolean (and full-size show-recent))
|
||||
|
||||
select-next
|
||||
@@ -131,6 +130,13 @@
|
||||
(dom/prevent-default event)
|
||||
(swap! selected get-prev-font fonts)))
|
||||
|
||||
on-select-and-close
|
||||
(mf/use-fn
|
||||
(mf/deps on-select on-close)
|
||||
(fn [font]
|
||||
(on-select font)
|
||||
(on-close)))
|
||||
|
||||
on-key-down
|
||||
(mf/use-fn
|
||||
(mf/deps fonts)
|
||||
@@ -139,7 +145,7 @@
|
||||
(kbd/up-arrow? event) (select-prev event)
|
||||
(kbd/down-arrow? event) (select-next event)
|
||||
(kbd/esc? event) (on-close)
|
||||
(kbd/enter? event) (on-close)
|
||||
(kbd/enter? event) (do (on-select-and-close @selected))
|
||||
:else (dom/focus! (mf/ref-val input)))))
|
||||
|
||||
on-filter-change
|
||||
@@ -163,9 +169,6 @@
|
||||
(when-let [index (:index @selected)]
|
||||
(.scrollToRow ^js inst index))))
|
||||
|
||||
(mf/with-effect [@selected]
|
||||
(on-select @selected))
|
||||
|
||||
(mf/with-effect []
|
||||
(st/emit! (dsc/push-shortcuts :typography {}))
|
||||
(fn []
|
||||
@@ -178,6 +181,10 @@
|
||||
#(let [offset (.getOffsetForRow ^js inst #js {:alignment "center" :index index})]
|
||||
(.scrollToPosition ^js inst offset)))))
|
||||
|
||||
(mf/with-effect [(:term state) fonts]
|
||||
(when (and (seq fonts) (not= (:id @selected) (:id (first fonts))))
|
||||
(reset! selected (first fonts))))
|
||||
|
||||
[:div {:class (stl/css :font-selector)}
|
||||
[:div {:class (stl/css-case :font-selector-dropdown true :font-selector-dropdown-full-size full-size?)}
|
||||
[:div {:class (stl/css :header)}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
[app.common.types.container :as ctn]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.context :as ctx]
|
||||
@@ -277,7 +278,7 @@
|
||||
;; The side handler is always rendered horizontally and then rotated
|
||||
(mf/defc resize-side-handler
|
||||
{::mf/wrap-props false}
|
||||
[{:keys [x y length align angle zoom position rotation transform on-resize color show-handler scale-text]}]
|
||||
[{:keys [x y length align angle zoom position rotation transform on-resize color show-handler scale-text shape-id shape-type]}]
|
||||
(let [height (/ resize-side-height zoom)
|
||||
offset-y (if (= align :outside) (- height) (- (/ height 2)))
|
||||
target-y (+ y offset-y)
|
||||
@@ -289,7 +290,18 @@
|
||||
(cur/get-dynamic "resize-ew" rotation))
|
||||
(if ^boolean scale-text
|
||||
(cur/get-dynamic "scale-ns" rotation)
|
||||
(cur/get-dynamic "resize-ns" rotation)))]
|
||||
(cur/get-dynamic "resize-ns" rotation)))
|
||||
|
||||
on-double-click
|
||||
(mf/use-fn
|
||||
(mf/deps shape-id position shape-type)
|
||||
(fn [_event]
|
||||
(when (= shape-type :text)
|
||||
(cond
|
||||
(= position :right)
|
||||
(st/emit! (dwsh/update-shapes [shape-id] #(assoc % :grow-type :auto-width)))
|
||||
(= position :bottom)
|
||||
(st/emit! (dwsh/update-shapes [shape-id] #(assoc % :grow-type :auto-height)))))))]
|
||||
|
||||
[:g.resize-handler
|
||||
(when ^boolean show-handler
|
||||
@@ -311,6 +323,7 @@
|
||||
:data-position (name position)
|
||||
:transform transform-str
|
||||
:on-pointer-down on-resize
|
||||
:on-double-click on-double-click
|
||||
:style {:fill (if (dbg/enabled? :handlers) "yellow" "none")
|
||||
:stroke-width 0}}]]))
|
||||
|
||||
@@ -399,7 +412,9 @@
|
||||
:on-resize on-resize
|
||||
:transform transform
|
||||
:rotation rotation
|
||||
:color color}
|
||||
:color color
|
||||
:shape-id (dm/get-prop shape :id)
|
||||
:shape-type (dm/get-prop shape :type)}
|
||||
props)]
|
||||
(case type
|
||||
:rotation [:> rotation-handler props]
|
||||
@@ -482,16 +497,36 @@
|
||||
{::mf/private true}
|
||||
[{:keys [shape zoom color disabled]}]
|
||||
(let [shape-id (dm/get-prop shape :id)
|
||||
grow-type (dm/get-prop shape :grow-type)
|
||||
shape-type (dm/get-prop shape :type)
|
||||
|
||||
on-resize
|
||||
(mf/use-fn
|
||||
(mf/deps shape-id shape)
|
||||
(mf/deps shape-id shape grow-type shape-type)
|
||||
(fn [event]
|
||||
(when (dom/left-mouse? event)
|
||||
(dom/stop-propagation event)
|
||||
(let [target (dom/get-current-target event)
|
||||
position (-> (dom/get-data target "position")
|
||||
(keyword))]
|
||||
(cond
|
||||
;; If text and in auto-width and the resize is horizontal, switch to auto-height and mark direction
|
||||
(and (= shape-type :text)
|
||||
(= grow-type :auto-width)
|
||||
(or (= position :right) (= position :left)))
|
||||
(st/emit! (dwsh/update-shapes [shape-id] #(-> % (assoc :grow-type :auto-height) (assoc :last-resize-direction :horizontal))))
|
||||
;; If text and in auto-height and the resize is horizontal, mark direction but do not change grow-type
|
||||
(and (= shape-type :text)
|
||||
(= grow-type :auto-height)
|
||||
(or (= position :right) (= position :left)))
|
||||
(st/emit! (dwsh/update-shapes [shape-id] #(assoc % :last-resize-direction :horizontal)))
|
||||
;; If text and in auto-height and the resize is vertical, mark direction
|
||||
(and (= shape-type :text)
|
||||
(= grow-type :auto-height)
|
||||
(or (= position :top) (= position :bottom)))
|
||||
(st/emit! (dwsh/update-shapes [shape-id] #(assoc % :last-resize-direction :vertical)))
|
||||
:else
|
||||
nil)
|
||||
(st/emit! (dw/start-resize position #{shape-id} shape))))))
|
||||
|
||||
on-rotate
|
||||
|
||||
@@ -172,6 +172,7 @@ body {
|
||||
(format-value property value options))))
|
||||
|
||||
(defn format-css-property
|
||||
"Format a single CSS property in the format 'property: value;'."
|
||||
[[property value] options]
|
||||
(when (some? value)
|
||||
(let [formatted-value (format-css-value property value options)
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
:else value))
|
||||
|
||||
(defn format-color
|
||||
"Format a color value to a CSS compatible string based on the given format."
|
||||
[value options]
|
||||
(let [format (get options :format :hex)]
|
||||
(cond
|
||||
|
||||
@@ -891,3 +891,12 @@
|
||||
(defn last-child
|
||||
[^js node]
|
||||
(.. node -lastChild))
|
||||
|
||||
(defn prevent-browser-gesture-navigation!
|
||||
[]
|
||||
;; Prevent the browser from interpreting trackpad horizontal swipe as back/forth
|
||||
;;
|
||||
;; In theory We could disable this only for the workspace. However gets too unreliable.
|
||||
;; It is better to be safe and disable for the dashboard as well.
|
||||
(set! (.. js/document -documentElement -style -overscrollBehaviorX) "none")
|
||||
(set! (.. js/document -body -style -overscrollBehaviorX) "none"))
|
||||
@@ -11,6 +11,7 @@
|
||||
[app.common.test-helpers.files :as cthf]
|
||||
[app.common.test-helpers.ids-map :as cthi]
|
||||
[app.common.test-helpers.shapes :as cths]
|
||||
[app.common.types.component :as ctk]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.colors :as dc]
|
||||
@@ -394,3 +395,60 @@
|
||||
(t/is (= (count-shapes file' "rect-simple-1" "#111111") 10))
|
||||
(t/is (= (count-shapes file' "rect-simple-1" "#222222") 4))
|
||||
(t/is (= (count-shapes file' "rect-simple-1" "#333333") 0)))))))))
|
||||
|
||||
(t/deftest duplicate-page-integrity-frame-group-component
|
||||
;; This test covers the bug fixed in 2.9.0: duplicating a page with a mainInstance inside a group
|
||||
;; must preserve parent/child referential integrity (parent-id and :shapes).
|
||||
;;
|
||||
;; Structure created:
|
||||
;; Page
|
||||
;; └─ Group ("group-1")
|
||||
;; └─ Main component ("frame-1")
|
||||
;; └─ Shape ("shape-1")
|
||||
;; The frame is also promoted to a component (main).
|
||||
;;
|
||||
;; The test checks:
|
||||
;; - The group, frame, and shape exist in the duplicated page.
|
||||
;; - The parent/child relationships are correct (group:shapes contains frame, frame:shapes contains shape, etc).
|
||||
;; - The duplicated page contains an instance of the component whose main is in the original page.
|
||||
(t/async done
|
||||
(with-redefs [uuid/next cthi/next-uuid]
|
||||
(let [file (-> (cthf/sample-file :file1 :page-label :page-1)
|
||||
(ctho/add-group :group-1 {:name "group-1"})
|
||||
(ctho/add-frame :frame-1 :parent-label :group-1 {:name "frame-1"})
|
||||
(cths/add-sample-shape :shape-1 :parent-label :frame-1 {:name "shape-1"})
|
||||
(cthc/make-component :component-1 :frame-1))
|
||||
page-id (cthf/current-page-id file)
|
||||
store (ths/setup-store file)
|
||||
events [(app.main.data.workspace.pages/duplicate-page page-id)]]
|
||||
(ths/run-store
|
||||
store done events
|
||||
(fn [new-state]
|
||||
(let [file' (ths/get-file-from-state new-state)
|
||||
pages-vec (get-in file' [:data :pages])
|
||||
pages-index (get-in file' [:data :pages-index])
|
||||
new-page-id (first (remove #(= page-id %) pages-vec))
|
||||
new-page (get pages-index new-page-id)
|
||||
new-objects (:objects new-page)
|
||||
group (some #(when (= (:name %) "group-1") %) (vals new-objects))
|
||||
frame (some #(when (= (:name %) "frame-1") %) (vals new-objects))
|
||||
shape (some #(when (= (:name %) "shape-1") %) (vals new-objects))
|
||||
component-ids (map :component-id (filter :component-root (vals new-objects)))]
|
||||
|
||||
(t/is group "Group exists in duplicated page")
|
||||
(t/is frame "Frame exists in duplicated page")
|
||||
(t/is shape "Shape exists in duplicated page")
|
||||
(t/is (some #(= (:id frame) %) (:shapes group)) "Group's :shapes contains frame's id")
|
||||
(t/is (some #(= (:id shape) %) (:shapes frame)) "Frame's :shapes contains shape's id")
|
||||
(t/is (= (:parent-id frame) (:id group)) "Frame's parent is group")
|
||||
(t/is (= (:parent-id shape) (:id frame)) "Shape's parent is frame")
|
||||
|
||||
;; Check the duplicated page must contain an instance of the component whose main is in the original page
|
||||
(let [original-page (get pages-index page-id)
|
||||
original-main (some #(when (:component-root %) %) (vals (:objects original-page)))
|
||||
instance (some #(when (:component-root %) %) (vals (:objects new-page)))
|
||||
component-id (:component-id original-main)]
|
||||
(t/is (ctk/instance-of? instance (:id file) component-id)
|
||||
(str "Duplicated page contains an instance of the original main component (component-id: " component-id ")")))
|
||||
|
||||
(done))))))))
|
||||
|
||||
@@ -2919,9 +2919,7 @@ msgstr "Emails, comma separated"
|
||||
|
||||
#: src/app/main/ui/dashboard/team.cljs:228
|
||||
msgid "modals.invite-member.repeated-invitation"
|
||||
msgstr ""
|
||||
"Some emails are from current team members. Their invitations will not be "
|
||||
"sent."
|
||||
msgstr "Some members are already on the team. We'll invite the rest."
|
||||
|
||||
#: src/app/main/ui/dashboard/team.cljs:221
|
||||
msgid "modals.invite-team-member.text"
|
||||
@@ -4322,10 +4320,10 @@ msgstr "Advanced security, activity logs, dedicated support and more."
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:60
|
||||
#, markdown
|
||||
msgid "subscription.dashboard.power-up.professional.bottom-description"
|
||||
msgid "subscription.dashboard.power-up.professional.bottom"
|
||||
msgstr ""
|
||||
"Get extra editors and storage, file backup and more with the Unlimited "
|
||||
"plan[Power up|target:self](%s)"
|
||||
"Get extra editors and storage, file recovery and more with the Unlimited "
|
||||
"plan. [Power up|target:self](%s)"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:59
|
||||
msgid "subscription.dashboard.power-up.professional.top-title"
|
||||
@@ -4359,10 +4357,10 @@ msgstr "Enterprise plan (trial)"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:74
|
||||
#, markdown
|
||||
msgid "subscription.dashboard.power-up.unlimited.bottom-description"
|
||||
msgid "subscription.dashboard.power-up.unlimited.bottom"
|
||||
msgstr ""
|
||||
"Get advanced security, activity logs, dedicated support and more. Take a "
|
||||
"look to the[Enterprise plan.|target:self](%s)"
|
||||
"Get extra editors, more storage and backup, advanced security and more. "
|
||||
"[Take a look to the Enterprise plan.|target:self](%s)"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:70
|
||||
#, unused
|
||||
@@ -4416,16 +4414,16 @@ msgid "subscription.settings.enterprise-trial"
|
||||
msgstr "Enterprise (trial)"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:271, src/app/main/ui/settings/subscription.cljs:320
|
||||
msgid "subscription.settings.enterprise.logs"
|
||||
msgstr "Activity logs"
|
||||
msgid "subscription.settings.enterprise.unlimited-storage"
|
||||
msgstr "Unlimited storage and 90-day autosave versions and file recovery"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:270, src/app/main/ui/settings/subscription.cljs:319
|
||||
msgid "subscription.settings.enterprise.security"
|
||||
msgstr "Advanced security"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:269, src/app/main/ui/settings/subscription.cljs:318
|
||||
msgid "subscription.settings.enterprise.support"
|
||||
msgstr "Dedicated support"
|
||||
msgid "subscription.settings.enterprise.capped-bill"
|
||||
msgstr "Capped monthly bill"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:114, src/app/main/ui/settings/subscription.cljs:251, src/app/main/ui/settings/subscription.cljs:262, src/app/main/ui/settings/subscription.cljs:272
|
||||
msgid "subscription.settings.manage-your-subscription"
|
||||
@@ -4494,8 +4492,8 @@ msgid "subscription.settings.professional.projects-files"
|
||||
msgstr "Unlimited projects, files and drafts"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:241, src/app/main/ui/settings/subscription.cljs:292
|
||||
msgid "subscription.settings.professional.storage"
|
||||
msgstr "10GB of storage and 7-day autosave versions"
|
||||
msgid "subscription.settings.professional.storage-autosave"
|
||||
msgstr "10GB of storage and 7-day autosave versions and file recovery"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:240, src/app/main/ui/settings/subscription.cljs:291
|
||||
msgid "subscription.settings.professional.teams-editors"
|
||||
@@ -4539,11 +4537,6 @@ msgstr "You've been supporting us with this plan since: %s"
|
||||
msgid "subscription.settings.try-it-free"
|
||||
msgstr "Try it free for 14 days"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:119
|
||||
#, unused
|
||||
msgid "subscription.settings.ulimited.try-it-free"
|
||||
msgstr "Try it free for 14 days"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:108, src/app/main/ui/settings/subscription.cljs:56, src/app/main/ui/settings/subscription.cljs:256, src/app/main/ui/settings/subscription.cljs:299
|
||||
msgid "subscription.settings.unlimited"
|
||||
msgstr "Unlimited"
|
||||
@@ -4557,8 +4550,8 @@ msgid "subscription.settings.unlimited.bill"
|
||||
msgstr "Capped monthly bill"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:250, src/app/main/ui/settings/subscription.cljs:261, src/app/main/ui/settings/subscription.cljs:306
|
||||
msgid "subscription.settings.unlimited.storage"
|
||||
msgstr "25GB of storage and 30-day autosave versions and file backup"
|
||||
msgid "subscription.settings.unlimited.storage-autosave"
|
||||
msgstr "25GB of storage and 30-day autosave versions and file recovery"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:248, src/app/main/ui/settings/subscription.cljs:259, src/app/main/ui/settings/subscription.cljs:304
|
||||
msgid "subscription.settings.unlimited.teams"
|
||||
|
||||
@@ -4347,9 +4347,9 @@ msgstr "Seguridad avanzada, registros de actividad, asistencia dedicada y mucho
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:60
|
||||
#, markdown
|
||||
msgid "subscription.dashboard.power-up.professional.bottom-description"
|
||||
msgid "subscription.dashboard.power-up.professional.bottom"
|
||||
msgstr ""
|
||||
"Consigue editores y almacenamiento adicionales, copias de seguridad de "
|
||||
"Consigue editores y almacenamiento adicionales, recuperación de "
|
||||
"archivos y mucho más con el Plan Unlimited[Mejóralo|target:self](%s)"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:59
|
||||
@@ -4388,10 +4388,10 @@ msgstr "Plan Unlimited"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:74
|
||||
#, markdown
|
||||
msgid "subscription.dashboard.power-up.unlimited.bottom-description"
|
||||
msgid "subscription.dashboard.power-up.unlimited.bottom"
|
||||
msgstr ""
|
||||
"Obtenga seguridad avanzada, registros de actividad, asistencia dedicada y "
|
||||
"mucho más. Echa un ojo al[Plan Enterprise|target:self](%s)"
|
||||
"Consigue editores adicionales, más almacenamiento y copias de seguridad, seguridad avanzada y mucho más. "
|
||||
"[Echa un ojo al Plan Enterprise|target:self](%s)"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:70
|
||||
#, unused
|
||||
@@ -4442,16 +4442,16 @@ msgid "subscription.settings.enterprise-trial"
|
||||
msgstr "Enterprise (prueba)"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:271, src/app/main/ui/settings/subscription.cljs:320
|
||||
msgid "subscription.settings.enterprise.logs"
|
||||
msgstr "Registros de actividad"
|
||||
msgid "subscription.settings.enterprise.unlimited-storage"
|
||||
msgstr "Almacenamiento ilimitado y versiones de autoguardado de 90 días y recuperación de archivos"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:270, src/app/main/ui/settings/subscription.cljs:319
|
||||
msgid "subscription.settings.enterprise.security"
|
||||
msgstr "Seguridad avanzada"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:269, src/app/main/ui/settings/subscription.cljs:318
|
||||
msgid "subscription.settings.enterprise.support"
|
||||
msgstr "Apoyo específico"
|
||||
msgid "subscription.settings.enterprise.capped-bill"
|
||||
msgstr "Factura mensual limitada"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:114, src/app/main/ui/settings/subscription.cljs:251, src/app/main/ui/settings/subscription.cljs:262, src/app/main/ui/settings/subscription.cljs:272
|
||||
msgid "subscription.settings.manage-your-subscription"
|
||||
@@ -4516,8 +4516,8 @@ msgid "subscription.settings.professional.projects-files"
|
||||
msgstr "Proyectos, archivos y borradores ilimitados"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:241, src/app/main/ui/settings/subscription.cljs:292
|
||||
msgid "subscription.settings.professional.storage"
|
||||
msgstr "10 GB de almacenamiento y versiones de autoguardado de 7 días"
|
||||
msgid "subscription.settings.professional.storage-autosave"
|
||||
msgstr "10 GB de almacenamiento y versiones de autoguardado de 7 días y recuperación de archivos"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:240, src/app/main/ui/settings/subscription.cljs:291
|
||||
msgid "subscription.settings.professional.teams-editors"
|
||||
@@ -4560,11 +4560,6 @@ msgstr "Nos has estado apoyando con este plan desde: %s"
|
||||
msgid "subscription.settings.try-it-free"
|
||||
msgstr "Pruébalo gratis durante 14 días"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:119
|
||||
#, unused
|
||||
msgid "subscription.settings.ulimited.try-it-free"
|
||||
msgstr "Pruébalo gratis durante 14 días"
|
||||
|
||||
#: src/app/main/ui/dashboard/subscription.cljs:108, src/app/main/ui/settings/subscription.cljs:56, src/app/main/ui/settings/subscription.cljs:256, src/app/main/ui/settings/subscription.cljs:299
|
||||
msgid "subscription.settings.unlimited"
|
||||
msgstr "Unlimited"
|
||||
@@ -4578,10 +4573,10 @@ msgid "subscription.settings.unlimited.bill"
|
||||
msgstr "Factura mensual limitada"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:250, src/app/main/ui/settings/subscription.cljs:261, src/app/main/ui/settings/subscription.cljs:306
|
||||
msgid "subscription.settings.unlimited.storage"
|
||||
msgid "subscription.settings.unlimited.storage-autosave"
|
||||
msgstr ""
|
||||
"25 GB de almacenamiento y 30 días de autoguardado de versiones y copias de "
|
||||
"seguridad de archivos"
|
||||
"25 GB de almacenamiento y 30 días de autoguardado de versiones y recuperación "
|
||||
"de archivos"
|
||||
|
||||
#: src/app/main/ui/settings/subscription.cljs:248, src/app/main/ui/settings/subscription.cljs:259, src/app/main/ui/settings/subscription.cljs:304
|
||||
msgid "subscription.settings.unlimited.teams"
|
||||
|
||||
119
manage.sh
119
manage.sh
@@ -7,6 +7,7 @@ export DEVENV_PNAME="penpotdev";
|
||||
export CURRENT_USER_ID=$(id -u);
|
||||
export CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD);
|
||||
|
||||
export IMAGEMAGICK_VERSION=7.1.1-47
|
||||
|
||||
# Safe directory to avoid ownership errors with Git
|
||||
git config --global --add safe.directory /home/penpot/penpot || true
|
||||
@@ -16,16 +17,23 @@ export JAVA_OPTS=${JAVA_OPTS:-"-Xmx1000m -Xms50m"};
|
||||
|
||||
set -e
|
||||
|
||||
ARCH=$(uname -m)
|
||||
|
||||
if [[ "$ARCH" == "x86_64" || "$ARCH" == "i386" || "$ARCH" == "i686" ]]; then
|
||||
ARCH="amd64"
|
||||
elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
|
||||
ARCH="arm64"
|
||||
else
|
||||
echo "Unknown architecture $ARCH"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
function print-current-version {
|
||||
echo -n "$(git describe --tags --match "*.*.*")";
|
||||
}
|
||||
|
||||
function build-devenv {
|
||||
set +e;
|
||||
echo "Building development image $DEVENV_IMGNAME:latest..."
|
||||
|
||||
pushd docker/devenv;
|
||||
|
||||
function setup-buildx {
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
docker buildx inspect penpot > /dev/null 2>&1;
|
||||
|
||||
@@ -36,19 +44,28 @@ function build-devenv {
|
||||
docker buildx use penpot;
|
||||
docker buildx inspect --bootstrap > /dev/null 2>&1;
|
||||
fi
|
||||
|
||||
# docker build -t $DEVENV_IMGNAME:latest .
|
||||
docker buildx build --platform linux/amd64,linux/arm64 --push -t $DEVENV_IMGNAME:latest .;
|
||||
docker pull $DEVENV_IMGNAME:latest;
|
||||
|
||||
popd;
|
||||
}
|
||||
|
||||
function build-devenv-local {
|
||||
echo "Building local only development image $DEVENV_IMGNAME:latest..."
|
||||
function build-devenv {
|
||||
set +e;
|
||||
|
||||
pushd docker/devenv;
|
||||
docker build -t $DEVENV_IMGNAME:latest .;
|
||||
|
||||
if [ "$1" = "--local" ]; then
|
||||
echo "Build local only $DEVENV_IMGNAME:latest image";
|
||||
docker build -t $DEVENV_IMGNAME:latest .;
|
||||
else
|
||||
echo "Build and push $DEVENV_IMGNAME:latest image";
|
||||
setup-buildx;
|
||||
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--output type=registry \
|
||||
-t $DEVENV_IMGNAME:latest .;
|
||||
|
||||
docker pull $DEVENV_IMGNAME:latest;
|
||||
fi
|
||||
|
||||
popd;
|
||||
}
|
||||
|
||||
@@ -124,6 +141,32 @@ function run-devenv-isolated-shell {
|
||||
$DEVENV_IMGNAME:latest sudo -EH -u penpot bash
|
||||
}
|
||||
|
||||
function build-imagemagick-docker-image {
|
||||
set +e;
|
||||
echo "Building image penpotapp/imagemagick:$IMAGEMAGICK_VERSION"
|
||||
|
||||
pushd docker/imagemagick;
|
||||
|
||||
output_option="type=registry";
|
||||
platform="linux/amd64,linux/arm64";
|
||||
|
||||
if [ "$1" = "--local" ]; then
|
||||
output_option="type=docker";
|
||||
platform="linux/$ARCH"
|
||||
fi
|
||||
|
||||
setup-buildx;
|
||||
|
||||
docker buildx build \
|
||||
--build-arg IMAGEMAGICK_VERSION=$IMAGEMAGICK_VERSION \
|
||||
--platform $platform \
|
||||
--output $output_option \
|
||||
-t penpotapp/imagemagick:latest \
|
||||
-t penpotapp/imagemagick:$IMAGEMAGICK_VERSION .;
|
||||
|
||||
popd;
|
||||
}
|
||||
|
||||
function build {
|
||||
echo ">> build start: $1"
|
||||
local version=$(print-current-version);
|
||||
@@ -219,21 +262,21 @@ function build-docs-bundle {
|
||||
echo ">> bundle docs end";
|
||||
}
|
||||
|
||||
function build-frontend-docker-images {
|
||||
function build-frontend-docker-image {
|
||||
rsync -avr --delete ./bundles/frontend/ ./docker/images/bundle-frontend/;
|
||||
pushd ./docker/images;
|
||||
docker build -t penpotapp/frontend:$CURRENT_BRANCH -t penpotapp/frontend:latest -f Dockerfile.frontend .;
|
||||
popd;
|
||||
}
|
||||
|
||||
function build-backend-docker-images {
|
||||
function build-backend-docker-image {
|
||||
rsync -avr --delete ./bundles/backend/ ./docker/images/bundle-backend/;
|
||||
pushd ./docker/images;
|
||||
docker build -t penpotapp/backend:$CURRENT_BRANCH -t penpotapp/backend:latest -f Dockerfile.backend .;
|
||||
popd;
|
||||
}
|
||||
|
||||
function build-exporter-docker-images {
|
||||
function build-exporter-docker-image {
|
||||
rsync -avr --delete ./bundles/exporter/ ./docker/images/bundle-exporter/;
|
||||
pushd ./docker/images;
|
||||
docker build -t penpotapp/exporter:$CURRENT_BRANCH -t penpotapp/exporter:latest -f Dockerfile.exporter .;
|
||||
@@ -246,7 +289,7 @@ function usage {
|
||||
echo "Options:"
|
||||
echo "- pull-devenv Pulls docker development oriented image"
|
||||
echo "- build-devenv Build docker development oriented image"
|
||||
echo "- build-devenv-local Build a local docker development oriented image"
|
||||
echo "- build-devenv --local Build a local docker development oriented image"
|
||||
echo "- create-devenv Create the development oriented docker compose service."
|
||||
echo "- start-devenv Start the development oriented docker compose service."
|
||||
echo "- stop-devenv Stops the development oriented docker compose service."
|
||||
@@ -263,9 +306,9 @@ function usage {
|
||||
echo "- build-docs-bundle Build docs bundle."
|
||||
echo ""
|
||||
echo "- build-docker-images Build all docker images (frontend, backend and exporter)."
|
||||
echo "- build-frontend-docker-images Build frontend docker images."
|
||||
echo "- build-backend-docker-images Build backend docker images."
|
||||
echo "- build-exporter-docker-images Build exporter docker images."
|
||||
echo "- build-frontend-docker-image Build frontend docker images."
|
||||
echo "- build-backend-docker-image Build backend docker images."
|
||||
echo "- build-exporter-docker-image Build exporter docker images."
|
||||
echo ""
|
||||
echo "- version Show penpot's version."
|
||||
}
|
||||
@@ -281,11 +324,8 @@ case $1 in
|
||||
;;
|
||||
|
||||
build-devenv)
|
||||
build-devenv ${@:2}
|
||||
;;
|
||||
|
||||
build-devenv-local)
|
||||
build-devenv-local ${@:2}
|
||||
shift;
|
||||
build-devenv $@;
|
||||
;;
|
||||
|
||||
create-devenv)
|
||||
@@ -339,25 +379,30 @@ case $1 in
|
||||
build-docs-bundle;
|
||||
;;
|
||||
|
||||
build-imagemagick-docker-image)
|
||||
shift;
|
||||
build-imagemagick-docker-image $@;
|
||||
;;
|
||||
|
||||
build-docker-images)
|
||||
build-frontend-docker-images
|
||||
build-backend-docker-images
|
||||
build-exporter-docker-images
|
||||
build-frontend-docker-image
|
||||
build-backend-docker-image
|
||||
build-exporter-docker-image
|
||||
;;
|
||||
|
||||
build-frontend-docker-images)
|
||||
build-frontend-docker-images
|
||||
build-frontend-docker-image)
|
||||
build-frontend-docker-image
|
||||
;;
|
||||
|
||||
build-backend-docker-images)
|
||||
build-backend-docker-images
|
||||
build-backend-docker-image)
|
||||
build-backend-docker-image
|
||||
;;
|
||||
|
||||
build-exporter-docker-images)
|
||||
build-exporter-docker-images
|
||||
build-exporter-docker-image)
|
||||
build-exporter-docker-image
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
@@ -460,37 +460,44 @@ impl RenderState {
|
||||
});
|
||||
|
||||
let text_content = text_content.new_bounds(shape.selrect());
|
||||
let paragraphs = text_content.get_skia_paragraphs(self.fonts.font_collection());
|
||||
let mut paragraphs = text_content.get_skia_paragraphs();
|
||||
|
||||
shadows::render_text_drop_shadows(self, &shape, ¶graphs, antialias);
|
||||
text::render(self, &shape, ¶graphs, None);
|
||||
shadows::render_text_drop_shadows(self, &shape, &mut paragraphs, antialias);
|
||||
text::render(self, &shape, &mut paragraphs, None);
|
||||
|
||||
if shape.has_inner_strokes() {
|
||||
// Inner strokes paints need the text fill to apply correctly their blend modes
|
||||
// (e.g., SrcATop, DstOver)
|
||||
text::render(self, &shape, ¶graphs, Some(SurfaceId::Strokes));
|
||||
text::render(self, &shape, &mut paragraphs, Some(SurfaceId::Strokes));
|
||||
}
|
||||
|
||||
for stroke in shape.strokes().rev() {
|
||||
let stroke_paragraphs = text_content.get_skia_stroke_paragraphs(
|
||||
stroke,
|
||||
&shape.selrect(),
|
||||
self.fonts.font_collection(),
|
||||
let mut stroke_paragraphs =
|
||||
text_content.get_skia_stroke_paragraphs(stroke, &shape.selrect());
|
||||
shadows::render_text_drop_shadows(
|
||||
self,
|
||||
&shape,
|
||||
&mut stroke_paragraphs,
|
||||
antialias,
|
||||
);
|
||||
shadows::render_text_drop_shadows(self, &shape, &stroke_paragraphs, antialias);
|
||||
strokes::render(
|
||||
self,
|
||||
&shape,
|
||||
stroke,
|
||||
None,
|
||||
None,
|
||||
Some(&stroke_paragraphs),
|
||||
Some(&mut stroke_paragraphs),
|
||||
antialias,
|
||||
);
|
||||
shadows::render_text_inner_shadows(
|
||||
self,
|
||||
&shape,
|
||||
&mut stroke_paragraphs,
|
||||
antialias,
|
||||
);
|
||||
shadows::render_text_inner_shadows(self, &shape, &stroke_paragraphs, antialias);
|
||||
}
|
||||
|
||||
shadows::render_text_inner_shadows(self, &shape, ¶graphs, antialias);
|
||||
shadows::render_text_inner_shadows(self, &shape, &mut paragraphs, antialias);
|
||||
}
|
||||
_ => {
|
||||
let surface_ids = SurfaceId::Strokes as u32
|
||||
|
||||
@@ -2,7 +2,8 @@ use super::{RenderState, SurfaceId};
|
||||
use crate::render::strokes;
|
||||
use crate::render::text::{self};
|
||||
use crate::shapes::{Shadow, Shape, Stroke, Type};
|
||||
use skia_safe::{canvas::SaveLayerRec, textlayout::Paragraph, Paint, Path};
|
||||
use skia_safe::textlayout::ParagraphBuilder;
|
||||
use skia_safe::{canvas::SaveLayerRec, Paint, Path};
|
||||
|
||||
// Fill Shadows
|
||||
pub fn render_fill_drop_shadows(render_state: &mut RenderState, shape: &Shape, antialias: bool) {
|
||||
@@ -88,7 +89,7 @@ pub fn render_stroke_inner_shadows(
|
||||
pub fn render_text_drop_shadows(
|
||||
render_state: &mut RenderState,
|
||||
shape: &Shape,
|
||||
paragraphs: &[Vec<Paragraph>],
|
||||
paragraphs: &mut [ParagraphBuilder],
|
||||
antialias: bool,
|
||||
) {
|
||||
for shadow in shape.drop_shadows().rev().filter(|s| !s.hidden()) {
|
||||
@@ -123,7 +124,7 @@ pub fn render_text_drop_shadow(
|
||||
render_state: &mut RenderState,
|
||||
shape: &Shape,
|
||||
shadow: &Shadow,
|
||||
paragraphs: &[Vec<Paragraph>],
|
||||
paragraphs: &mut [ParagraphBuilder],
|
||||
antialias: bool,
|
||||
) {
|
||||
let paint = shadow.get_drop_shadow_paint(antialias);
|
||||
@@ -145,7 +146,7 @@ pub fn render_text_drop_shadow(
|
||||
pub fn render_text_inner_shadows(
|
||||
render_state: &mut RenderState,
|
||||
shape: &Shape,
|
||||
paragraphs: &[Vec<Paragraph>],
|
||||
paragraphs: &mut [ParagraphBuilder],
|
||||
antialias: bool,
|
||||
) {
|
||||
for shadow in shape.inner_shadows().rev().filter(|s| !s.hidden()) {
|
||||
@@ -157,7 +158,7 @@ pub fn render_text_inner_shadow(
|
||||
render_state: &mut RenderState,
|
||||
shape: &Shape,
|
||||
shadow: &Shadow,
|
||||
paragraphs: &[Vec<Paragraph>],
|
||||
paragraphs: &mut [ParagraphBuilder],
|
||||
antialias: bool,
|
||||
) {
|
||||
let paint = shadow.get_inner_shadow_paint(antialias);
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use crate::math::{Matrix, Point, Rect};
|
||||
|
||||
use crate::shapes::{Corners, Fill, ImageFill, Path, Shape, Stroke, StrokeCap, StrokeKind, Type};
|
||||
use skia_safe::{self as skia, textlayout::Paragraph, ImageFilter, RRect};
|
||||
use skia_safe::{self as skia, textlayout::ParagraphBuilder, ImageFilter, RRect};
|
||||
|
||||
use super::{RenderState, SurfaceId};
|
||||
use crate::render::text::{self};
|
||||
@@ -485,7 +485,7 @@ pub fn render(
|
||||
stroke: &Stroke,
|
||||
surface_id: Option<SurfaceId>,
|
||||
shadow: Option<&ImageFilter>,
|
||||
paragraphs: Option<&[Vec<Paragraph>]>,
|
||||
paragraphs: Option<&mut [ParagraphBuilder]>,
|
||||
antialias: bool,
|
||||
) {
|
||||
let scale = render_state.get_scale();
|
||||
|
||||
@@ -1,35 +1,129 @@
|
||||
use super::{RenderState, Shape, SurfaceId};
|
||||
use crate::shapes::VerticalAlign;
|
||||
use skia_safe::{textlayout::Paragraph, Paint, Path};
|
||||
use skia_safe::{textlayout::ParagraphBuilder, FontMetrics, Paint, Path};
|
||||
|
||||
pub fn render(
|
||||
render_state: &mut RenderState,
|
||||
shape: &Shape,
|
||||
paragraphs: &[Vec<Paragraph>],
|
||||
paragraphs: &mut [ParagraphBuilder],
|
||||
surface_id: Option<SurfaceId>,
|
||||
) {
|
||||
let canvas = render_state
|
||||
.surfaces
|
||||
.canvas(surface_id.unwrap_or(SurfaceId::Fills));
|
||||
|
||||
let mut offset_y = 0.0;
|
||||
let container_height = shape.selrect().height();
|
||||
for group in paragraphs {
|
||||
let total_paragraphs_height: f32 = group.iter().map(|p| p.height()).sum();
|
||||
|
||||
let mut offset_y = match shape.vertical_align() {
|
||||
VerticalAlign::Center => (container_height - total_paragraphs_height) / 2.0,
|
||||
VerticalAlign::Bottom => container_height - total_paragraphs_height,
|
||||
for builder in paragraphs {
|
||||
let mut skia_paragraph = builder.build();
|
||||
skia_paragraph.layout(shape.bounds().width());
|
||||
let paragraph_height: f32 = skia_paragraph.height();
|
||||
|
||||
let paragraph_offset_y = match shape.vertical_align() {
|
||||
VerticalAlign::Center => (container_height - paragraph_height) / 2.0,
|
||||
VerticalAlign::Bottom => container_height - paragraph_height,
|
||||
_ => 0.0,
|
||||
};
|
||||
|
||||
for skia_paragraph in group {
|
||||
let xy = (shape.selrect().x(), shape.selrect.y() + offset_y);
|
||||
skia_paragraph.paint(canvas, xy);
|
||||
offset_y += skia_paragraph.height();
|
||||
offset_y += paragraph_offset_y;
|
||||
|
||||
let xy = (shape.selrect().x(), shape.selrect().y() + offset_y);
|
||||
skia_paragraph.paint(canvas, xy);
|
||||
|
||||
offset_y += paragraph_height;
|
||||
|
||||
for line_metrics in skia_paragraph.get_line_metrics().iter() {
|
||||
let style_metrics: Vec<_> = line_metrics
|
||||
.get_style_metrics(line_metrics.start_index..line_metrics.end_index)
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let mut current_x_offset = 0.0;
|
||||
let total_line_width = line_metrics.width as f32;
|
||||
let total_chars = line_metrics.end_index - line_metrics.start_index;
|
||||
|
||||
// No text decoration for empty lines
|
||||
if total_chars == 0 || style_metrics.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i, (index, style_metric)) in style_metrics.iter().enumerate() {
|
||||
let text_style = style_metric.text_style;
|
||||
let font_metrics = style_metric.font_metrics;
|
||||
let next_index = style_metrics
|
||||
.get(i + 1)
|
||||
.map(|(next_i, _)| *next_i)
|
||||
.unwrap_or(line_metrics.end_index);
|
||||
let char_count = next_index - index;
|
||||
let segment_width = if total_chars > 0 {
|
||||
(char_count as f32 / total_chars as f32) * total_line_width
|
||||
} else {
|
||||
char_count as f32 * font_metrics.avg_char_width
|
||||
};
|
||||
|
||||
if text_style.decoration().ty
|
||||
!= skia_safe::textlayout::TextDecoration::NO_DECORATION
|
||||
{
|
||||
let decoration_type = text_style.decoration().ty;
|
||||
let text_left = xy.0 + current_x_offset;
|
||||
let text_top = xy.1 + line_metrics.baseline as f32 - line_metrics.ascent as f32;
|
||||
let text_width = segment_width;
|
||||
let line_height = line_metrics.height as f32;
|
||||
|
||||
let r = calculate_text_decoration_rect(
|
||||
decoration_type,
|
||||
font_metrics,
|
||||
text_left,
|
||||
text_top,
|
||||
text_width,
|
||||
line_height,
|
||||
);
|
||||
|
||||
if let Some(decoration_rect) = r {
|
||||
let decoration_paint = text_style.foreground();
|
||||
canvas.draw_rect(decoration_rect, &decoration_paint);
|
||||
}
|
||||
}
|
||||
|
||||
current_x_offset += segment_width;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn calculate_text_decoration_rect(
|
||||
decoration: skia_safe::textlayout::TextDecoration,
|
||||
font_metrics: FontMetrics,
|
||||
blob_left: f32,
|
||||
blob_offset_y: f32,
|
||||
text_width: f32,
|
||||
blob_height: f32,
|
||||
) -> Option<skia_safe::Rect> {
|
||||
let thickness = font_metrics.underline_thickness().unwrap_or(1.0);
|
||||
match decoration {
|
||||
skia_safe::textlayout::TextDecoration::LINE_THROUGH => {
|
||||
let line_position = blob_height / 2.0;
|
||||
Some(skia_safe::Rect::new(
|
||||
blob_left,
|
||||
blob_offset_y + line_position - thickness / 2.0,
|
||||
blob_left + text_width,
|
||||
blob_offset_y + line_position + thickness / 2.0,
|
||||
))
|
||||
}
|
||||
skia_safe::textlayout::TextDecoration::UNDERLINE => {
|
||||
let underline_y = blob_offset_y + blob_height - thickness;
|
||||
Some(skia_safe::Rect::new(
|
||||
blob_left,
|
||||
underline_y,
|
||||
blob_left + text_width,
|
||||
underline_y + thickness,
|
||||
))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
// Render text paths (unused)
|
||||
#[allow(dead_code)]
|
||||
pub fn render_as_path(
|
||||
|
||||
@@ -164,8 +164,6 @@ fn propagate_transform(
|
||||
};
|
||||
|
||||
let shapes = &state.shapes;
|
||||
let font_col = state.render_state.fonts.font_collection();
|
||||
|
||||
let shape_bounds_before = bounds.find(shape);
|
||||
let mut shape_bounds_after = shape_bounds_before.transform(&entry.transform);
|
||||
|
||||
@@ -173,9 +171,9 @@ fn propagate_transform(
|
||||
|
||||
if let Type::Text(content) = &shape.shape_type {
|
||||
if content.grow_type() == GrowType::AutoHeight {
|
||||
let mut paragraphs = content.get_skia_paragraphs(font_col);
|
||||
let mut paragraphs = content.get_skia_paragraphs();
|
||||
set_paragraphs_width(shape_bounds_after.width(), &mut paragraphs);
|
||||
let height = auto_height(¶graphs);
|
||||
let height = auto_height(&mut paragraphs, shape_bounds_after.width());
|
||||
let resize_transform = math::resize_matrix(
|
||||
&shape_bounds_after,
|
||||
&shape_bounds_after,
|
||||
|
||||
@@ -5,13 +5,13 @@ use crate::{
|
||||
use skia_safe::{
|
||||
self as skia,
|
||||
paint::Paint,
|
||||
textlayout::{FontCollection, ParagraphBuilder, ParagraphStyle},
|
||||
textlayout::{ParagraphBuilder, ParagraphStyle},
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
use super::FontFamily;
|
||||
use crate::shapes::{self, merge_fills, set_paint_fill, Stroke, StrokeKind};
|
||||
use crate::utils::{get_fallback_fonts, uuid_from_u32};
|
||||
use crate::utils::{get_fallback_fonts, get_font_collection, uuid_from_u32};
|
||||
use crate::wasm::fills::parse_fills_from_bytes;
|
||||
use crate::Uuid;
|
||||
|
||||
@@ -40,15 +40,14 @@ pub struct TextContent {
|
||||
pub grow_type: GrowType,
|
||||
}
|
||||
|
||||
pub fn set_paragraphs_width(width: f32, paragraphs: &mut Vec<Vec<skia::textlayout::Paragraph>>) {
|
||||
for group in paragraphs {
|
||||
for paragraph in group {
|
||||
// We first set max so we can get the min_intrinsic_width (this is the min word size)
|
||||
// then after we set either the real with or the min.
|
||||
// This is done this way so the words are not break into lines.
|
||||
paragraph.layout(f32::MAX);
|
||||
paragraph.layout(f32::max(width, paragraph.min_intrinsic_width().ceil()));
|
||||
}
|
||||
pub fn set_paragraphs_width(width: f32, paragraphs: &mut [ParagraphBuilder]) {
|
||||
for p in paragraphs {
|
||||
// We first set max so we can get the min_intrinsic_width (this is the min word size)
|
||||
// then after we set either the real with or the min.
|
||||
// This is done this way so the words are not break into lines.
|
||||
let mut paragraph = p.build();
|
||||
paragraph.layout(f32::MAX);
|
||||
paragraph.layout(f32::max(width, paragraph.min_intrinsic_width().ceil()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,67 +93,61 @@ impl TextContent {
|
||||
self.paragraphs.push(paragraph);
|
||||
}
|
||||
|
||||
pub fn to_paragraphs(&self, fonts: &FontCollection) -> Vec<Vec<skia::textlayout::Paragraph>> {
|
||||
pub fn to_paragraphs(&self) -> Vec<ParagraphBuilder> {
|
||||
let fonts = get_font_collection();
|
||||
let fallback_fonts = get_fallback_fonts();
|
||||
let mut paragraph_group = Vec::new();
|
||||
let paragraphs = self
|
||||
.paragraphs
|
||||
self.paragraphs
|
||||
.iter()
|
||||
.map(|p| {
|
||||
let paragraph_style = p.paragraph_to_style();
|
||||
let mut builder = ParagraphBuilder::new(¶graph_style, fonts);
|
||||
for leaf in &p.children {
|
||||
let text_style = leaf.to_style(p, &self.bounds, fallback_fonts); // FIXME
|
||||
let text_style = leaf.to_style(p, &self.bounds, fallback_fonts);
|
||||
let text = leaf.apply_text_transform();
|
||||
builder.push_style(&text_style);
|
||||
builder.add_text(&text);
|
||||
builder.pop();
|
||||
}
|
||||
builder.build()
|
||||
builder
|
||||
})
|
||||
.collect();
|
||||
paragraph_group.push(paragraphs);
|
||||
paragraph_group
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn to_stroke_paragraphs(
|
||||
&self,
|
||||
stroke: &Stroke,
|
||||
bounds: &Rect,
|
||||
fonts: &FontCollection,
|
||||
) -> Vec<Vec<skia::textlayout::Paragraph>> {
|
||||
pub fn to_stroke_paragraphs(&self, stroke: &Stroke, bounds: &Rect) -> Vec<ParagraphBuilder> {
|
||||
let fallback_fonts = get_fallback_fonts();
|
||||
let mut paragraph_group = Vec::new();
|
||||
let stroke_paints = get_text_stroke_paints(stroke, bounds);
|
||||
let fonts = get_font_collection();
|
||||
|
||||
for stroke_paint in stroke_paints {
|
||||
let mut stroke_paragraphs = Vec::new();
|
||||
for paragraph in &self.paragraphs {
|
||||
let paragraph_style = paragraph.paragraph_to_style();
|
||||
let mut builder = ParagraphBuilder::new(¶graph_style, fonts);
|
||||
for leaf in ¶graph.children {
|
||||
let stroke_style =
|
||||
leaf.to_stroke_style(paragraph, &stroke_paint, fallback_fonts);
|
||||
let text: String = leaf.apply_text_transform();
|
||||
builder.push_style(&stroke_style);
|
||||
builder.add_text(&text);
|
||||
builder.pop();
|
||||
}
|
||||
let p = builder.build();
|
||||
stroke_paragraphs.push(p);
|
||||
}
|
||||
paragraph_group.push(stroke_paragraphs);
|
||||
}
|
||||
paragraph_group
|
||||
stroke_paints
|
||||
.into_iter()
|
||||
.flat_map(|stroke_paint| {
|
||||
self.paragraphs
|
||||
.iter()
|
||||
.map(|paragraph| {
|
||||
let paragraph_style = paragraph.paragraph_to_style();
|
||||
let mut builder = ParagraphBuilder::new(¶graph_style, fonts);
|
||||
for leaf in ¶graph.children {
|
||||
let stroke_style =
|
||||
leaf.to_stroke_style(paragraph, &stroke_paint, fallback_fonts);
|
||||
let text: String = leaf.apply_text_transform();
|
||||
builder.push_style(&stroke_style);
|
||||
builder.add_text(&text);
|
||||
builder.pop();
|
||||
}
|
||||
builder
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn collect_paragraphs(
|
||||
&self,
|
||||
mut paragraphs: Vec<Vec<skia::textlayout::Paragraph>>,
|
||||
) -> Vec<Vec<skia::textlayout::Paragraph>> {
|
||||
mut paragraphs: Vec<ParagraphBuilder>,
|
||||
) -> Vec<ParagraphBuilder> {
|
||||
if self.grow_type() == GrowType::AutoWidth {
|
||||
set_paragraphs_width(f32::MAX, &mut paragraphs);
|
||||
let max_width = auto_width(¶graphs).ceil();
|
||||
let max_width = auto_width(&mut paragraphs).ceil();
|
||||
set_paragraphs_width(max_width, &mut paragraphs);
|
||||
} else {
|
||||
set_paragraphs_width(self.width(), &mut paragraphs);
|
||||
@@ -162,20 +155,16 @@ impl TextContent {
|
||||
paragraphs
|
||||
}
|
||||
|
||||
pub fn get_skia_paragraphs(
|
||||
&self,
|
||||
fonts: &FontCollection,
|
||||
) -> Vec<Vec<skia::textlayout::Paragraph>> {
|
||||
self.collect_paragraphs(self.to_paragraphs(fonts))
|
||||
pub fn get_skia_paragraphs(&self) -> Vec<ParagraphBuilder> {
|
||||
self.collect_paragraphs(self.to_paragraphs())
|
||||
}
|
||||
|
||||
pub fn get_skia_stroke_paragraphs(
|
||||
&self,
|
||||
stroke: &Stroke,
|
||||
bounds: &Rect,
|
||||
fonts: &FontCollection,
|
||||
) -> Vec<Vec<skia::textlayout::Paragraph>> {
|
||||
self.collect_paragraphs(self.to_stroke_paragraphs(stroke, bounds, fonts))
|
||||
) -> Vec<ParagraphBuilder> {
|
||||
self.collect_paragraphs(self.to_stroke_paragraphs(stroke, bounds))
|
||||
}
|
||||
|
||||
pub fn grow_type(&self) -> GrowType {
|
||||
@@ -286,6 +275,26 @@ impl Paragraph {
|
||||
1 => skia::textlayout::TextDirection::RTL,
|
||||
_ => skia::textlayout::TextDirection::LTR,
|
||||
});
|
||||
|
||||
// Force minimum line height for empty lines using strut style
|
||||
if !self.children.is_empty() {
|
||||
let reference_child = self
|
||||
.children
|
||||
.iter()
|
||||
.find(|child| !child.text.trim().is_empty())
|
||||
.unwrap_or(&self.children[0]);
|
||||
|
||||
let mut strut_style = skia::textlayout::StrutStyle::default();
|
||||
strut_style.set_font_size(reference_child.font_size);
|
||||
strut_style.set_height(self.line_height);
|
||||
strut_style.set_height_override(true);
|
||||
strut_style.set_half_leading(false);
|
||||
strut_style.set_leading(0.0);
|
||||
strut_style.set_strut_enabled(true);
|
||||
strut_style.set_force_strut_height(true);
|
||||
style.set_strut_style(strut_style);
|
||||
}
|
||||
|
||||
style
|
||||
}
|
||||
|
||||
@@ -350,6 +359,8 @@ impl TextLeaf {
|
||||
style.set_letter_spacing(paragraph.letter_spacing);
|
||||
style.set_height(paragraph.line_height);
|
||||
style.set_height_override(true);
|
||||
style.set_half_leading(false);
|
||||
|
||||
style.set_decoration_type(match self.text_decoration {
|
||||
0 => skia::textlayout::TextDecoration::NO_DECORATION,
|
||||
1 => skia::textlayout::TextDecoration::UNDERLINE,
|
||||
@@ -358,8 +369,8 @@ impl TextLeaf {
|
||||
_ => skia::textlayout::TextDecoration::NO_DECORATION,
|
||||
});
|
||||
|
||||
// FIXME fix decoration styles
|
||||
style.set_decoration_color(paint.color());
|
||||
// Trick to avoid showing the text decoration
|
||||
style.set_decoration_thickness_multiplier(0.0);
|
||||
|
||||
let mut font_families = vec![
|
||||
self.serialized_font_family(),
|
||||
@@ -626,24 +637,28 @@ impl From<&Vec<u8>> for RawTextData {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn auto_width(paragraphs: &[Vec<skia::textlayout::Paragraph>]) -> f32 {
|
||||
paragraphs.iter().flatten().fold(0.0, |auto_width, p| {
|
||||
f32::max(p.max_intrinsic_width(), auto_width)
|
||||
pub fn auto_width(paragraphs: &mut [ParagraphBuilder]) -> f32 {
|
||||
paragraphs.iter_mut().fold(0.0, |auto_width, p| {
|
||||
let mut paragraph = p.build();
|
||||
paragraph.layout(f32::MAX);
|
||||
f32::max(paragraph.max_intrinsic_width(), auto_width)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn max_width(paragraphs: &[Vec<skia::textlayout::Paragraph>]) -> f32 {
|
||||
paragraphs
|
||||
.iter()
|
||||
.flatten()
|
||||
.fold(0.0, |max_width, p| f32::max(p.max_width(), max_width))
|
||||
pub fn max_width(paragraphs: &mut [ParagraphBuilder]) -> f32 {
|
||||
paragraphs.iter_mut().fold(0.0, |max_width, p| {
|
||||
let mut paragraph = p.build();
|
||||
paragraph.layout(f32::MAX);
|
||||
f32::max(paragraph.max_width(), max_width)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn auto_height(paragraphs: &[Vec<skia::textlayout::Paragraph>]) -> f32 {
|
||||
paragraphs
|
||||
.iter()
|
||||
.flatten()
|
||||
.fold(0.0, |auto_height, p| auto_height + p.height())
|
||||
pub fn auto_height(paragraphs: &mut [ParagraphBuilder], width: f32) -> f32 {
|
||||
paragraphs.iter_mut().fold(0.0, |auto_height, p| {
|
||||
let mut paragraph = p.build();
|
||||
paragraph.layout(width);
|
||||
auto_height + paragraph.height()
|
||||
})
|
||||
}
|
||||
|
||||
fn get_text_stroke_paints(stroke: &Stroke, bounds: &Rect) -> Vec<Paint> {
|
||||
@@ -651,14 +666,9 @@ fn get_text_stroke_paints(stroke: &Stroke, bounds: &Rect) -> Vec<Paint> {
|
||||
|
||||
match stroke.kind {
|
||||
StrokeKind::Inner => {
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_blend_mode(skia::BlendMode::DstOver);
|
||||
paint.set_anti_alias(true);
|
||||
paints.push(paint);
|
||||
|
||||
let mut paint = skia::Paint::default();
|
||||
paint.set_style(skia::PaintStyle::Stroke);
|
||||
paint.set_blend_mode(skia::BlendMode::SrcATop);
|
||||
paint.set_blend_mode(skia::BlendMode::SrcIn);
|
||||
paint.set_anti_alias(true);
|
||||
paint.set_stroke_width(stroke.width * 2.0);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use skia_safe::{self as skia, Path, Point};
|
||||
use skia_safe::{self as skia, textlayout::FontCollection, Path, Point};
|
||||
use std::collections::HashMap;
|
||||
|
||||
mod shapes_pool;
|
||||
@@ -167,6 +167,10 @@ impl State {
|
||||
.rebuild_modifier_tiles(&self.shapes, &self.modifiers);
|
||||
}
|
||||
|
||||
pub fn font_collection(&self) -> &FontCollection {
|
||||
self.render_state.fonts().font_collection()
|
||||
}
|
||||
|
||||
pub fn get_grid_coords(&self, pos_x: f32, pos_y: f32) -> Option<(i32, i32)> {
|
||||
let shape = self.current_shape()?;
|
||||
let bounds = shape.bounds();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::skia::textlayout::FontCollection;
|
||||
use crate::skia::Image;
|
||||
use crate::uuid::Uuid;
|
||||
use crate::with_state_mut;
|
||||
@@ -31,3 +32,7 @@ pub fn get_image(image_id: &Uuid) -> Option<&Image> {
|
||||
pub fn get_fallback_fonts() -> &'static HashSet<String> {
|
||||
with_state_mut!(state, { state.render_state().fonts().get_fallback() })
|
||||
}
|
||||
|
||||
pub fn get_font_collection() -> &'static FontCollection {
|
||||
with_state_mut!(state, { state.font_collection() })
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::mem;
|
||||
use crate::shapes::{auto_height, auto_width, max_width, GrowType, RawTextData, Type};
|
||||
|
||||
use crate::STATE;
|
||||
use crate::{with_current_shape, with_current_shape_mut, with_state_mut};
|
||||
use crate::{with_current_shape, with_current_shape_mut};
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn clear_shape_text() {
|
||||
@@ -35,11 +35,6 @@ pub extern "C" fn set_shape_grow_type(grow_type: u8) {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn get_text_dimensions() -> *mut u8 {
|
||||
let font_col;
|
||||
with_state_mut!(state, {
|
||||
font_col = state.render_state.fonts.font_collection();
|
||||
});
|
||||
|
||||
let mut width = 0.01;
|
||||
let mut height = 0.01;
|
||||
let mut m_width = 0.01;
|
||||
@@ -49,16 +44,16 @@ pub extern "C" fn get_text_dimensions() -> *mut u8 {
|
||||
height = shape.selrect.height();
|
||||
|
||||
if let Type::Text(content) = &shape.shape_type {
|
||||
let paragraphs = content.get_skia_paragraphs(font_col);
|
||||
m_width = max_width(¶graphs);
|
||||
let mut paragraphs = content.get_skia_paragraphs();
|
||||
m_width = max_width(&mut paragraphs);
|
||||
|
||||
match content.grow_type() {
|
||||
GrowType::AutoHeight => {
|
||||
height = auto_height(¶graphs).ceil();
|
||||
height = auto_height(&mut paragraphs, width).ceil();
|
||||
}
|
||||
GrowType::AutoWidth => {
|
||||
width = auto_width(¶graphs).ceil();
|
||||
height = auto_height(¶graphs).ceil();
|
||||
width = auto_width(&mut paragraphs).ceil();
|
||||
height = auto_height(&mut paragraphs, width).ceil();
|
||||
}
|
||||
GrowType::Fixed => {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user