mirror of
https://github.com/penpot/penpot.git
synced 2026-02-05 12:12:07 -05:00
Compare commits
1 Commits
niwinz-plu
...
ladybenko-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e26110378 |
45
.github/workflows/tests-mcp.yml
vendored
45
.github/workflows/tests-mcp.yml
vendored
@@ -1,45 +0,0 @@
|
||||
name: "MCP CI"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- develop
|
||||
- staging
|
||||
- main
|
||||
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
|
||||
paths:
|
||||
- 'mcp/**'
|
||||
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
- staging
|
||||
- main
|
||||
|
||||
paths:
|
||||
- 'mcp/**'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: "Test"
|
||||
runs-on: penpot-runner-02
|
||||
container: penpotapp/devenv:latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup
|
||||
working-directory: ./mcp
|
||||
run: ./scripts/setup
|
||||
|
||||
- name: Check
|
||||
working-directory: ./mcp
|
||||
run: |
|
||||
pnpm run fmt:check;
|
||||
pnpm -r run build;
|
||||
pnpm -r run types:check;
|
||||
10
CHANGES.md
10
CHANGES.md
@@ -32,9 +32,12 @@
|
||||
- Fix exception on uploading large fonts [Github #8135](https://github.com/penpot/penpot/pull/8135)
|
||||
- Fix boolean operators in menu for boards [Taiga #13174](https://tree.taiga.io/project/penpot/issue/13174)
|
||||
- Fix viewer can update library [Taiga #13186](https://tree.taiga.io/project/penpot/issue/13186)
|
||||
- Fix remove fill affects different element than selected [Taiga #13128](https://tree.taiga.io/project/penpot/issue/13128)
|
||||
|
||||
## 2.13.0
|
||||
## 2.13.0 (Unreleased)
|
||||
|
||||
### :boom: Breaking changes & Deprecations
|
||||
|
||||
### :rocket: Epics and highlights
|
||||
|
||||
### :heart: Community contributions (Thank you!)
|
||||
|
||||
@@ -70,9 +73,6 @@
|
||||
- Fix incorrect handling of input values on layout gap and padding inputs [Github #8113](https://github.com/penpot/penpot/issues/8113)
|
||||
- Fix several race conditions on path editor [Github #8187](https://github.com/penpot/penpot/pull/8187)
|
||||
- Fix app freeze when introducing an error on a very long token name [Taiga #13214](https://tree.taiga.io/project/penpot/issue/13214)
|
||||
- Fix import a file with shadow tokens [Taiga #13229](https://tree.taiga.io/project/penpot/issue/13229)
|
||||
- Fix allow spaces on token description [Taiga #13184](https://tree.taiga.io/project/penpot/issue/13184)
|
||||
- Fix error when creating a token with an invalid name [Taiga #13219](https://tree.taiga.io/project/penpot/issue/13219)
|
||||
|
||||
## 2.12.1
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
:deps
|
||||
{penpot/common {:local/root "../common"}
|
||||
org.clojure/clojure {:mvn/version "1.12.4"}
|
||||
org.clojure/clojure {:mvn/version "1.12.2"}
|
||||
org.clojure/tools.namespace {:mvn/version "1.5.0"}
|
||||
|
||||
com.github.luben/zstd-jni {:mvn/version "1.5.7-4"}
|
||||
@@ -28,8 +28,8 @@
|
||||
com.google.guava/guava {:mvn/version "33.4.8-jre"}
|
||||
|
||||
funcool/yetti
|
||||
{:git/tag "v11.9"
|
||||
:git/sha "5fad7a9"
|
||||
{:git/tag "v11.8"
|
||||
:git/sha "1d1b33f"
|
||||
:git/url "https://github.com/funcool/yetti.git"
|
||||
:exclusions [org.slf4j/slf4j-api]}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
metosin/reitit-core {:mvn/version "0.9.1"}
|
||||
nrepl/nrepl {:mvn/version "1.4.0"}
|
||||
|
||||
org.postgresql/postgresql {:mvn/version "42.7.9"}
|
||||
org.postgresql/postgresql {:mvn/version "42.7.7"}
|
||||
org.xerial/sqlite-jdbc {:mvn/version "3.50.3.0"}
|
||||
|
||||
com.zaxxer/HikariCP {:mvn/version "7.0.2"}
|
||||
@@ -49,7 +49,7 @@
|
||||
buddy/buddy-hashers {:mvn/version "2.0.167"}
|
||||
buddy/buddy-sign {:mvn/version "3.6.1-359"}
|
||||
|
||||
com.github.ben-manes.caffeine/caffeine {:mvn/version "3.2.3"}
|
||||
com.github.ben-manes.caffeine/caffeine {:mvn/version "3.2.2"}
|
||||
|
||||
org.jsoup/jsoup {:mvn/version "1.21.2"}
|
||||
org.im4java/im4java
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
;; Pretty Print specs
|
||||
pretty-spec/pretty-spec {:mvn/version "0.1.4"}
|
||||
software.amazon.awssdk/s3 {:mvn/version "2.41.21"}}
|
||||
software.amazon.awssdk/s3 {:mvn/version "2.33.10"}}
|
||||
|
||||
:paths ["src" "resources" "target/classes"]
|
||||
:aliases
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono">
|
||||
<style>
|
||||
{% include "app/templates/styles.css" %}
|
||||
</style>
|
||||
|
||||
@@ -5,25 +5,23 @@ penpot - error list
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<nav>
|
||||
<div class="title">
|
||||
<a href="/dbg"> [BACK]</a>
|
||||
<h1>Error reports (last 300)</h1>
|
||||
|
||||
<a class="{% if version = 3 %}strong{% endif %}" href="?version=3">[BACKEND ERRORS]</a>
|
||||
<a class="{% if version = 4 %}strong{% endif %}" href="?version=4">[FRONTEND ERRORS]</a>
|
||||
</div>
|
||||
</nav>
|
||||
<main class="horizontal-list">
|
||||
<ul>
|
||||
{% for item in items %}
|
||||
<li>
|
||||
<a class="date" href="/dbg/error/{{item.id}}">{{item.created-at}}</a>
|
||||
<a class="hint" href="/dbg/error/{{item.id}}">
|
||||
<span class="title">{{item.hint|abbreviate:150}}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</main>
|
||||
<nav>
|
||||
<div class="title">
|
||||
<h1>Error reports (last 200)
|
||||
<a href="/dbg">[GO BACK]</a>
|
||||
</h1>
|
||||
</div>
|
||||
</nav>
|
||||
<main class="horizontal-list">
|
||||
<ul>
|
||||
{% for item in items %}
|
||||
<li>
|
||||
<a class="date" href="/dbg/error/{{item.id}}">{{item.created-at}}</a>
|
||||
<a class="hint" href="/dbg/error/{{item.id}}">
|
||||
<span class="title">{{item.hint|abbreviate:150}}</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</main>
|
||||
{% endblock %}
|
||||
|
||||
@@ -6,7 +6,7 @@ Report: {{hint|abbreviate:150}} - {{id}} - Penpot Error Report (v3)
|
||||
|
||||
{% block content %}
|
||||
<nav>
|
||||
<div>[<a href="/dbg/error?version={{version}}">⮜</a>]</div>
|
||||
<div>[<a href="/dbg/error">⮜</a>]</div>
|
||||
<div>[<a href="#head">head</a>]</div>
|
||||
<div>[<a href="#props">props</a>]</div>
|
||||
<div>[<a href="#context">context</a>]</div>
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
{% extends "app/templates/base.tmpl" %}
|
||||
|
||||
{% block title %}
|
||||
Report: {{hint|abbreviate:150}} - {{id}} - Penpot Error Report (v4)
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<nav>
|
||||
<div>[<a href="/dbg/error?version={{version}}">⮜</a>]</div>
|
||||
<div>[<a href="#head">head</a>]</div>
|
||||
<!-- <div>[<a href="#props">props</a>]</div> -->
|
||||
<div>[<a href="#context">context</a>]</div>
|
||||
{% if report %}
|
||||
<div>[<a href="#report">report</a>]</div>
|
||||
{% endif %}
|
||||
</nav>
|
||||
<main>
|
||||
<div class="table">
|
||||
<div class="table-row multiline">
|
||||
<div id="head" class="table-key">HEAD</div>
|
||||
<div class="table-val">
|
||||
<h1><span class="not-important">Hint:</span> <br/> {{hint}}</h1>
|
||||
<h2><span class="not-important">Reported at:</span> <br/> {{created-at}}</h2>
|
||||
<h2><span class="not-important">Report ID:</span> <br/> {{id}}</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-row multiline">
|
||||
<div id="context" class="table-key">CONTEXT: </div>
|
||||
|
||||
<div class="table-val">
|
||||
<pre>{{context}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if report %}
|
||||
<div class="table-row multiline">
|
||||
<div id="report" class="table-key">REPORT:</div>
|
||||
<div class="table-val">
|
||||
<pre>{{report}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
||||
@@ -1,5 +1,5 @@
|
||||
* {
|
||||
font-family: monospace;
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@@ -36,10 +36,6 @@ small {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.strong {
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.not-important {
|
||||
color: #888;
|
||||
font-weight: 200;
|
||||
@@ -61,26 +57,14 @@ nav {
|
||||
|
||||
nav > .title {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
nav > .title > a {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
nav > .title > a.strong {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
nav > .title > h1 {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
font-size: 11px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
nav > .title > * {
|
||||
padding: 0px 6px;
|
||||
}
|
||||
|
||||
nav > div {
|
||||
|
||||
@@ -232,22 +232,13 @@
|
||||
(-> (io/resource "app/templates/error-report.v3.tmpl")
|
||||
(tmpl/render (-> content
|
||||
(assoc :id id)
|
||||
(assoc :version 3)
|
||||
(assoc :created-at (ct/format-inst created-at :rfc1123))))))
|
||||
|
||||
(render-template-v4 [{:keys [content id created-at]}]
|
||||
(-> (io/resource "app/templates/error-report.v4.tmpl")
|
||||
(tmpl/render (-> content
|
||||
(assoc :id id)
|
||||
(assoc :version 4)
|
||||
(assoc :created-at (ct/format-inst created-at :rfc1123))))))]
|
||||
|
||||
(if-let [report (get-report request)]
|
||||
(let [result (case (:version report)
|
||||
1 (render-template-v1 report)
|
||||
2 (render-template-v2 report)
|
||||
3 (render-template-v3 report)
|
||||
4 (render-template-v4 report))]
|
||||
3 (render-template-v3 report))]
|
||||
{::yres/status 200
|
||||
::yres/body result
|
||||
::yres/headers {"content-type" "text/html; charset=utf-8"
|
||||
@@ -255,22 +246,20 @@
|
||||
{::yres/status 404
|
||||
::yres/body "not found"})))
|
||||
|
||||
(def ^:private sql:error-reports
|
||||
(def sql:error-reports
|
||||
"SELECT id, created_at,
|
||||
content->>'~:hint' AS hint
|
||||
FROM server_error_report
|
||||
WHERE version = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 300")
|
||||
LIMIT 200")
|
||||
|
||||
(defn- error-list-handler
|
||||
[{:keys [::db/pool]} {:keys [params]}]
|
||||
(let [version (or (some-> (get params :version) parse-long) 3)
|
||||
items (->> (db/exec! pool [sql:error-reports version])
|
||||
(map #(update % :created-at ct/format-inst :rfc1123)))]
|
||||
(defn error-list-handler
|
||||
[{:keys [::db/pool]} _request]
|
||||
(let [items (->> (db/exec! pool [sql:error-reports])
|
||||
(map #(update % :created-at ct/format-inst :rfc1123)))]
|
||||
{::yres/status 200
|
||||
::yres/body (-> (io/resource "app/templates/error-list.tmpl")
|
||||
(tmpl/render {:items items :version version}))
|
||||
(tmpl/render {:items items}))
|
||||
::yres/headers {"content-type" "text/html; charset=utf-8"
|
||||
"x-robots-tag" "noindex"}}))
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
(assoc :request/ip-addr (inet/parse-request request))
|
||||
(assoc :request/profile-id (get claims :uid))
|
||||
(assoc :request/auth-data auth)
|
||||
(assoc :frontend/version (or (yreq/get-header request "x-frontend-version") "unknown")))))
|
||||
(assoc :version/frontend (or (yreq/get-header request "x-frontend-version") "unknown")))))
|
||||
|
||||
(defmulti handle-error
|
||||
(fn [cause _ _]
|
||||
|
||||
@@ -113,8 +113,6 @@
|
||||
;; COLLECTOR API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare ^:private prepare-context-from-request)
|
||||
|
||||
;; Defines a service that collects the audit/activity log using
|
||||
;; internal database. Later this audit log can be transferred to
|
||||
;; an external storage and data cleared.
|
||||
@@ -128,8 +126,6 @@
|
||||
[::props {:optional true} [:map-of :keyword :any]]
|
||||
[::context {:optional true} [:map-of :keyword :any]]
|
||||
[::tracked-at {:optional true} ::ct/inst]
|
||||
[::created-at {:optional true} ::ct/inst]
|
||||
[::source {:optional true} ::sm/text]
|
||||
[::webhooks/event? {:optional true} ::sm/boolean]
|
||||
[::webhooks/batch-timeout {:optional true} ::ct/duration]
|
||||
[::webhooks/batch-key {:optional true}
|
||||
@@ -138,8 +134,36 @@
|
||||
(def ^:private check-event
|
||||
(sm/check-fn schema:event))
|
||||
|
||||
(def valid-event?
|
||||
(sm/validator schema:event))
|
||||
(defn- prepare-context-from-request
|
||||
[request]
|
||||
(let [client-event-origin (get-client-event-origin request)
|
||||
client-version (get-client-version request)
|
||||
client-user-agent (get-client-user-agent request)
|
||||
session-id (get-external-session-id request)
|
||||
key-id (::http/auth-key-id request)
|
||||
token-id (::actoken/id request)
|
||||
token-type (::actoken/type request)]
|
||||
(d/without-nils
|
||||
{:external-session-id session-id
|
||||
:initiator (or key-id "app")
|
||||
:access-token-id (some-> token-id str)
|
||||
:access-token-type (some-> token-type str)
|
||||
:client-event-origin client-event-origin
|
||||
:client-user-agent client-user-agent
|
||||
:client-version client-version
|
||||
:version (:full cf/version)})))
|
||||
|
||||
(defn event-from-rpc-params
|
||||
"Create a base event skeleton with pre-filled some important
|
||||
data that can be extracted from RPC params object"
|
||||
[params]
|
||||
(let [context (some-> params meta ::http/request prepare-context-from-request)
|
||||
event {::type "action"
|
||||
::profile-id (or (::rpc/profile-id params) uuid/zero)
|
||||
::ip-addr (::rpc/ip-addr params)}]
|
||||
(cond-> event
|
||||
(some? context)
|
||||
(assoc ::context context))))
|
||||
|
||||
(defn prepare-event
|
||||
[cfg mdata params result]
|
||||
@@ -188,38 +212,6 @@
|
||||
(::webhooks/event? resultm)
|
||||
false)}))
|
||||
|
||||
(defn- prepare-context-from-request
|
||||
"Prepare backend event context from request"
|
||||
[request]
|
||||
(let [client-event-origin (get-client-event-origin request)
|
||||
client-version (get-client-version request)
|
||||
client-user-agent (get-client-user-agent request)
|
||||
session-id (get-external-session-id request)
|
||||
key-id (::http/auth-key-id request)
|
||||
token-id (::actoken/id request)
|
||||
token-type (::actoken/type request)]
|
||||
(d/without-nils
|
||||
{:external-session-id session-id
|
||||
:initiator (or key-id "app")
|
||||
:access-token-id (some-> token-id str)
|
||||
:access-token-type (some-> token-type str)
|
||||
:client-event-origin client-event-origin
|
||||
:client-user-agent client-user-agent
|
||||
:client-version client-version
|
||||
:version (:full cf/version)})))
|
||||
|
||||
(defn event-from-rpc-params
|
||||
"Create a base event skeleton with pre-filled some important
|
||||
data that can be extracted from RPC params object"
|
||||
[params]
|
||||
(let [context (some-> params meta ::http/request prepare-context-from-request)
|
||||
event {::type "action"
|
||||
::profile-id (or (::rpc/profile-id params) uuid/zero)
|
||||
::ip-addr (::rpc/ip-addr params)}]
|
||||
(cond-> event
|
||||
(some? context)
|
||||
(assoc ::context context))))
|
||||
|
||||
(defn- event->params
|
||||
[event]
|
||||
(let [params {:id (uuid/next)
|
||||
@@ -246,10 +238,8 @@
|
||||
|
||||
(defn- handle-event!
|
||||
[cfg event]
|
||||
(let [tnow (ct/now)
|
||||
params (-> (event->params event)
|
||||
(assoc :created-at tnow)
|
||||
(update :tracked-at #(or % tnow)))]
|
||||
(let [params (event->params event)
|
||||
tnow (ct/now)]
|
||||
|
||||
(when (contains? cf/flags :audit-log-logger)
|
||||
(l/log! ::l/logger "app.audit"
|
||||
@@ -265,7 +255,10 @@
|
||||
;; NOTE: this operation may cause primary key conflicts on inserts
|
||||
;; because of the timestamp precission (two concurrent requests), in
|
||||
;; this case we just retry the operation.
|
||||
(append-audit-entry cfg params))
|
||||
(let [params (-> params
|
||||
(assoc :created-at tnow)
|
||||
(update :tracked-at #(or % tnow)))]
|
||||
(append-audit-entry cfg params)))
|
||||
|
||||
(when (and (or (contains? cf/flags :telemetry)
|
||||
(cf/get :telemetry-enabled))
|
||||
@@ -276,6 +269,8 @@
|
||||
;;
|
||||
;; NOTE: this is only executed when general audit log is disabled
|
||||
(let [params (-> params
|
||||
(assoc :created-at tnow)
|
||||
(update :tracked-at #(or % tnow))
|
||||
(assoc :props {})
|
||||
(assoc :context {}))]
|
||||
(append-audit-entry cfg params)))
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
[app.common.schema :as sm]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.loggers.audit :as audit]
|
||||
[clojure.spec.alpha :as s]
|
||||
[integrant.core :as ig]
|
||||
[promesa.exec :as px]
|
||||
@@ -29,108 +28,69 @@
|
||||
(defonce enabled (atom true))
|
||||
|
||||
(defn- persist-on-database!
|
||||
[pool id version report]
|
||||
[pool id report]
|
||||
(when-not (db/read-only? pool)
|
||||
(db/insert! pool :server-error-report
|
||||
{:id id
|
||||
:version version
|
||||
:version 3
|
||||
:content (db/tjson report)})))
|
||||
|
||||
(defn- concurrent-exception?
|
||||
[cause]
|
||||
(or (instance? java.util.concurrent.CompletionException cause)
|
||||
(instance? java.util.concurrent.ExecutionException cause)))
|
||||
|
||||
(defn record->report
|
||||
[{:keys [::l/context ::l/message ::l/props ::l/logger ::l/level ::l/cause] :as record}]
|
||||
(assert (l/valid-record? record) "expectd valid log record")
|
||||
(let [data (if (concurrent-exception? cause)
|
||||
(ex-data (ex-cause cause))
|
||||
(ex-data cause))
|
||||
(if (or (instance? java.util.concurrent.CompletionException cause)
|
||||
(instance? java.util.concurrent.ExecutionException cause))
|
||||
(-> record
|
||||
(assoc ::trace (ex/format-throwable cause :data? true :explain? false :header? false :summary? false))
|
||||
(assoc ::l/cause (ex-cause cause))
|
||||
(record->report))
|
||||
|
||||
ctx (-> context
|
||||
(assoc :service/tenant (cf/get :tenant))
|
||||
(assoc :service/host (cf/get :host))
|
||||
(assoc :service/public-uri (str (cf/get :public-uri)))
|
||||
(assoc :backend/version (:full cf/version))
|
||||
(assoc :logger/name logger)
|
||||
(assoc :logger/level level)
|
||||
(dissoc :request/params :value :params :data))]
|
||||
(let [data (ex-data cause)
|
||||
ctx (-> context
|
||||
(assoc :tenant (cf/get :tenant))
|
||||
(assoc :host (cf/get :host))
|
||||
(assoc :public-uri (str (cf/get :public-uri)))
|
||||
(assoc :logger/name logger)
|
||||
(assoc :logger/level level)
|
||||
(dissoc :request/params :value :params :data))]
|
||||
|
||||
(merge
|
||||
{:context (-> (into (sorted-map) ctx)
|
||||
(pp/pprint-str :length 50))
|
||||
:props (pp/pprint-str props :length 50)
|
||||
:hint (or (when-let [message (ex-message cause)]
|
||||
(if-let [props-hint (:hint props)]
|
||||
(str props-hint ": " message)
|
||||
message))
|
||||
@message)
|
||||
:trace (or (::trace record)
|
||||
(some-> cause (ex/format-throwable :data? true :explain? false :header? false :summary? false)))}
|
||||
(merge
|
||||
{:context (-> (into (sorted-map) ctx)
|
||||
(pp/pprint-str :length 50))
|
||||
:props (pp/pprint-str props :length 50)
|
||||
:hint (or (when-let [message (ex-message cause)]
|
||||
(if-let [props-hint (:hint props)]
|
||||
(str props-hint ": " message)
|
||||
message))
|
||||
@message)
|
||||
:trace (or (::trace record)
|
||||
(some-> cause (ex/format-throwable :data? true :explain? false :header? false :summary? false)))}
|
||||
|
||||
(when-let [params (or (:request/params context) (:params context))]
|
||||
{:params (pp/pprint-str params :length 20 :level 20)})
|
||||
(when-let [params (or (:request/params context) (:params context))]
|
||||
{:params (pp/pprint-str params :length 20 :level 20)})
|
||||
|
||||
(when-let [value (:value context)]
|
||||
{:value (pp/pprint-str value :length 30 :level 13)})
|
||||
(when-let [value (:value context)]
|
||||
{:value (pp/pprint-str value :length 30 :level 13)})
|
||||
|
||||
(when-let [data (some-> data (dissoc ::s/problems ::s/value ::s/spec ::sm/explain :hint))]
|
||||
{:data (pp/pprint-str data :length 30 :level 13)})
|
||||
(when-let [data (some-> data (dissoc ::s/problems ::s/value ::s/spec ::sm/explain :hint))]
|
||||
{:data (pp/pprint-str data :length 30 :level 13)})
|
||||
|
||||
(when-let [explain (ex/explain data :length 30 :level 13)]
|
||||
{:explain explain}))))
|
||||
(when-let [explain (ex/explain data :length 30 :level 13)]
|
||||
{:explain explain})))))
|
||||
|
||||
(defn- handle-log-record
|
||||
"Convert the log record into a report object and persist it on the database"
|
||||
(defn error-record?
|
||||
[{:keys [::l/level]}]
|
||||
(= :error level))
|
||||
|
||||
(defn- handle-event
|
||||
[{:keys [::db/pool]} {:keys [::l/id] :as record}]
|
||||
(try
|
||||
(let [uri (cf/get :public-uri)
|
||||
report (-> record record->report d/without-nils)]
|
||||
(l/dbg :hint "registering error on database"
|
||||
:id id
|
||||
:src "logging"
|
||||
:uri (str uri "/dbg/error/" id))
|
||||
(persist-on-database! pool id 3 report))
|
||||
(catch Throwable cause
|
||||
(l/warn :hint "unexpected exception on database error logger" :cause cause))))
|
||||
(l/debug :hint "registering error on database" :id id
|
||||
:uri (str uri "/dbg/error/" id))
|
||||
|
||||
(defn- event->report
|
||||
[{:keys [::audit/context ::audit/props ::audit/ip-addr] :as record}]
|
||||
(let [context
|
||||
(reduce-kv (fn [context k v]
|
||||
(let [k' (keyword "frontend" (name k))]
|
||||
(-> context
|
||||
(dissoc k)
|
||||
(assoc k' v))))
|
||||
context
|
||||
context)
|
||||
|
||||
context
|
||||
(-> context
|
||||
(assoc :backend/tenant (cf/get :tenant))
|
||||
(assoc :backend/host (cf/get :host))
|
||||
(assoc :backend/public-uri (str (cf/get :public-uri)))
|
||||
(assoc :backend/version (:full cf/version))
|
||||
(assoc :frontend/ip-addr ip-addr))]
|
||||
|
||||
{:context (-> (into (sorted-map) context)
|
||||
(pp/pprint-str :length 50))
|
||||
:props (pp/pprint-str props :length 50)
|
||||
:hint (get props :hint)
|
||||
:report (get props :report)}))
|
||||
|
||||
(defn- handle-audit-event
|
||||
"Convert the log record into a report object and persist it on the database"
|
||||
[{:keys [::db/pool]} {:keys [::audit/id] :as event}]
|
||||
(try
|
||||
(let [uri (cf/get :public-uri)
|
||||
report (-> event event->report d/without-nils)]
|
||||
(l/dbg :hint "registering error on database"
|
||||
:id id
|
||||
:src "audit-log"
|
||||
:uri (str uri "/dbg/error/" id))
|
||||
(persist-on-database! pool id 4 report))
|
||||
(persist-on-database! pool id report))
|
||||
(catch Throwable cause
|
||||
(l/warn :hint "unexpected exception on database error logger" :cause cause))))
|
||||
|
||||
@@ -140,49 +100,26 @@
|
||||
|
||||
(defmethod ig/init-key ::reporter
|
||||
[_ cfg]
|
||||
(let [input (sp/chan :buf (sp/sliding-buffer 256))
|
||||
thread (px/thread
|
||||
{:name "penpot/reporter/database"}
|
||||
(l/info :hint "initializing database error persistence")
|
||||
(try
|
||||
(loop []
|
||||
(when-let [item (sp/take! input)]
|
||||
(cond
|
||||
(::l/id item)
|
||||
(handle-log-record cfg item)
|
||||
(let [input (sp/chan :buf (sp/sliding-buffer 64)
|
||||
:xf (filter error-record?))]
|
||||
(add-watch l/log-record ::reporter #(sp/put! input %4))
|
||||
|
||||
(::audit/id item)
|
||||
(handle-audit-event cfg item)
|
||||
|
||||
:else
|
||||
(l/warn :hint "received unexpected item" :item item))
|
||||
|
||||
(recur)))
|
||||
|
||||
(catch InterruptedException _
|
||||
(l/debug :hint "reporter interrupted"))
|
||||
(catch Throwable cause
|
||||
(l/error :hint "unexpected error" :cause cause))
|
||||
(finally
|
||||
(l/info :hint "reporter terminated"))))]
|
||||
|
||||
(add-watch l/log-record ::reporter
|
||||
(fn [_ _ _ record]
|
||||
(when (= :error (::l/level record))
|
||||
(sp/put! input record))))
|
||||
|
||||
{::input input
|
||||
::thread thread}))
|
||||
(px/thread {:name "penpot/database-reporter"}
|
||||
(l/info :hint "initializing database error persistence")
|
||||
(try
|
||||
(loop []
|
||||
(when-let [record (sp/take! input)]
|
||||
(handle-event cfg record)
|
||||
(recur)))
|
||||
(catch InterruptedException _
|
||||
(l/debug :hint "reporter interrupted"))
|
||||
(catch Throwable cause
|
||||
(l/error :hint "unexpected error" :cause cause))
|
||||
(finally
|
||||
(sp/close! input)
|
||||
(remove-watch l/log-record ::reporter)
|
||||
(l/info :hint "reporter terminated"))))))
|
||||
|
||||
(defmethod ig/halt-key! ::reporter
|
||||
[_ {:keys [::input ::thread]}]
|
||||
(remove-watch l/log-record ::reporter)
|
||||
(sp/close! input)
|
||||
(px/interrupt! thread))
|
||||
|
||||
(defn emit
|
||||
"Emit an event/report into the database reporter"
|
||||
[cfg event]
|
||||
(when-let [{:keys [::input]} (get cfg ::reporter)]
|
||||
(sp/put! input event)))
|
||||
|
||||
[_ thread]
|
||||
(some-> thread px/interrupt!))
|
||||
|
||||
@@ -9,10 +9,9 @@
|
||||
(:require
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.logging :as l]
|
||||
[app.common.uri :as u]
|
||||
[app.config :as cf]
|
||||
[app.http.client :as http]
|
||||
[app.loggers.audit :as audit]
|
||||
[app.loggers.database :as ldb]
|
||||
[app.util.json :as json]
|
||||
[integrant.core :as ig]
|
||||
[promesa.exec :as px]
|
||||
@@ -21,27 +20,24 @@
|
||||
(defonce enabled (atom true))
|
||||
|
||||
(defn- send-mattermost-notification!
|
||||
[cfg {:keys [id] :as report}]
|
||||
[cfg {:keys [id public-uri] :as report}]
|
||||
|
||||
|
||||
(let [url (u/join (cf/get :public-uri) "/dbg/error/" id)
|
||||
|
||||
text (str "Exception: " url " "
|
||||
(let [text (str "Exception: " public-uri "/dbg/error/" id " "
|
||||
(when-let [pid (:profile-id report)]
|
||||
(str "(pid: #uuid-" pid ")"))
|
||||
"\n"
|
||||
"- host: #" (:host report) "\n"
|
||||
"- tenant: #" (:tenant report) "\n"
|
||||
"- origin: #" (:origin report) "\n"
|
||||
"- href: `" (:href report) "`\n"
|
||||
"- logger: #" (:logger report) "\n"
|
||||
"- request-path: `" (:request-path report) "`\n"
|
||||
"- frontend-version: `" (:frontend-version report) "`\n"
|
||||
"- backend-version: `" (:backend-version report) "`\n"
|
||||
"\n"
|
||||
(when-let [trace (:trace report)]
|
||||
(str "```\n"
|
||||
"Trace:\n"
|
||||
trace
|
||||
"```")))
|
||||
"```\n"
|
||||
"Trace:\n"
|
||||
(:trace report)
|
||||
"```")
|
||||
|
||||
resp (http/req! cfg
|
||||
{:uri (cf/get :error-report-webhook)
|
||||
@@ -54,49 +50,28 @@
|
||||
(l/warn :hint "error on sending data"
|
||||
:response (pr-str resp)))))
|
||||
|
||||
(defn- record->report
|
||||
(defn record->report
|
||||
[{:keys [::l/context ::l/id ::l/cause] :as record}]
|
||||
(assert (l/valid-record? record) "expectd valid log record")
|
||||
|
||||
(let [public-uri (cf/get :public-uri)]
|
||||
{:id id
|
||||
:origin "logging"
|
||||
:tenant (cf/get :tenant)
|
||||
:host (cf/get :host)
|
||||
:backend-version (:full cf/version)
|
||||
:frontend-version (:frontend/version context)
|
||||
:profile-id (:request/profile-id context)
|
||||
:href (-> public-uri
|
||||
(assoc :path (:request/path context))
|
||||
(str))
|
||||
:trace (ex/format-throwable cause :detail? false :header? false)}))
|
||||
|
||||
(defn- audit-event->report
|
||||
[{:keys [::audit/context ::audit/props ::audit/id] :as event}]
|
||||
{:id id
|
||||
:origin "audit-log"
|
||||
:tenant (cf/get :tenant)
|
||||
:host (cf/get :host)
|
||||
:backend-version (:full cf/version)
|
||||
:frontend-version (:version context)
|
||||
:profile-id (:audit/profile-id event)
|
||||
:href (get props :href)})
|
||||
:public-uri (cf/get :public-uri)
|
||||
:backend-version (or (:version/backend context) (:full cf/version))
|
||||
:frontend-version (:version/frontend context)
|
||||
:profile-id (:request/profile-id context)
|
||||
:request-path (:request/path context)
|
||||
:logger (::l/logger record)
|
||||
:trace (ex/format-throwable cause :detail? false :header? false)})
|
||||
|
||||
(defn- handle-log-record
|
||||
(defn handle-event
|
||||
[cfg record]
|
||||
(try
|
||||
(let [report (record->report record)]
|
||||
(send-mattermost-notification! cfg report))
|
||||
(catch Throwable cause
|
||||
(l/warn :hint "unhandled error" :cause cause))))
|
||||
|
||||
(defn- handle-audit-event
|
||||
[cfg record]
|
||||
(try
|
||||
(let [report (audit-event->report record)]
|
||||
(send-mattermost-notification! cfg report))
|
||||
(catch Throwable cause
|
||||
(l/warn :hint "unhandled error" :cause cause))))
|
||||
(when @enabled
|
||||
(try
|
||||
(let [report (record->report record)]
|
||||
(send-mattermost-notification! cfg report))
|
||||
(catch Throwable cause
|
||||
(l/warn :hint "unhandled error" :cause cause)))))
|
||||
|
||||
(defmethod ig/assert-key ::reporter
|
||||
[_ params]
|
||||
@@ -105,49 +80,27 @@
|
||||
(defmethod ig/init-key ::reporter
|
||||
[_ cfg]
|
||||
(when-let [uri (cf/get :error-report-webhook)]
|
||||
(let [input (sp/chan :buf (sp/sliding-buffer 256))
|
||||
thread (px/thread
|
||||
{:name "penpot/reporter/mattermost"}
|
||||
(l/info :hint "initializing error reporter" :uri uri)
|
||||
|
||||
(try
|
||||
(loop []
|
||||
(when-let [item (sp/take! input)]
|
||||
(when @enabled
|
||||
(cond
|
||||
(::l/id item)
|
||||
(handle-log-record cfg item)
|
||||
|
||||
(::audit/id item)
|
||||
(handle-audit-event cfg item)
|
||||
|
||||
:else
|
||||
(l/warn :hint "received unexpected item" :item item)))
|
||||
|
||||
(recur)))
|
||||
(catch InterruptedException _
|
||||
(l/debug :hint "reporter interrupted"))
|
||||
(catch Throwable cause
|
||||
(l/error :hint "unexpected error" :cause cause))
|
||||
(finally
|
||||
(l/info :hint "reporter terminated"))))]
|
||||
|
||||
(add-watch l/log-record ::reporter
|
||||
(fn [_ _ _ record]
|
||||
(when (= :error (::l/level record))
|
||||
(sp/put! input record))))
|
||||
|
||||
{::input input
|
||||
::thread thread})))
|
||||
(px/thread
|
||||
{:name "penpot/mattermost-reporter"
|
||||
:virtual true}
|
||||
(l/info :hint "initializing error reporter" :uri uri)
|
||||
(let [input (sp/chan :buf (sp/sliding-buffer 128)
|
||||
:xf (filter ldb/error-record?))]
|
||||
(add-watch l/log-record ::reporter #(sp/put! input %4))
|
||||
(try
|
||||
(loop []
|
||||
(when-let [msg (sp/take! input)]
|
||||
(handle-event cfg msg)
|
||||
(recur)))
|
||||
(catch InterruptedException _
|
||||
(l/debug :hint "reporter interrupted"))
|
||||
(catch Throwable cause
|
||||
(l/error :hint "unexpected error" :cause cause))
|
||||
(finally
|
||||
(sp/close! input)
|
||||
(remove-watch l/log-record ::reporter)
|
||||
(l/info :hint "reporter terminated")))))))
|
||||
|
||||
(defmethod ig/halt-key! ::reporter
|
||||
[_ {:keys [::input ::thread]}]
|
||||
(remove-watch l/log-record ::reporter)
|
||||
(some-> input sp/close!)
|
||||
[_ thread]
|
||||
(some-> thread px/interrupt!))
|
||||
|
||||
(defn emit
|
||||
"Emit an event/report into the mattermost reporter"
|
||||
[cfg event]
|
||||
(when-let [{:keys [::input]} (get cfg ::reporter)]
|
||||
(sp/put! input event)))
|
||||
|
||||
@@ -337,13 +337,7 @@
|
||||
::setup/props (ig/ref ::setup/props)
|
||||
|
||||
::email/blacklist (ig/ref ::email/blacklist)
|
||||
::email/whitelist (ig/ref ::email/whitelist)
|
||||
|
||||
:app.loggers.database/reporter
|
||||
(ig/ref :app.loggers.database/reporter)
|
||||
|
||||
:app.loggers.mattermost/reporter
|
||||
(ig/ref :app.loggers.mattermost/reporter)}
|
||||
::email/whitelist (ig/ref ::email/whitelist)}
|
||||
|
||||
:app.nitrate/client
|
||||
{::http.client/client (ig/ref ::http.client/client)
|
||||
@@ -369,7 +363,6 @@
|
||||
;; FIXME: revisit if db/pool is necessary here
|
||||
::db/pool (ig/ref ::db/pool)
|
||||
::session/manager (ig/ref ::session/manager)
|
||||
::setup/props (ig/ref ::setup/props)
|
||||
::setup/shared-keys (ig/ref ::setup/shared-keys)}
|
||||
|
||||
::wrk/registry
|
||||
|
||||
@@ -456,10 +456,7 @@
|
||||
:fn (mg/resource "app/migrations/sql/0142-add-sso-provider-table.sql")}
|
||||
|
||||
{:name "0143-http-session-v2-table"
|
||||
:fn (mg/resource "app/migrations/sql/0143-add-http-session-v2-table.sql")}
|
||||
|
||||
{:name "0144-mod-server-error-report-table"
|
||||
:fn (mg/resource "app/migrations/sql/0144-mod-server-error-report-table.sql")}])
|
||||
:fn (mg/resource "app/migrations/sql/0143-add-http-session-v2-table.sql")}])
|
||||
|
||||
(defn apply-migrations!
|
||||
[pool name migrations]
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
ALTER TABLE server_error_report DROP CONSTRAINT server_error_report_pkey;
|
||||
|
||||
DELETE FROM server_error_report a
|
||||
USING server_error_report b
|
||||
WHERE a.id = b.id
|
||||
AND a.ctid < b.ctid;
|
||||
|
||||
ALTER TABLE server_error_report ADD PRIMARY KEY (id);
|
||||
|
||||
CREATE INDEX server_error_report__version__idx
|
||||
ON server_error_report ( version );
|
||||
@@ -16,8 +16,6 @@
|
||||
[app.db :as db]
|
||||
[app.http :as-alias http]
|
||||
[app.loggers.audit :as-alias audit]
|
||||
[app.loggers.database :as loggers.db]
|
||||
[app.loggers.mattermost :as loggers.mm]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.rpc.climit :as-alias climit]
|
||||
[app.rpc.doc :as-alias doc]
|
||||
@@ -38,79 +36,52 @@
|
||||
:context])
|
||||
|
||||
(defn- event->row [event]
|
||||
[(::audit/id event)
|
||||
(::audit/name event)
|
||||
(::audit/source event)
|
||||
(::audit/type event)
|
||||
(::audit/tracked-at event)
|
||||
(::audit/created-at event)
|
||||
(::audit/profile-id event)
|
||||
(db/inet (::audit/ip-addr event))
|
||||
(db/tjson (::audit/props event))
|
||||
(db/tjson (d/without-nils (::audit/context event)))])
|
||||
[(uuid/next)
|
||||
(:name event)
|
||||
(:source event)
|
||||
(:type event)
|
||||
(:timestamp event)
|
||||
(:created-at event)
|
||||
(:profile-id event)
|
||||
(db/inet (:ip-addr event))
|
||||
(db/tjson (:props event))
|
||||
(db/tjson (d/without-nils (:context event)))])
|
||||
|
||||
(defn- adjust-timestamp
|
||||
[{:keys [::audit/tracked-at ::audit/created-at] :as event}]
|
||||
(let [margin (inst-ms (ct/diff tracked-at created-at))]
|
||||
[{:keys [timestamp created-at] :as event}]
|
||||
(let [margin (inst-ms (ct/diff timestamp created-at))]
|
||||
(if (or (neg? margin)
|
||||
(> margin 3600000))
|
||||
;; If event is in future or lags more than 1 hour, we reasign
|
||||
;; tracked-at to the server creation date
|
||||
;; timestamp to the server creation date
|
||||
(-> event
|
||||
(assoc ::audit/tracked-at created-at)
|
||||
(update ::audit/context assoc :original-tracked-at tracked-at))
|
||||
(assoc :timestamp created-at)
|
||||
(update :context assoc :original-timestamp timestamp))
|
||||
event)))
|
||||
|
||||
(defn- exception-event?
|
||||
[{:keys [::audit/type ::audit/name] :as ev}]
|
||||
(and (= "action" type)
|
||||
(or (= "unhandled-exception" name)
|
||||
(= "exception-page" name))))
|
||||
|
||||
(def ^:private xf:map-event-row
|
||||
(comp
|
||||
(map adjust-timestamp)
|
||||
(map event->row)))
|
||||
|
||||
(defn- get-events
|
||||
[{:keys [::rpc/request-at ::rpc/profile-id events] :as params}]
|
||||
(defn- handle-events
|
||||
[{:keys [::db/pool]} {:keys [::rpc/profile-id events] :as params}]
|
||||
(let [request (-> params meta ::http/request)
|
||||
ip-addr (inet/parse-request request)
|
||||
|
||||
xform (map (fn [event]
|
||||
{::audit/id (uuid/next)
|
||||
::audit/type (:type event)
|
||||
::audit/name (:name event)
|
||||
::audit/props (:props event)
|
||||
::audit/context (:context event)
|
||||
::audit/profile-id profile-id
|
||||
::audit/ip-addr ip-addr
|
||||
::audit/source "frontend"
|
||||
::audit/tracked-at (:timestamp event)
|
||||
::audit/created-at request-at}))]
|
||||
|
||||
(sequence xform events)))
|
||||
|
||||
(defn- handle-events
|
||||
[{:keys [::db/pool] :as cfg} params]
|
||||
(let [events (get-events params)]
|
||||
|
||||
;; Look for error reports and save them on internal reports table
|
||||
(when-let [events (->> events
|
||||
(sequence (filter exception-event?))
|
||||
(not-empty))]
|
||||
(run! (partial loggers.db/emit cfg) events)
|
||||
(run! (partial loggers.mm/emit cfg) events))
|
||||
|
||||
;; Process and save events
|
||||
tnow (ct/now)
|
||||
xform (comp
|
||||
(map (fn [event]
|
||||
(-> event
|
||||
(assoc :created-at tnow)
|
||||
(assoc :profile-id profile-id)
|
||||
(assoc :ip-addr ip-addr)
|
||||
(assoc :source "frontend"))))
|
||||
(filter :profile-id)
|
||||
(map adjust-timestamp)
|
||||
(map event->row))
|
||||
events (sequence xform events)]
|
||||
(when (seq events)
|
||||
(let [rows (sequence xf:map-event-row events)]
|
||||
(db/insert-many! pool :audit-log event-columns rows)))))
|
||||
(db/insert-many! pool :audit-log event-columns events))))
|
||||
|
||||
(def ^:private valid-event-types
|
||||
(def valid-event-types
|
||||
#{"action" "identify" "trigger"})
|
||||
|
||||
(def ^:private schema:frontend-event
|
||||
(def schema:event
|
||||
[:map {:title "Event"}
|
||||
[:name
|
||||
[:and {:gen/elements ["update-file", "get-profile"]}
|
||||
@@ -122,13 +93,12 @@
|
||||
[::sm/one-of {:format "string"} valid-event-types]]]
|
||||
[:props
|
||||
[:map-of :keyword ::sm/any]]
|
||||
[:timestamp ::ct/inst]
|
||||
[:context {:optional true}
|
||||
[:map-of :keyword ::sm/any]]])
|
||||
|
||||
(def ^:private schema:push-audit-events
|
||||
(def schema:push-audit-events
|
||||
[:map {:title "push-audit-events"}
|
||||
[:events [:vector schema:frontend-event]]])
|
||||
[:events [:vector schema:event]]])
|
||||
|
||||
(sv/defmethod ::push-audit-events
|
||||
{::climit/id :submit-audit-events/by-profile
|
||||
|
||||
@@ -103,14 +103,6 @@
|
||||
(assoc-in [::db/pool ::db/username] (:database-username config))
|
||||
(assoc-in [::db/pool ::db/password] (:database-password config))
|
||||
(assoc-in [:app.rpc/methods :app.setup/templates] templates)
|
||||
(assoc-in [:app.rpc/methods :app.setup/templates] templates)
|
||||
(update :app.rpc/methods
|
||||
(fn [state]
|
||||
(-> state
|
||||
(assoc :app.setup/templates templates)
|
||||
(assoc :app.loggers.mattermost/reporter nil)
|
||||
(assoc :app.loggers.database/reporter nil))))
|
||||
|
||||
(dissoc :app.srepl/server
|
||||
:app.http/server
|
||||
:app.http/route
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{:deps
|
||||
{org.clojure/clojure {:mvn/version "1.12.4"}
|
||||
{org.clojure/clojure {:mvn/version "1.12.2"}
|
||||
org.clojure/data.json {:mvn/version "2.5.1"}
|
||||
org.clojure/tools.cli {:mvn/version "1.1.230"}
|
||||
org.clojure/test.check {:mvn/version "1.1.1"}
|
||||
@@ -9,15 +9,15 @@
|
||||
org.apache.commons/commons-pool2 {:mvn/version "2.12.1"}
|
||||
|
||||
;; Logging
|
||||
org.apache.logging.log4j/log4j-api {:mvn/version "2.25.3"}
|
||||
org.apache.logging.log4j/log4j-core {:mvn/version "2.25.3"}
|
||||
org.apache.logging.log4j/log4j-web {:mvn/version "2.25.3"}
|
||||
org.apache.logging.log4j/log4j-jul {:mvn/version "2.25.3"}
|
||||
org.apache.logging.log4j/log4j-slf4j2-impl {:mvn/version "2.25.3"}
|
||||
org.apache.logging.log4j/log4j-api {:mvn/version "2.25.1"}
|
||||
org.apache.logging.log4j/log4j-core {:mvn/version "2.25.1"}
|
||||
org.apache.logging.log4j/log4j-web {:mvn/version "2.25.1"}
|
||||
org.apache.logging.log4j/log4j-jul {:mvn/version "2.25.1"}
|
||||
org.apache.logging.log4j/log4j-slf4j2-impl {:mvn/version "2.25.1"}
|
||||
org.slf4j/slf4j-api {:mvn/version "2.0.17"}
|
||||
pl.tkowalcz.tjahzi/log4j2-appender {:mvn/version "0.9.41"}
|
||||
pl.tkowalcz.tjahzi/log4j2-appender {:mvn/version "0.9.40"}
|
||||
|
||||
selmer/selmer {:mvn/version "1.12.70"}
|
||||
selmer/selmer {:mvn/version "1.12.69"}
|
||||
criterium/criterium {:mvn/version "0.4.6"}
|
||||
|
||||
metosin/jsonista {:mvn/version "0.3.13"}
|
||||
@@ -27,7 +27,7 @@
|
||||
com.cognitect/transit-clj {:mvn/version "1.0.333"}
|
||||
com.cognitect/transit-cljs {:mvn/version "0.8.280"}
|
||||
java-http-clj/java-http-clj {:mvn/version "0.4.3"}
|
||||
integrant/integrant {:mvn/version "1.0.1"}
|
||||
integrant/integrant {:mvn/version "1.0.0"}
|
||||
|
||||
funcool/cuerdas {:mvn/version "2026.415"}
|
||||
funcool/promesa
|
||||
|
||||
@@ -239,63 +239,22 @@
|
||||
(recur cause))))))]
|
||||
|
||||
(with-out-str
|
||||
(print-all cause))))
|
||||
|
||||
:cljs
|
||||
(defn format-throwable
|
||||
[cause & {:as opts}]
|
||||
(with-out-str
|
||||
(when-let [exdata (ex-data cause)]
|
||||
(when-let [hint (get exdata :hint)]
|
||||
(when (str/index-of hint "\n")
|
||||
(println "Hint:")
|
||||
(println "--------------------")
|
||||
(println hint)
|
||||
(println)))
|
||||
|
||||
(when-let [explain (get exdata ::sm/explain)]
|
||||
(println "Explain:")
|
||||
(println "--------------------")
|
||||
|
||||
(println (sm/humanize-explain explain))
|
||||
(println))
|
||||
|
||||
(when-let [explain (get exdata :explain)]
|
||||
(println "Server Explain:")
|
||||
(println "--------------------")
|
||||
(println explain))
|
||||
|
||||
(println "Data:")
|
||||
(println "--------------------")
|
||||
(pp/pprint (dissoc exdata ::sm/explain :explain))
|
||||
(println))
|
||||
|
||||
(when-let [trace (.-stack cause)]
|
||||
(println "Trace:")
|
||||
(println "--------------------")
|
||||
(println (.-stack cause))))))
|
||||
|
||||
(defn first-line
|
||||
[s]
|
||||
(let [break-index (str/index-of s "\n")]
|
||||
(if (pos? break-index)
|
||||
(subs s 0 break-index)
|
||||
s)))
|
||||
(print-all cause)))))
|
||||
|
||||
(defn print-throwable
|
||||
[cause & {:as opts}]
|
||||
#?(:clj
|
||||
(println (format-throwable cause opts))
|
||||
:cljs
|
||||
(let [prefix (get opts :prefix)
|
||||
data (ex-data cause)
|
||||
title (cond->> (or (some-> (:hint data) first-line)
|
||||
(ex-message cause))
|
||||
(string? prefix)
|
||||
(str prefix ": "))]
|
||||
|
||||
(let [prefix (get opts :prefix "exception")
|
||||
title (str prefix ": " (ex-message cause))
|
||||
exdata (ex-data cause)]
|
||||
(js/console.group title)
|
||||
(try
|
||||
(js/console.log (format-throwable cause))
|
||||
(finally
|
||||
(js/console.groupEnd))))))
|
||||
(when-let [explain (get exdata ::sm/explain)]
|
||||
(println (sm/humanize-explain explain)))
|
||||
|
||||
(js/console.log "\nData:")
|
||||
(pp/pprint (dissoc exdata ::sm/explain))
|
||||
|
||||
(js/console.log "\nTrace:")
|
||||
(js/console.error (.-stack cause)))))
|
||||
|
||||
@@ -2016,9 +2016,7 @@
|
||||
(let [;; We need to sync only the position relative to the origin of the component.
|
||||
;; (see update-attrs for a full explanation)
|
||||
previous-shape (reposition-shape previous-shape prev-root current-root)
|
||||
touched (get previous-shape :touched #{})
|
||||
text-auto? (and (cfh/text-shape? current-shape)
|
||||
(contains? #{:auto-height :auto-width} (:grow-type current-shape)))]
|
||||
touched (get previous-shape :touched #{})]
|
||||
|
||||
(loop [attrs updatable-attrs
|
||||
roperations [{:type :set-touched :touched (:touched previous-shape)}]
|
||||
@@ -2027,10 +2025,6 @@
|
||||
(let [attr-group (get ctk/sync-attrs attr)
|
||||
skip-operations?
|
||||
(or
|
||||
;; For auto text, avoid copying geometry-driven attrs on switch.
|
||||
(and text-auto?
|
||||
(contains? #{:points :selrect :width :height :position-data} attr))
|
||||
|
||||
;; If the attribute is not valid for the destiny, don't copy it
|
||||
(not (cts/is-allowed-switch-keep-attr? attr (:type current-shape)))
|
||||
|
||||
|
||||
@@ -109,12 +109,9 @@
|
||||
(def token-types
|
||||
(into #{} (keys token-type->dtcg-token-type)))
|
||||
|
||||
(def token-name-validation-regex
|
||||
#"^[a-zA-Z0-9_-][a-zA-Z0-9$_-]*(\.[a-zA-Z0-9$_-]+)*$")
|
||||
|
||||
(def token-name-ref
|
||||
[:re {:title "TokenNameRef" :gen/gen sg/text}
|
||||
token-name-validation-regex])
|
||||
#"^[a-zA-Z0-9_-][a-zA-Z0-9$_-]*(\.[a-zA-Z0-9$_-]+)*$"])
|
||||
|
||||
(def ^:private schema:color
|
||||
[:map
|
||||
|
||||
@@ -1467,12 +1467,11 @@ Will return a value that matches this schema:
|
||||
(def ^:private schema:dtcg-node
|
||||
[:schema {:registry
|
||||
{::simple-value
|
||||
[:or :string :int :double ::sm/boolean]
|
||||
[:or :string :int :double]
|
||||
::value
|
||||
[:or
|
||||
[:ref ::simple-value]
|
||||
[:vector ::simple-value]
|
||||
[:vector [:map-of :string ::simple-value]]
|
||||
[:map-of :string [:or
|
||||
[:ref ::simple-value]
|
||||
[:vector ::simple-value]]]]}}
|
||||
|
||||
@@ -31,7 +31,7 @@ RUN set -ex; \
|
||||
|
||||
FROM base AS setup-node
|
||||
|
||||
ENV NODE_VERSION=v22.22.0 \
|
||||
ENV NODE_VERSION=v22.21.1 \
|
||||
PATH=/opt/node/bin:$PATH
|
||||
|
||||
RUN set -eux; \
|
||||
@@ -97,19 +97,18 @@ RUN set -eux; \
|
||||
|
||||
FROM base AS setup-jvm
|
||||
|
||||
# https://clojure.org/releases/tools
|
||||
ENV CLOJURE_VERSION=1.12.4.1602
|
||||
ENV CLOJURE_VERSION=1.12.3.1577
|
||||
|
||||
RUN set -eux; \
|
||||
ARCH="$(dpkg --print-architecture)"; \
|
||||
case "${ARCH}" in \
|
||||
aarch64|arm64) \
|
||||
ESUM='9903c6b19183a33725ca1dfdae5b72400c9d00995c76fafc4a0d31c5152f33f7'; \
|
||||
BINARY_URL='https://cdn.azul.com/zulu/bin/zulu25.32.21-ca-jdk25.0.2-linux_aarch64.tar.gz'; \
|
||||
ESUM='8c5321f16d9f1d8149f83e4e9ff8ca5d9e94320b92d205e6db42a604de3d1140'; \
|
||||
BINARY_URL='https://cdn.azul.com/zulu/bin/zulu25.30.17-ca-jdk25.0.1-linux_aarch64.tar.gz'; \
|
||||
;; \
|
||||
amd64|x86_64) \
|
||||
ESUM='946ad9766d98fc6ab495a1a120072197db54997f6925fb96680f1ecd5591db4e'; \
|
||||
BINARY_URL='https://cdn.azul.com/zulu/bin/zulu25.32.21-ca-jdk25.0.2-linux_x64.tar.gz'; \
|
||||
ESUM='471b3e62bdffaed27e37005d842d8639f10d244ccce1c7cdebf7abce06c8313e'; \
|
||||
BINARY_URL='https://cdn.azul.com/zulu/bin/zulu25.30.17-ca-jdk25.0.1-linux_x64.tar.gz'; \
|
||||
;; \
|
||||
*) \
|
||||
echo "Unsupported arch: ${ARCH}"; \
|
||||
@@ -182,8 +181,7 @@ FROM base AS setup-utils
|
||||
|
||||
ENV CLJKONDO_VERSION=2026.01.19 \
|
||||
BABASHKA_VERSION=1.12.208 \
|
||||
CLJFMT_VERSION=0.15.6 \
|
||||
PIXI_VERSION=0.63.2
|
||||
CLJFMT_VERSION=0.15.6
|
||||
|
||||
RUN set -ex; \
|
||||
ARCH="$(dpkg --print-architecture)"; \
|
||||
@@ -226,26 +224,6 @@ RUN set -ex; \
|
||||
tar -xf /tmp/babashka.tar.gz; \
|
||||
rm -rf /tmp/babashka.tar.gz;
|
||||
|
||||
RUN set -ex; \
|
||||
ARCH="$(dpkg --print-architecture)"; \
|
||||
case "${ARCH}" in \
|
||||
aarch64|arm64) \
|
||||
BINARY_URL="https://github.com/prefix-dev/pixi/releases/download/v$PIXI_VERSION/pixi-aarch64-unknown-linux-musl.tar.gz"; \
|
||||
;; \
|
||||
amd64|x86_64) \
|
||||
BINARY_URL="https://github.com/prefix-dev/pixi/releases/download/v$PIXI_VERSION/pixi-x86_64-unknown-linux-musl.tar.gz"; \
|
||||
;; \
|
||||
*) \
|
||||
echo "Unsupported arch: ${ARCH}"; \
|
||||
exit 1; \
|
||||
;; \
|
||||
esac; \
|
||||
cd /tmp; \
|
||||
curl -LfsSo /tmp/pixi.tar.gz ${BINARY_URL}; \
|
||||
cd /opt/utils/bin; \
|
||||
tar -xf /tmp/pixi.tar.gz; \
|
||||
rm -rf /tmp/pixi.tar.gz;
|
||||
|
||||
RUN set -ex; \
|
||||
ARCH="$(dpkg --print-architecture)"; \
|
||||
case "${ARCH}" in \
|
||||
@@ -397,7 +375,7 @@ ENV LANG='C.UTF-8' \
|
||||
RUSTUP_HOME="/opt/rustup" \
|
||||
PATH="/opt/jdk/bin:/opt/utils/bin:/opt/clojure/bin:/opt/node/bin:/opt/imagick/bin:/opt/cargo/bin:$PATH"
|
||||
|
||||
COPY --from=penpotapp/imagemagick:7.1.2-13 /opt/imagick /opt/imagick
|
||||
COPY --from=penpotapp/imagemagick:7.1.2-0 /opt/imagick /opt/imagick
|
||||
COPY --from=setup-jvm /opt/jdk /opt/jdk
|
||||
COPY --from=setup-jvm /opt/clojure /opt/clojure
|
||||
COPY --from=setup-node /opt/node /opt/node
|
||||
|
||||
@@ -46,11 +46,6 @@ services:
|
||||
- 9090:9090
|
||||
- 9091:9091
|
||||
|
||||
# MCP
|
||||
- 4400:4400
|
||||
- 4401:4401
|
||||
- 4402:4402
|
||||
|
||||
environment:
|
||||
- EXTERNAL_UID=${CURRENT_USER_ID}
|
||||
# SMTP setup
|
||||
|
||||
@@ -6,8 +6,7 @@ export PATH="/home/penpot/.cargo/bin:/opt/jdk/bin:/opt/utils/bin:/opt/clojure/bi
|
||||
export CARGO_HOME="/home/penpot/.cargo"
|
||||
|
||||
alias l='ls --color -GFlh'
|
||||
alias ll='ls --color -GFlh'
|
||||
alias rm='rm -rf'
|
||||
alias rm='rm -r'
|
||||
alias ls='ls --color -F'
|
||||
alias lsd='ls -d *(/)'
|
||||
alias lsf='ls -h *(.)'
|
||||
|
||||
@@ -121,28 +121,6 @@ http {
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
location /mcp {
|
||||
alias /home/penpot/penpot/mcp/packages/plugin/dist;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
location /mcp/ws {
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_pass http://127.0.0.1:4402;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
location /mcp/stream {
|
||||
proxy_pass http://127.0.0.1:4401/mcp;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
location /mcp/sse {
|
||||
proxy_pass http://127.0.0.1:4401/sse;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
|
||||
location /admin {
|
||||
proxy_pass http://127.0.0.1:6063/admin;
|
||||
}
|
||||
|
||||
@@ -41,4 +41,9 @@ tmux select-window -t penpot:3
|
||||
tmux send-keys -t penpot 'cd penpot/backend' enter C-l
|
||||
tmux send-keys -t penpot './scripts/start-dev' enter
|
||||
|
||||
tmux new-window -t penpot:4 -n 'rust-wasm'
|
||||
tmux select-window -t penpot:4
|
||||
tmux send-keys -t penpot 'cd penpot/render-wasm' enter C-l
|
||||
tmux send-keys -t penpot './build' enter
|
||||
|
||||
tmux -2 attach-session -t penpot
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
set -g default-command "${SHELL}"
|
||||
set -g mouse off
|
||||
set -g history-limit 50000
|
||||
setw -g mode-keys emacs
|
||||
|
||||
@@ -6,7 +6,7 @@ ENV LANG='C.UTF-8' \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
TZ=Etc/UTC
|
||||
|
||||
ARG IMAGEMAGICK_VERSION=7.1.2-13
|
||||
ARG IMAGEMAGICK_VERSION=7.1.1-47
|
||||
|
||||
RUN set -e; \
|
||||
apt-get -qq update; \
|
||||
|
||||
@@ -5,7 +5,7 @@ ENV LANG='C.UTF-8' \
|
||||
LC_ALL='C.UTF-8' \
|
||||
JAVA_HOME="/opt/jdk" \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
NODE_VERSION=v22.22.0 \
|
||||
NODE_VERSION=v22.21.1 \
|
||||
TZ=Etc/UTC
|
||||
|
||||
RUN set -ex; \
|
||||
@@ -46,12 +46,12 @@ RUN set -eux; \
|
||||
ARCH="$(dpkg --print-architecture)"; \
|
||||
case "${ARCH}" in \
|
||||
aarch64|arm64) \
|
||||
ESUM='9903c6b19183a33725ca1dfdae5b72400c9d00995c76fafc4a0d31c5152f33f7'; \
|
||||
BINARY_URL='https://cdn.azul.com/zulu/bin/zulu25.32.21-ca-jdk25.0.2-linux_aarch64.tar.gz'; \
|
||||
ESUM='8c5321f16d9f1d8149f83e4e9ff8ca5d9e94320b92d205e6db42a604de3d1140'; \
|
||||
BINARY_URL='https://cdn.azul.com/zulu/bin/zulu25.30.17-ca-jdk25.0.1-linux_aarch64.tar.gz'; \
|
||||
;; \
|
||||
amd64|x86_64) \
|
||||
ESUM='946ad9766d98fc6ab495a1a120072197db54997f6925fb96680f1ecd5591db4e'; \
|
||||
BINARY_URL='https://cdn.azul.com/zulu/bin/zulu25.32.21-ca-jdk25.0.2-linux_x64.tar.gz'; \
|
||||
ESUM='471b3e62bdffaed27e37005d842d8639f10d244ccce1c7cdebf7abce06c8313e'; \
|
||||
BINARY_URL='https://cdn.azul.com/zulu/bin/zulu25.30.17-ca-jdk25.0.1-linux_x64.tar.gz'; \
|
||||
;; \
|
||||
*) \
|
||||
echo "Unsupported arch: ${ARCH}"; \
|
||||
|
||||
@@ -3,7 +3,7 @@ LABEL maintainer="Penpot <docker@penpot.app>"
|
||||
|
||||
ENV LANG=en_US.UTF-8 \
|
||||
LC_ALL=en_US.UTF-8 \
|
||||
NODE_VERSION=v22.22.0 \
|
||||
NODE_VERSION=v22.21.1 \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
PATH=/opt/node/bin:/opt/imagick/bin:$PATH
|
||||
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
FROM ubuntu:24.04
|
||||
LABEL maintainer="Penpot <docker@penpot.app>"
|
||||
|
||||
ENV LANG=en_US.UTF-8 \
|
||||
LC_ALL=en_US.UTF-8 \
|
||||
NODE_VERSION=v22.21.1 \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
PATH=/opt/node/bin:$PATH
|
||||
|
||||
RUN set -ex; \
|
||||
useradd -U -M -u 1001 -s /bin/false -d /opt/penpot penpot; \
|
||||
mkdir -p /etc/resolvconf/resolv.conf.d; \
|
||||
echo "nameserver 127.0.0.11" > /etc/resolvconf/resolv.conf.d/tail; \
|
||||
apt-get -qq update; \
|
||||
apt-get -qqy --no-install-recommends install \
|
||||
curl \
|
||||
tzdata \
|
||||
locales \
|
||||
ca-certificates \
|
||||
; \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \
|
||||
locale-gen; \
|
||||
find /usr/share/i18n/locales/ -type f ! -name "en_US" ! -name "POSIX" ! -name "C" -delete;
|
||||
|
||||
RUN set -eux; \
|
||||
ARCH="$(dpkg --print-architecture)"; \
|
||||
case "${ARCH}" in \
|
||||
aarch64|arm64) \
|
||||
BINARY_URL="https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-arm64.tar.gz"; \
|
||||
;; \
|
||||
amd64|x86_64) \
|
||||
BINARY_URL="https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-x64.tar.gz"; \
|
||||
;; \
|
||||
*) \
|
||||
echo "Unsupported arch: ${ARCH}"; \
|
||||
exit 1; \
|
||||
;; \
|
||||
esac; \
|
||||
curl -LfsSo /tmp/nodejs.tar.gz ${BINARY_URL}; \
|
||||
mkdir -p /opt/node; \
|
||||
cd /opt/node; \
|
||||
tar -xf /tmp/nodejs.tar.gz --strip-components=1; \
|
||||
chown -R root /opt/node; \
|
||||
rm -rf /tmp/nodejs.tar.gz; \
|
||||
corepack enable; \
|
||||
mkdir -p /opt/penpot; \
|
||||
chown -R penpot:penpot /opt/penpot;
|
||||
|
||||
ARG BUNDLE_PATH="./bundle-mcp/"
|
||||
COPY --chown=penpot:penpot $BUNDLE_PATH /opt/penpot/mcp/
|
||||
|
||||
WORKDIR /opt/penpot/mcp
|
||||
USER penpot:penpot
|
||||
|
||||
RUN ./setup
|
||||
|
||||
CMD ["node", "index.js", "--multi-user"]
|
||||
@@ -198,13 +198,6 @@ services:
|
||||
## Valkey (or previously Redis) is used for the websockets notifications.
|
||||
PENPOT_REDIS_URI: redis://penpot-valkey/0
|
||||
|
||||
penpot-mcp:
|
||||
image: penpotapp/mcp:${PENPOT_VERSION:-latest}
|
||||
restart: always
|
||||
|
||||
networks:
|
||||
- penpot
|
||||
|
||||
penpot-postgres:
|
||||
image: "postgres:15"
|
||||
restart: always
|
||||
|
||||
@@ -130,7 +130,6 @@ http {
|
||||
}
|
||||
|
||||
location /readyz {
|
||||
access_log off;
|
||||
proxy_pass $PENPOT_BACKEND_URI$request_uri;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { defineConfig, devices } from "@playwright/test";
|
||||
import { platform } from "os";
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
@@ -7,10 +6,6 @@ import { platform } from "os";
|
||||
*/
|
||||
// require('dotenv').config();
|
||||
|
||||
const userAgent = platform === 'darwin' ?
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" :
|
||||
undefined;
|
||||
|
||||
/**
|
||||
* @see https://playwright.dev/docs/test-configuration
|
||||
*/
|
||||
@@ -48,20 +43,12 @@ export default defineConfig({
|
||||
projects: [
|
||||
{
|
||||
name: "default",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
testDir: "./playwright/ui/specs",
|
||||
use: {
|
||||
...devices["Desktop Chrome"],
|
||||
viewport: { width: 1920, height: 1080 }, // Add custom viewport size
|
||||
video: 'retain-on-failure',
|
||||
trace: 'retain-on-failure',
|
||||
userAgent,
|
||||
},
|
||||
snapshotPathTemplate: "{testDir}/{testFilePath}-snapshots/{arg}.png",
|
||||
expect: {
|
||||
toHaveScreenshot: {
|
||||
maxDiffPixelRatio: 0.001,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "ds",
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"~:file-id": "~u8d38942d-b01f-800e-8007-79ee6a9bac45",
|
||||
"~:tag": "component",
|
||||
"~:object-id": "8d38942d-b01f-800e-8007-79ee6a9bac45/8d38942d-b01f-800e-8007-79ee6a9bac46/6b68aedd-4c5b-80b9-8007-7b38c1d34ce4/component",
|
||||
"~:media-id": "~ube2dc82e-615b-486b-a193-8768bdb51d7a",
|
||||
"~:created-at": "~m1769523563389"
|
||||
}
|
||||
@@ -253,7 +253,7 @@ export class WorkspacePage extends BaseWebSocketPage {
|
||||
|
||||
async #waitForWebSocketReadiness() {
|
||||
// TODO: find a better event to settle whether the app is ready to receive notifications via ws
|
||||
await expect(this.pageName).toHaveText("Page 1", { timeout: 30000 })
|
||||
await expect(this.pageName).toHaveText("Page 1");
|
||||
}
|
||||
|
||||
async sendPresenceMessage(fixture) {
|
||||
@@ -383,46 +383,19 @@ export class WorkspacePage extends BaseWebSocketPage {
|
||||
await this.page.keyboard.press("T");
|
||||
await this.page.waitForTimeout(timeToWait);
|
||||
await this.clickAndMove(x1, y1, x2, y2);
|
||||
await expect(this.page.getByTestId("text-editor")).toBeVisible();
|
||||
|
||||
await this.page.waitForTimeout(timeToWait);
|
||||
if (initialText) {
|
||||
await this.page.keyboard.type(initialText);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the selected element into the clipboard, or copy the
|
||||
* content of the locator into the clipboard.
|
||||
* Copies the selected element into the clipboard.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async copy(kind = "keyboard", locator = undefined) {
|
||||
if (kind === "context-menu" && locator) {
|
||||
await locator.click({ button: "right" });
|
||||
await this.page.getByText("Copy", { exact: true }).click();
|
||||
} else {
|
||||
await this.page.keyboard.press("ControlOrMeta+C");
|
||||
}
|
||||
// wait for the clipboard to be updated
|
||||
await this.page.waitForFunction(async () => {
|
||||
const content = await navigator.clipboard.readText()
|
||||
return content !== "";
|
||||
}, { timeout: 1000 });
|
||||
}
|
||||
|
||||
async cut(kind = "keyboard", locator = undefined) {
|
||||
if (kind === "context-menu" && locator) {
|
||||
await locator.click({ button: "right" });
|
||||
await this.page.getByText("Cut", { exact: true }).click();
|
||||
} else {
|
||||
await this.page.keyboard.press("ControlOrMeta+X");
|
||||
}
|
||||
// wait for the clipboard to be updated
|
||||
await this.page.waitForFunction(async () => {
|
||||
const content = await navigator.clipboard.readText()
|
||||
return content !== "";
|
||||
}, { timeout: 1000 });
|
||||
|
||||
async copy() {
|
||||
return this.page.keyboard.press("Control+C");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -434,9 +407,9 @@ export class WorkspacePage extends BaseWebSocketPage {
|
||||
async paste(kind = "keyboard") {
|
||||
if (kind === "context-menu") {
|
||||
await this.viewport.click({ button: "right" });
|
||||
return this.page.getByText("Paste", { exact: true }).click();
|
||||
return this.page.getByText("PasteCtrlV").click();
|
||||
}
|
||||
return this.page.keyboard.press("ControlOrMeta+V");
|
||||
return this.page.keyboard.press("Control+V");
|
||||
}
|
||||
|
||||
async panOnViewportAt(x, y, width, height) {
|
||||
@@ -475,11 +448,11 @@ export class WorkspacePage extends BaseWebSocketPage {
|
||||
const layer = this.layers
|
||||
.getByTestId("layer-row")
|
||||
.filter({ hasText: name });
|
||||
const button = layer.getByTestId("toggle-content");
|
||||
const button = layer.getByRole("button");
|
||||
|
||||
await expect(button).toBeVisible();
|
||||
await button.waitFor();
|
||||
await button.click(clickOptions);
|
||||
await button.waitFor({ ariaExpanded: true });
|
||||
await this.page.waitForTimeout(500);
|
||||
}
|
||||
|
||||
async expectSelectedLayer(name) {
|
||||
@@ -522,7 +495,13 @@ export class WorkspacePage extends BaseWebSocketPage {
|
||||
|
||||
async clickColorPalette(clickOptions = {}) {
|
||||
await this.palette
|
||||
.getByRole("button", { name: /Color Palette/ })
|
||||
.getByRole("button", { name: "Color Palette (Alt+P)" })
|
||||
.click(clickOptions);
|
||||
}
|
||||
|
||||
async clickColorPalette(clickOptions = {}) {
|
||||
await this.palette
|
||||
.getByRole("button", { name: "Color Palette (Alt+P)" })
|
||||
.click(clickOptions);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ test("User can complete the onboarding", async ({ page }) => {
|
||||
const dashboardPage = new DashboardPage(page);
|
||||
const onboardingPage = new OnboardingPage(page);
|
||||
|
||||
await dashboardPage.mockConfigFlags(["enable-onboarding"]);
|
||||
|
||||
await dashboardPage.goToDashboard();
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Help us get to know you" }),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { WasmWorkspacePage } from "../pages/WasmWorkspacePage";
|
||||
import { WasmWorkspacePage, WASM_FLAGS } from "../pages/WasmWorkspacePage";
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await WasmWorkspacePage.init(page);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { WorkspacePage } from "../pages/WorkspacePage";
|
||||
const timeToWait = 100;
|
||||
|
||||
test.beforeEach(async ({ page, context }) => {
|
||||
await Clipboard.enable(context, Clipboard.Permission.ALL);
|
||||
await Clipboard.enable(context, Clipboard.Permission.ONLY_WRITE);
|
||||
|
||||
await WorkspacePage.init(page);
|
||||
await WorkspacePage.mockConfigFlags(page, ["enable-feature-text-editor-v2"]);
|
||||
@@ -110,7 +110,7 @@ test("Update an already created text shape by prepending text", async ({
|
||||
await workspace.textEditor.stopEditing();
|
||||
});
|
||||
|
||||
test.skip("Update an already created text shape by inserting text in between", async ({
|
||||
test("Update an already created text shape by inserting text in between", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = new WorkspacePage(page, {
|
||||
@@ -151,7 +151,7 @@ test("Update a new text shape appending text by pasting text", async ({
|
||||
await workspace.textEditor.stopEditing();
|
||||
});
|
||||
|
||||
test.skip("Update a new text shape prepending text by pasting text", async ({
|
||||
test("Update a new text shape prepending text by pasting text", async ({
|
||||
page,
|
||||
context,
|
||||
}) => {
|
||||
|
||||
@@ -158,7 +158,7 @@ test.describe("Tokens - creation", () => {
|
||||
const selfReferenceError = "Token has self reference";
|
||||
const missingReferenceError = "Missing token references";
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar, tokensSidebar } =
|
||||
await setupEmptyTokensFile(page);
|
||||
await setupEmptyTokensFile(page);
|
||||
|
||||
await tokensSidebar
|
||||
.getByRole("button", { name: "Add Token: Color" })
|
||||
@@ -189,7 +189,7 @@ test.describe("Tokens - creation", () => {
|
||||
// 2. Invalid value → disabled + error message
|
||||
await valueField.fill("1");
|
||||
const invalidValueErrorNode =
|
||||
tokensUpdateCreateModal.getByText(invalidValueError);
|
||||
tokensUpdateCreateModal.getByText(invalidValueError);
|
||||
await expect(invalidValueErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
|
||||
@@ -197,7 +197,7 @@ test.describe("Tokens - creation", () => {
|
||||
await nameField.fill("");
|
||||
|
||||
const emptyNameErrorNode =
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
|
||||
await expect(emptyNameErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -207,7 +207,7 @@ test.describe("Tokens - creation", () => {
|
||||
await valueField.fill("{color.primary}");
|
||||
|
||||
const selfRefErrorNode =
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
|
||||
await expect(selfRefErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -320,7 +320,7 @@ test.describe("Tokens - creation", () => {
|
||||
const missingReferenceError = "Missing token references";
|
||||
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar } =
|
||||
await setupEmptyTokensFile(page);
|
||||
await setupEmptyTokensFile(page);
|
||||
|
||||
// Open modal
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
@@ -356,7 +356,7 @@ test.describe("Tokens - creation", () => {
|
||||
await nameField.fill("");
|
||||
|
||||
const emptyNameErrorNode =
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
|
||||
await expect(emptyNameErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -366,7 +366,7 @@ test.describe("Tokens - creation", () => {
|
||||
await valueField.fill("{my-token}");
|
||||
|
||||
const selfRefErrorNode =
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
|
||||
await expect(selfRefErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -459,13 +459,13 @@ test.describe("Tokens - creation", () => {
|
||||
|
||||
test("User creates font weight token", async ({ page }) => {
|
||||
const invalidValueError =
|
||||
"Invalid font weight value: use numeric values (100-950) or standard names (thin, light, regular, bold, etc.) optionally followed by 'Italic'";
|
||||
"Invalid font weight value: use numeric values (100-950) or standard names (thin, light, regular, bold, etc.) optionally followed by 'Italic'";
|
||||
const emptyNameError = "Name should be at least 1 character";
|
||||
const selfReferenceError = "Token has self reference";
|
||||
const missingReferenceError = "Missing token references";
|
||||
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar } =
|
||||
await setupEmptyTokensFile(page);
|
||||
await setupEmptyTokensFile(page);
|
||||
|
||||
// Open modal
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
@@ -501,7 +501,7 @@ test.describe("Tokens - creation", () => {
|
||||
await valueField.fill("red");
|
||||
|
||||
const invalidValueErrorNode =
|
||||
tokensUpdateCreateModal.getByText(invalidValueError);
|
||||
tokensUpdateCreateModal.getByText(invalidValueError);
|
||||
|
||||
await expect(invalidValueErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -510,7 +510,7 @@ test.describe("Tokens - creation", () => {
|
||||
await nameField.fill("");
|
||||
|
||||
const emptyNameErrorNode =
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
|
||||
await expect(emptyNameErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -520,7 +520,7 @@ test.describe("Tokens - creation", () => {
|
||||
await valueField.fill("{my-token}");
|
||||
|
||||
const selfRefErrorNode =
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
|
||||
await expect(selfRefErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -595,13 +595,13 @@ test.describe("Tokens - creation", () => {
|
||||
|
||||
test("User creates text case token", async ({ page }) => {
|
||||
const invalidValueError =
|
||||
"Invalid token value: only none, Uppercase, Lowercase or Capitalize are accepted";
|
||||
"Invalid token value: only none, Uppercase, Lowercase or Capitalize are accepted";
|
||||
const emptyNameError = "Name should be at least 1 character";
|
||||
const selfReferenceError = "Token has self reference";
|
||||
const missingReferenceError = "Missing token references";
|
||||
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar } =
|
||||
await setupEmptyTokensFile(page);
|
||||
await setupEmptyTokensFile(page);
|
||||
|
||||
// Open modal
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
@@ -637,7 +637,7 @@ test.describe("Tokens - creation", () => {
|
||||
await valueField.fill("red");
|
||||
|
||||
const invalidValueErrorNode =
|
||||
tokensUpdateCreateModal.getByText(invalidValueError);
|
||||
tokensUpdateCreateModal.getByText(invalidValueError);
|
||||
|
||||
await expect(invalidValueErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -646,7 +646,7 @@ test.describe("Tokens - creation", () => {
|
||||
await nameField.fill("");
|
||||
|
||||
const emptyNameErrorNode =
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
|
||||
await expect(emptyNameErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -656,7 +656,7 @@ test.describe("Tokens - creation", () => {
|
||||
await valueField.fill("{my-token}");
|
||||
|
||||
const selfRefErrorNode =
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
|
||||
await expect(selfRefErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -711,13 +711,13 @@ test.describe("Tokens - creation", () => {
|
||||
|
||||
test("User creates text decoration token", async ({ page }) => {
|
||||
const invalidValueError =
|
||||
"Invalid token value: only none, underline and strike-through are accepted";
|
||||
"Invalid token value: only none, underline and strike-through are accepted";
|
||||
const emptyNameError = "Name should be at least 1 character";
|
||||
const selfReferenceError = "Token has self reference";
|
||||
const missingReferenceError = "Missing token references";
|
||||
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar } =
|
||||
await setupEmptyTokensFile(page);
|
||||
await setupEmptyTokensFile(page);
|
||||
|
||||
// Open modal
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
@@ -755,7 +755,7 @@ test.describe("Tokens - creation", () => {
|
||||
await valueField.fill("red");
|
||||
|
||||
const invalidValueErrorNode =
|
||||
tokensUpdateCreateModal.getByText(invalidValueError);
|
||||
tokensUpdateCreateModal.getByText(invalidValueError);
|
||||
|
||||
await expect(invalidValueErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -764,7 +764,7 @@ test.describe("Tokens - creation", () => {
|
||||
await nameField.fill("");
|
||||
|
||||
const emptyNameErrorNode =
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
|
||||
await expect(emptyNameErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -774,7 +774,7 @@ test.describe("Tokens - creation", () => {
|
||||
await valueField.fill("{my-token}");
|
||||
|
||||
const selfRefErrorNode =
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
tokensUpdateCreateModal.getByText(selfReferenceError);
|
||||
|
||||
await expect(selfRefErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -831,7 +831,7 @@ test.describe("Tokens - creation", () => {
|
||||
const emptyNameError = "Name should be at least 1 character";
|
||||
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar } =
|
||||
await setupEmptyTokensFile(page, { flags: ["enable-token-shadow"] });
|
||||
await setupEmptyTokensFile(page, { flags: ["enable-token-shadow"] });
|
||||
|
||||
// Open modal
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
@@ -900,7 +900,7 @@ test.describe("Tokens - creation", () => {
|
||||
await nameField.fill("");
|
||||
|
||||
const emptyNameErrorNode =
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
|
||||
await expect(emptyNameErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -977,9 +977,9 @@ test.describe("Tokens - creation", () => {
|
||||
|
||||
await nameField.fill("my-token-2");
|
||||
const referenceToggle =
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
const compositeToggle =
|
||||
tokensUpdateCreateModal.getByTestId("composite-opt");
|
||||
tokensUpdateCreateModal.getByTestId("composite-opt");
|
||||
await referenceToggle.click();
|
||||
|
||||
const referenceInput = tokensUpdateCreateModal.getByPlaceholder(
|
||||
@@ -1012,7 +1012,7 @@ test.describe("Tokens - creation", () => {
|
||||
page,
|
||||
}) => {
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar, tokensSidebar } =
|
||||
await setupTypographyTokensFile(page);
|
||||
await setupTypographyTokensFile(page);
|
||||
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
await tokensTabPanel
|
||||
@@ -1038,7 +1038,7 @@ test.describe("Tokens - creation", () => {
|
||||
|
||||
// Switch to reference tab, should not be submittable either
|
||||
const referenceTabButton =
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
await referenceTabButton.click();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
});
|
||||
@@ -1047,7 +1047,7 @@ test.describe("Tokens - creation", () => {
|
||||
const emptyNameError = "Name should be at least 1 character";
|
||||
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar } =
|
||||
await setupEmptyTokensFile(page, { flags: ["enable-token-shadow"] });
|
||||
await setupEmptyTokensFile(page, {flags: ["enable-token-shadow"]});
|
||||
|
||||
// Open modal
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
@@ -1116,7 +1116,7 @@ test.describe("Tokens - creation", () => {
|
||||
await nameField.fill("");
|
||||
|
||||
const emptyNameErrorNode =
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
|
||||
await expect(emptyNameErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -1198,9 +1198,9 @@ test.describe("Tokens - creation", () => {
|
||||
|
||||
await nameField.fill("my-token-2");
|
||||
const referenceToggle =
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
const compositeToggle =
|
||||
tokensUpdateCreateModal.getByTestId("composite-opt");
|
||||
tokensUpdateCreateModal.getByTestId("composite-opt");
|
||||
await referenceToggle.click();
|
||||
|
||||
const referenceInput = tokensUpdateCreateModal.getByPlaceholder(
|
||||
@@ -1232,7 +1232,7 @@ test.describe("Tokens - creation", () => {
|
||||
test("User creates typography token", async ({ page }) => {
|
||||
const emptyNameError = "Name should be at least 1 character";
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar } =
|
||||
await setupEmptyTokensFile(page);
|
||||
await setupEmptyTokensFile(page);
|
||||
|
||||
// Open modal
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
@@ -1287,7 +1287,7 @@ test.describe("Tokens - creation", () => {
|
||||
await nameField.fill("");
|
||||
|
||||
const emptyNameErrorNode =
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
tokensUpdateCreateModal.getByText(emptyNameError);
|
||||
|
||||
await expect(emptyNameErrorNode).toBeVisible();
|
||||
await expect(submitButton).toBeDisabled();
|
||||
@@ -1443,9 +1443,9 @@ test.describe("Tokens - creation", () => {
|
||||
await nameField.fill("my-token-2");
|
||||
|
||||
const referenceToggle =
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
const compositeToggle =
|
||||
tokensUpdateCreateModal.getByTestId("composite-opt");
|
||||
tokensUpdateCreateModal.getByTestId("composite-opt");
|
||||
|
||||
await referenceToggle.click();
|
||||
|
||||
@@ -1479,7 +1479,7 @@ test.describe("Tokens - creation", () => {
|
||||
|
||||
test("User adds typography token with reference", async ({ page }) => {
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar, tokensSidebar } =
|
||||
await setupTypographyTokensFile(page);
|
||||
await setupTypographyTokensFile(page);
|
||||
|
||||
const newTokenTitle = "NewReference";
|
||||
|
||||
@@ -1508,7 +1508,7 @@ test.describe("Tokens - creation", () => {
|
||||
});
|
||||
|
||||
const resolvedValue =
|
||||
await tokensUpdateCreateModal.getByText("Resolved value:");
|
||||
await tokensUpdateCreateModal.getByText("Resolved value:");
|
||||
await expect(resolvedValue).toBeVisible();
|
||||
await expect(resolvedValue).toContainText("Font Family: 42dot Sans");
|
||||
await expect(resolvedValue).toContainText("Font Size: 100");
|
||||
@@ -1531,7 +1531,7 @@ test.describe("Tokens - creation", () => {
|
||||
|
||||
test("User creates grouped color token", async ({ page }) => {
|
||||
const { workspacePage, tokensUpdateCreateModal, tokensSidebar } =
|
||||
await setupEmptyTokensFile(page);
|
||||
await setupEmptyTokensFile(page);
|
||||
|
||||
await tokensSidebar
|
||||
.getByRole("button", { name: "Add Token: Color" })
|
||||
@@ -1591,7 +1591,7 @@ test.describe("Tokens - creation", () => {
|
||||
|
||||
test("User duplicate color token", async ({ page }) => {
|
||||
const { tokensSidebar, tokenContextMenuForToken } =
|
||||
await setupTokensFile(page);
|
||||
await setupTokensFile(page);
|
||||
|
||||
await expect(tokensSidebar).toBeVisible();
|
||||
|
||||
@@ -1613,11 +1613,15 @@ test.describe("Tokens - creation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
test("User creates grouped color token", async ({ page }) => {
|
||||
const { workspacePage, tokensUpdateCreateModal, tokensSidebar } =
|
||||
await setupEmptyTokensFile(page);
|
||||
await setupEmptyTokensFile(page);
|
||||
|
||||
await tokensSidebar.getByRole("button", { name: "Add Token: Color" }).click();
|
||||
await tokensSidebar
|
||||
.getByRole("button", { name: "Add Token: Color" })
|
||||
.click();
|
||||
|
||||
// Create grouped color token with mouse
|
||||
|
||||
@@ -1643,7 +1647,9 @@ test("User creates grouped color token", async ({ page }) => {
|
||||
await expect(tokensSidebar.getByLabel("primary")).toBeEnabled();
|
||||
});
|
||||
|
||||
test("User cant create regular token with value missing", async ({ page }) => {
|
||||
test("User cant create regular token with value missing", async ({
|
||||
page,
|
||||
}) => {
|
||||
const { tokensUpdateCreateModal } = await setupEmptyTokensFile(page);
|
||||
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
@@ -1671,7 +1677,7 @@ test("User cant create regular token with value missing", async ({ page }) => {
|
||||
|
||||
test("User duplicate color token", async ({ page }) => {
|
||||
const { tokensSidebar, tokenContextMenuForToken } =
|
||||
await setupTokensFile(page);
|
||||
await setupTokensFile(page);
|
||||
|
||||
await expect(tokensSidebar).toBeVisible();
|
||||
|
||||
@@ -1697,7 +1703,7 @@ test.describe("Tokens tab - edition", () => {
|
||||
page,
|
||||
}) => {
|
||||
const { tokensUpdateCreateModal, tokenThemesSetsSidebar, tokensSidebar } =
|
||||
await setupTypographyTokensFile(page);
|
||||
await setupTypographyTokensFile(page);
|
||||
|
||||
await tokensSidebar
|
||||
.getByRole("button")
|
||||
@@ -1718,8 +1724,8 @@ test.describe("Tokens tab - edition", () => {
|
||||
|
||||
// Fill font-family to verify to verify that input value doesn't get split into list of characters
|
||||
const fontFamilyField = tokensUpdateCreateModal
|
||||
.getByLabel("Font family")
|
||||
.first();
|
||||
.getByLabel("Font family")
|
||||
.first();
|
||||
await fontFamilyField.fill("OneWord");
|
||||
|
||||
// Invalidate incorrect values for font size
|
||||
@@ -1740,11 +1746,11 @@ test.describe("Tokens tab - edition", () => {
|
||||
|
||||
const fontWeightField = tokensUpdateCreateModal.getByLabel(/Font Weight/i);
|
||||
const letterSpacingField =
|
||||
tokensUpdateCreateModal.getByLabel(/Letter Spacing/i);
|
||||
tokensUpdateCreateModal.getByLabel(/Letter Spacing/i);
|
||||
const lineHeightField = tokensUpdateCreateModal.getByLabel(/Line Height/i);
|
||||
const textCaseField = tokensUpdateCreateModal.getByLabel(/Text Case/i);
|
||||
const textDecorationField =
|
||||
tokensUpdateCreateModal.getByLabel(/Text Decoration/i);
|
||||
tokensUpdateCreateModal.getByLabel(/Text Decoration/i);
|
||||
|
||||
// Capture all values before switching tabs
|
||||
const originalValues = {
|
||||
@@ -1759,14 +1765,14 @@ test.describe("Tokens tab - edition", () => {
|
||||
|
||||
// Switch to reference tab and back to composite tab
|
||||
const referenceTabButton =
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
tokensUpdateCreateModal.getByTestId("reference-opt");
|
||||
await referenceTabButton.click();
|
||||
|
||||
// Empty reference tab should be disabled
|
||||
await expect(saveButton).toBeDisabled();
|
||||
|
||||
const compositeTabButton =
|
||||
tokensUpdateCreateModal.getByTestId("composite-opt");
|
||||
tokensUpdateCreateModal.getByTestId("composite-opt");
|
||||
await compositeTabButton.click();
|
||||
|
||||
// Filled composite tab should be enabled
|
||||
@@ -1793,7 +1799,7 @@ test.describe("Tokens tab - edition", () => {
|
||||
page,
|
||||
}) => {
|
||||
const { tokensUpdateCreateModal, tokensSidebar, tokenContextMenuForToken } =
|
||||
await setupTokensFile(page);
|
||||
await setupTokensFile(page);
|
||||
|
||||
await expect(tokensSidebar).toBeVisible();
|
||||
|
||||
@@ -1829,7 +1835,7 @@ test.describe("Tokens tab - edition", () => {
|
||||
page,
|
||||
}) => {
|
||||
const { workspacePage, tokensUpdateCreateModal, tokenThemesSetsSidebar } =
|
||||
await setupEmptyTokensFile(page);
|
||||
await setupEmptyTokensFile(page);
|
||||
|
||||
const tokensTabPanel = page.getByRole("tabpanel", { name: "tokens" });
|
||||
await tokensTabPanel
|
||||
@@ -1884,7 +1890,7 @@ test.describe("Tokens tab - edition", () => {
|
||||
test.describe("Tokens tab - delete", () => {
|
||||
test("User delete color token", async ({ page }) => {
|
||||
const { tokensSidebar, tokenContextMenuForToken } =
|
||||
await setupTokensFile(page);
|
||||
await setupTokensFile(page);
|
||||
|
||||
await expect(tokensSidebar).toBeVisible();
|
||||
|
||||
@@ -1904,7 +1910,7 @@ test.describe("Tokens tab - delete", () => {
|
||||
});
|
||||
|
||||
test("User removes node and all child tokens", async ({ page }) => {
|
||||
const { tokensSidebar } = await setupTokensFile(page);
|
||||
const { tokensSidebar, workspacePage } = await setupTokensFile(page);
|
||||
|
||||
await expect(tokensSidebar).toBeVisible();
|
||||
|
||||
@@ -1913,7 +1919,7 @@ test.describe("Tokens tab - delete", () => {
|
||||
|
||||
// Verify that the node and child token are visible before deletion
|
||||
const colorNode = tokensSidebar.getByRole("button", {
|
||||
name: "colors",
|
||||
name: "blue",
|
||||
exact: true,
|
||||
});
|
||||
const colorNodeToken = tokensSidebar.getByRole("button", {
|
||||
@@ -1937,13 +1943,5 @@ test.describe("Tokens tab - delete", () => {
|
||||
await expect(colorNode).not.toBeVisible();
|
||||
// Verify that child token is also removed
|
||||
await expect(colorNodeToken).not.toBeVisible();
|
||||
|
||||
// Save the type button to verify that expands/folds
|
||||
const tokenTypeButton = await tokensSidebar.getByRole("button", {
|
||||
name: "Color",
|
||||
exact: true,
|
||||
});
|
||||
|
||||
await expect(tokenTypeButton).toHaveAttribute("aria-expanded", "false");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { WorkspacePage } from "../pages/WorkspacePage";
|
||||
import { WorkspacePage } from "../pages/WorkspacePage";
|
||||
import { BaseWebSocketPage } from "../pages/BaseWebSocketPage";
|
||||
import { Clipboard } from "../../helpers/Clipboard";
|
||||
|
||||
test.beforeEach(async ({ page, context }) => {
|
||||
await Clipboard.enable(context, Clipboard.Permission.ALL);
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await WorkspacePage.init(page);
|
||||
await BaseWebSocketPage.mockRPC(page, "get-teams", "get-teams-variants.json");
|
||||
});
|
||||
|
||||
test.afterEach(async ({ context }) => {
|
||||
context.clearPermissions();
|
||||
});
|
||||
|
||||
const setupVariantsFile = async (workspacePage) => {
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPC(
|
||||
@@ -41,9 +34,9 @@ const setupVariantsFileWithVariant = async (workspacePage) => {
|
||||
await setupVariantsFile(workspacePage);
|
||||
|
||||
await workspacePage.clickLeafLayer("Rectangle");
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+k");
|
||||
await workspacePage.page.keyboard.press("Control+k");
|
||||
await workspacePage.page.waitForTimeout(500);
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+k");
|
||||
await workspacePage.page.keyboard.press("Control+k");
|
||||
await workspacePage.page.waitForTimeout(500);
|
||||
|
||||
// We wait until layer-row starts looking like it an component
|
||||
@@ -163,7 +156,7 @@ test("User duplicates a variant container", async ({ page }) => {
|
||||
await variant.container.click();
|
||||
|
||||
//Duplicate the variant container
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+d");
|
||||
await workspacePage.page.keyboard.press("Control+d");
|
||||
|
||||
const variant_original = await findVariant(workspacePage, 1); // On duplicate, the new item is the first
|
||||
const variant_duplicate = await findVariant(workspacePage, 0);
|
||||
@@ -176,27 +169,25 @@ test("User duplicates a variant container", async ({ page }) => {
|
||||
await validateVariant(variant_duplicate);
|
||||
});
|
||||
|
||||
test("User copy paste a variant container", async ({ page, context }) => {
|
||||
test("User copy paste a variant container", async ({ page }) => {
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
// Access to the read/write clipboard necesary for this functionality
|
||||
await setupVariantsFileWithVariant(workspacePage);
|
||||
await workspacePage.mockRPC(
|
||||
/create-file-object-thumbnail.*/,
|
||||
"workspace/create-file-object-thumbnail.json",
|
||||
);
|
||||
|
||||
const variant = findVariantNoWait(workspacePage, 0);
|
||||
|
||||
// await variant.container.waitFor();
|
||||
|
||||
// Select the variant container
|
||||
await variant.container.click();
|
||||
|
||||
await workspacePage.page.waitForTimeout(1000);
|
||||
|
||||
// Copy the variant container
|
||||
await workspacePage.clickLeafLayer("Rectangle");
|
||||
await workspacePage.copy("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+c");
|
||||
|
||||
// Paste the variant container
|
||||
await workspacePage.clickAt(400, 400);
|
||||
await workspacePage.paste("keyboard");
|
||||
|
||||
const variants = workspacePage.layers.getByText("Rectangle");
|
||||
await expect(variants).toHaveCount(2);
|
||||
await workspacePage.page.keyboard.press("Control+v");
|
||||
|
||||
const variantDuplicate = findVariantNoWait(workspacePage, 0);
|
||||
const variantOriginal = findVariantNoWait(workspacePage, 1);
|
||||
@@ -221,17 +212,18 @@ test("User cut paste a variant container", async ({ page }) => {
|
||||
await variant.container.click();
|
||||
|
||||
//Cut the variant container
|
||||
await workspacePage.cut("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+x");
|
||||
await workspacePage.page.waitForTimeout(500);
|
||||
|
||||
//Paste the variant container
|
||||
await workspacePage.clickAt(500, 500);
|
||||
await workspacePage.paste("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+v");
|
||||
await workspacePage.page.waitForTimeout(500);
|
||||
|
||||
const variantPasted = await findVariant(workspacePage, 0);
|
||||
|
||||
// Expand the layers
|
||||
await workspacePage.clickToggableLayer("Rectangle");
|
||||
await variantPasted.container.locator("button").first().click();
|
||||
|
||||
// The variants are valid
|
||||
await validateVariant(variantPasted);
|
||||
@@ -247,34 +239,27 @@ test("User cut paste a variant container into a board, and undo twice", async ({
|
||||
|
||||
//Create a board
|
||||
await workspacePage.boardButton.click();
|
||||
// NOTE: this board should not intersect the existing variants, otherwise
|
||||
// this test is flaky
|
||||
await workspacePage.clickWithDragViewportAt(200, 200, 100, 100);
|
||||
await workspacePage.clickWithDragViewportAt(500, 500, 100, 100);
|
||||
await workspacePage.clickAt(495, 495);
|
||||
const board = await workspacePage.rootShape.locator("Board");
|
||||
|
||||
// Select the variant container
|
||||
// await variant.container.click();
|
||||
await workspacePage.clickLeafLayer("Rectangle");
|
||||
await variant.container.click();
|
||||
|
||||
//Cut the variant container
|
||||
await workspacePage.cut("keyboard");
|
||||
await expect(variant.container).not.toBeVisible();
|
||||
await workspacePage.page.keyboard.press("Control+x");
|
||||
await workspacePage.page.waitForTimeout(500);
|
||||
|
||||
//Select the board
|
||||
await workspacePage.clickLeafLayer("Board");
|
||||
|
||||
//Paste the variant container inside the board
|
||||
await workspacePage.paste("keyboard");
|
||||
await expect(variant.container).toBeVisible();
|
||||
await workspacePage.page.keyboard.press("Control+v");
|
||||
|
||||
//Undo twice
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+z");
|
||||
|
||||
await expect(variant.container).not.toBeVisible();
|
||||
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+z");
|
||||
await expect(variant.container).toBeVisible();
|
||||
await workspacePage.page.keyboard.press("Control+z");
|
||||
await workspacePage.page.keyboard.press("Control+z");
|
||||
await workspacePage.page.waitForTimeout(500);
|
||||
|
||||
const variantAfterUndo = await findVariant(workspacePage, 0);
|
||||
|
||||
@@ -291,12 +276,12 @@ test("User copy paste a variant", async ({ page }) => {
|
||||
// Select the variant1
|
||||
await variant.variant1.click();
|
||||
|
||||
// Copy the variant
|
||||
await workspacePage.copy("keyboard");
|
||||
//Cut the variant
|
||||
await workspacePage.page.keyboard.press("Control+c");
|
||||
|
||||
// Paste the variant
|
||||
//Paste the variant
|
||||
await workspacePage.clickAt(500, 500);
|
||||
await workspacePage.paste("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+v");
|
||||
|
||||
const copy = await workspacePage.layers
|
||||
.getByTestId("layer-row")
|
||||
@@ -317,11 +302,11 @@ test("User cut paste a variant outside the container", async ({ page }) => {
|
||||
await variant.variant1.click();
|
||||
|
||||
//Cut the variant
|
||||
await workspacePage.cut("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+x");
|
||||
|
||||
//Paste the variant
|
||||
await workspacePage.clickAt(500, 500);
|
||||
await workspacePage.paste("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+v");
|
||||
|
||||
const component = await workspacePage.layers
|
||||
.getByTestId("layer-row")
|
||||
@@ -339,11 +324,15 @@ test("User drag and drop a variant outside the container", async ({ page }) => {
|
||||
const variant = await findVariant(workspacePage, 0);
|
||||
|
||||
// Drag and drop the variant
|
||||
// FIXME: to make this test more resilient, we should get the bounding box of the Value 1 variant
|
||||
// and use it to calculate the target position
|
||||
await workspacePage.clickWithDragViewportAt(600, 500, 0, 300);
|
||||
await workspacePage.clickWithDragViewportAt(350, 400, 0, 200);
|
||||
|
||||
await expect(workspacePage.layers.getByText("Rectangle / Value 1")).toBeVisible();
|
||||
const component = await workspacePage.layers
|
||||
.getByTestId("layer-row")
|
||||
.filter({ has: workspacePage.page.getByText("Rectangle / Value 1") })
|
||||
.filter({ has: workspacePage.page.getByTestId("icon-component") });
|
||||
|
||||
//The component exists and is visible
|
||||
await expect(component).toBeVisible();
|
||||
});
|
||||
|
||||
test("User cut paste a component inside a variant", async ({ page }) => {
|
||||
@@ -356,14 +345,14 @@ test("User cut paste a component inside a variant", async ({ page }) => {
|
||||
await workspacePage.ellipseShapeButton.click();
|
||||
await workspacePage.clickWithDragViewportAt(500, 500, 20, 20);
|
||||
await workspacePage.clickLeafLayer("Ellipse");
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+k");
|
||||
await workspacePage.page.keyboard.press("Control+k");
|
||||
|
||||
//Cut the component
|
||||
await workspacePage.cut("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+x");
|
||||
|
||||
//Paste the component inside the variant
|
||||
await variant.container.click();
|
||||
await workspacePage.paste("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+v");
|
||||
|
||||
const variant3 = await workspacePage.layers
|
||||
.getByTestId("layer-row")
|
||||
@@ -387,7 +376,7 @@ test("User cut paste a component with path inside a variant", async ({
|
||||
await workspacePage.ellipseShapeButton.click();
|
||||
await workspacePage.clickWithDragViewportAt(500, 500, 20, 20);
|
||||
await workspacePage.clickLeafLayer("Ellipse");
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+k");
|
||||
await workspacePage.page.keyboard.press("Control+k");
|
||||
|
||||
//Rename the component
|
||||
await workspacePage.layers.getByText("Ellipse").dblclick();
|
||||
@@ -398,11 +387,11 @@ test("User cut paste a component with path inside a variant", async ({
|
||||
await workspacePage.page.keyboard.press("Enter");
|
||||
|
||||
//Cut the component
|
||||
await workspacePage.cut("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+x");
|
||||
|
||||
//Paste the component inside the variant
|
||||
await variant.container.click();
|
||||
await workspacePage.paste("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+v");
|
||||
|
||||
const variant3 = await workspacePage.layers
|
||||
.getByTestId("layer-row")
|
||||
@@ -426,7 +415,7 @@ test("User drag and drop a component with path inside a variant", async ({
|
||||
await workspacePage.ellipseShapeButton.click();
|
||||
await workspacePage.clickWithDragViewportAt(500, 500, 20, 20);
|
||||
await workspacePage.clickLeafLayer("Ellipse");
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+k");
|
||||
await workspacePage.page.keyboard.press("Control+k");
|
||||
|
||||
//Rename the component
|
||||
await workspacePage.layers.getByText("Ellipse").dblclick();
|
||||
@@ -437,7 +426,7 @@ test("User drag and drop a component with path inside a variant", async ({
|
||||
await workspacePage.page.keyboard.press("Enter");
|
||||
|
||||
//Drag and drop the component the component
|
||||
await workspacePage.clickWithDragViewportAt(510, 510, 200, 0);
|
||||
await workspacePage.clickWithDragViewportAt(510, 510, 0, -200);
|
||||
|
||||
const variant3 = await workspacePage.layers
|
||||
.getByTestId("layer-row")
|
||||
@@ -457,8 +446,8 @@ test("User cut paste a variant into another container", async ({ page }) => {
|
||||
await workspacePage.ellipseShapeButton.click();
|
||||
await workspacePage.clickWithDragViewportAt(500, 500, 20, 20);
|
||||
await workspacePage.clickLeafLayer("Ellipse");
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+k");
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+k");
|
||||
await workspacePage.page.keyboard.press("Control+k");
|
||||
await workspacePage.page.keyboard.press("Control+k");
|
||||
|
||||
const variantOrigin = await findVariantNoWait(workspacePage, 1);
|
||||
|
||||
@@ -468,11 +457,11 @@ test("User cut paste a variant into another container", async ({ page }) => {
|
||||
await variantOrigin.variant1.click();
|
||||
|
||||
//Cut the variant
|
||||
await workspacePage.cut("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+x");
|
||||
|
||||
//Paste the variant
|
||||
await workspacePage.layers.getByText("Ellipse").first().click();
|
||||
await workspacePage.paste("keyboard");
|
||||
await workspacePage.page.keyboard.press("Control+v");
|
||||
|
||||
const variant3 = workspacePage.layers
|
||||
.getByTestId("layer-row")
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { WasmWorkspacePage } from "../pages/WasmWorkspacePage";
|
||||
import { WorkspacePage } from "../pages/WorkspacePage";
|
||||
import { presenceFixture, joinFixture2, joinFixture3 } from "../../data/workspace/ws-notifications";
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await WasmWorkspacePage.init(page);
|
||||
await WorkspacePage.init(page);
|
||||
});
|
||||
|
||||
test("User loads worskpace with empty file", async ({ page }) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
|
||||
await workspacePage.goToWorkspace();
|
||||
@@ -16,7 +16,7 @@ test("User loads worskpace with empty file", async ({ page }) => {
|
||||
});
|
||||
|
||||
test("User opens a file with a bad page id", async ({ page }) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
|
||||
await workspacePage.goToWorkspace({
|
||||
@@ -29,7 +29,7 @@ test("User opens a file with a bad page id", async ({ page }) => {
|
||||
test("User receives presence notifications updates in the workspace", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
|
||||
await workspacePage.goToWorkspace();
|
||||
@@ -43,7 +43,7 @@ test("User receives presence notifications updates in the workspace", async ({
|
||||
test("BUG 13058 - Presence list shows up to 3 user avatars", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
|
||||
await workspacePage.goToWorkspace();
|
||||
@@ -63,7 +63,7 @@ test("BUG 13058 - Presence list shows up to 3 user avatars", async ({
|
||||
});
|
||||
|
||||
test("User draws a rect", async ({ page }) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPC(
|
||||
"update-file?id=*",
|
||||
@@ -74,12 +74,13 @@ test("User draws a rect", async ({ page }) => {
|
||||
await workspacePage.rectShapeButton.click();
|
||||
await workspacePage.clickWithDragViewportAt(128, 128, 200, 100);
|
||||
|
||||
await workspacePage.hideUI();
|
||||
await expect(workspacePage.canvas).toHaveScreenshot();
|
||||
const shape = await workspacePage.rootShape.locator("rect");
|
||||
await expect(shape).toHaveAttribute("width", "200");
|
||||
await expect(shape).toHaveAttribute("height", "100");
|
||||
});
|
||||
|
||||
test("User makes a group", async ({ page }) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPC(
|
||||
/get\-file\?/,
|
||||
@@ -95,14 +96,14 @@ test("User makes a group", async ({ page }) => {
|
||||
pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375",
|
||||
});
|
||||
await workspacePage.clickLeafLayer("Rectangle");
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+g");
|
||||
await workspacePage.page.keyboard.press("Control+g");
|
||||
await workspacePage.expectSelectedLayer("Group");
|
||||
});
|
||||
|
||||
test("Bug 7654 - Toolbar keeps toggling on and off on spacebar press", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
@@ -112,10 +113,10 @@ test("Bug 7654 - Toolbar keeps toggling on and off on spacebar press", async ({
|
||||
await workspacePage.expectHiddenToolbarOptions();
|
||||
});
|
||||
|
||||
test("Bug 7525 - User moves a scrollbar and no selection rectangle appears", async ({
|
||||
test("Bug 7525 - User moves a scrollbar and no selciont rectangle appears", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPC(
|
||||
/get\-file\?/,
|
||||
@@ -131,8 +132,8 @@ test("Bug 7525 - User moves a scrollbar and no selection rectangle appears", asy
|
||||
pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375",
|
||||
});
|
||||
|
||||
// Move created rect to a corner, in order to get scrollbars
|
||||
await workspacePage.panOnViewportAt(128, 128, 600, 600);
|
||||
// Move created rect to a corner, in orther to get scrollbars
|
||||
await workspacePage.panOnViewportAt(128, 128, 300, 300);
|
||||
|
||||
// Check scrollbars appear
|
||||
const horizontalScrollbar = workspacePage.horizontalScrollbar;
|
||||
@@ -151,7 +152,7 @@ test("Bug 7525 - User moves a scrollbar and no selection rectangle appears", asy
|
||||
test("User adds a library and its automatically selected in the color palette", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.mockRPC(
|
||||
"link-file-to-library",
|
||||
@@ -196,7 +197,7 @@ test("User adds a library and its automatically selected in the color palette",
|
||||
test("Bug 10179 - Drag & drop doesn't add colors to the Recent Colors palette", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.goToWorkspace();
|
||||
await workspacePage.moveButton.click();
|
||||
@@ -239,7 +240,7 @@ test("Bug 10179 - Drag & drop doesn't add colors to the Recent Colors palette",
|
||||
test("Bug 7489 - Workspace-palette items stay hidden when opening with keyboard-shortcut", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
@@ -256,7 +257,7 @@ test("Bug 7489 - Workspace-palette items stay hidden when opening with keyboard-
|
||||
test("Bug 8784 - Use keyboard arrow to move inside a text input does not change tabs", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile();
|
||||
await workspacePage.goToWorkspace();
|
||||
await workspacePage.pageName.click();
|
||||
@@ -266,7 +267,7 @@ test("Bug 8784 - Use keyboard arrow to move inside a text input does not change
|
||||
});
|
||||
|
||||
test("Bug 9066 - Problem with grid layout", async ({ page }) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
await workspacePage.mockRPC(/get\-file\?/, "workspace/get-file-9066.json");
|
||||
|
||||
@@ -294,7 +295,7 @@ test("Bug 9066 - Problem with grid layout", async ({ page }) => {
|
||||
});
|
||||
|
||||
test("User have toolbar", async ({ page }) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
@@ -303,7 +304,7 @@ test("User have toolbar", async ({ page }) => {
|
||||
});
|
||||
|
||||
test("User have edition menu entries", async ({ page }) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
await workspacePage.goToWorkspace();
|
||||
|
||||
@@ -319,7 +320,7 @@ test("User have edition menu entries", async ({ page }) => {
|
||||
});
|
||||
|
||||
test("Copy/paste properties", async ({ page, context }) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
await workspacePage.mockRPC(
|
||||
/get\-file\?/,
|
||||
@@ -385,23 +386,23 @@ test("Copy/paste properties", async ({ page, context }) => {
|
||||
});
|
||||
|
||||
test("[Taiga #9929] Paste text in workspace", async ({ page, context }) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
await workspacePage.goToWorkspace();
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
await page.evaluate(() => navigator.clipboard.writeText("Lorem ipsum dolor"));
|
||||
await workspacePage.viewport.click({ button: "right" });
|
||||
await page.getByText(/^Paste/i).click();
|
||||
await page.getByText("PasteCtrlV").click();
|
||||
await workspacePage.viewport
|
||||
.getByRole("textbox")
|
||||
.getByText("Lorem ipsum dolor");
|
||||
});
|
||||
|
||||
test("[Taiga #9930] Zoom fit all doesn't fit all shapes", async ({
|
||||
test("[Taiga #9930] Zoom fit all doesn't fits all", async ({
|
||||
page,
|
||||
context,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
await workspacePage.mockRPC(/get\-file\?/, "workspace/get-file-9930.json");
|
||||
await workspacePage.goToWorkspace({
|
||||
@@ -409,18 +410,16 @@ test("[Taiga #9930] Zoom fit all doesn't fit all shapes", async ({
|
||||
pageId: "fb9798e7-a547-80ae-8005-9ffda4a13e2c",
|
||||
});
|
||||
|
||||
const zoom = page.getByTitle("Zoom");
|
||||
const zoom = await page.getByTitle("Zoom");
|
||||
await zoom.click();
|
||||
|
||||
const zoomIn = page.getByRole("button", { name: "Zoom in" });
|
||||
const zoomIn = await page.getByRole("button", { name: "Zoom in" });
|
||||
await zoomIn.click();
|
||||
await zoomIn.click();
|
||||
await zoomIn.click();
|
||||
|
||||
// Zoom fit all
|
||||
await page.keyboard.press("Shift+1");
|
||||
// Select all shapes to display selrect
|
||||
await workspacePage.page.keyboard.press("ControlOrMeta+a");
|
||||
|
||||
const ids = [
|
||||
"shape-165d1e5a-5873-8010-8005-9ffdbeaeec59",
|
||||
@@ -442,7 +441,7 @@ test("[Taiga #9930] Zoom fit all doesn't fit all shapes", async ({
|
||||
|
||||
const viewportBoundingBox = await workspacePage.viewport.boundingBox();
|
||||
for (const id of ids) {
|
||||
const shape = page.locator(`.viewport-selrect`);
|
||||
const shape = await page.locator(`.ws-shape-wrapper > g#${id}`);
|
||||
const shapeBoundingBox = await shape.boundingBox();
|
||||
expect(contains(viewportBoundingBox, shapeBoundingBox)).toBeTruthy();
|
||||
}
|
||||
@@ -451,7 +450,7 @@ test("[Taiga #9930] Zoom fit all doesn't fit all shapes", async ({
|
||||
test("Bug 9877, user navigation to dashboard from header goes to blank page", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
|
||||
await workspacePage.goToWorkspace();
|
||||
@@ -468,7 +467,7 @@ test("Bug 9877, user navigation to dashboard from header goes to blank page", as
|
||||
test("Bug 8371 - Flatten option is not visible in context menu", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspacePage = new WasmWorkspacePage(page);
|
||||
const workspacePage = new WorkspacePage(page);
|
||||
await workspacePage.setupEmptyFile(page);
|
||||
await workspacePage.mockGetFile("workspace/get-file-8371.json");
|
||||
await workspacePage.goToWorkspace({
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
@@ -1,90 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>WASM + WebGL2 Canvas</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
background: #111;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<script type="module">
|
||||
import initWasmModule from '/js/render-wasm.js';
|
||||
import {
|
||||
init, addShapeSolidFill, assignCanvas, hexToU32ARGB, getRandomInt, getRandomColor,
|
||||
getRandomFloat, useShape, setShapeChildren, setupInteraction, addShapeSolidStrokeFill
|
||||
} from './js/lib.js';
|
||||
|
||||
const canvas = document.getElementById("canvas");
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
|
||||
const params = new URLSearchParams(document.location.search);
|
||||
const shapes = params.get("shapes") || 1000;
|
||||
|
||||
initWasmModule().then(Module => {
|
||||
init(Module);
|
||||
assignCanvas(canvas);
|
||||
Module._set_canvas_background(hexToU32ARGB("#FABADA", 1));
|
||||
Module._init_shapes_pool(shapes + 1);
|
||||
setupInteraction(canvas);
|
||||
|
||||
const children = [];
|
||||
for (let i = 0; i < shapes; i++) {
|
||||
const uuid = crypto.randomUUID();
|
||||
children.push(uuid);
|
||||
|
||||
useShape(uuid);
|
||||
Module._set_parent(0, 0, 0, 0);
|
||||
Module._set_shape_type(3);
|
||||
const x1 = getRandomInt(0, canvas.width);
|
||||
const y1 = getRandomInt(0, canvas.height);
|
||||
const width = getRandomInt(20, 100);
|
||||
const height = getRandomInt(20, 100);
|
||||
Module._set_shape_selrect(x1, y1, x1 + width, y1 + height);
|
||||
|
||||
const color = getRandomColor();
|
||||
const argb = hexToU32ARGB(color, getRandomFloat(0.1, 1.0));
|
||||
addShapeSolidFill(argb)
|
||||
|
||||
Module._add_shape_center_stroke(10, 0, 0, 0);
|
||||
const argb2 = hexToU32ARGB(color, getRandomFloat(0.1, 1.0));
|
||||
addShapeSolidStrokeFill(argb2);
|
||||
|
||||
// Add shadows
|
||||
// Shadow 1: drop-shadow, #dedede opacity 0.33, blur 4, spread -2, offsetX 0, offsetY 2
|
||||
Module._add_shape_shadow(hexToU32ARGB("#dedede", 0.33), 4, -2, 0, 2, 0, false);
|
||||
// Shadow 2: drop-shadow, #dedede opacity 1, blur 12, spread -8, offsetX 0, offsetY 12
|
||||
Module._add_shape_shadow(hexToU32ARGB("#dedede", 1), 12, -8, 0, 12, 0, false);
|
||||
// Shadow 3: inner-shadow, #002046 opacity 0.12, blur 12, spread -8, offsetX 0, offsetY -4
|
||||
Module._add_shape_shadow(hexToU32ARGB("#002046", 0.12), 12, -8, 0, -4, 1, false);
|
||||
}
|
||||
|
||||
useShape("00000000-0000-0000-0000-000000000000");
|
||||
setShapeChildren(children);
|
||||
|
||||
performance.mark('render:begin');
|
||||
Module._set_view(1, 0, 0);
|
||||
Module._render(Date.now());
|
||||
performance.mark('render:end');
|
||||
const { duration } = performance.measure('render', 'render:begin', 'render:end');
|
||||
// alert(`render time: ${duration.toFixed(2)}ms`);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -44,20 +44,6 @@
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-local :open-plugins] (fnil conj #{}) id))))
|
||||
|
||||
(defn reset-plugin-flags
|
||||
[id]
|
||||
(ptk/reify ::reset-plugin-flags
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-local :plugin-flags] assoc id {}))))
|
||||
|
||||
(defn set-plugin-flag
|
||||
[id key value]
|
||||
(ptk/reify ::set-plugin-flag
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-local :plugin-flags id] assoc key value))))
|
||||
|
||||
(defn remove-current-plugin
|
||||
[id]
|
||||
(ptk/reify ::remove-current-plugin
|
||||
@@ -68,9 +54,7 @@
|
||||
(defn- load-plugin!
|
||||
[{:keys [plugin-id name description host code icon permissions]}]
|
||||
(try
|
||||
(st/emit! (save-current-plugin plugin-id)
|
||||
(reset-plugin-flags plugin-id))
|
||||
|
||||
(st/emit! (save-current-plugin plugin-id))
|
||||
(.ɵloadPlugin
|
||||
^js ug/global
|
||||
#js {:pluginId plugin-id
|
||||
|
||||
@@ -1410,7 +1410,6 @@
|
||||
(dm/export dwt/start-move-selected)
|
||||
(dm/export dwt/move-selected)
|
||||
(dm/export dwt/update-position)
|
||||
(dm/export dwt/update-positions)
|
||||
(dm/export dwt/flip-horizontal-selected)
|
||||
(dm/export dwt/flip-vertical-selected)
|
||||
(dm/export dwly/set-opacity)
|
||||
|
||||
@@ -46,9 +46,7 @@
|
||||
[app.main.data.workspace.thumbnails :as dwt]
|
||||
[app.main.data.workspace.transforms :as dwtr]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.data.workspace.wasm-text :as dwwt]
|
||||
[app.main.data.workspace.zoom :as dwz]
|
||||
[app.main.features :as features]
|
||||
[app.main.features.pointer-map :as fpmap]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.repo :as rp]
|
||||
@@ -1014,13 +1012,6 @@
|
||||
|
||||
updated-objects (pcb/get-objects changes)
|
||||
new-children-ids (cfh/get-children-ids-with-self updated-objects (:id new-shape))
|
||||
new-text-ids (->> new-children-ids
|
||||
(keep (fn [id]
|
||||
(when-let [child (get updated-objects id)]
|
||||
(when (and (cfh/text-shape? child)
|
||||
(not= :fixed (:grow-type child)))
|
||||
id))))
|
||||
(vec))
|
||||
|
||||
[changes parents-of-swapped]
|
||||
(if keep-touched?
|
||||
@@ -1030,9 +1021,6 @@
|
||||
(rx/of
|
||||
(dwu/start-undo-transaction undo-id)
|
||||
(dch/commit-changes changes)
|
||||
(when (and (features/active-feature? state "render-wasm/v1")
|
||||
(seq new-text-ids))
|
||||
(dwwt/resize-wasm-text-all new-text-ids))
|
||||
(ptk/data-event :layout/update {:ids update-layout-ids :undo-group undo-group})
|
||||
(dwu/commit-undo-transaction undo-id)
|
||||
(dws/select-shape (:id new-shape) false))))))
|
||||
|
||||
@@ -712,7 +712,8 @@
|
||||
(ctm/rotation-modifiers shape center angle))
|
||||
|
||||
modif-tree
|
||||
(build-modif-tree ids objects get-modifier)
|
||||
(-> (build-modif-tree ids objects get-modifier)
|
||||
(gm/set-objects-modifiers objects))
|
||||
|
||||
modifiers
|
||||
(mapv (fn [[id {:keys [modifiers]}]]
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.math :as mth]
|
||||
@@ -28,10 +29,10 @@
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.transforms :as dwt]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.data.workspace.wasm-text :as dwwt]
|
||||
[app.main.features :as features]
|
||||
[app.main.fonts :as fonts]
|
||||
[app.main.router :as rt]
|
||||
[app.render-wasm.api :as wasm.api]
|
||||
[app.util.text-editor :as ted]
|
||||
[app.util.text.content.styles :as styles]
|
||||
[app.util.timers :as ts]
|
||||
@@ -51,6 +52,50 @@
|
||||
(declare v2-update-text-shape-content)
|
||||
(declare v2-update-text-editor-styles)
|
||||
|
||||
(defn resize-wasm-text-modifiers
|
||||
([shape]
|
||||
(resize-wasm-text-modifiers shape (:content shape)))
|
||||
|
||||
([{:keys [id points selrect grow-type] :as shape} content]
|
||||
(wasm.api/use-shape id)
|
||||
(wasm.api/set-shape-text-content id content)
|
||||
(wasm.api/set-shape-text-images id content)
|
||||
|
||||
(let [dimension (wasm.api/get-text-dimensions)
|
||||
width-scale (if (#{:fixed :auto-height} grow-type)
|
||||
1.0
|
||||
(/ (:width dimension) (:width selrect)))
|
||||
height-scale (if (= :fixed grow-type)
|
||||
1.0
|
||||
(/ (:height dimension) (:height selrect)))
|
||||
resize-v (gpt/point width-scale height-scale)
|
||||
origin (first points)]
|
||||
|
||||
{id
|
||||
{:modifiers
|
||||
(ctm/resize-modifiers
|
||||
resize-v
|
||||
origin
|
||||
(:transform shape (gmt/matrix))
|
||||
(:transform-inverse shape (gmt/matrix)))}})))
|
||||
|
||||
(defn resize-wasm-text
|
||||
[id]
|
||||
(ptk/reify ::resize-wasm-text
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [objects (dsh/lookup-page-objects state)
|
||||
shape (get objects id)]
|
||||
(rx/of (dwm/apply-wasm-modifiers (resize-wasm-text-modifiers shape)))))))
|
||||
|
||||
(defn resize-wasm-text-all
|
||||
[ids]
|
||||
(ptk/reify ::resize-wasm-text-all
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(->> (rx/from ids)
|
||||
(rx/map resize-wasm-text)))))
|
||||
|
||||
;; -- Content helpers
|
||||
|
||||
(defn- v2-content-has-text?
|
||||
@@ -133,7 +178,7 @@
|
||||
{:undo-group (when new-shape? id)})
|
||||
|
||||
(dwm/apply-wasm-modifiers
|
||||
(dwwt/resize-wasm-text-modifiers shape content)
|
||||
(resize-wasm-text-modifiers shape content)
|
||||
{:undo-group (when new-shape? id)})))))
|
||||
|
||||
(let [content (d/merge (ted/export-content content)
|
||||
@@ -778,7 +823,7 @@
|
||||
(when (features/active-feature? state "render-wasm/v1")
|
||||
;; This delay is to give time for the font to be correctly rendered
|
||||
;; in wasm.
|
||||
(cond->> (rx/of (dwwt/resize-wasm-text id))
|
||||
(cond->> (rx/of (resize-wasm-text id))
|
||||
(contains? attrs :font-id)
|
||||
(rx/delay 200)))))))
|
||||
|
||||
@@ -928,11 +973,11 @@
|
||||
|
||||
(if (and (not= :fixed (:grow-type shape)) finalize?)
|
||||
(dwm/apply-wasm-modifiers
|
||||
(dwwt/resize-wasm-text-modifiers shape content)
|
||||
(resize-wasm-text-modifiers shape content)
|
||||
{:undo-group (when new-shape? id)})
|
||||
|
||||
(dwm/set-wasm-modifiers
|
||||
(dwwt/resize-wasm-text-modifiers shape content)
|
||||
(resize-wasm-text-modifiers shape content)
|
||||
{:undo-group (when new-shape? id)})))
|
||||
|
||||
(when finalize?
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
[app.main.data.workspace.colors :as wdc]
|
||||
[app.main.data.workspace.shape-layout :as dwsl]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.texts :as dwt]
|
||||
[app.main.data.workspace.transforms :as dwtr]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.data.workspace.wasm-text :as dwwt]
|
||||
[app.main.features :as features]
|
||||
[app.main.fonts :as fonts]
|
||||
[app.main.store :as st]
|
||||
@@ -304,7 +304,7 @@
|
||||
(and affects-layout?
|
||||
(features/active-feature? state "render-wasm/v1"))
|
||||
(rx/merge
|
||||
(rx/of (dwwt/resize-wasm-text-all shape-ids))))))))
|
||||
(rx/of (dwt/resize-wasm-text-all shape-ids))))))))
|
||||
|
||||
(defn update-line-height
|
||||
([value shape-ids attributes] (update-line-height value shape-ids attributes nil))
|
||||
@@ -363,7 +363,7 @@
|
||||
:page-id page-id}))
|
||||
(features/active-feature? state "render-wasm/v1")
|
||||
(rx/merge
|
||||
(rx/of (dwwt/resize-wasm-text-all shape-ids))))))))
|
||||
(rx/of (dwt/resize-wasm-text-all shape-ids))))))))
|
||||
|
||||
(defn- create-font-family-text-attrs
|
||||
[value]
|
||||
@@ -440,7 +440,7 @@
|
||||
:page-id page-id}))
|
||||
(features/active-feature? state "render-wasm/v1")
|
||||
(rx/merge
|
||||
(rx/of (dwwt/resize-wasm-text-all shape-ids))))))))
|
||||
(rx/of (dwt/resize-wasm-text-all shape-ids))))))))
|
||||
|
||||
(defn update-font-weight
|
||||
([value shape-ids attributes] (update-font-weight value shape-ids attributes nil))
|
||||
|
||||
@@ -62,52 +62,6 @@
|
||||
(watch [_ _ _]
|
||||
(rx/of (dwsh/update-shapes [id] #(merge % attrs)))))))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Toggle tree nodes
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn- remove-paths-recursively
|
||||
[path paths]
|
||||
(->> paths
|
||||
(remove #(str/starts-with? % (str path)))
|
||||
vec))
|
||||
|
||||
(defn add-path
|
||||
[path paths]
|
||||
(let [split-path (cpn/split-path path :separator ".")
|
||||
partial-paths (->> split-path
|
||||
(reduce
|
||||
(fn [acc segment]
|
||||
(let [new-acc (if (empty? acc)
|
||||
segment
|
||||
(str (last acc) "." segment))]
|
||||
(conj acc new-acc)))
|
||||
[]))]
|
||||
(->> paths
|
||||
(into partial-paths)
|
||||
distinct
|
||||
vec)))
|
||||
|
||||
(defn clear-tokens-paths
|
||||
[]
|
||||
(ptk/reify ::clear-tokens-paths
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:workspace-tokens :unfolded-token-paths] []))))
|
||||
|
||||
(defn toggle-token-path
|
||||
[path]
|
||||
(ptk/reify ::toggle-token-path
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-tokens :unfolded-token-paths]
|
||||
(fn [paths]
|
||||
(let [paths (or paths [])]
|
||||
(if (some #(= % path) paths)
|
||||
(remove-paths-recursively path paths)
|
||||
(add-path path paths))))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; TOKENS Actions
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -291,9 +245,8 @@
|
||||
(pcb/with-library-data data)
|
||||
(clt/generate-toggle-token-set tlib name))]
|
||||
|
||||
(rx/of
|
||||
(dch/commit-changes changes)
|
||||
(dwtp/propagate-workspace-tokens))))))
|
||||
(rx/of (dch/commit-changes changes)
|
||||
(dwtp/propagate-workspace-tokens))))))
|
||||
|
||||
(defn toggle-token-set-group
|
||||
[group-path]
|
||||
@@ -304,7 +257,6 @@
|
||||
changes (-> (pcb/empty-changes)
|
||||
(pcb/with-library-data data)
|
||||
(clt/generate-toggle-token-set-group (get-tokens-lib state) group-path))]
|
||||
|
||||
(rx/of
|
||||
(dch/commit-changes changes)
|
||||
(dwtp/propagate-workspace-tokens))))))
|
||||
@@ -534,7 +486,35 @@
|
||||
;; TOKEN UI OPS
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn clean-tokens-paths
|
||||
[]
|
||||
(ptk/reify ::clean-tokens-paths
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:workspace-tokens :unfolded-token-paths] []))))
|
||||
|
||||
(defn toggle-token-path
|
||||
[path]
|
||||
(ptk/reify ::toggle-token-path
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-tokens :unfolded-token-paths]
|
||||
(fn [paths]
|
||||
(let [paths (or paths [])]
|
||||
(if (some #(= % path) paths)
|
||||
(vec (remove #(or (= % path)
|
||||
(str/starts-with? % (str path ".")))
|
||||
paths))
|
||||
(let [split-path (cpn/split-path path :separator ".")
|
||||
partial-paths (reduce
|
||||
(fn [acc segment]
|
||||
(let [new-acc (if (empty? acc)
|
||||
segment
|
||||
(str (last acc) "." segment))]
|
||||
(conj acc new-acc)))
|
||||
[]
|
||||
split-path)]
|
||||
(into paths partial-paths)))))))))
|
||||
|
||||
(defn assign-token-context-menu
|
||||
[{:keys [position] :as params}]
|
||||
|
||||
@@ -406,13 +406,13 @@
|
||||
(ctm/change-property :grow-type new-grow-type)))
|
||||
modifiers)))
|
||||
|
||||
modif-tree (dwm/build-modif-tree ids objects get-modifier)]
|
||||
modif-tree
|
||||
(-> (dwm/build-modif-tree ids objects get-modifier)
|
||||
(gm/set-objects-modifiers objects))]
|
||||
|
||||
(if (features/active-feature? state "render-wasm/v1")
|
||||
(rx/of (dwm/apply-wasm-modifiers modif-tree {:ignore-snap-pixel true}))
|
||||
|
||||
(let [modif-tree (gm/set-objects-modifiers modif-tree objects)]
|
||||
(rx/of (dwm/apply-modifiers* objects modif-tree nil options)))))))))
|
||||
(rx/of (dwm/apply-modifiers* objects modif-tree nil options))))))))
|
||||
|
||||
(defn change-orientation
|
||||
"Change orientation of shapes, from the sidebar options form.
|
||||
@@ -1050,20 +1050,6 @@
|
||||
:ignore-touched (:ignore-touched options)
|
||||
:ignore-snap-pixel true}))))))))
|
||||
|
||||
(defn update-positions
|
||||
"Move multiple shapes to a new position."
|
||||
([ids position] (update-positions ids position nil))
|
||||
([ids position options]
|
||||
(assert (every? uuid? ids)
|
||||
"expected valid coll of uuids")
|
||||
(assert (map? position) "expected a valid map for `position`")
|
||||
(ptk/reify ::update-positions
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(->> ids
|
||||
(map (fn [id] (update-position id position options)))
|
||||
(rx/from))))))
|
||||
|
||||
(defn position-shapes
|
||||
[shapes]
|
||||
(ptk/reify ::position-shapes
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.main.data.workspace.wasm-text
|
||||
"Helpers/events to resize wasm text shapes without depending on workspace.texts.
|
||||
|
||||
This exists to avoid circular deps:
|
||||
workspace.texts -> workspace.libraries -> workspace.texts"
|
||||
(:require
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.types.modifiers :as ctm]
|
||||
[app.main.data.helpers :as dsh]
|
||||
[app.main.data.workspace.modifiers :as dwm]
|
||||
[app.render-wasm.api :as wasm.api]
|
||||
[beicon.v2.core :as rx]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
(defn resize-wasm-text-modifiers
|
||||
([shape]
|
||||
(resize-wasm-text-modifiers shape (:content shape)))
|
||||
|
||||
([{:keys [id points selrect grow-type] :as shape} content]
|
||||
(wasm.api/use-shape id)
|
||||
(wasm.api/set-shape-text-content id content)
|
||||
(wasm.api/set-shape-text-images id content)
|
||||
|
||||
(let [dimension (wasm.api/get-text-dimensions)
|
||||
width-scale (if (#{:fixed :auto-height} grow-type)
|
||||
1.0
|
||||
(/ (:width dimension) (:width selrect)))
|
||||
height-scale (if (= :fixed grow-type)
|
||||
1.0
|
||||
(/ (:height dimension) (:height selrect)))
|
||||
resize-v (gpt/point width-scale height-scale)
|
||||
origin (first points)]
|
||||
|
||||
{id
|
||||
{:modifiers
|
||||
(ctm/resize-modifiers
|
||||
resize-v
|
||||
origin
|
||||
(:transform shape (gmt/matrix))
|
||||
(:transform-inverse shape (gmt/matrix)))}})))
|
||||
|
||||
(defn resize-wasm-text
|
||||
"Resize a single text shape (auto-width/auto-height) by id.
|
||||
No-op if the id is not a text shape or is :fixed."
|
||||
[id]
|
||||
(ptk/reify ::resize-wasm-text
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [objects (dsh/lookup-page-objects state)
|
||||
shape (get objects id)]
|
||||
(if (and (some? shape)
|
||||
(cfh/text-shape? shape)
|
||||
(not= :fixed (:grow-type shape)))
|
||||
(rx/of (dwm/apply-wasm-modifiers (resize-wasm-text-modifiers shape)))
|
||||
(rx/empty))))))
|
||||
|
||||
(defn resize-wasm-text-all
|
||||
"Resize all text shapes (auto-width/auto-height) from a collection of ids."
|
||||
[ids]
|
||||
(ptk/reify ::resize-wasm-text-all
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(->> (rx/from ids)
|
||||
(rx/map resize-wasm-text)))))
|
||||
@@ -9,16 +9,15 @@
|
||||
(:require
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.pprint :as pp]
|
||||
[app.config :as cf]
|
||||
[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.notifications :as ntf]
|
||||
[app.main.data.workspace :as-alias dw]
|
||||
[app.main.router :as rt]
|
||||
[app.main.store :as st]
|
||||
[app.main.worker]
|
||||
[app.util.globals :as g]
|
||||
[app.util.globals :as glob]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[app.util.timers :as ts]
|
||||
[cuerdas.core :as str]
|
||||
@@ -33,6 +32,44 @@
|
||||
;; Will contain last uncaught exception
|
||||
(def last-exception nil)
|
||||
|
||||
(defn- print-data!
|
||||
[data]
|
||||
(-> data
|
||||
(dissoc ::sm/explain)
|
||||
(dissoc :explain)
|
||||
(dissoc ::trace)
|
||||
(dissoc ::instance)
|
||||
(pp/pprint {:width 70})))
|
||||
|
||||
(defn- print-explain!
|
||||
[data]
|
||||
(when-let [{:keys [errors] :as explain} (::sm/explain data)]
|
||||
(let [errors (mapv #(update % :schema sm/form) errors)]
|
||||
(pp/pprint errors {:width 100 :level 15 :length 20})))
|
||||
|
||||
(when-let [explain (:explain data)]
|
||||
(js/console.log explain)))
|
||||
|
||||
(defn- print-trace!
|
||||
[data]
|
||||
(some-> data ::trace js/console.log))
|
||||
|
||||
(defn- print-group!
|
||||
[message f]
|
||||
(try
|
||||
(js/console.group message)
|
||||
(f)
|
||||
(catch :default _ nil)
|
||||
(finally
|
||||
(js/console.groupEnd message))))
|
||||
|
||||
(defn print-cause!
|
||||
[message cause]
|
||||
(print-group! message (fn []
|
||||
(print-data! cause)
|
||||
(print-explain! cause)
|
||||
(print-trace! cause))))
|
||||
|
||||
(defn exception->error-data
|
||||
[cause]
|
||||
(let [data (ex-data cause)]
|
||||
@@ -41,6 +78,18 @@
|
||||
(assoc ::instance cause)
|
||||
(assoc ::trace (.-stack cause)))))
|
||||
|
||||
(defn print-error!
|
||||
[cause]
|
||||
(cond
|
||||
(map? cause)
|
||||
(print-cause! (:hint cause "Unexpected Error") cause)
|
||||
|
||||
(ex/error? cause)
|
||||
(print-cause! (ex-message cause) (ex-data cause))
|
||||
|
||||
:else
|
||||
(print-cause! (ex-message cause) (exception->error-data cause))))
|
||||
|
||||
(defn on-error
|
||||
"A general purpose error handler."
|
||||
[error]
|
||||
@@ -55,66 +104,13 @@
|
||||
;; Set the main potok error handler
|
||||
(reset! st/on-error on-error)
|
||||
|
||||
(defn generate-report
|
||||
[cause]
|
||||
(try
|
||||
(let [team-id (:current-team-id @st/state)
|
||||
file-id (:current-file-id @st/state)
|
||||
profile-id (:profile-id @st/state)
|
||||
data (ex-data cause)]
|
||||
|
||||
(with-out-str
|
||||
(println "Context:")
|
||||
(println "--------------------")
|
||||
(println "Hint: " (or (:hint data) (ex-message cause) "--"))
|
||||
(println "Prof ID: " (str (or profile-id "--")))
|
||||
(println "Team ID: " (str (or team-id "--")))
|
||||
(when-let [file-id (or (:file-id data) file-id)]
|
||||
(println "File ID: " (str file-id)))
|
||||
(println "Version: " (:full cf/version))
|
||||
(println "URI: " (str cf/public-uri))
|
||||
(println "HREF: " (rt/get-current-href))
|
||||
(println)
|
||||
|
||||
(println
|
||||
(ex/format-throwable cause))
|
||||
(println)
|
||||
|
||||
(println "Last events:")
|
||||
(println "--------------------")
|
||||
(pp/pprint @st/last-events {:length 200})
|
||||
(println)))
|
||||
(catch :default cause
|
||||
(.error js/console "error on generating report" cause)
|
||||
nil)))
|
||||
|
||||
(defn- show-not-blocking-error
|
||||
"Show a non user blocking error notification"
|
||||
[cause]
|
||||
(let [data (ex-data cause)
|
||||
hint (or (some-> (:hint data) ex/first-line)
|
||||
(ex-message cause))]
|
||||
|
||||
(st/emit!
|
||||
(ev/event {::ev/name "unhandled-exception"
|
||||
:hint hint
|
||||
:href (rt/get-current-href)
|
||||
:type (get data :type :unknown)
|
||||
:report (generate-report cause)})
|
||||
|
||||
(ntf/show {:content (tr "errors.unexpected-exception" hint)
|
||||
:type :toast
|
||||
:level :error
|
||||
:timeout 3000}))))
|
||||
|
||||
(defmethod ptk/handle-error :default
|
||||
[error]
|
||||
(if (and (string? (:hint error))
|
||||
(str/starts-with? (:hint error) "Assert failed:"))
|
||||
(ptk/handle-error (assoc error :type :assertion))
|
||||
(when-let [cause (::instance error)]
|
||||
(ex/print-throwable cause :prefix "Unexpected Error")
|
||||
(show-not-blocking-error cause))))
|
||||
(st/async-emit! (rt/assign-exception error))
|
||||
(print-group! "Unhandled Error"
|
||||
(fn []
|
||||
(print-trace! error)
|
||||
(print-data! error))))
|
||||
|
||||
;; We receive a explicit authentication error; If the uri is for
|
||||
;; workspace, dashboard, viewer or settings, then assign the exception
|
||||
@@ -146,10 +142,10 @@
|
||||
|
||||
(defmethod ptk/handle-error :validation
|
||||
[{:keys [code] :as error}]
|
||||
|
||||
(when-let [instance (get error ::instance)]
|
||||
(ex/print-throwable instance :prefix "Validation Error"))
|
||||
|
||||
(print-group! "Validation Error"
|
||||
(fn []
|
||||
(print-data! error)
|
||||
(print-explain! error)))
|
||||
(cond
|
||||
(= code :invalid-paste-data)
|
||||
(let [message (tr "errors.paste-data-validation")]
|
||||
@@ -197,14 +193,23 @@
|
||||
:else
|
||||
(st/async-emit! (rt/assign-exception error))))
|
||||
|
||||
|
||||
;; This is a pure frontend error that can be caused by an active
|
||||
;; assertion (assertion that is preserved on production builds). From
|
||||
;; the user perspective this should be treated as internal error.
|
||||
(defmethod ptk/handle-error :assertion
|
||||
[error]
|
||||
(when-let [cause (::instance error)]
|
||||
(show-not-blocking-error cause)
|
||||
(ex/print-throwable cause :prefix "Assertion Error")))
|
||||
(ts/schedule
|
||||
#(st/emit! (ntf/show {:content (tr "errors.internal-assertion-error")
|
||||
:type :toast
|
||||
:level :error
|
||||
:timeout 3000})))
|
||||
|
||||
(print-group! "Internal Assertion Error"
|
||||
(fn []
|
||||
(print-trace! error)
|
||||
(print-data! error)
|
||||
(print-explain! error))))
|
||||
|
||||
;; ;; All the errors that happens on worker are handled here.
|
||||
(defmethod ptk/handle-error :worker-error
|
||||
@@ -216,8 +221,9 @@
|
||||
:level :error
|
||||
:timeout 3000})))
|
||||
|
||||
(some-> (::instance error)
|
||||
(ex/print-throwable :prefix "Web Worker Error")))
|
||||
(print-group! "Internal Worker Error"
|
||||
(fn []
|
||||
(print-data! error))))
|
||||
|
||||
;; Error on parsing an SVG
|
||||
(defmethod ptk/handle-error :svg-parser
|
||||
@@ -246,9 +252,11 @@
|
||||
|
||||
(defmethod ptk/handle-error ::exceptional-state
|
||||
[error]
|
||||
(when-let [instance (get error ::instance)]
|
||||
(ex/print-throwable instance :prefix "Exceptional State"))
|
||||
(ts/schedule #(st/emit! (rt/assign-exception error))))
|
||||
(when-let [cause (::instance error)]
|
||||
(js/console.log (.-stack cause)))
|
||||
|
||||
(ts/schedule
|
||||
#(st/emit! (rt/assign-exception error))))
|
||||
|
||||
(defn- redirect-to-dashboard
|
||||
[]
|
||||
@@ -256,7 +264,7 @@
|
||||
project-id (:current-project-id @st/state)]
|
||||
(if (and project-id team-id)
|
||||
(st/emit! (rt/nav :dashboard-files {:team-id team-id :project-id project-id}))
|
||||
(set! (.-href g/location) ""))))
|
||||
(set! (.-href glob/location) ""))))
|
||||
|
||||
(defmethod ptk/handle-error :restriction
|
||||
[{:keys [code] :as error}]
|
||||
@@ -304,10 +312,9 @@
|
||||
:text (tr "errors.deprecated.contact.text")
|
||||
:after (tr "errors.deprecated.contact.after")
|
||||
:on-click #(st/emit! (rt/nav :settings-feedback))}}))
|
||||
|
||||
:else
|
||||
(when-let [cause (::instance error)]
|
||||
(ex/print-throwable cause :prefix "Restriction Error")
|
||||
(show-not-blocking-error cause))))
|
||||
(print-cause! "Restriction Error" error)))
|
||||
|
||||
;; This happens when the backed server fails to process the
|
||||
;; request. This can be caused by an internal assertion or any other
|
||||
@@ -315,9 +322,24 @@
|
||||
|
||||
(defmethod ptk/handle-error :server-error
|
||||
[error]
|
||||
(when-let [instance (get error ::instance)]
|
||||
(ex/print-throwable instance :prefix "Server Error"))
|
||||
(st/async-emit! (rt/assign-exception error)))
|
||||
(st/async-emit! (rt/assign-exception error))
|
||||
(print-group! "Server Error"
|
||||
(fn []
|
||||
(print-data! (dissoc error :data))
|
||||
|
||||
(when-let [werror (:data error)]
|
||||
(cond
|
||||
(= :assertion (:type werror))
|
||||
(print-group! "Assertion Error"
|
||||
(fn []
|
||||
(print-data! werror)
|
||||
(print-explain! werror)))
|
||||
|
||||
:else
|
||||
(print-group! "Unexpected"
|
||||
(fn []
|
||||
(print-data! werror)
|
||||
(print-explain! werror))))))))
|
||||
|
||||
(defonce uncaught-error-handler
|
||||
(letfn [(is-ignorable-exception? [cause]
|
||||
@@ -332,19 +354,28 @@
|
||||
(when-let [cause (unchecked-get event "error")]
|
||||
(set! last-exception cause)
|
||||
(when-not (is-ignorable-exception? cause)
|
||||
(ex/print-throwable cause :prefix "Uncaught Exception")
|
||||
(ts/schedule #(show-not-blocking-error cause)))))
|
||||
(ex/print-throwable cause :prefix "uncaught exception")
|
||||
(st/async-emit!
|
||||
(ntf/show {:content (tr "errors.unexpected-exception" (ex-message cause))
|
||||
:type :toast
|
||||
:level :error
|
||||
:timeout 3000})))))
|
||||
|
||||
|
||||
(on-unhandled-rejection [event]
|
||||
(.preventDefault ^js event)
|
||||
(when-let [cause (unchecked-get event "reason")]
|
||||
(set! last-exception cause)
|
||||
(ex/print-throwable cause :prefix "Uncaught Rejection")
|
||||
(ts/schedule #(show-not-blocking-error cause))))]
|
||||
(ex/print-throwable cause :prefix "uncaught rejection")
|
||||
(st/async-emit!
|
||||
(ntf/show {:content (tr "errors.unexpected-exception" (ex-message cause))
|
||||
:type :toast
|
||||
:level :error
|
||||
:timeout 3000}))))]
|
||||
|
||||
(.addEventListener g/window "error" on-unhandled-error)
|
||||
(.addEventListener g/window "unhandledrejection" on-unhandled-rejection)
|
||||
(.addEventListener glob/window "error" on-unhandled-error)
|
||||
(.addEventListener glob/window "unhandledrejection" on-unhandled-rejection)
|
||||
(fn []
|
||||
(.removeEventListener g/window "error" on-unhandled-error)
|
||||
(.removeEventListener g/window "unhandledrejection" on-unhandled-rejection))))
|
||||
(.removeEventListener glob/window "error" on-unhandled-error)
|
||||
(.removeEventListener glob/window "unhandledrejection" on-unhandled-rejection))))
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.logging :as log]
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.notifications :as ntf]
|
||||
[app.main.errors :as errors]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.file-uploader :refer [file-uploader*]]
|
||||
[app.main.ui.ds.product.loader :refer [loader*]]
|
||||
@@ -360,7 +360,7 @@
|
||||
on-error
|
||||
(fn [cause]
|
||||
(reset! status* :error)
|
||||
(ex/print-throwable cause)
|
||||
(errors/print-error! cause)
|
||||
(rx/of (modal/hide)
|
||||
(ntf/error (tr "dashboard.libraries-and-templates.import-error"))))
|
||||
|
||||
|
||||
@@ -36,12 +36,10 @@
|
||||
|
||||
(defn- hide-popover
|
||||
[node]
|
||||
(when (and (some? node)
|
||||
(fn? (.-hidePopover node)))
|
||||
(dom/unset-css-property! node "block-size")
|
||||
(dom/unset-css-property! node "inset-block-start")
|
||||
(dom/unset-css-property! node "inset-inline-start")
|
||||
(.hidePopover ^js node)))
|
||||
(dom/unset-css-property! node "block-size")
|
||||
(dom/unset-css-property! node "inset-block-start")
|
||||
(dom/unset-css-property! node "inset-inline-start")
|
||||
(.hidePopover ^js node))
|
||||
|
||||
(defn- calculate-placement-bounding-rect
|
||||
"Given a placement, calcultates the bounding rect for it taking in
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
(def context (mf/create-context nil))
|
||||
|
||||
(mf/defc form-input*
|
||||
[{:keys [name trim] :rest props}]
|
||||
[{:keys [name] :rest props}]
|
||||
|
||||
(let [form (mf/use-ctx context)
|
||||
input-name name
|
||||
@@ -33,7 +33,7 @@
|
||||
(mf/deps input-name)
|
||||
(fn [event]
|
||||
(let [value (-> event dom/get-target dom/get-input-value)]
|
||||
(fm/on-input-change form input-name value trim))))
|
||||
(fm/on-input-change form input-name value true))))
|
||||
|
||||
props
|
||||
(mf/spread-props props {:on-change on-change
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
(def ^:private schema:properties-row
|
||||
[:map
|
||||
[:term :string]
|
||||
[:detail {:optional true} [:maybe :string]]
|
||||
[:detail :string]
|
||||
[:property {:optional true} :string] ;; CSS valid property
|
||||
[:token {:optional true} :any] ;; resolved token object
|
||||
[:copiable {:optional true} :boolean]])
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
[app.util.webapi :as wapi]
|
||||
[beicon.v2.core :as rx]
|
||||
[cuerdas.core :as str]
|
||||
[potok.v2.core :as ptk]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
;; FIXME: this is a workaround until we export this class on beicon library
|
||||
@@ -446,24 +447,25 @@
|
||||
(rx/of default)
|
||||
(rx/throw cause)))))))
|
||||
|
||||
|
||||
(mf/defc exception-section*
|
||||
{::mf/private true}
|
||||
[{:keys [data route] :as props}]
|
||||
(let [type (get data :type)
|
||||
report (mf/with-memo [data]
|
||||
(some-> data ::errors/instance errors/generate-report))
|
||||
(generate-report data))
|
||||
props (mf/spread-props props {:report report})]
|
||||
|
||||
(mf/with-effect [data route report]
|
||||
(let [params (:query-params route)
|
||||
params (u/map->query-string params)]
|
||||
(st/emit! (ev/event {::ev/name "exception-page"
|
||||
:type (get data :type :unknown)
|
||||
:href (rt/get-current-href)
|
||||
:hint (get data :hint)
|
||||
:path (get route :path)
|
||||
:report report
|
||||
:params params}))))
|
||||
(st/emit! (ptk/data-event ::ev/event
|
||||
{::ev/name "exception-page"
|
||||
:type (get data :type :unknown)
|
||||
:hint (get data :hint)
|
||||
:path (get route :path)
|
||||
:report report
|
||||
:params params}))))
|
||||
|
||||
(case type
|
||||
:not-found
|
||||
|
||||
@@ -78,15 +78,13 @@
|
||||
(fn []
|
||||
(close-modals)
|
||||
;; FIXME: move set-mode to uri?
|
||||
(st/emit! :interrupt
|
||||
(dw/set-options-mode :design)
|
||||
(st/emit! (dw/set-options-mode :design)
|
||||
(dcm/go-to-dashboard-recent))))
|
||||
|
||||
nav-to-project
|
||||
(mf/use-fn
|
||||
(mf/deps project-id)
|
||||
#(st/emit! :interrupt
|
||||
(dcm/go-to-dashboard-files ::rt/new-window true :project-id project-id)))]
|
||||
#(st/emit! (dcm/go-to-dashboard-files ::rt/new-window true :project-id project-id)))]
|
||||
|
||||
(mf/with-effect [editing?]
|
||||
(when ^boolean editing?
|
||||
|
||||
@@ -95,10 +95,10 @@
|
||||
[]
|
||||
|
||||
(let [plugins-state* (mf/use-state #(preg/plugins-list))
|
||||
plugins-state (deref plugins-state*)
|
||||
plugins-state @plugins-state*
|
||||
|
||||
plugin-url* (mf/use-state "")
|
||||
plugin-url (deref plugin-url*)
|
||||
plugin-url* (mf/use-state "")
|
||||
plugin-url @plugin-url*
|
||||
|
||||
fetching-manifest? (mf/use-state false)
|
||||
|
||||
|
||||
@@ -401,8 +401,7 @@
|
||||
(dm/fmt "scale(%)" maybe-zoom))}))]
|
||||
|
||||
[:g.text-editor {:clip-path (dm/fmt "url(#%)" clip-id)
|
||||
:transform (dm/str transform)
|
||||
:data-testid "text-editor"}
|
||||
:transform (dm/str transform)}
|
||||
[:defs
|
||||
[:clipPath {:id clip-id}
|
||||
[:rect {:x x :y y :width width :height height}]]]
|
||||
|
||||
@@ -119,8 +119,7 @@
|
||||
[:button {:class (stl/css-case
|
||||
:toggle-content true
|
||||
:inverse expanded?)
|
||||
:data-testid "toggle-content"
|
||||
:aria-expanded expanded?
|
||||
:aria-label "Toggle layer"
|
||||
:on-click on-toggle-collapse}
|
||||
deprecated-icon/arrow])
|
||||
|
||||
|
||||
@@ -108,7 +108,6 @@
|
||||
:on-blur accept-edit
|
||||
:on-key-down on-key-down
|
||||
:auto-focus true
|
||||
:id (dm/str "layer-name-" shape-id)
|
||||
:default-value (d/nilv default-value "")}]
|
||||
[:*
|
||||
[:span
|
||||
@@ -119,7 +118,6 @@
|
||||
:hidden is-hidden
|
||||
:type-comp type-comp
|
||||
:type-frame type-frame)
|
||||
:id (dm/str "layer-name-" shape-id)
|
||||
:style {"--depth" depth "--parent-size" parent-size}
|
||||
:ref ref
|
||||
:on-double-click start-edit}
|
||||
|
||||
@@ -283,7 +283,7 @@
|
||||
(if (or (string? value) (number? value))
|
||||
(do
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids))
|
||||
(st/emit! (udw/update-positions ids {attr value})))
|
||||
(st/emit! (udw/update-position ids {attr value})))
|
||||
(st/emit! (udw/trigger-bounding-box-cloaking ids)
|
||||
(dwta/toggle-token {:token (first value)
|
||||
:attrs #{attr}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
[app.main.data.workspace.shortcuts :as sc]
|
||||
[app.main.data.workspace.texts :as dwt]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.data.workspace.wasm-text :as dwwt]
|
||||
[app.main.features :as features]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
@@ -142,7 +141,7 @@
|
||||
(dwsh/update-shapes ids #(assoc % :grow-type grow-type)))
|
||||
|
||||
(when (features/active-feature? @st/state "render-wasm/v1")
|
||||
(st/emit! (dwwt/resize-wasm-text-all ids)))
|
||||
(st/emit! (dwt/resize-wasm-text-all ids)))
|
||||
;; We asynchronously commit so every sychronous event is resolved first and inside the transaction
|
||||
(ts/schedule #(st/emit! (dwu/commit-undo-transaction uid))))
|
||||
(when (some? on-blur)
|
||||
|
||||
@@ -309,7 +309,7 @@
|
||||
|
||||
on-remove'
|
||||
(mf/use-fn
|
||||
(mf/deps index on-remove)
|
||||
(mf/deps index)
|
||||
(fn [_]
|
||||
(when on-remove
|
||||
(on-remove index))))
|
||||
|
||||
@@ -94,7 +94,10 @@
|
||||
;; This only checks for the currently explicitly selected set
|
||||
;; id, it is ephimeral and can be nil
|
||||
;; FIXME: this is a repeated deref for the same `:workspace-tokens` state
|
||||
selected-token-set-id (mf/deref refs/selected-token-set-id)
|
||||
selected-token-set-id
|
||||
(mf/deref refs/selected-token-set-id)
|
||||
|
||||
|
||||
|
||||
;; If we have not selected any set explicitly we just
|
||||
;; select the first one from the list of sets
|
||||
@@ -109,7 +112,6 @@
|
||||
tokens
|
||||
(sd/use-resolved-tokens* tokens)
|
||||
|
||||
;; Group tokens by their type
|
||||
tokens-by-type
|
||||
(mf/with-memo [tokens selected-token-set-tokens]
|
||||
(let [tokens (reduce-kv (fn [tokens k _]
|
||||
@@ -127,9 +129,9 @@
|
||||
;; Filter tokens by their path and return their ids
|
||||
filter-tokens-by-path-ids
|
||||
(mf/use-fn
|
||||
(mf/deps selected-token-set-tokens)
|
||||
(mf/deps tokens)
|
||||
(fn [type path]
|
||||
(->> selected-token-set-tokens
|
||||
(->> tokens
|
||||
(filter (fn [token]
|
||||
(let [[_ token-value] token]
|
||||
(and (= (:type token-value) type) (str/starts-with? (:name token-value) path)))))
|
||||
@@ -137,47 +139,12 @@
|
||||
(let [[_ token-value] token]
|
||||
(:id token-value)))))))
|
||||
|
||||
remaining-tokens-of-type-in-set?
|
||||
(mf/use-fn
|
||||
(fn [selected-token-set-tokens tokens-in-path-ids]
|
||||
(let [token-ids (set tokens-in-path-ids)
|
||||
remaining-tokens (filter (fn [token]
|
||||
(not (contains? token-ids (:id token))))
|
||||
selected-token-set-tokens)
|
||||
_ (prn "Remaining tokens:" remaining-tokens)]
|
||||
(seq remaining-tokens))))
|
||||
|
||||
delete-token
|
||||
(mf/with-memo [selected-token-set-tokens selected-token-set-id]
|
||||
(fn [token]
|
||||
(let [id (:id token)
|
||||
type (:type token)
|
||||
path (:name token)
|
||||
tokens-by-type (ctob/group-by-type selected-token-set-tokens)
|
||||
tokens-filtered-by-type (get tokens-by-type type)
|
||||
tokens-in-path-ids (filter-tokens-by-path-ids type path)
|
||||
remaining-tokens? (remaining-tokens-of-type-in-set? tokens-filtered-by-type tokens-in-path-ids)]
|
||||
;; Delete the token
|
||||
(st/emit! (dwtl/delete-token selected-token-set-id id))
|
||||
;; Remove from unfolded tree path
|
||||
(if remaining-tokens?
|
||||
(st/emit! (dwtl/toggle-token-path (str (name type) "." path)))
|
||||
(st/emit! (dwtl/toggle-token-path (name type)))))))
|
||||
|
||||
delete-node
|
||||
(mf/with-memo [selected-token-set-tokens selected-token-set-id]
|
||||
(mf/with-memo [tokens selected-token-set-id]
|
||||
(fn [node type]
|
||||
(let [path (:path node)
|
||||
tokens-by-type (ctob/group-by-type selected-token-set-tokens)
|
||||
tokens-filtered-by-type (get tokens-by-type type)
|
||||
tokens-in-path-ids (filter-tokens-by-path-ids type path)
|
||||
remaining-tokens? (remaining-tokens-of-type-in-set? tokens-filtered-by-type tokens-in-path-ids)]
|
||||
;; Delete tokens in path
|
||||
(st/emit! (dwtl/bulk-delete-tokens selected-token-set-id tokens-in-path-ids))
|
||||
;; Remove from unfolded tree path
|
||||
(if remaining-tokens?
|
||||
(st/emit! (dwtl/toggle-token-path (str (name type) "." path)))
|
||||
(st/emit! (dwtl/toggle-token-path (name type)))))))]
|
||||
tokens-in-path-ids (filter-tokens-by-path-ids type path)]
|
||||
(st/emit! (dwtl/bulk-delete-tokens selected-token-set-id tokens-in-path-ids)))))]
|
||||
|
||||
(mf/with-effect [tokens-lib selected-token-set-id]
|
||||
(when (and tokens-lib
|
||||
@@ -190,7 +157,7 @@
|
||||
(st/emit! (dwtl/set-selected-token-set-id (ctob/get-id match)))))))
|
||||
|
||||
[:*
|
||||
[:& token-context-menu {:on-delete-token delete-token}]
|
||||
[:& token-context-menu]
|
||||
[:> token-node-context-menu* {:on-delete-node delete-node}]
|
||||
|
||||
[:> selected-set-info* {:tokens-lib tokens-lib
|
||||
|
||||
@@ -316,9 +316,8 @@
|
||||
(generic-attribute-actions #{:y} "Y" (assoc context-data :on-update-shape dwta/update-shape-position)))
|
||||
(clean-separators)))}))
|
||||
|
||||
(defn default-actions [{:keys [token selected-token-set-id on-delete-token]}]
|
||||
(let [{:keys [modal]} (dwta/get-token-properties token)
|
||||
on-duplicate-token #(st/emit! (dwtl/duplicate-token (:id token)))]
|
||||
(defn default-actions [{:keys [token selected-token-set-id]}]
|
||||
(let [{:keys [modal]} (dwta/get-token-properties token)]
|
||||
[{:title (tr "workspace.tokens.edit")
|
||||
:no-selectable true
|
||||
:action (fn [event]
|
||||
@@ -334,10 +333,12 @@
|
||||
:token token}))))}
|
||||
{:title (tr "workspace.tokens.duplicate")
|
||||
:no-selectable true
|
||||
:action on-duplicate-token}
|
||||
:action #(st/emit! (dwtl/duplicate-token (:id token)))}
|
||||
{:title (tr "workspace.tokens.delete")
|
||||
:no-selectable true
|
||||
:action #(on-delete-token token)}]))
|
||||
:action #(st/emit! (dwtl/delete-token
|
||||
selected-token-set-id
|
||||
(:id token)))}]))
|
||||
|
||||
(defn- allowed-shape-attributes [shapes]
|
||||
(reduce into #{} (map #(ctt/shape-type->attributes (:type %) (:layout %)) shapes)))
|
||||
@@ -463,7 +464,7 @@
|
||||
:selected? selected?}])])))
|
||||
|
||||
(mf/defc token-context-menu-tree
|
||||
[{:keys [width errors on-delete-token] :as mdata}]
|
||||
[{:keys [width errors] :as mdata}]
|
||||
(let [objects (mf/deref refs/workspace-page-objects)
|
||||
selected (mf/deref refs/selected-shapes)
|
||||
|
||||
@@ -487,11 +488,10 @@
|
||||
:errors errors
|
||||
:selected-token-set-id selected-token-set-id
|
||||
:selected-shapes selected-shapes
|
||||
:is-selected-inside-layout is-selected-inside-layout
|
||||
:on-delete-token on-delete-token}]]))
|
||||
:is-selected-inside-layout is-selected-inside-layout}]]))
|
||||
|
||||
(mf/defc token-context-menu
|
||||
[{:keys [on-delete-token]}]
|
||||
[]
|
||||
(let [mdata (mf/deref tokens-menu-ref)
|
||||
is-open? (boolean mdata)
|
||||
width (mf/use-state 0)
|
||||
@@ -538,5 +538,5 @@
|
||||
:left (dm/str left "px")}
|
||||
:on-context-menu prevent-default}
|
||||
(when mdata
|
||||
[:& token-context-menu-tree (assoc mdata :width @width :on-delete-token on-delete-token)])]])
|
||||
[:& token-context-menu-tree (assoc mdata :width @width)])]])
|
||||
(dom/get-body)))))
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.types.color :as cl]
|
||||
[app.common.types.token :as cto]
|
||||
[app.common.types.tokens-lib :as ctob]
|
||||
[app.main.data.style-dictionary :as sd]
|
||||
[app.main.data.tinycolor :as tinycolor]
|
||||
@@ -52,15 +51,12 @@
|
||||
;; Both variants provide identical color-picker and text-input behavior, but
|
||||
;; differ in how they persist the value within the form’s nested structure.
|
||||
|
||||
|
||||
(defn- resolve-value
|
||||
[tokens prev-token token-name value]
|
||||
(let [valid-token-name?
|
||||
(and (string? token-name)
|
||||
(re-matches cto/token-name-validation-regex token-name))
|
||||
|
||||
token
|
||||
(let [token
|
||||
{:value value
|
||||
:name (if (or (not valid-token-name?) (str/blank? token-name))
|
||||
:name (if (str/blank? token-name)
|
||||
"__PENPOT__TOKEN__NAME__PLACEHOLDER__"
|
||||
token-name)}
|
||||
|
||||
|
||||
@@ -50,13 +50,9 @@
|
||||
|
||||
(defn- resolve-value
|
||||
[tokens prev-token token-name value]
|
||||
(let [valid-token-name?
|
||||
(and (string? token-name)
|
||||
(re-matches cto/token-name-validation-regex token-name))
|
||||
|
||||
token
|
||||
(let [token
|
||||
{:value (cto/split-font-family value)
|
||||
:name (if (or (not valid-token-name?) (str/blank? token-name))
|
||||
:name (if (str/blank? token-name)
|
||||
"__PENPOT__TOKEN__NAME__PLACEHOLDER__"
|
||||
token-name)}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.files.tokens :as cft]
|
||||
[app.common.types.token :as cto]
|
||||
[app.common.types.tokens-lib :as ctob]
|
||||
[app.main.data.style-dictionary :as sd]
|
||||
[app.main.data.workspace.tokens.format :as dwtf]
|
||||
@@ -141,13 +140,9 @@
|
||||
|
||||
(defn- resolve-value
|
||||
[tokens prev-token token-name value]
|
||||
(let [valid-token-name?
|
||||
(and (string? token-name)
|
||||
(re-matches cto/token-name-validation-regex token-name))
|
||||
|
||||
token
|
||||
(let [token
|
||||
{:value value
|
||||
:name (if (or (not valid-token-name?) (str/blank? token-name))
|
||||
:name (if (str/blank? token-name)
|
||||
"__PENPOT__TOKEN__NAME__PLACEHOLDER__"
|
||||
token-name)}
|
||||
tokens
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
[app.main.ui.ds.buttons.button :refer [button*]]
|
||||
[app.main.ui.ds.foundations.assets.icon :as i]
|
||||
[app.main.ui.ds.foundations.typography.heading :refer [heading*]]
|
||||
[app.main.ui.ds.notifications.context-notification :refer [context-notification*]]
|
||||
[app.main.ui.forms :as fc]
|
||||
[app.main.ui.workspace.tokens.management.forms.controls :as token.controls]
|
||||
[app.main.ui.workspace.tokens.management.forms.validators :refer [default-validate-token]]
|
||||
@@ -98,12 +97,12 @@
|
||||
value-subfield
|
||||
input-value-placeholder] :as props}]
|
||||
|
||||
(let [make-schema (or make-schema default-make-schema)
|
||||
(let [make-schema (or make-schema default-make-schema)
|
||||
input-component (or input-component token.controls/input*)
|
||||
validate-token (or validator default-validate-token)
|
||||
validate-token (or validator default-validate-token)
|
||||
|
||||
active-tab* (mf/use-state #(if (cft/is-reference? token) :reference :composite))
|
||||
active-tab (deref active-tab*)
|
||||
active-tab* (mf/use-state #(if (cft/is-reference? token) :reference :composite))
|
||||
active-tab (deref active-tab*)
|
||||
|
||||
token
|
||||
(mf/with-memo [token]
|
||||
@@ -143,10 +142,6 @@
|
||||
(fm/use-form :schema schema
|
||||
:initial initial)
|
||||
|
||||
warning-name-change?
|
||||
(not= (get-in @form [:data :name])
|
||||
(:name initial))
|
||||
|
||||
on-toggle-tab
|
||||
(mf/use-fn
|
||||
(mf/deps form)
|
||||
@@ -275,13 +270,7 @@
|
||||
:placeholder (tr "workspace.tokens.enter-token-name" token-title)
|
||||
:max-length max-input-length
|
||||
:variant "comfortable"
|
||||
:trim true
|
||||
:auto-focus true}]
|
||||
|
||||
(when (and warning-name-change? (= action "edit"))
|
||||
[:div {:class (stl/css :warning-name-change-notification-wrapper)}
|
||||
[:> context-notification*
|
||||
{:level :warning :appearance :ghost} (tr "workspace.tokens.warning-name-change")]])]
|
||||
:auto-focus true}]]
|
||||
|
||||
[:div {:class (stl/css :input-row)}
|
||||
(case type
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(defn- on-select-token-set-click [id]
|
||||
(st/emit! (dwtl/clear-tokens-paths))
|
||||
(st/emit! (dwtl/set-selected-token-set-id id)))
|
||||
|
||||
(defn- on-toggle-token-set-click [name]
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
[app.main.ui.shapes.text.fontfaces :refer [shapes->fonts]]
|
||||
[app.plugins.events :as events]
|
||||
[app.plugins.file :as file]
|
||||
[app.plugins.flags :as flags]
|
||||
[app.plugins.fonts :as fonts]
|
||||
[app.plugins.format :as format]
|
||||
[app.plugins.history :as history]
|
||||
@@ -41,7 +40,6 @@
|
||||
[app.plugins.page :as page]
|
||||
[app.plugins.parser :as parser]
|
||||
[app.plugins.shape :as shape]
|
||||
[app.plugins.system-events :as se]
|
||||
[app.plugins.user :as user]
|
||||
[app.plugins.utils :as u]
|
||||
[app.plugins.viewport :as viewport]
|
||||
@@ -67,10 +65,7 @@
|
||||
(cb/with-objects (:objects page))
|
||||
(cb/add-object shape))]
|
||||
|
||||
(st/emit!
|
||||
(ch/commit-changes changes)
|
||||
(se/event plugin-id "create-shape" :type type))
|
||||
|
||||
(st/emit! (ch/commit-changes changes))
|
||||
(shape/shape-proxy plugin-id (:id shape))))
|
||||
|
||||
(defn create-context
|
||||
@@ -129,9 +124,6 @@
|
||||
:fonts
|
||||
{:get (fn [] (fonts/fonts-subcontext plugin-id))}
|
||||
|
||||
:flags
|
||||
{:get (fn [] (flags/flags-proxy plugin-id))}
|
||||
|
||||
:library
|
||||
{:get (fn [] (library/library-subcontext plugin-id))}
|
||||
|
||||
@@ -293,8 +285,7 @@
|
||||
page-id (:current-page-id @st/state)
|
||||
id (uuid/next)
|
||||
ids (into #{} (map #(obj/get % "$id")) shapes)]
|
||||
(st/emit! (dwg/group-shapes id ids)
|
||||
(se/event plugin-id "create-shape" :type type))
|
||||
(st/emit! (dwg/group-shapes id ids))
|
||||
(shape/shape-proxy plugin-id file-id page-id id))))
|
||||
|
||||
:ungroup
|
||||
@@ -336,8 +327,7 @@
|
||||
(cb/with-objects (:objects page))
|
||||
(cb/add-object shape))]
|
||||
|
||||
(st/emit! (ch/commit-changes changes)
|
||||
(se/event plugin-id "create-shape" :type :path))
|
||||
(st/emit! (ch/commit-changes changes))
|
||||
(shape/shape-proxy plugin-id (:id shape))))
|
||||
|
||||
:createText
|
||||
@@ -358,9 +348,7 @@
|
||||
(cb/with-objects (:objects page))
|
||||
(cb/add-object shape))]
|
||||
|
||||
(st/emit!
|
||||
(ch/commit-changes changes)
|
||||
(se/event plugin-id "create-shape" :type :text))
|
||||
(st/emit! (ch/commit-changes changes))
|
||||
(shape/shape-proxy plugin-id (:id shape)))))
|
||||
|
||||
:createShapeFromSvg
|
||||
@@ -373,8 +361,7 @@
|
||||
(let [id (uuid/next)
|
||||
file-id (:current-file-id @st/state)
|
||||
page-id (:current-page-id @st/state)]
|
||||
(st/emit! (dwm/create-svg-shape id "svg" svg-string (gpt/point 0 0))
|
||||
(se/event plugin-id "create-shape" :type :svg))
|
||||
(st/emit! (dwm/create-svg-shape id "svg" svg-string (gpt/point 0 0)))
|
||||
(shape/shape-proxy plugin-id file-id page-id id))))
|
||||
|
||||
:createShapeFromSvgWithImages
|
||||
@@ -394,8 +381,7 @@
|
||||
(st/emit! (dwm/create-svg-shape-with-images
|
||||
file-id id "svg" svg-string (gpt/point 0 0)
|
||||
#(resolve (shape/shape-proxy plugin-id file-id page-id id))
|
||||
reject)
|
||||
(se/event plugin-id "create-shape" :type :text)))))))
|
||||
reject)))))))
|
||||
|
||||
:createBoolean
|
||||
(fn [bool-type shapes]
|
||||
@@ -410,8 +396,7 @@
|
||||
:else
|
||||
(let [ids (into #{} (map #(obj/get % "$id")) shapes)
|
||||
shape-id (uuid/next)]
|
||||
(st/emit! (dwb/create-bool bool-type :ids ids :force-shape-id shape-id)
|
||||
(se/event plugin-id "create-shape" :type :boolean))
|
||||
(st/emit! (dwb/create-bool bool-type :ids ids :force-shape-id shape-id))
|
||||
(shape/shape-proxy plugin-id shape-id)))))
|
||||
|
||||
:generateMarkup
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.plugins.flags
|
||||
(:require
|
||||
[app.main.data.plugins :as dp]
|
||||
[app.main.store :as st]
|
||||
[app.plugins.utils :as u]
|
||||
[app.util.object :as obj]))
|
||||
|
||||
(defn flags-proxy
|
||||
[plugin-id]
|
||||
(obj/reify {:name "FlagProxy"}
|
||||
:naturalChildOrdering
|
||||
{:this false
|
||||
:get
|
||||
(fn []
|
||||
(boolean
|
||||
(get-in
|
||||
@st/state
|
||||
[:workspace-local :plugin-flags plugin-id :natural-child-ordering])))
|
||||
|
||||
:set
|
||||
(fn [value]
|
||||
(cond
|
||||
(not (boolean? value))
|
||||
(u/display-not-valid :naturalChildOrdering value)
|
||||
|
||||
:else
|
||||
(st/emit! (dp/set-plugin-flag plugin-id :natural-child-ordering value))))}))
|
||||
@@ -10,7 +10,6 @@
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.types.plugins :as ctp]
|
||||
[app.common.uri :as u]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.store :as st]
|
||||
@@ -38,7 +37,6 @@
|
||||
desc (obj/get manifest "description")
|
||||
code (obj/get manifest "code")
|
||||
icon (obj/get manifest "icon")
|
||||
vers (d/nilv (obj/get manifest "version") 1)
|
||||
|
||||
permissions (into #{} (obj/get manifest "permissions" []))
|
||||
permissions
|
||||
@@ -52,17 +50,7 @@
|
||||
(contains? permissions "comment:write")
|
||||
(conj "comment:read"))
|
||||
|
||||
plugin-url
|
||||
(u/uri plugin-url)
|
||||
|
||||
origin
|
||||
(if (= vers 1)
|
||||
(-> plugin-url
|
||||
(assoc :path "/")
|
||||
(str))
|
||||
(-> plugin-url
|
||||
(u/join ".")
|
||||
(str)))
|
||||
origin (obj/get (js/URL. plugin-url) "origin")
|
||||
|
||||
prev-plugin
|
||||
(->> (:data @registry)
|
||||
@@ -71,13 +59,12 @@
|
||||
(and (= name (:name plugin))
|
||||
(= origin (:host plugin))))))
|
||||
|
||||
plugin-id
|
||||
(d/nilv (:plugin-id prev-plugin) (str (uuid/next)))
|
||||
plugin-id (d/nilv (:plugin-id prev-plugin) (str (uuid/next)))
|
||||
|
||||
manifest
|
||||
(d/without-nils
|
||||
{:plugin-id plugin-id
|
||||
:url (str plugin-url)
|
||||
:url plugin-url
|
||||
:name name
|
||||
:description desc
|
||||
:host origin
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
[app.plugins.parser :as parser]
|
||||
[app.plugins.register :as r]
|
||||
[app.plugins.ruler-guides :as rg]
|
||||
[app.plugins.state :refer [natural-child-ordering?]]
|
||||
[app.plugins.text :as text]
|
||||
[app.plugins.utils :as u]
|
||||
[app.util.http :as http]
|
||||
@@ -922,6 +921,7 @@
|
||||
(fn []
|
||||
(let [shape (u/locate-shape file-id page-id id)]
|
||||
(cond
|
||||
|
||||
(and (not (cfh/frame-shape? shape))
|
||||
(not (cfh/group-shape? shape))
|
||||
(not (cfh/svg-raw-shape? shape))
|
||||
@@ -929,14 +929,9 @@
|
||||
(u/display-not-valid :getChildren (:type shape))
|
||||
|
||||
:else
|
||||
(let [is-reversed? (ctl/flex-layout? shape)
|
||||
reverse-fn
|
||||
(if (and (natural-child-ordering? plugin-id) is-reversed?)
|
||||
reverse identity)]
|
||||
(->> (u/locate-shape file-id page-id id)
|
||||
(:shapes)
|
||||
(reverse-fn)
|
||||
(format/format-array #(shape-proxy plugin-id file-id page-id %)))))))
|
||||
(->> (u/locate-shape file-id page-id id)
|
||||
(:shapes)
|
||||
(format/format-array #(shape-proxy plugin-id file-id page-id %))))))
|
||||
|
||||
:appendChild
|
||||
(fn [child]
|
||||
@@ -955,10 +950,8 @@
|
||||
(u/display-not-valid :appendChild "Plugin doesn't have 'content:write' permission")
|
||||
|
||||
:else
|
||||
(let [child-id (obj/get child "$id")
|
||||
is-reversed? (ctl/flex-layout? shape)
|
||||
index (if (and (natural-child-ordering? plugin-id) is-reversed?) 0 (count (:shapes shape)))]
|
||||
(st/emit! (dwsh/relocate-shapes #{child-id} id index))))))
|
||||
(let [child-id (obj/get child "$id")]
|
||||
(st/emit! (dwsh/relocate-shapes #{child-id} id 0))))))
|
||||
|
||||
:insertChild
|
||||
(fn [index child]
|
||||
@@ -977,12 +970,7 @@
|
||||
(u/display-not-valid :insertChild "Plugin doesn't have 'content:write' permission")
|
||||
|
||||
:else
|
||||
(let [child-id (obj/get child "$id")
|
||||
is-reversed? (ctl/flex-layout? shape)
|
||||
index
|
||||
(if (and (natural-child-ordering? plugin-id) is-reversed?)
|
||||
(- (count (:shapes shape)) index)
|
||||
index)]
|
||||
(let [child-id (obj/get child "$id")]
|
||||
(st/emit! (dwsh/relocate-shapes #{child-id} id index))))))
|
||||
|
||||
;; Only for frames
|
||||
@@ -1372,8 +1360,7 @@
|
||||
(let [shape (u/proxy->shape self)
|
||||
file-id (obj/get self "$file")
|
||||
page-id (obj/get self "$page")
|
||||
reverse-fn (if (natural-child-ordering? plugin-id) reverse identity)
|
||||
ids (->> children reverse-fn (map #(obj/get % "$id")))]
|
||||
ids (->> children (map #(obj/get % "$id")))]
|
||||
|
||||
(cond
|
||||
(not= (set ids) (set (:shapes shape)))
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.plugins.state
|
||||
(:require
|
||||
[app.main.store :as st]))
|
||||
|
||||
(defn natural-child-ordering?
|
||||
[plugin-id]
|
||||
(boolean
|
||||
(get-in
|
||||
@st/state
|
||||
[:workspace-local :plugin-flags plugin-id :natural-child-ordering])))
|
||||
@@ -1,23 +0,0 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.plugins.system-events
|
||||
(:require
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.store :as st]))
|
||||
|
||||
;; Formats an event from the plugin system
|
||||
(defn event
|
||||
[plugin-id name & {:as props}]
|
||||
(let [plugin-data (get-in @st/state [:profile :props :plugins :data plugin-id])]
|
||||
(-> props
|
||||
(assoc ::ev/name name)
|
||||
(assoc ::ev/origin "plugin")
|
||||
(assoc ::ev/context
|
||||
{:plugin-name (:name plugin-data)
|
||||
:plugin-url (:url plugin-data)})
|
||||
(ev/event))))
|
||||
|
||||
@@ -106,20 +106,17 @@
|
||||
|
||||
(defn stop-propagation
|
||||
[^js event]
|
||||
(when (and (some? event)
|
||||
(fn? (.-stopPropagation event)))
|
||||
(when event
|
||||
(.stopPropagation event)))
|
||||
|
||||
(defn stop-immediate-propagation
|
||||
[^js event]
|
||||
(when (and (some? event)
|
||||
(fn? (.-stopImmediatePropagation event)))
|
||||
(when event
|
||||
(.stopImmediatePropagation event)))
|
||||
|
||||
(defn prevent-default
|
||||
[^js event]
|
||||
(when (and (some? event)
|
||||
(fn? (.-preventDefault event)))
|
||||
(when event
|
||||
(.preventDefault event)))
|
||||
|
||||
(defn get-target
|
||||
|
||||
@@ -7,16 +7,15 @@
|
||||
(ns app.util.keyboard
|
||||
(:require
|
||||
[app.config :as cfg]
|
||||
[app.util.dom :as dom]
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
(defrecord KeyboardEvent [type key shift ctrl alt meta mod editing native-event]
|
||||
Object
|
||||
(preventDefault [_]
|
||||
(dom/prevent-default native-event))
|
||||
(.preventDefault native-event))
|
||||
|
||||
(stopPropagation [_]
|
||||
(dom/stop-propagation native-event)))
|
||||
(.stopPropagation native-event)))
|
||||
|
||||
(defn keyboard-event?
|
||||
[o]
|
||||
|
||||
@@ -391,7 +391,7 @@
|
||||
(group-by :code)
|
||||
(clj->js))
|
||||
(catch :default cause
|
||||
(ex/print-throwable cause))))))
|
||||
(errors/print-error! cause))))))
|
||||
|
||||
(defn ^:export validate-schema
|
||||
[]
|
||||
@@ -399,7 +399,7 @@
|
||||
(let [file (dsh/lookup-file @st/state)]
|
||||
(cfv/validate-file-schema! file))
|
||||
(catch :default cause
|
||||
(ex/print-throwable cause))))
|
||||
(errors/print-error! cause))))
|
||||
|
||||
(defn ^:export repair
|
||||
[reload?]
|
||||
@@ -431,7 +431,7 @@
|
||||
(when reload?
|
||||
(dom/reload-current-window)))
|
||||
(fn [cause]
|
||||
(ex/print-throwable cause)))))))))
|
||||
(errors/print-error! cause)))))))))
|
||||
|
||||
(defn ^:export fix-orphan-shapes
|
||||
[]
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns frontend-tests.logic.update-position-test
|
||||
(:require
|
||||
[app.common.geom.rect :as grc]
|
||||
[app.common.test-helpers.compositions :as ctho]
|
||||
[app.common.test-helpers.files :as cthf]
|
||||
[app.common.test-helpers.shapes :as cths]
|
||||
[app.main.data.workspace :as dw]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[frontend-tests.helpers.state :as ths]))
|
||||
|
||||
(t/deftest test-update-positions-multiple-ids
|
||||
(t/async
|
||||
done
|
||||
(let [file (-> (cthf/sample-file :file1)
|
||||
(ctho/add-rect :rect1 :x 10 :y 20 :width 10 :height 10)
|
||||
(ctho/add-rect :rect2 :x 30 :y 40 :width 10 :height 10))
|
||||
store (ths/setup-store file)
|
||||
rect1 (cths/get-shape file :rect1)
|
||||
rect2 (cths/get-shape file :rect2)
|
||||
ids [(:id rect1) (:id rect2)]
|
||||
events [(dw/update-positions ids {:x 123.45})]]
|
||||
(ths/run-store
|
||||
store done events
|
||||
(fn [new-state]
|
||||
(let [file' (ths/get-file-from-state new-state)
|
||||
rect1' (cths/get-shape file' :rect1)
|
||||
rect2' (cths/get-shape file' :rect2)
|
||||
x1 (-> rect1' :points grc/points->rect :x)
|
||||
x2 (-> rect2' :points grc/points->rect :x)]
|
||||
(t/is (= 123.45 x1))
|
||||
(t/is (= 123.45 x2))))))))
|
||||
@@ -405,8 +405,12 @@ export class TextEditor extends EventTarget {
|
||||
|
||||
if (e.inputType in commands) {
|
||||
const command = commands[e.inputType];
|
||||
if (!this.#selectionController.startMutation()) {
|
||||
return;
|
||||
}
|
||||
command(e, this, this.#selectionController);
|
||||
this.#notifyLayout(LayoutType.FULL);
|
||||
const mutations = this.#selectionController.endMutation();
|
||||
this.#notifyLayout(LayoutType.FULL, mutations);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -452,12 +456,19 @@ export class TextEditor extends EventTarget {
|
||||
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "Backspace") {
|
||||
e.preventDefault();
|
||||
|
||||
if (!this.#selectionController.startMutation()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.#selectionController.isCollapsed) {
|
||||
this.#selectionController.removeWordBackward();
|
||||
} else {
|
||||
this.#selectionController.removeSelected();
|
||||
}
|
||||
this.#notifyLayout(LayoutType.FULL);
|
||||
|
||||
const mutations = this.#selectionController.endMutation();
|
||||
this.#notifyLayout(LayoutType.FULL, mutations);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -465,12 +476,14 @@ export class TextEditor extends EventTarget {
|
||||
* Notifies that the edited texts needs layout.
|
||||
*
|
||||
* @param {'full'|'partial'} type
|
||||
* @param {CommandMutations} mutations
|
||||
*/
|
||||
#notifyLayout(type = LayoutType.FULL) {
|
||||
#notifyLayout(type = LayoutType.FULL, mutations) {
|
||||
this.dispatchEvent(
|
||||
new CustomEvent("needslayout", {
|
||||
detail: {
|
||||
type: type,
|
||||
mutations: mutations,
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -617,8 +630,10 @@ export class TextEditor extends EventTarget {
|
||||
* @returns {TextEditor}
|
||||
*/
|
||||
applyStylesToSelection(styles) {
|
||||
this.#selectionController.startMutation();
|
||||
this.#selectionController.applyStyles(styles);
|
||||
this.#notifyLayout(LayoutType.FULL);
|
||||
const mutations = this.#selectionController.endMutation();
|
||||
this.#notifyLayout(LayoutType.FULL, mutations);
|
||||
this.#changeController.notifyImmediately();
|
||||
return this;
|
||||
}
|
||||
|
||||
66
frontend/text-editor/src/editor/commands/CommandMutations.js
Normal file
66
frontend/text-editor/src/editor/commands/CommandMutations.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright (c) KALEIDOS INC
|
||||
*/
|
||||
|
||||
/**
|
||||
* Command mutations
|
||||
*/
|
||||
export class CommandMutations {
|
||||
#added = new Set();
|
||||
#removed = new Set();
|
||||
#updated = new Set();
|
||||
|
||||
constructor(added, updated, removed) {
|
||||
if (added && Array.isArray(added)) this.#added = new Set(added);
|
||||
if (updated && Array.isArray(updated)) this.#updated = new Set(updated);
|
||||
if (removed && Array.isArray(removed)) this.#removed = new Set(removed);
|
||||
}
|
||||
|
||||
get added() {
|
||||
return this.#added;
|
||||
}
|
||||
|
||||
get removed() {
|
||||
return this.#removed;
|
||||
}
|
||||
|
||||
get updated() {
|
||||
return this.#updated;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.#added.clear();
|
||||
this.#removed.clear();
|
||||
this.#updated.clear();
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.#added.clear();
|
||||
this.#added = null;
|
||||
this.#removed.clear();
|
||||
this.#removed = null;
|
||||
this.#updated.clear();
|
||||
this.#updated = null;
|
||||
}
|
||||
|
||||
add(node) {
|
||||
this.#added.add(node);
|
||||
return this;
|
||||
}
|
||||
|
||||
remove(node) {
|
||||
this.#removed.add(node);
|
||||
return this;
|
||||
}
|
||||
|
||||
update(node) {
|
||||
this.#updated.add(node);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
export default CommandMutations;
|
||||
@@ -0,0 +1,71 @@
|
||||
import { describe, test, expect } from "vitest";
|
||||
import CommandMutations from "./CommandMutations.js";
|
||||
|
||||
describe("CommandMutations", () => {
|
||||
test("should create a new CommandMutations", () => {
|
||||
const mutations = new CommandMutations();
|
||||
expect(mutations).toHaveProperty("added");
|
||||
expect(mutations).toHaveProperty("updated");
|
||||
expect(mutations).toHaveProperty("removed");
|
||||
});
|
||||
|
||||
test("should create an initialized new CommandMutations", () => {
|
||||
const mutations = new CommandMutations([1], [2], [3]);
|
||||
expect(mutations.added.size).toBe(1);
|
||||
expect(mutations.updated.size).toBe(1);
|
||||
expect(mutations.removed.size).toBe(1);
|
||||
expect(mutations.added.has(1)).toBe(true);
|
||||
expect(mutations.updated.has(2)).toBe(true);
|
||||
expect(mutations.removed.has(3)).toBe(true);
|
||||
});
|
||||
|
||||
test("should add an added node to a CommandMutations", () => {
|
||||
const mutations = new CommandMutations();
|
||||
mutations.add(1);
|
||||
expect(mutations.added.has(1)).toBe(true);
|
||||
});
|
||||
|
||||
test("should add an updated node to a CommandMutations", () => {
|
||||
const mutations = new CommandMutations();
|
||||
mutations.update(1);
|
||||
expect(mutations.updated.has(1)).toBe(true);
|
||||
});
|
||||
|
||||
test("should add an removed node to a CommandMutations", () => {
|
||||
const mutations = new CommandMutations();
|
||||
mutations.remove(1);
|
||||
expect(mutations.removed.has(1)).toBe(true);
|
||||
});
|
||||
|
||||
test("should clear a CommandMutations", () => {
|
||||
const mutations = new CommandMutations();
|
||||
mutations.add(1);
|
||||
mutations.update(2);
|
||||
mutations.remove(3);
|
||||
expect(mutations.added.has(1)).toBe(true);
|
||||
expect(mutations.added.size).toBe(1);
|
||||
expect(mutations.updated.has(2)).toBe(true);
|
||||
expect(mutations.updated.size).toBe(1);
|
||||
expect(mutations.removed.has(3)).toBe(true);
|
||||
expect(mutations.removed.size).toBe(1);
|
||||
|
||||
mutations.clear();
|
||||
expect(mutations.added.size).toBe(0);
|
||||
expect(mutations.added.has(1)).toBe(false);
|
||||
expect(mutations.updated.size).toBe(0);
|
||||
expect(mutations.updated.has(1)).toBe(false);
|
||||
expect(mutations.removed.size).toBe(0);
|
||||
expect(mutations.removed.has(1)).toBe(false);
|
||||
});
|
||||
|
||||
test("should dispose a CommandMutations", () => {
|
||||
const mutations = new CommandMutations();
|
||||
mutations.add(1);
|
||||
mutations.update(2);
|
||||
mutations.remove(3);
|
||||
mutations.dispose();
|
||||
expect(mutations.added).toBe(null);
|
||||
expect(mutations.updated).toBe(null);
|
||||
expect(mutations.removed).toBe(null);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, test, expect } from "vitest";
|
||||
import { insertInto, removeSlice, removeBackward, removeForward, removeWordBackward, replaceWith, findPreviousWordBoundary } from "./Text";
|
||||
import { insertInto, removeBackward, removeForward, replaceWith } from "./Text";
|
||||
|
||||
describe("Text", () => {
|
||||
test("* should throw when passed wrong parameters", () => {
|
||||
@@ -51,23 +51,4 @@ describe("Text", () => {
|
||||
test("`removeForward` should remove string forward from offset 6", () => {
|
||||
expect(removeForward("Hello, World!", 6)).toBe("Hello,World!");
|
||||
});
|
||||
|
||||
test("`removeSlice` should remove a part of a text", () => {
|
||||
expect(removeSlice("Hello, World!", 7, 12)).toBe("Hello, !");
|
||||
});
|
||||
|
||||
test("`findPreviousWordBoundary` edge cases", () => {
|
||||
expect(findPreviousWordBoundary(null)).toBe(0);
|
||||
expect(findPreviousWordBoundary("Hello, World!", 0)).toBe(0);
|
||||
expect(findPreviousWordBoundary(" Hello, World!", 3)).toBe(0);
|
||||
})
|
||||
|
||||
test("`removeWordBackward` with no text should return an empty string", () => {
|
||||
expect(removeWordBackward(null, 0)).toBe("");
|
||||
});
|
||||
|
||||
test("`removeWordBackward` should remove a word backward", () => {
|
||||
expect(removeWordBackward("Hello, World!", 13)).toBe("Hello, World");
|
||||
expect(removeWordBackward("Hello, World", 12)).toBe("Hello, ");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, test, expect } from "vitest";
|
||||
import { getFills } from "./Color.js";
|
||||
|
||||
/* @vitest-environment jsdom */
|
||||
describe.skip("Color", () => {
|
||||
describe("Color", () => {
|
||||
test("getFills", () => {
|
||||
expect(getFills("#aa0000")).toBe(
|
||||
'[["^ ","~:fill-color","#aa0000","~:fill-opacity",1]]',
|
||||
|
||||
@@ -49,6 +49,7 @@ import {
|
||||
} from "../content/dom/TextNode.js";
|
||||
import TextNodeIterator from "../content/dom/TextNodeIterator.js";
|
||||
import TextEditor from "../TextEditor.js";
|
||||
import CommandMutations from "../commands/CommandMutations.js";
|
||||
import { isRoot, setRootStyles } from "../content/dom/Root.js";
|
||||
import { SelectionDirection } from "./SelectionDirection.js";
|
||||
import { SafeGuard } from "./SafeGuard.js";
|
||||
@@ -144,6 +145,13 @@ export class SelectionController extends EventTarget {
|
||||
*/
|
||||
#debug = null;
|
||||
|
||||
/**
|
||||
* Command Mutations.
|
||||
*
|
||||
* @type {CommandMutations}
|
||||
*/
|
||||
#mutations = new CommandMutations();
|
||||
|
||||
/**
|
||||
* Style defaults.
|
||||
*
|
||||
@@ -441,14 +449,14 @@ export class SelectionController extends EventTarget {
|
||||
dispose() {
|
||||
document.removeEventListener("selectionchange", this.#onSelectionChange);
|
||||
this.#textEditor = null;
|
||||
this.#currentStyle = null;
|
||||
this.#options = null;
|
||||
this.#ranges.clear();
|
||||
this.#ranges = null;
|
||||
this.#range = null;
|
||||
this.#selection = null;
|
||||
this.#focusNode = null;
|
||||
this.#anchorNode = null;
|
||||
this.#mutations.dispose();
|
||||
this.#mutations = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -514,6 +522,28 @@ export class SelectionController extends EventTarget {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the start of a mutation.
|
||||
*
|
||||
* Clears all the mutations kept in CommandMutations.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
startMutation() {
|
||||
this.#mutations.clear();
|
||||
if (!this.#focusNode) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the end of a mutation.
|
||||
*
|
||||
* @returns {CommandMutations}
|
||||
*/
|
||||
endMutation() {
|
||||
return this.#mutations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects all content.
|
||||
*
|
||||
@@ -567,18 +597,11 @@ export class SelectionController extends EventTarget {
|
||||
* @returns {SelectionController}
|
||||
*/
|
||||
cursorToEnd() {
|
||||
const root = this.#textEditor.root;
|
||||
|
||||
const range = document.createRange(); //Create a range (a range is a like the selection but invisible)
|
||||
range.setStart(root.lastChild.firstChild.firstChild, root.lastChild.firstChild.firstChild?.nodeValue?.length ?? 0);
|
||||
range.setEnd(root.lastChild.firstChild.firstChild, root.lastChild.firstChild.firstChild?.nodeValue?.length ?? 0);
|
||||
range.selectNodeContents(this.#textEditor.element);
|
||||
range.collapse(false);
|
||||
|
||||
this.#selection.removeAllRanges();
|
||||
this.#selection.addRange(range);
|
||||
|
||||
this.#updateState();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1317,6 +1340,7 @@ export class SelectionController extends EventTarget {
|
||||
|
||||
if (this.focusNode.nodeValue !== removedData) {
|
||||
this.focusNode.nodeValue = removedData;
|
||||
this.#mutations.update(this.focusTextSpan);
|
||||
}
|
||||
|
||||
const paragraph = this.focusParagraph;
|
||||
@@ -1359,6 +1383,7 @@ export class SelectionController extends EventTarget {
|
||||
this.focusOffset,
|
||||
newText,
|
||||
);
|
||||
this.#mutations.update(this.focusTextSpan);
|
||||
return this.collapse(this.focusNode, this.focusOffset + newText.length);
|
||||
}
|
||||
|
||||
@@ -1422,6 +1447,7 @@ export class SelectionController extends EventTarget {
|
||||
this.#textEditor.root.replaceChildren(newParagraph);
|
||||
return this.collapse(newTextNode, newText.length + 1);
|
||||
}
|
||||
this.#mutations.update(this.focusTextSpan);
|
||||
return this.collapse(this.focusNode, startOffset + newText.length);
|
||||
}
|
||||
|
||||
@@ -1499,6 +1525,8 @@ export class SelectionController extends EventTarget {
|
||||
const currentParagraph = this.focusParagraph;
|
||||
const newParagraph = createEmptyParagraph(this.#currentStyle);
|
||||
currentParagraph.after(newParagraph);
|
||||
this.#mutations.update(currentParagraph);
|
||||
this.#mutations.add(newParagraph);
|
||||
return this.collapse(newParagraph.firstChild.firstChild, 0);
|
||||
}
|
||||
|
||||
@@ -1509,6 +1537,8 @@ export class SelectionController extends EventTarget {
|
||||
const currentParagraph = this.focusParagraph;
|
||||
const newParagraph = createEmptyParagraph(this.#currentStyle);
|
||||
currentParagraph.before(newParagraph);
|
||||
this.#mutations.update(currentParagraph);
|
||||
this.#mutations.add(newParagraph);
|
||||
return this.collapse(currentParagraph.firstChild.firstChild, 0);
|
||||
}
|
||||
|
||||
@@ -1523,6 +1553,8 @@ export class SelectionController extends EventTarget {
|
||||
this.#focusOffset,
|
||||
);
|
||||
this.focusParagraph.after(newParagraph);
|
||||
this.#mutations.update(currentParagraph);
|
||||
this.#mutations.add(newParagraph);
|
||||
return this.collapse(newParagraph.firstChild.firstChild, 0);
|
||||
}
|
||||
|
||||
@@ -1554,6 +1586,10 @@ export class SelectionController extends EventTarget {
|
||||
this.focusOffset,
|
||||
);
|
||||
currentParagraph.after(newParagraph);
|
||||
|
||||
this.#mutations.update(currentParagraph);
|
||||
this.#mutations.add(newParagraph);
|
||||
|
||||
// FIXME: Missing collapse?
|
||||
}
|
||||
|
||||
@@ -1574,6 +1610,7 @@ export class SelectionController extends EventTarget {
|
||||
const previousOffset = isLineBreak(previousTextSpan.firstChild)
|
||||
? 0
|
||||
: previousTextSpan.firstChild.nodeValue?.length || 0;
|
||||
this.#mutations.remove(paragraphToBeRemoved);
|
||||
return this.collapse(previousTextSpan.firstChild, previousOffset);
|
||||
}
|
||||
|
||||
@@ -1595,6 +1632,8 @@ export class SelectionController extends EventTarget {
|
||||
} else {
|
||||
mergeParagraphs(previousParagraph, currentParagraph);
|
||||
}
|
||||
this.#mutations.remove(currentParagraph);
|
||||
this.#mutations.update(previousParagraph);
|
||||
return this.collapse(previousTextSpan.firstChild, previousOffset);
|
||||
}
|
||||
|
||||
@@ -1608,6 +1647,8 @@ export class SelectionController extends EventTarget {
|
||||
return;
|
||||
}
|
||||
mergeParagraphs(this.focusParagraph, nextParagraph);
|
||||
this.#mutations.update(currentParagraph);
|
||||
this.#mutations.remove(nextParagraph);
|
||||
|
||||
// FIXME: Missing collapse?
|
||||
}
|
||||
@@ -1624,6 +1665,7 @@ export class SelectionController extends EventTarget {
|
||||
paragraphToBeRemoved.remove();
|
||||
const nextTextSpan = nextParagraph.firstChild;
|
||||
const nextOffset = this.focusOffset;
|
||||
this.#mutations.remove(paragraphToBeRemoved);
|
||||
return this.collapse(nextTextSpan.firstChild, nextOffset);
|
||||
}
|
||||
|
||||
@@ -1638,6 +1680,7 @@ export class SelectionController extends EventTarget {
|
||||
for (const textSpan of affectedTextSpans) {
|
||||
if (textSpan.textContent === "") {
|
||||
textSpan.remove();
|
||||
this.#mutations.remove(textSpan);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1645,6 +1688,7 @@ export class SelectionController extends EventTarget {
|
||||
for (const paragraph of affectedParagraphs) {
|
||||
if (paragraph.children.length === 0) {
|
||||
paragraph.remove();
|
||||
this.#mutations.remove(paragraph);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,136 +581,6 @@ describe("SelectionController", () => {
|
||||
expect(textEditorMock.root.textContent).toBe("");
|
||||
});
|
||||
|
||||
test("`insertParagraph` should insert a new paragraph in an empty editor", () => {
|
||||
const textEditorMock = TextEditorMock.createTextEditorMockEmpty();
|
||||
const root = textEditorMock.root;
|
||||
const selection = document.getSelection();
|
||||
const selectionController = new SelectionController(textEditorMock, selection);
|
||||
focus(
|
||||
selection,
|
||||
textEditorMock,
|
||||
root.firstChild.firstChild.firstChild,
|
||||
0,
|
||||
);
|
||||
selectionController.insertParagraph();
|
||||
expect(textEditorMock.root).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.dataset.itype).toBe("root");
|
||||
expect(textEditorMock.root.children.length).toBe(2);
|
||||
expect(textEditorMock.root.children.item(0)).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.children.item(0).dataset.itype).toBe("paragraph");
|
||||
expect(textEditorMock.root.children.item(0).firstChild).toBeInstanceOf(
|
||||
HTMLSpanElement,
|
||||
);
|
||||
expect(textEditorMock.root.children.item(0).firstChild.dataset.itype).toBe("span");
|
||||
expect(textEditorMock.root.children.item(1)).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.children.item(1).dataset.itype).toBe("paragraph");
|
||||
expect(textEditorMock.root.children.item(1).firstChild).toBeInstanceOf(
|
||||
HTMLSpanElement,
|
||||
);
|
||||
expect(textEditorMock.root.children.item(1).firstChild.dataset.itype).toBe(
|
||||
"span",
|
||||
);
|
||||
expect(textEditorMock.root.textContent).toBe("");
|
||||
});
|
||||
|
||||
test("`insertParagraph` should insert a new paragraph after a text", () => {
|
||||
const textEditorMock = TextEditorMock.createTextEditorMockWith([
|
||||
["Hello, World!"]
|
||||
]);
|
||||
const root = textEditorMock.root;
|
||||
const selection = document.getSelection();
|
||||
const selectionController = new SelectionController(
|
||||
textEditorMock,
|
||||
selection,
|
||||
);
|
||||
focus(
|
||||
selection,
|
||||
textEditorMock,
|
||||
root.firstChild.firstChild.firstChild,
|
||||
"Hello, World!".length
|
||||
);
|
||||
selectionController.insertParagraph();
|
||||
expect(textEditorMock.root).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.dataset.itype).toBe("root");
|
||||
expect(textEditorMock.root.children.length).toBe(2);
|
||||
expect(textEditorMock.root.children.item(0)).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.children.item(0).dataset.itype).toBe(
|
||||
"paragraph",
|
||||
);
|
||||
expect(textEditorMock.root.children.item(0).firstChild).toBeInstanceOf(
|
||||
HTMLSpanElement,
|
||||
);
|
||||
expect(textEditorMock.root.children.item(0).firstChild.dataset.itype).toBe(
|
||||
"span",
|
||||
);
|
||||
expect(textEditorMock.root.children.item(0).firstChild.textContent).toBe(
|
||||
"Hello, World!",
|
||||
);
|
||||
expect(textEditorMock.root.children.item(1)).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.children.item(1).dataset.itype).toBe(
|
||||
"paragraph",
|
||||
);
|
||||
expect(textEditorMock.root.children.item(1).firstChild).toBeInstanceOf(
|
||||
HTMLSpanElement,
|
||||
);
|
||||
expect(textEditorMock.root.children.item(1).firstChild.dataset.itype).toBe(
|
||||
"span",
|
||||
);
|
||||
expect(textEditorMock.root.children.item(1).firstChild.firstChild).toBeInstanceOf(
|
||||
HTMLBRElement,
|
||||
);
|
||||
expect(textEditorMock.root.textContent).toBe("Hello, World!");
|
||||
});
|
||||
|
||||
test("`insertParagraph` should insert a new paragraph before a text", () => {
|
||||
const textEditorMock = TextEditorMock.createTextEditorMockWith([
|
||||
["Hello, World!"],
|
||||
]);
|
||||
const root = textEditorMock.root;
|
||||
const selection = document.getSelection();
|
||||
const selectionController = new SelectionController(
|
||||
textEditorMock,
|
||||
selection,
|
||||
);
|
||||
focus(
|
||||
selection,
|
||||
textEditorMock,
|
||||
root.firstChild.firstChild.firstChild,
|
||||
0,
|
||||
);
|
||||
selectionController.insertParagraph();
|
||||
expect(textEditorMock.root).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.dataset.itype).toBe("root");
|
||||
expect(textEditorMock.root.children.length).toBe(2);
|
||||
expect(textEditorMock.root.children.item(0)).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.children.item(0).dataset.itype).toBe(
|
||||
"paragraph",
|
||||
);
|
||||
expect(textEditorMock.root.children.item(0).firstChild).toBeInstanceOf(
|
||||
HTMLSpanElement,
|
||||
);
|
||||
expect(textEditorMock.root.children.item(0).firstChild.dataset.itype).toBe(
|
||||
"span",
|
||||
);
|
||||
expect(textEditorMock.root.children.item(0).firstChild.firstChild).toBeInstanceOf(
|
||||
HTMLBRElement,
|
||||
);
|
||||
expect(textEditorMock.root.children.item(1)).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.children.item(1).dataset.itype).toBe(
|
||||
"paragraph",
|
||||
);
|
||||
expect(textEditorMock.root.children.item(1).firstChild).toBeInstanceOf(
|
||||
HTMLSpanElement,
|
||||
);
|
||||
expect(textEditorMock.root.children.item(1).firstChild.dataset.itype).toBe(
|
||||
"span",
|
||||
);
|
||||
expect(textEditorMock.root.children.item(1).firstChild.textContent).toBe(
|
||||
"Hello, World!",
|
||||
);
|
||||
expect(textEditorMock.root.textContent).toBe("Hello, World!");
|
||||
});
|
||||
|
||||
test("`mergeBackwardParagraph` should merge two paragraphs in backward direction (backspace)", () => {
|
||||
const textEditorMock = TextEditorMock.createTextEditorMockWith([
|
||||
["Hello, "],
|
||||
@@ -1157,7 +1027,7 @@ describe("SelectionController", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("`removeSelected` multiple paragraphs", () => {
|
||||
test.skip("`removeSelected` multiple paragraphs", () => {
|
||||
const textEditorMock = TextEditorMock.createTextEditorMockWith([
|
||||
["Hello, "],
|
||||
["\n"],
|
||||
@@ -1522,10 +1392,7 @@ describe("SelectionController", () => {
|
||||
root.firstChild.lastChild.firstChild.nodeValue.length - 3,
|
||||
);
|
||||
selectionController.applyStyles({
|
||||
"font-family": "Montserrat, sans-serif",
|
||||
"font-weight": "bold",
|
||||
"--fills":
|
||||
'[["^ ","~:fill-color","#000000","~:fill-opacity",1],["^ ","~:fill-color","#aa0000","~:fill-opacity",1]]',
|
||||
});
|
||||
expect(textEditorMock.root).toBeInstanceOf(HTMLDivElement);
|
||||
expect(textEditorMock.root.children.length).toBe(1);
|
||||
@@ -1625,68 +1492,4 @@ describe("SelectionController", () => {
|
||||
"ld!",
|
||||
);
|
||||
});
|
||||
|
||||
test("`selectAll` should select everything", () => {
|
||||
const textEditorMock = TextEditorMock.createTextEditorMockWithParagraphs([
|
||||
createParagraphWith(["Hello, "], {
|
||||
"font-style": "italic",
|
||||
}),
|
||||
createParagraphWith(["World!"], {
|
||||
"font-style": "oblique",
|
||||
}),
|
||||
]);
|
||||
const root = textEditorMock.root;
|
||||
const selection = document.getSelection();
|
||||
const selectionController = new SelectionController(textEditorMock, selection);
|
||||
textEditorMock.element.focus();
|
||||
selectionController.selectAll();
|
||||
expect(selectionController.anchorNode).toBe(
|
||||
root.firstChild.firstChild.firstChild
|
||||
);
|
||||
expect(selectionController.focusNode).toBe(
|
||||
root.lastChild.firstChild.firstChild,
|
||||
);
|
||||
});
|
||||
|
||||
test("`cursorToEnd` should move cursor to the end", () => {
|
||||
const textEditorMock = TextEditorMock.createTextEditorMockWithParagraphs([
|
||||
createParagraphWith(["Hello, "], {
|
||||
"font-style": "italic",
|
||||
}),
|
||||
createParagraphWith(["World!"], {
|
||||
"font-style": "oblique",
|
||||
}),
|
||||
]);
|
||||
const root = textEditorMock.root;
|
||||
const selection = document.getSelection();
|
||||
const selectionController = new SelectionController(textEditorMock, selection);
|
||||
textEditorMock.element.focus();
|
||||
selectionController.cursorToEnd();
|
||||
expect(selectionController.focusNode).toBe(root.lastChild.firstChild.firstChild);
|
||||
expect(selectionController.focusAtEnd).toBeTruthy();
|
||||
})
|
||||
|
||||
test("`dispose` should release every held reference", () => {
|
||||
const textEditorMock = TextEditorMock.createTextEditorMockWithParagraphs([
|
||||
createParagraphWith(["Hello, "], {
|
||||
"font-style": "italic",
|
||||
}),
|
||||
createParagraphWith(["World!"], {
|
||||
"font-style": "oblique",
|
||||
}),
|
||||
]);
|
||||
const root = textEditorMock.root;
|
||||
const selection = document.getSelection();
|
||||
const selectionController = new SelectionController(textEditorMock, selection);
|
||||
focus(
|
||||
selection,
|
||||
textEditorMock,
|
||||
root.firstChild.firstChild.firstChild,
|
||||
0
|
||||
);
|
||||
selectionController.dispose();
|
||||
expect(selectionController.selection).toBe(null);
|
||||
expect(selectionController.currentStyle).toBe(null);
|
||||
expect(selectionController.options).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1467,7 +1467,7 @@ msgid "errors.generic"
|
||||
msgstr "Something wrong has happened."
|
||||
|
||||
msgid "errors.unexpected-exception"
|
||||
msgstr "Unexpected error: %s"
|
||||
msgstr "Unexpected exception: %s"
|
||||
|
||||
#: src/app/main/errors.cljs:200
|
||||
msgid "errors.internal-assertion-error"
|
||||
|
||||
42
manage.sh
42
manage.sh
@@ -7,7 +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.2-13
|
||||
export IMAGEMAGICK_VERSION=7.1.2-0
|
||||
|
||||
# Safe directory to avoid ownership errors with Git
|
||||
git config --global --add safe.directory /home/penpot/penpot || true
|
||||
@@ -215,23 +215,6 @@ function build-frontend-bundle {
|
||||
echo ">> bundle frontend end";
|
||||
}
|
||||
|
||||
function build-mcp-bundle {
|
||||
echo ">> bundle mcp start";
|
||||
|
||||
mkdir -p ./bundles
|
||||
local version=$(print-current-version);
|
||||
local bundle_dir="./bundles/mcp";
|
||||
|
||||
build "mcp";
|
||||
|
||||
rm -rf $bundle_dir;
|
||||
mv ./mcp/dist $bundle_dir;
|
||||
echo $version > $bundle_dir/version.txt;
|
||||
put-license-file $bundle_dir;
|
||||
echo ">> bundle mcp end";
|
||||
}
|
||||
|
||||
|
||||
function build-backend-bundle {
|
||||
echo ">> bundle backend start";
|
||||
|
||||
@@ -326,16 +309,6 @@ function build-exporter-docker-image {
|
||||
popd;
|
||||
}
|
||||
|
||||
function build-mcp-docker-image {
|
||||
rsync -avr --delete ./bundles/mcp/ ./docker/images/bundle-mcp/;
|
||||
pushd ./docker/images;
|
||||
docker build \
|
||||
-t penpotapp/mcp:$CURRENT_BRANCH -t penpotapp/mcp:latest \
|
||||
--build-arg BUNDLE_PATH="./bundle-mcp/" \
|
||||
-f Dockerfile.mcp .;
|
||||
popd;
|
||||
}
|
||||
|
||||
function build-storybook-docker-image {
|
||||
rsync -avr --delete ./bundles/storybook/ ./docker/images/bundle-storybook/;
|
||||
pushd ./docker/images;
|
||||
@@ -373,7 +346,6 @@ function usage {
|
||||
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 "- build-mcp-docker-image Build exporter docker images."
|
||||
echo "- build-storybook-docker-image Build storybook docker images."
|
||||
echo ""
|
||||
echo "- version Show penpot's version."
|
||||
@@ -425,7 +397,6 @@ case $1 in
|
||||
## production builds
|
||||
build-bundle)
|
||||
build-frontend-bundle;
|
||||
build-mcp-bundle;
|
||||
build-backend-bundle;
|
||||
build-exporter-bundle;
|
||||
build-storybook-bundle;
|
||||
@@ -435,10 +406,6 @@ case $1 in
|
||||
build-frontend-bundle;
|
||||
;;
|
||||
|
||||
build-mcp-bundle)
|
||||
build-mcp-bundle;
|
||||
;;
|
||||
|
||||
build-backend-bundle)
|
||||
build-backend-bundle;
|
||||
;;
|
||||
@@ -464,7 +431,6 @@ case $1 in
|
||||
build-frontend-docker-image
|
||||
build-backend-docker-image
|
||||
build-exporter-docker-image
|
||||
build-mcp-docker-image
|
||||
build-storybook-docker-image
|
||||
;;
|
||||
|
||||
@@ -479,11 +445,7 @@ case $1 in
|
||||
build-exporter-docker-image)
|
||||
build-exporter-docker-image
|
||||
;;
|
||||
|
||||
build-mcp-docker-image)
|
||||
build-mcp-docker-image
|
||||
;;
|
||||
|
||||
|
||||
build-storybook-docker-image)
|
||||
build-storybook-docker-image
|
||||
;;
|
||||
|
||||
11
mcp/.gitignore
vendored
11
mcp/.gitignore
vendored
@@ -1,11 +0,0 @@
|
||||
.idea
|
||||
node_modules
|
||||
dist
|
||||
*.bak
|
||||
*.orig
|
||||
temp
|
||||
*.tsbuildinfo
|
||||
|
||||
# Log files
|
||||
logs/
|
||||
*.log
|
||||
@@ -1,7 +0,0 @@
|
||||
*.md
|
||||
*.json
|
||||
python-scripts/
|
||||
.serena/
|
||||
|
||||
# auto-generated files
|
||||
mcp-server/data/api_types.yml
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"tabWidth": 4,
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.yml",
|
||||
"options": {
|
||||
"tabWidth": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"quoteProps": "as-needed",
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always",
|
||||
"printWidth": 120,
|
||||
"endOfLine": "auto"
|
||||
}
|
||||
1
mcp/.serena/.gitignore
vendored
1
mcp/.serena/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/cache
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user