feat(rules): 建立共享排版契约并收束 WebKit 与 Unicode 基线
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
// order=10:standalone 群之首(於 charify 群後執行;charify 之 jz-* 包裹皆行內
|
||||
// 元素,不改變「文本之最近塊祖先」,故時點無影響)。
|
||||
|
||||
import { revertOwnedAttributes, setOwnedAttribute } from "../core/dom.js";
|
||||
import type { RenderContext, StandalonePass } from "../types.js";
|
||||
|
||||
const ATTR = "data-jz-block-level";
|
||||
@@ -65,13 +66,11 @@ export const levelMarkPass: StandalonePass = {
|
||||
const block = p ? nearestBlock(p) : null;
|
||||
if (!block) { return; }
|
||||
const level = finder.levelFor(block);
|
||||
if (block.getAttribute(ATTR) !== level) { block.setAttribute(ATTR, level); }
|
||||
setOwnedAttribute(block, ATTR, level, ctx.ownerToken);
|
||||
});
|
||||
},
|
||||
revert(ctx: RenderContext): void
|
||||
{
|
||||
if (ctx.root.hasAttribute(ATTR)) { ctx.root.removeAttribute(ATTR); }
|
||||
ctx.root.querySelectorAll("[" + ATTR + "]")
|
||||
.forEach((el) => el.removeAttribute(ATTR));
|
||||
revertOwnedAttributes(ctx.root, ATTR, ctx.ownerToken);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user