@aeriz/wysiwyg 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/aeriz-wysiwyg.esm.js +24 -4
- package/dist/aeriz-wysiwyg.esm.min.js +273 -258
- package/dist/aeriz-wysiwyg.js +24 -4
- package/dist/aeriz-wysiwyg.min.js +11 -11
- package/dist-types/core/blocks.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/aeriz-wysiwyg.js
CHANGED
|
@@ -3861,12 +3861,32 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
3861
3861
|
function mergeInlineStyle(el, portable) {
|
|
3862
3862
|
const existing = (el.getAttribute("style") ?? "").trim();
|
|
3863
3863
|
if (!existing) {
|
|
3864
|
-
|
|
3864
|
+
const trimmed = portable.replace(/;\s*$/, "").trim();
|
|
3865
|
+
if (trimmed) el.setAttribute("style", trimmed);
|
|
3865
3866
|
return;
|
|
3866
3867
|
}
|
|
3867
|
-
const
|
|
3868
|
-
const
|
|
3869
|
-
|
|
3868
|
+
const userDecls = parseStyleDeclarations(existing);
|
|
3869
|
+
const userProps = new Set(userDecls.map((d) => d.prop));
|
|
3870
|
+
const portableDecls = parseStyleDeclarations(portable).filter(
|
|
3871
|
+
(d) => !userProps.has(d.prop)
|
|
3872
|
+
);
|
|
3873
|
+
const merged = [...portableDecls, ...userDecls].map((d) => `${d.prop}:${d.value}`).join(";");
|
|
3874
|
+
if (merged) el.setAttribute("style", merged);
|
|
3875
|
+
else el.removeAttribute("style");
|
|
3876
|
+
}
|
|
3877
|
+
function parseStyleDeclarations(s) {
|
|
3878
|
+
const out = [];
|
|
3879
|
+
for (const part of s.split(";")) {
|
|
3880
|
+
const trimmed = part.trim();
|
|
3881
|
+
if (!trimmed) continue;
|
|
3882
|
+
const idx = trimmed.indexOf(":");
|
|
3883
|
+
if (idx <= 0) continue;
|
|
3884
|
+
const prop = trimmed.slice(0, idx).trim().toLowerCase();
|
|
3885
|
+
const value = trimmed.slice(idx + 1).trim();
|
|
3886
|
+
if (!prop || !value) continue;
|
|
3887
|
+
out.push({ prop, value });
|
|
3888
|
+
}
|
|
3889
|
+
return out;
|
|
3870
3890
|
}
|
|
3871
3891
|
function stripEditorOnlyAttrs(root) {
|
|
3872
3892
|
for (const el of Array.from(root.querySelectorAll("[data-block-kind]"))) {
|