palt-typesetting 0.4.0 → 0.5.1

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.
@@ -1,6 +1,6 @@
1
1
  @font-face {
2
2
  /*
3
- * カスタムフォント: 1/10000 UPM 幅のスペースとノンブレーキングスペースを定義。
3
+ * カスタムフォント: 1/10000 UPM 幅の Space と No-Break Space を定義。
4
4
  * 注意:完全なゼロ幅スペースを使用すると、Safari では letter-spacing が無視される。
5
5
  * @sharapeco による貢献に感謝します。{@link https://gist.github.com/sharapeco/1dd7f4433dad07648e1325e1fa5926ee}
6
6
  */
@@ -9,6 +9,14 @@
9
9
  format('woff2');
10
10
  }
11
11
 
12
+ /*
13
+ * Safari のリーダーモード対応
14
+ * See: {@link https://github.com/yamatoiizuka/palt-typesetting/issues/96}
15
+ */
16
+ .typeset wbr {
17
+ visibility: hidden;
18
+ }
19
+
12
20
  .typeset-word-break {
13
21
  word-break: keep-all;
14
22
  overflow-wrap: anywhere;
@@ -16,12 +24,17 @@
16
24
 
17
25
  .typeset-thin-space,
18
26
  .typeset-kerning {
19
- font-family: ling-one; /* カスタムフォントのスペースを使用します。 */
20
- line-height: 0; /* 空白による行の高さの影響を無視します。 */
21
27
  letter-spacing: 0; /* 親要素から継承される letter-spacing の影響を無視します。 */
22
28
  user-select: none; /* ユーザーによるテキストのコピーを無効にします。 */
23
29
  }
24
30
 
31
+ .typeset-thin-space[data-content]::after,
32
+ .typeset-kerning[data-content]::after {
33
+ content: attr(data-content); /* Space または No-Break Space */
34
+ font-family: ling-one; /* カスタムフォントのスペースを使用します。 */
35
+ line-height: 0; /* 空白による行の高さの影響を無視します。 */
36
+ }
37
+
25
38
  .typeset-no-breaks {
26
39
  letter-spacing: 0; /* 親要素から継承される letter-spacing の影響を無視します。 */
27
40
  }
@@ -1,6 +1,6 @@
1
1
  import './style/typesetting.css';
2
2
  declare const createWbr: () => string;
3
- declare const createThinSpace: (thisSpaceWidth: string, breakable?: boolean) => string;
3
+ declare const createThinSpace: (thinSpaceWidth: string, breakable?: boolean) => string;
4
4
  declare const createKerning: (kerningValue: number, breakable?: boolean) => string;
5
5
  declare const applyWrapperStyle: (text: string, useWordBreak: boolean) => string;
6
6
  declare const applyLatinStyle: (segment: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"util-tags.d.ts","sourceRoot":"","sources":["../src/util-tags.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA;AAMhC,QAAA,MAAM,SAAS,QAAO,MAErB,CAAA;AAQD,QAAA,MAAM,eAAe,mBAAoB,MAAM,cAAc,OAAO,KAAG,MAMtE,CAAA;AASD,QAAA,MAAM,aAAa,iBAAkB,MAAM,cAAc,OAAO,KAAG,MAiBlE,CAAA;AAQD,QAAA,MAAM,iBAAiB,SAAU,MAAM,gBAAgB,OAAO,KAAG,MAKhE,CAAA;AAOD,QAAA,MAAM,eAAe,YAAa,MAAM,KAAG,MAG1C,CAAA;AAOD,QAAA,MAAM,kBAAkB,YAAa,MAAM,KAAG,MAG7C,CAAA;AAuBD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAA"}
1
+ {"version":3,"file":"util-tags.d.ts","sourceRoot":"","sources":["../src/util-tags.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA;AAQhC,QAAA,MAAM,SAAS,QAAO,MAErB,CAAA;AAQD,QAAA,MAAM,eAAe,mBAAoB,MAAM,cAAc,OAAO,KAAG,MAItE,CAAA;AASD,QAAA,MAAM,aAAa,iBAAkB,MAAM,cAAc,OAAO,KAAG,MAclE,CAAA;AAQD,QAAA,MAAM,iBAAiB,SAAU,MAAM,gBAAgB,OAAO,KAAG,MAKhE,CAAA;AAOD,QAAA,MAAM,eAAe,YAAa,MAAM,KAAG,MAG1C,CAAA;AAOD,QAAA,MAAM,kBAAkB,YAAa,MAAM,KAAG,MAG7C,CAAA;AAkCD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAA"}
package/dist/util-tags.js CHANGED
@@ -1,49 +1,49 @@
1
1
  import "./style/typesetting.css";
2
+ const prefix = "typeset";
2
3
  const createWbr = () => {
3
4
  return "<wbr>";
4
5
  };
5
- const createThinSpace = (thisSpaceWidth, breakable) => {
6
- const content = breakable ? " " : "&nbsp;";
7
- const className = "typeset-thin-space";
8
- const style = `letter-spacing: ${thisSpaceWidth};`;
9
- const uiIgnored = true;
10
- return createStyledSpan(content, className, style, uiIgnored);
6
+ const createThinSpace = (thinSpaceWidth, breakable) => {
7
+ const content = "";
8
+ const className = `${prefix}-thin-space`;
9
+ return createSpacer(content, className, thinSpaceWidth, breakable);
11
10
  };
12
11
  const createKerning = (kerningValue, breakable) => {
13
12
  if (kerningValue === 0)
14
13
  return "";
15
- const className = "typeset-kerning";
16
- const uiIgnored = true;
14
+ const content = "";
15
+ const className = `${prefix}-kerning`;
17
16
  if (kerningValue < 0) {
18
- const content = "";
19
17
  const emValue = kerningValue / 1e3 / 2 + "em";
20
18
  const style = `margin: ${emValue};`;
21
- return createStyledSpan(content, className, style, uiIgnored);
19
+ return createStyledSpan(content, className, style);
22
20
  } else {
23
- const content = breakable ? " " : "&nbsp;";
24
21
  const emValue = kerningValue / 1e3 + "em";
25
- const style = `letter-spacing: ${emValue};`;
26
- return createStyledSpan(content, className, style, uiIgnored);
22
+ return createSpacer(content, className, emValue, breakable);
27
23
  }
28
24
  };
29
25
  const applyWrapperStyle = (text, useWordBreak) => {
30
- const wrapperName = "typeset";
31
- const wordBreakName = "typeset-word-break";
26
+ const wrapperName = prefix;
27
+ const wordBreakName = `${prefix}-word-break`;
32
28
  const className = useWordBreak ? `${wrapperName} ${wordBreakName}` : wrapperName;
33
29
  return createStyledSpan(text, className);
34
30
  };
35
31
  const applyLatinStyle = (segment) => {
36
- const className = "typeset-latin";
32
+ const className = `${prefix}-latin`;
37
33
  return createStyledSpan(segment, className);
38
34
  };
39
35
  const applyNoBreaksStyle = (segment) => {
40
- const className = "typeset-no-breaks";
36
+ const className = `${prefix}-no-breaks`;
41
37
  return createStyledSpan(segment, className);
42
38
  };
43
- const createStyledSpan = (content, className, style = "", uiIgnored = false) => {
39
+ const createStyledSpan = (content, className, style = "", attr = "") => {
44
40
  const styleAttr = style ? ` style="${style}"` : "";
45
- const extraAttrs = uiIgnored ? ' aria-hidden="true" data-nosnippet=""' : "";
46
- return `<span class="${className}"${styleAttr}${extraAttrs}>${content}</span>`;
41
+ return `<span class="${className}"${styleAttr}${attr}>${content}</span>`;
42
+ };
43
+ const createSpacer = (content, className, value, breakable) => {
44
+ const style = `letter-spacing: ${value};`;
45
+ const data = ` data-content="${breakable ? " " : "&nbsp;"}"`;
46
+ return createStyledSpan(content, className, style, data);
47
47
  };
48
48
  export {
49
49
  applyLatinStyle,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "palt-typesetting",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "A typesetting library.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",