0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 06:58:58 -05:00

🐛 Fix typography unlinking.

This commit is contained in:
Andrey Antukh 2021-04-14 08:32:06 +02:00
parent 14359d9acf
commit a8565dc2c2
4 changed files with 39 additions and 30 deletions

View file

@ -176,7 +176,6 @@
(defn update-text-attrs
[{:keys [id attrs]}]
(let [attrs (d/without-nils attrs)]
(ptk/reify ::update-text-attrs
ptk/UpdateEvent
(update [_ state]
@ -191,7 +190,7 @@
update-fn #(update-shape % txt/is-text-node? attrs/merge attrs)
shape-ids (cond (= (:type shape) :text) [id]
(= (:type shape) :group) (cp/get-children id objects))]
(rx/of (dwc/update-shapes shape-ids update-fn))))))))
(rx/of (dwc/update-shapes shape-ids update-fn)))))))
;; --- RESIZE UTILS

View file

@ -240,7 +240,8 @@
(when-not (empty? attrs)
(st/emit! (dwt/update-text-attrs {:id id :attrs attrs})))))
typography (cond
typography
(cond
(and (:typography-ref-id values)
(not= (:typography-ref-id values) :multiple)
(not= (:typography-ref-file values) file-id))

View file

@ -10,14 +10,15 @@
(ns app.util.text-editor
"Draft related abstraction functions."
(:require
["draft-js" :as draft]
["./text_editor_impl.js" :as impl]
["draft-js" :as draft]
[app.common.attrs :as attrs]
[app.common.text :as txt]
[app.common.data :as d]
[app.util.transit :as t]
[app.common.text :as txt]
[app.common.uuid :as uuid]
[app.util.array :as arr]
[app.util.object :as obj]
[app.util.transit :as t]
[clojure.walk :as walk]
[cuerdas.core :as str]))
@ -26,6 +27,7 @@
(defn encode-style-value
[v]
(cond
(uuid? v) (str "u:" v)
(string? v) (str "s:" v)
(number? v) (str "n:" v)
(keyword? v) (str "k:" (name v))
@ -41,6 +43,7 @@
"n:" (js/Number (subs v 2))
"k:" (keyword (subs v 2))
"m:" (t/decode (subs v 2))
"u:" (uuid/uuid (subs v 2))
"z:" nil
"o:" (subs v 2)
v)))

View file

@ -109,12 +109,18 @@ export function applyInlineStyle(state, styles) {
let content = null;
for (let style of styles) {
const [p, k, _] = style.split("$$$");
console.log("applyInlineStyle", style);
const [p, k, v] = style.split("$$$");
const prefix = [p, k, ""].join("$$$");
content = state.getCurrentContent();
content = removeInlineStylePrefix(content, selection, prefix);
if (v !== "z:null") {
content = Modifier.applyInlineStyle(content, selection, style);
}
state = EditorState.push(state, content, "change-inline-style");
}