文档核心功能

DOM 范围

使用 mountJuliyaScope 显式指定范围。排除代码块和控件,并保护内联代码。

挂载与清理

仅管理 include 选择器或 data-juliya 指定的元素。使用 refresh 重新读取样式,update 更新配置,移除容器时调用 destroy。

ts
import { mountJuliyaScope } from '@oddmash/juliya/dom';
const scope = mountJuliyaScope(root, { include: ['h1', 'p'], locale: 'zh-Hans' });
scope.destroy();

目标与排除

exclude 和 data-juliya-ignore 可排除元素。最近的范围拥有元素,表单、可编辑元素和代码块不会处理。如果计划的换行穿过内联代码,段落将使用浏览器的默认换行。

CSS 选项

--juliya-locale、--juliya-strategy 和 --juliya-break-long-words 优先于选择器规则,有效的 data-juliya-* 优先于 CSS。仅声明 CSS 不会启动引擎。

css
.article p {
  --juliya-strategy: balanced;
  --juliya-break-long-words: true;
}
@media (max-width: 480px) {
  .article p { --juliya-strategy: greedy; }
}