@inshapardaz/likhari-react 0.1.18-dev.126 → 0.1.18-dev.130

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 +1 @@
1
- {"version":3,"file":"PoetryNode.d.ts","sourceRoot":"","sources":["../../src/blocks/PoetryNode.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAC1B,KAAK,MAAM,EACX,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,YAAY,CAAC;AACnD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAKjE,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,EAAE,qBAAqB,CAAC,CAAC;AAEpH;;;;;;;;;GASG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;gBAET,MAAM,GAAE,YAAuB,EAAE,KAAK,GAAE,WAAuB,EAAE,GAAG,CAAC,EAAE,OAAO;IAM1F,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe;IAIpD,SAAS,IAAI,YAAY;IAIzB,QAAQ,IAAI,WAAW;IAIvB;;gEAE4D;IAC5D,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAM9C,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAMlC,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,yBAAyB,GAAG,eAAe;IAI7E,UAAU,IAAI,yBAA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OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe;IAIpD,SAAS,IAAI,YAAY;IAIzB,QAAQ,IAAI,WAAW;IAIvB;;gEAE4D;IAC5D,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAM9C,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAMlC,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,yBAAyB,GAAG,eAAe;IAI7E,UAAU,IAAI,yBAAyB;IAIvC,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAa3C,SAAS,IAAI,eAAe;IAQ5B,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAY5C,SAAS,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO;IAYrF,UAAU,IAAI,KAAK;IAInB,YAAY,IAAI,OAAO;CAGxB;AAED,wBAAgB,sBAAsB,CAAC,MAAM,GAAE,YAAuB,EAAE,KAAK,GAAE,WAAuB,GAAG,eAAe,CAEvH;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,eAAe,CAEhG"}
@@ -2,6 +2,15 @@ import { addClassNamesToElement } from '@lexical/utils';
2
2
  import { $applyNodeReplacement, ElementNode, } from 'lexical';
3
3
  const VALID_LAYOUTS = new Set(['single', 'two-column']);
4
4
  const VALID_ALIGNS = new Set(['justify', 'left', 'right', 'start']);
5
+ /** `text-align: justify` only stretches a line that actually wraps — a
6
+ * misra short enough to fit on one line would otherwise just sit at its own
7
+ * start edge. `text-align-last: center` centers that single/last line while
8
+ * still justifying any line that does wrap, which is what "justified
9
+ * couplets, centered on the page" means in practice for most real verse. */
10
+ function applyAlignStyle(element, align) {
11
+ element.style.textAlign = align;
12
+ element.style.textAlignLast = align === 'justify' ? 'center' : '';
13
+ }
5
14
  /**
6
15
  * A couplet (two-line verse unit), the one extensible primitive requirements
7
16
  * doc §4.11 recommends in place of four fixed templates. `layout` picks
@@ -66,14 +75,14 @@ export class PoetryBlockNode extends ElementNode {
66
75
  const element = document.createElement('div');
67
76
  element.setAttribute('data-likhari-poetry-layout', this.getLayout());
68
77
  element.setAttribute('data-likhari-poetry-align', this.getAlign());
69
- element.style.textAlign = this.getAlign();
78
+ applyAlignStyle(element, this.getAlign());
70
79
  return { element };
71
80
  }
72
81
  createDOM(config) {
73
82
  const element = document.createElement('div');
74
83
  const base = config.theme.poetry ?? 'likhari-poetry';
75
84
  addClassNamesToElement(element, base, `${base}--${this.__layout}`);
76
- element.style.textAlign = this.__align;
85
+ applyAlignStyle(element, this.__align);
77
86
  return element;
78
87
  }
79
88
  // Only ever adds/removes the layout modifier class, never touches the
@@ -87,7 +96,7 @@ export class PoetryBlockNode extends ElementNode {
87
96
  dom.classList.add(`${base}--${this.__layout}`);
88
97
  }
89
98
  if (prevNode.__align !== this.__align) {
90
- dom.style.textAlign = this.__align;
99
+ applyAlignStyle(dom, this.__align);
91
100
  }
92
101
  return false;
93
102
  }
@@ -378,9 +378,20 @@
378
378
  Own type scale and spacing, distinct from body text — the .likhari-ltr/
379
379
  .likhari-rtl per-block classes (above) already switch font-family for this
380
380
  element same as any other block; these rules layer poetry's own size/
381
- line-height/gap on top, combined with those same classes. */
381
+ line-height/gap on top, combined with those same classes.
382
+ Capped width + auto margins read verse as a centered block on the page —
383
+ conventional poetry typesetting — rather than a full-width paragraph where
384
+ a short line just hugs the start edge regardless of its own text-align. */
382
385
  .likhari-poetry {
383
- margin: 0 0 1.4em 0;
386
+ box-sizing: border-box;
387
+ margin: 0 auto 1.4em auto;
388
+ max-width: 70%;
389
+ /* A visible boundary while editing, same affordance as a table's own
390
+ border — poetry couplets are a distinct structural block, not a plain
391
+ paragraph, and should read as one at a glance. */
392
+ border: 1px dashed var(--editor-line-strong);
393
+ border-radius: 6px;
394
+ padding: 10px 16px;
384
395
  }
385
396
 
386
397
  .likhari-poetry.likhari-ltr {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inshapardaz/likhari-react",
3
- "version": "0.1.18-dev.126",
3
+ "version": "0.1.18-dev.130",
4
4
  "description": "React implementation of the Likhari editor, built on @lexical/react.",
5
5
  "license": "MIT",
6
6
  "repository": {