mirror of
https://github.com/penpot/penpot.git
synced 2026-02-12 14:42:56 +00:00
🐛 Fix text editor fills not being updated
This commit is contained in:
@@ -508,12 +508,12 @@
|
|||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ state _]
|
(effect [_ state _]
|
||||||
(when (features/active-feature? state "text-editor/v2")
|
(when (features/active-feature? state "text-editor/v2")
|
||||||
(let [instance (:workspace-editor state)
|
(when-let [instance (:workspace-editor state)]
|
||||||
styles (some-> (editor.v2/getCurrentStyle instance)
|
(let [styles (some-> (editor.v2/getCurrentStyle instance)
|
||||||
(styles/get-styles-from-style-declaration :removed-mixed true)
|
(styles/get-styles-from-style-declaration :removed-mixed true)
|
||||||
((comp update-node-fn migrate-node))
|
((comp update-node-fn migrate-node))
|
||||||
(styles/attrs->styles))]
|
(styles/attrs->styles))]
|
||||||
(editor.v2/applyStylesToSelection instance styles)))))))
|
(editor.v2/applyStylesToSelection instance styles))))))))
|
||||||
|
|
||||||
;; --- RESIZE UTILS
|
;; --- RESIZE UTILS
|
||||||
|
|
||||||
@@ -782,12 +782,12 @@
|
|||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ state _]
|
(effect [_ state _]
|
||||||
(when (features/active-feature? state "text-editor/v2")
|
(when (features/active-feature? state "text-editor/v2")
|
||||||
(let [instance (:workspace-editor state)
|
(when-let [instance (:workspace-editor state)]
|
||||||
attrs-to-override (some-> (editor.v2/getCurrentStyle instance)
|
(let [attrs-to-override (some-> (editor.v2/getCurrentStyle instance)
|
||||||
(styles/get-styles-from-style-declaration))
|
(styles/get-styles-from-style-declaration))
|
||||||
overriden-attrs (merge attrs-to-override attrs)
|
overriden-attrs (merge attrs-to-override attrs)
|
||||||
styles (styles/attrs->styles overriden-attrs)]
|
styles (styles/attrs->styles overriden-attrs)]
|
||||||
(editor.v2/applyStylesToSelection instance styles))))))
|
(editor.v2/applyStylesToSelection instance styles)))))))
|
||||||
|
|
||||||
(defn update-all-attrs
|
(defn update-all-attrs
|
||||||
[ids attrs]
|
[ids attrs]
|
||||||
|
|||||||
@@ -326,9 +326,7 @@ export class TextEditor extends EventTarget {
|
|||||||
* @param {FocusEvent} e
|
* @param {FocusEvent} e
|
||||||
*/
|
*/
|
||||||
#onBlur = (e) => {
|
#onBlur = (e) => {
|
||||||
if (!this.isEmpty) {
|
this.#changeController.notifyImmediately();
|
||||||
this.#changeController.notifyImmediately();
|
|
||||||
}
|
|
||||||
this.#selectionController.saveSelection();
|
this.#selectionController.saveSelection();
|
||||||
this.dispatchEvent(new FocusEvent(e.type, e));
|
this.dispatchEvent(new FocusEvent(e.type, e));
|
||||||
};
|
};
|
||||||
@@ -685,7 +683,7 @@ export function createRootFromString(string) {
|
|||||||
* Returns true if the passed object is a TextEditor
|
* Returns true if the passed object is a TextEditor
|
||||||
* instance.
|
* instance.
|
||||||
*
|
*
|
||||||
* @param {TextEditor} instance
|
* @param {*} instance
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function isTextEditor(instance) {
|
export function isTextEditor(instance) {
|
||||||
@@ -702,8 +700,7 @@ export function isEmpty(instance) {
|
|||||||
if (isTextEditor(instance)) {
|
if (isTextEditor(instance)) {
|
||||||
return instance.isEmpty;
|
return instance.isEmpty;
|
||||||
}
|
}
|
||||||
return null;
|
throw new TypeError('Instance is not a TextEditor');
|
||||||
// throw new TypeError('Instance is not a TextEditor');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -718,7 +715,6 @@ export function getRoot(instance) {
|
|||||||
return instance.root;
|
return instance.root;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
// throw new TypeError("Instance is not a TextEditor");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -731,10 +727,9 @@ export function getRoot(instance) {
|
|||||||
export function setRoot(instance, root) {
|
export function setRoot(instance, root) {
|
||||||
if (isTextEditor(instance)) {
|
if (isTextEditor(instance)) {
|
||||||
instance.root = root;
|
instance.root = root;
|
||||||
// return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
return instance;
|
throw new TypeError("Instance is not a TextEditor");
|
||||||
// throw new TypeError("Instance is not a TextEditor");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -759,8 +754,7 @@ export function getCurrentStyle(instance) {
|
|||||||
if (isTextEditor(instance)) {
|
if (isTextEditor(instance)) {
|
||||||
return instance.currentStyle;
|
return instance.currentStyle;
|
||||||
}
|
}
|
||||||
// throw new TypeError("Instance is not a TextEditor");
|
throw new TypeError('Instance is not a TextEditor');
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -775,8 +769,7 @@ export function applyStylesToSelection(instance, styles) {
|
|||||||
if (isTextEditor(instance)) {
|
if (isTextEditor(instance)) {
|
||||||
return instance.applyStylesToSelection(styles);
|
return instance.applyStylesToSelection(styles);
|
||||||
}
|
}
|
||||||
// throw new TypeError("Instance is not a TextEditor");
|
throw new TypeError('Instance is not a TextEditor');
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -790,8 +783,7 @@ export function dispose(instance) {
|
|||||||
if (isTextEditor(instance)) {
|
if (isTextEditor(instance)) {
|
||||||
return instance.dispose();
|
return instance.dispose();
|
||||||
}
|
}
|
||||||
// throw new TypeError("Instance is not a TextEditor");
|
throw new TypeError('Instance is not a TextEditor');
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TextEditor;
|
export default TextEditor;
|
||||||
|
|||||||
@@ -1969,11 +1969,9 @@ export class SelectionController extends EventTarget {
|
|||||||
setTextSpanStyles(textSpan, newStyles);
|
setTextSpanStyles(textSpan, newStyles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.#notifyStyleChange();
|
// If the startContainer and endContainer are different
|
||||||
|
// then we need to iterate through those nodes to apply
|
||||||
// If the startContainer and endContainer are different
|
// the styles.
|
||||||
// then we need to iterate through those nodes to apply
|
|
||||||
// the styles.
|
|
||||||
} else if (startNode !== endNode) {
|
} else if (startNode !== endNode) {
|
||||||
const safeGuard = new SafeGuard("applyStylesTo");
|
const safeGuard = new SafeGuard("applyStylesTo");
|
||||||
safeGuard.start();
|
safeGuard.start();
|
||||||
@@ -2022,12 +2020,12 @@ export class SelectionController extends EventTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We've reached the final node so we can return safely.
|
// We've reached the final node so we can return safely.
|
||||||
if (this.#textNodeIterator.currentNode === expectedEndNode) return;
|
if (this.#textNodeIterator.currentNode === expectedEndNode)
|
||||||
|
break;
|
||||||
|
|
||||||
this.#textNodeIterator.nextNode();
|
this.#textNodeIterator.nextNode();
|
||||||
} while (this.#textNodeIterator.currentNode);
|
} while (this.#textNodeIterator.currentNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.#notifyStyleChange();
|
return this.#notifyStyleChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user