@inshapardaz/likhari-react 0.1.18-dev.158 → 0.1.18-dev.165
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.
- package/dist/blocks/PoetryNode.d.ts +24 -13
- package/dist/blocks/PoetryNode.d.ts.map +1 -1
- package/dist/blocks/PoetryNode.js +64 -43
- package/dist/blocks/poetryActions.d.ts +35 -12
- package/dist/blocks/poetryActions.d.ts.map +1 -1
- package/dist/blocks/poetryActions.js +175 -43
- package/dist/components/FindReplaceBar.d.ts +8 -0
- package/dist/components/FindReplaceBar.d.ts.map +1 -0
- package/dist/components/FindReplaceBar.js +57 -0
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/components/Toolbar.js +25 -23
- package/dist/find/findReplaceActions.d.ts +23 -0
- package/dist/find/findReplaceActions.d.ts.map +1 -0
- package/dist/find/findReplaceActions.js +81 -0
- package/dist/i18n/strings.d.ts +21 -0
- package/dist/i18n/strings.d.ts.map +1 -1
- package/dist/i18n/strings.js +63 -0
- package/dist/plugins/PoetryPlugin.d.ts +1 -2
- package/dist/plugins/PoetryPlugin.d.ts.map +1 -1
- package/dist/plugins/PoetryPlugin.js +9 -3
- package/dist/theme/editor.css +93 -2
- package/package.json +1 -1
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, type LexicalNode, type NodeKey, type SerializedElementNode, type Spread, ElementNode } from 'lexical';
|
|
2
|
-
export type PoetryLayout = 'single' | 'two-column';
|
|
3
|
-
export type PoetryAlign = 'justify' | 'left' | 'right' | 'start';
|
|
2
|
+
export type PoetryLayout = 'single' | 'two-column' | 'staggered';
|
|
4
3
|
/** Vertical space between couplets — an ordered scale the menu steps through. */
|
|
5
4
|
export declare const POETRY_SPACINGS: readonly ["compact", "normal", "relaxed", "loose"];
|
|
6
5
|
export type PoetrySpacing = (typeof POETRY_SPACINGS)[number];
|
|
7
6
|
export declare const DEFAULT_POETRY_SPACING: PoetrySpacing;
|
|
7
|
+
/** Horizontal space either side of the divider in two-column layout. */
|
|
8
|
+
export declare const POETRY_GUTTERS: readonly ["compact", "normal", "relaxed", "loose"];
|
|
9
|
+
export type PoetryGutter = (typeof POETRY_GUTTERS)[number];
|
|
10
|
+
export declare const DEFAULT_POETRY_GUTTER: PoetryGutter;
|
|
11
|
+
/** Width of each couplet box in staggered layout, as a share of the block. */
|
|
12
|
+
export declare const POETRY_STAGGERS: readonly ["compact", "normal", "relaxed", "loose"];
|
|
13
|
+
export type PoetryStagger = (typeof POETRY_STAGGERS)[number];
|
|
14
|
+
export declare const DEFAULT_POETRY_STAGGER: PoetryStagger;
|
|
8
15
|
export type SerializedPoetryBlockNode = Spread<{
|
|
9
16
|
layout: PoetryLayout;
|
|
10
|
-
align: PoetryAlign;
|
|
11
17
|
width?: number;
|
|
12
18
|
spacing?: PoetrySpacing;
|
|
19
|
+
gutter?: PoetryGutter;
|
|
20
|
+
stagger?: PoetryStagger;
|
|
13
21
|
}, SerializedElementNode>;
|
|
14
22
|
/**
|
|
15
23
|
* A poetry *section*: one or more couplets (two-line verse units) sharing
|
|
@@ -18,24 +26,24 @@ export type SerializedPoetryBlockNode = Spread<{
|
|
|
18
26
|
* couplet its own LayoutContainerNode row (built on the columns primitive,
|
|
19
27
|
* §4.9) — see blocks/poetryActions.ts's $getCouplets for how either shape
|
|
20
28
|
* is read, and $setPoetryLayout/$exitPoetryOnEnter for how children are
|
|
21
|
-
* restructured/grown between couplets and layouts. `layout`
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
29
|
+
* restructured/grown between couplets and layouts. `layout` applies to the
|
|
30
|
+
* whole section, not per couplet, and mutates in place via poetryActions so
|
|
31
|
+
* converting a section between layouts doesn't lose selection/undo
|
|
32
|
+
* coherence. One extensible primitive in place of four fixed templates,
|
|
33
|
+
* per requirements doc §4.11.
|
|
26
34
|
*/
|
|
27
35
|
export declare class PoetryBlockNode extends ElementNode {
|
|
28
36
|
__layout: PoetryLayout;
|
|
29
|
-
__align: PoetryAlign;
|
|
30
37
|
/** User-chosen width in px (drag-resized), overriding editor.css's default
|
|
31
38
|
* max-width: 70%. Undefined until the user resizes it. */
|
|
32
39
|
__width?: number;
|
|
33
40
|
__spacing: PoetrySpacing;
|
|
34
|
-
|
|
41
|
+
__gutter: PoetryGutter;
|
|
42
|
+
__stagger: PoetryStagger;
|
|
43
|
+
constructor(layout?: PoetryLayout, width?: number, spacing?: PoetrySpacing, gutter?: PoetryGutter, stagger?: PoetryStagger, key?: NodeKey);
|
|
35
44
|
static getType(): string;
|
|
36
45
|
static clone(node: PoetryBlockNode): PoetryBlockNode;
|
|
37
46
|
getLayout(): PoetryLayout;
|
|
38
|
-
getAlign(): PoetryAlign;
|
|
39
47
|
getWidth(): number | undefined;
|
|
40
48
|
setWidth(width: number | undefined): this;
|
|
41
49
|
/** Attribute-only — restructuring children for a layout change is
|
|
@@ -44,7 +52,10 @@ export declare class PoetryBlockNode extends ElementNode {
|
|
|
44
52
|
setLayoutAttribute(layout: PoetryLayout): this;
|
|
45
53
|
getSpacing(): PoetrySpacing;
|
|
46
54
|
setSpacing(spacing: PoetrySpacing): this;
|
|
47
|
-
|
|
55
|
+
getGutter(): PoetryGutter;
|
|
56
|
+
setGutter(gutter: PoetryGutter): this;
|
|
57
|
+
getStagger(): PoetryStagger;
|
|
58
|
+
setStagger(stagger: PoetryStagger): this;
|
|
48
59
|
static importJSON(serializedNode: SerializedPoetryBlockNode): PoetryBlockNode;
|
|
49
60
|
exportJSON(): SerializedPoetryBlockNode;
|
|
50
61
|
static importDOM(): DOMConversionMap | null;
|
|
@@ -54,6 +65,6 @@ export declare class PoetryBlockNode extends ElementNode {
|
|
|
54
65
|
canBeEmpty(): false;
|
|
55
66
|
isShadowRoot(): boolean;
|
|
56
67
|
}
|
|
57
|
-
export declare function $createPoetryBlockNode(layout?: PoetryLayout,
|
|
68
|
+
export declare function $createPoetryBlockNode(layout?: PoetryLayout, width?: number, spacing?: PoetrySpacing, gutter?: PoetryGutter, stagger?: PoetryStagger): PoetryBlockNode;
|
|
58
69
|
export declare function $isPoetryBlockNode(node: LexicalNode | null | undefined): node is PoetryBlockNode;
|
|
59
70
|
//# sourceMappingURL=PoetryNode.d.ts.map
|
|
@@ -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;
|
|
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,GAAG,WAAW,CAAC;AACjE,iFAAiF;AACjF,eAAO,MAAM,eAAe,oDAAqD,CAAC;AAClF,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7D,eAAO,MAAM,sBAAsB,EAAE,aAAwB,CAAC;AAC9D,wEAAwE;AACxE,eAAO,MAAM,cAAc,oDAAqD,CAAC;AACjF,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3D,eAAO,MAAM,qBAAqB,EAAE,YAAuB,CAAC;AAC5D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AS,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAMrC,UAAU,IAAI,aAAa;IAI3B,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAMxC,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,yBAAyB,GAAG,eAAe;IAI7E,UAAU,IAAI,yBAAyB;IAcvC,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAmB3C,SAAS,IAAI,eAAe;IAa5B,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAa5C,SAAS,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO;IAwBrF,UAAU,IAAI,KAAK;IAInB,YAAY,IAAI,OAAO;CAGxB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,GAAE,YAAuB,EAC/B,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,GAAE,aAAsC,EAC/C,MAAM,GAAE,YAAoC,EAC5C,OAAO,GAAE,aAAsC,GAC9C,eAAe,CAEjB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,eAAe,CAEhG"}
|
|
@@ -3,18 +3,22 @@ import { $applyNodeReplacement, ElementNode, } from 'lexical';
|
|
|
3
3
|
/** Vertical space between couplets — an ordered scale the menu steps through. */
|
|
4
4
|
export const POETRY_SPACINGS = ['compact', 'normal', 'relaxed', 'loose'];
|
|
5
5
|
export const DEFAULT_POETRY_SPACING = 'normal';
|
|
6
|
-
|
|
7
|
-
const
|
|
6
|
+
/** Horizontal space either side of the divider in two-column layout. */
|
|
7
|
+
export const POETRY_GUTTERS = ['compact', 'normal', 'relaxed', 'loose'];
|
|
8
|
+
export const DEFAULT_POETRY_GUTTER = 'normal';
|
|
9
|
+
/** Width of each couplet box in staggered layout, as a share of the block. */
|
|
10
|
+
export const POETRY_STAGGERS = ['compact', 'normal', 'relaxed', 'loose'];
|
|
11
|
+
export const DEFAULT_POETRY_STAGGER = 'normal';
|
|
12
|
+
const VALID_LAYOUTS = new Set(['single', 'two-column', 'staggered']);
|
|
8
13
|
const VALID_SPACINGS = new Set(POETRY_SPACINGS);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
element.style.
|
|
17
|
-
element.style.textAlignLast = align === 'justify' ? 'justify' : '';
|
|
14
|
+
const VALID_GUTTERS = new Set(POETRY_GUTTERS);
|
|
15
|
+
const VALID_STAGGERS = new Set(POETRY_STAGGERS);
|
|
16
|
+
/** Poetry is always justified: `text-align-last: justify` stretches a
|
|
17
|
+
* one-line misra across the full column width too, not just wrapped lines,
|
|
18
|
+
* so every line reads edge-to-edge. */
|
|
19
|
+
function applyJustifyStyle(element) {
|
|
20
|
+
element.style.textAlign = 'justify';
|
|
21
|
+
element.style.textAlignLast = 'justify';
|
|
18
22
|
}
|
|
19
23
|
/** A user-dragged width overrides editor.css's default max-width: 70% —
|
|
20
24
|
* clearing the inline style (rather than setting it to that same 70%)
|
|
@@ -32,32 +36,30 @@ function applyWidthStyle(element, width) {
|
|
|
32
36
|
* couplet its own LayoutContainerNode row (built on the columns primitive,
|
|
33
37
|
* §4.9) — see blocks/poetryActions.ts's $getCouplets for how either shape
|
|
34
38
|
* is read, and $setPoetryLayout/$exitPoetryOnEnter for how children are
|
|
35
|
-
* restructured/grown between couplets and layouts. `layout`
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
39
|
+
* restructured/grown between couplets and layouts. `layout` applies to the
|
|
40
|
+
* whole section, not per couplet, and mutates in place via poetryActions so
|
|
41
|
+
* converting a section between layouts doesn't lose selection/undo
|
|
42
|
+
* coherence. One extensible primitive in place of four fixed templates,
|
|
43
|
+
* per requirements doc §4.11.
|
|
40
44
|
*/
|
|
41
45
|
export class PoetryBlockNode extends ElementNode {
|
|
42
|
-
constructor(layout = 'single',
|
|
46
|
+
constructor(layout = 'single', width, spacing = DEFAULT_POETRY_SPACING, gutter = DEFAULT_POETRY_GUTTER, stagger = DEFAULT_POETRY_STAGGER, key) {
|
|
43
47
|
super(key);
|
|
44
48
|
this.__layout = layout;
|
|
45
|
-
this.__align = align;
|
|
46
49
|
this.__width = width;
|
|
47
50
|
this.__spacing = spacing;
|
|
51
|
+
this.__gutter = gutter;
|
|
52
|
+
this.__stagger = stagger;
|
|
48
53
|
}
|
|
49
54
|
static getType() {
|
|
50
55
|
return 'poetry-couplet';
|
|
51
56
|
}
|
|
52
57
|
static clone(node) {
|
|
53
|
-
return new PoetryBlockNode(node.__layout, node.
|
|
58
|
+
return new PoetryBlockNode(node.__layout, node.__width, node.__spacing, node.__gutter, node.__stagger, node.__key);
|
|
54
59
|
}
|
|
55
60
|
getLayout() {
|
|
56
61
|
return this.getLatest().__layout;
|
|
57
62
|
}
|
|
58
|
-
getAlign() {
|
|
59
|
-
return this.getLatest().__align;
|
|
60
|
-
}
|
|
61
63
|
getWidth() {
|
|
62
64
|
return this.getLatest().__width;
|
|
63
65
|
}
|
|
@@ -82,13 +84,24 @@ export class PoetryBlockNode extends ElementNode {
|
|
|
82
84
|
writable.__spacing = spacing;
|
|
83
85
|
return writable;
|
|
84
86
|
}
|
|
85
|
-
|
|
87
|
+
getGutter() {
|
|
88
|
+
return this.getLatest().__gutter;
|
|
89
|
+
}
|
|
90
|
+
setGutter(gutter) {
|
|
91
|
+
const writable = this.getWritable();
|
|
92
|
+
writable.__gutter = gutter;
|
|
93
|
+
return writable;
|
|
94
|
+
}
|
|
95
|
+
getStagger() {
|
|
96
|
+
return this.getLatest().__stagger;
|
|
97
|
+
}
|
|
98
|
+
setStagger(stagger) {
|
|
86
99
|
const writable = this.getWritable();
|
|
87
|
-
writable.
|
|
100
|
+
writable.__stagger = stagger;
|
|
88
101
|
return writable;
|
|
89
102
|
}
|
|
90
103
|
static importJSON(serializedNode) {
|
|
91
|
-
return $createPoetryBlockNode(serializedNode.layout, serializedNode.
|
|
104
|
+
return $createPoetryBlockNode(serializedNode.layout, serializedNode.width, serializedNode.spacing, serializedNode.gutter, serializedNode.stagger);
|
|
92
105
|
}
|
|
93
106
|
exportJSON() {
|
|
94
107
|
const width = this.getWidth();
|
|
@@ -97,8 +110,9 @@ export class PoetryBlockNode extends ElementNode {
|
|
|
97
110
|
type: 'poetry-couplet',
|
|
98
111
|
version: 1,
|
|
99
112
|
layout: this.getLayout(),
|
|
100
|
-
align: this.getAlign(),
|
|
101
113
|
spacing: this.getSpacing(),
|
|
114
|
+
gutter: this.getGutter(),
|
|
115
|
+
stagger: this.getStagger(),
|
|
102
116
|
...(width !== undefined ? { width } : {}),
|
|
103
117
|
};
|
|
104
118
|
}
|
|
@@ -109,53 +123,60 @@ export class PoetryBlockNode extends ElementNode {
|
|
|
109
123
|
if (!rawLayout)
|
|
110
124
|
return null;
|
|
111
125
|
const layout = VALID_LAYOUTS.has(rawLayout) ? rawLayout : 'single';
|
|
112
|
-
const rawAlign = domNode.getAttribute('data-likhari-poetry-align') ?? 'justify';
|
|
113
|
-
const align = VALID_ALIGNS.has(rawAlign) ? rawAlign : 'justify';
|
|
114
126
|
const rawWidth = Number(domNode.getAttribute('data-likhari-poetry-width'));
|
|
115
127
|
const width = Number.isFinite(rawWidth) && rawWidth > 0 ? rawWidth : undefined;
|
|
116
128
|
const rawSpacing = domNode.getAttribute('data-likhari-poetry-spacing');
|
|
117
129
|
const spacing = VALID_SPACINGS.has(rawSpacing) ? rawSpacing : DEFAULT_POETRY_SPACING;
|
|
118
|
-
|
|
130
|
+
const rawGutter = domNode.getAttribute('data-likhari-poetry-gutter');
|
|
131
|
+
const gutter = VALID_GUTTERS.has(rawGutter) ? rawGutter : DEFAULT_POETRY_GUTTER;
|
|
132
|
+
const rawStagger = domNode.getAttribute('data-likhari-poetry-stagger');
|
|
133
|
+
const stagger = VALID_STAGGERS.has(rawStagger) ? rawStagger : DEFAULT_POETRY_STAGGER;
|
|
134
|
+
return { conversion: () => ({ node: $createPoetryBlockNode(layout, width, spacing, gutter, stagger) }), priority: 2 };
|
|
119
135
|
},
|
|
120
136
|
};
|
|
121
137
|
}
|
|
122
138
|
exportDOM() {
|
|
123
139
|
const element = document.createElement('div');
|
|
124
140
|
element.setAttribute('data-likhari-poetry-layout', this.getLayout());
|
|
125
|
-
element.setAttribute('data-likhari-poetry-align', this.getAlign());
|
|
126
141
|
element.setAttribute('data-likhari-poetry-spacing', this.getSpacing());
|
|
142
|
+
element.setAttribute('data-likhari-poetry-gutter', this.getGutter());
|
|
143
|
+
element.setAttribute('data-likhari-poetry-stagger', this.getStagger());
|
|
127
144
|
const width = this.getWidth();
|
|
128
145
|
if (width !== undefined)
|
|
129
146
|
element.setAttribute('data-likhari-poetry-width', String(width));
|
|
130
|
-
|
|
147
|
+
applyJustifyStyle(element);
|
|
131
148
|
applyWidthStyle(element, width);
|
|
132
149
|
return { element };
|
|
133
150
|
}
|
|
134
151
|
createDOM(config) {
|
|
135
152
|
const element = document.createElement('div');
|
|
136
153
|
const base = config.theme.poetry ?? 'likhari-poetry';
|
|
137
|
-
addClassNamesToElement(element, base, `${base}--${this.__layout}`, `${base}--spacing-${this.__spacing}`);
|
|
138
|
-
|
|
154
|
+
addClassNamesToElement(element, base, `${base}--${this.__layout}`, `${base}--spacing-${this.__spacing}`, `${base}--gutter-${this.__gutter}`, `${base}--stagger-${this.__stagger}`);
|
|
155
|
+
applyJustifyStyle(element);
|
|
139
156
|
applyWidthStyle(element, this.__width);
|
|
140
157
|
return element;
|
|
141
158
|
}
|
|
142
|
-
// Only ever adds/removes
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
159
|
+
// Only ever adds/removes modifier classes, never touches the element's full
|
|
160
|
+
// className — the reconciler separately classList.adds the per-block ltr/rtl
|
|
161
|
+
// theme class (editor.css) onto this same element, and a wholesale className
|
|
162
|
+
// reassignment here would silently wipe it out.
|
|
146
163
|
updateDOM(prevNode, dom, config) {
|
|
164
|
+
const base = config.theme.poetry ?? 'likhari-poetry';
|
|
147
165
|
if (prevNode.__layout !== this.__layout) {
|
|
148
|
-
const base = config.theme.poetry ?? 'likhari-poetry';
|
|
149
166
|
dom.classList.remove(`${base}--${prevNode.__layout}`);
|
|
150
167
|
dom.classList.add(`${base}--${this.__layout}`);
|
|
151
168
|
}
|
|
152
169
|
if (prevNode.__spacing !== this.__spacing) {
|
|
153
|
-
const base = config.theme.poetry ?? 'likhari-poetry';
|
|
154
170
|
dom.classList.remove(`${base}--spacing-${prevNode.__spacing}`);
|
|
155
171
|
dom.classList.add(`${base}--spacing-${this.__spacing}`);
|
|
156
172
|
}
|
|
157
|
-
if (prevNode.
|
|
158
|
-
|
|
173
|
+
if (prevNode.__gutter !== this.__gutter) {
|
|
174
|
+
dom.classList.remove(`${base}--gutter-${prevNode.__gutter}`);
|
|
175
|
+
dom.classList.add(`${base}--gutter-${this.__gutter}`);
|
|
176
|
+
}
|
|
177
|
+
if (prevNode.__stagger !== this.__stagger) {
|
|
178
|
+
dom.classList.remove(`${base}--stagger-${prevNode.__stagger}`);
|
|
179
|
+
dom.classList.add(`${base}--stagger-${this.__stagger}`);
|
|
159
180
|
}
|
|
160
181
|
if (prevNode.__width !== this.__width) {
|
|
161
182
|
applyWidthStyle(dom, this.__width);
|
|
@@ -169,8 +190,8 @@ export class PoetryBlockNode extends ElementNode {
|
|
|
169
190
|
return true;
|
|
170
191
|
}
|
|
171
192
|
}
|
|
172
|
-
export function $createPoetryBlockNode(layout = 'single',
|
|
173
|
-
return $applyNodeReplacement(new PoetryBlockNode(layout,
|
|
193
|
+
export function $createPoetryBlockNode(layout = 'single', width, spacing = DEFAULT_POETRY_SPACING, gutter = DEFAULT_POETRY_GUTTER, stagger = DEFAULT_POETRY_STAGGER) {
|
|
194
|
+
return $applyNodeReplacement(new PoetryBlockNode(layout, width, spacing, gutter, stagger));
|
|
174
195
|
}
|
|
175
196
|
export function $isPoetryBlockNode(node) {
|
|
176
197
|
return node instanceof PoetryBlockNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ParagraphNode } from 'lexical';
|
|
2
|
-
import { type
|
|
2
|
+
import { type PoetryBlockNode, type PoetryLayout } from './PoetryNode.js';
|
|
3
3
|
/** One couplet's two misra paragraphs, in order. */
|
|
4
4
|
export type Couplet = [ParagraphNode, ParagraphNode];
|
|
5
5
|
/**
|
|
@@ -49,10 +49,10 @@ export declare function $ensureTrailingParagraph(node: PoetryBlockNode): void;
|
|
|
49
49
|
* semantics, in its existing layout: "one poetry block can contain one or
|
|
50
50
|
* more couplets, in one or two column layout", so a block's layout is
|
|
51
51
|
* fixed once it has couplets, not chosen per couplet) and focuses its first
|
|
52
|
-
* misra. Otherwise creates a new block (in `layout
|
|
52
|
+
* misra. Otherwise creates a new block (in `layout`) with one
|
|
53
53
|
* couplet, after the selection's top-level element.
|
|
54
54
|
*/
|
|
55
|
-
export declare function $insertPoetryCouplet(layout: PoetryLayout
|
|
55
|
+
export declare function $insertPoetryCouplet(layout: PoetryLayout): boolean;
|
|
56
56
|
/** Removes the couplet the selection is inside. If it's the block's only
|
|
57
57
|
* couplet, removes the whole block (an empty poetry section serves no
|
|
58
58
|
* purpose) — the explicit, always-available counterpart to
|
|
@@ -60,17 +60,21 @@ export declare function $insertPoetryCouplet(layout: PoetryLayout, align: Poetry
|
|
|
60
60
|
* menu's own "Delete table" action). */
|
|
61
61
|
export declare function $deletePoetryCouplet(): boolean;
|
|
62
62
|
/**
|
|
63
|
-
* Backspace at the
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* other caret position, including a non-empty couplet, so normal Backspace
|
|
71
|
-
* handling (e.g. deleting within text) proceeds.
|
|
63
|
+
* Backspace at the start of a misra never merges it into its neighbour: the
|
|
64
|
+
* block's lines are paired into couplets, so merging one line away would
|
|
65
|
+
* shift every couplet after it (and take the previous couplet's last line
|
|
66
|
+
* with it). Instead, Backspace at the start of an empty couplet removes that
|
|
67
|
+
* couplet, and at the start of any other line it moves the caret to the end
|
|
68
|
+
* of the previous line. Other caret positions (deleting within text) fall
|
|
69
|
+
* through to normal handling.
|
|
72
70
|
*/
|
|
73
71
|
export declare function $deletePoetryOnBackspace(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Forward Delete at the end of a misra never merges the next line into it, for
|
|
74
|
+
* the same reason as $deletePoetryOnBackspace: the caret moves to the start of
|
|
75
|
+
* the next line instead. Other caret positions fall through to normal handling.
|
|
76
|
+
*/
|
|
77
|
+
export declare function $deletePoetryForward(): boolean;
|
|
74
78
|
/**
|
|
75
79
|
* Enter inside a poetry block never grows a couplet past its fixed two
|
|
76
80
|
* misras. The block's *last* couplet being completely empty is always the
|
|
@@ -91,4 +95,23 @@ export declare function $exitPoetryOnEnter(): boolean;
|
|
|
91
95
|
/** Steps the caret's poetry block one notch looser (+1) or tighter (-1) on
|
|
92
96
|
* the couplet-spacing scale; clamps at either end. */
|
|
93
97
|
export declare function $adjustPoetrySpacing(step: 1 | -1): boolean;
|
|
98
|
+
/** Steps the caret's two-column gutter one notch wider (+1) or narrower (-1);
|
|
99
|
+
* clamps at either end. */
|
|
100
|
+
export declare function $adjustPoetryGutter(step: 1 | -1): boolean;
|
|
101
|
+
/** Steps the caret's staggered couplet width one notch narrower (-1) or wider
|
|
102
|
+
* (+1); clamps at either end. */
|
|
103
|
+
export declare function $adjustPoetryStagger(step: 1 | -1): boolean;
|
|
104
|
+
/** Whether the couplet the caret is in is centered, or null outside a
|
|
105
|
+
* two-column poetry block (centering only applies there). */
|
|
106
|
+
export declare function $getCoupletCenteredFromSelection(): boolean | null;
|
|
107
|
+
/** Centers (or un-centers) the caret's couplet within a two-column block by
|
|
108
|
+
* rebuilding its row around the same two misra paragraphs. */
|
|
109
|
+
export declare function $setCoupletCentered(centered: boolean): boolean;
|
|
110
|
+
/** Removes the whole poetry block the caret is in, including every couplet. */
|
|
111
|
+
export declare function $deletePoetryBlock(): boolean;
|
|
112
|
+
/** Single-column blocks pair their paragraphs into couplets, so a line left
|
|
113
|
+
* without a partner (from pasted or imported content) would be invisible to
|
|
114
|
+
* the couplet logic. Give it an empty partner instead, so every line belongs
|
|
115
|
+
* to a couplet and can be deleted like any other. */
|
|
116
|
+
export declare function $completeSingleCoupletBlock(node: PoetryBlockNode): void;
|
|
94
117
|
//# sourceMappingURL=poetryActions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poetryActions.d.ts","sourceRoot":"","sources":["../../src/blocks/poetryActions.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"poetryActions.d.ts","sourceRoot":"","sources":["../../src/blocks/poetryActions.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAEtB,oDAAoD;AACpD,MAAM,MAAM,OAAO,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAErD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,EAAE,CAqB7D;AAED;;6CAE6C;AAC7C,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,aAAa,EAAE,CAE1E;AAED,oEAAoE;AACpE,wBAAgB,4BAA4B,IAAI,eAAe,GAAG,IAAI,CAKrE;AA0DD;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAevF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAmBlF;AAED;;;;;;qDAMqD;AACrD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,eAAe,GA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