@inshapardaz/likhari-react 0.1.18-dev.128 → 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;
|
|
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;AAejE,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,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
|
|
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
|
|
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
|
|
99
|
+
applyAlignStyle(dom, this.__align);
|
|
91
100
|
}
|
|
92
101
|
return false;
|
|
93
102
|
}
|
package/dist/theme/editor.css
CHANGED
|
@@ -383,8 +383,15 @@
|
|
|
383
383
|
conventional poetry typesetting — rather than a full-width paragraph where
|
|
384
384
|
a short line just hugs the start edge regardless of its own text-align. */
|
|
385
385
|
.likhari-poetry {
|
|
386
|
+
box-sizing: border-box;
|
|
386
387
|
margin: 0 auto 1.4em auto;
|
|
387
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;
|
|
388
395
|
}
|
|
389
396
|
|
|
390
397
|
.likhari-poetry.likhari-ltr {
|