@inshapardaz/likhari-react 0.1.18-dev.148 → 0.1.18-dev.150
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.
|
@@ -39,13 +39,17 @@ export declare function $deletePoetryCouplet(): boolean;
|
|
|
39
39
|
*/
|
|
40
40
|
export declare function $deletePoetryOnBackspace(): boolean;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
42
|
+
* A couplet is always exactly two misras — Enter must never grow it past
|
|
43
|
+
* that. Pressed anywhere in the first misra, Enter moves the caret to the
|
|
44
|
+
* second (the line already exists; nothing is inserted). Pressed anywhere
|
|
45
|
+
* in the second (the last), Enter exits: ParagraphNode's own
|
|
46
|
+
* insertNewAfter would otherwise insert the new paragraph as a sibling of
|
|
47
|
+
* the misra — i.e. still inside the couplet, growing it to three lines
|
|
48
|
+
* and, on the next Enter, four, and so on — so that's handled here
|
|
49
|
+
* instead, reusing or creating a plain paragraph after the whole couplet.
|
|
50
|
+
* Intercepts Enter at *any* caret position inside the couplet (not just
|
|
51
|
+
* at an edge) specifically to prevent that growth; returns false only
|
|
52
|
+
* when the selection isn't inside a couplet at all.
|
|
49
53
|
*/
|
|
50
54
|
export declare function $exitPoetryOnEnter(): boolean;
|
|
51
55
|
//# sourceMappingURL=poetryActions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poetryActions.d.ts","sourceRoot":"","sources":["../../src/blocks/poetryActions.ts"],"names":[],"mappings":"AACA,OAAO,EAA4F,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvI,OAAO,EAA8C,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAErI;wCACwC;AACxC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,aAA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K9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,OAAO,CAoBlD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAyB5C"}
|
|
@@ -134,13 +134,17 @@ export function $deletePoetryOnBackspace() {
|
|
|
134
134
|
return true;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
137
|
+
* A couplet is always exactly two misras — Enter must never grow it past
|
|
138
|
+
* that. Pressed anywhere in the first misra, Enter moves the caret to the
|
|
139
|
+
* second (the line already exists; nothing is inserted). Pressed anywhere
|
|
140
|
+
* in the second (the last), Enter exits: ParagraphNode's own
|
|
141
|
+
* insertNewAfter would otherwise insert the new paragraph as a sibling of
|
|
142
|
+
* the misra — i.e. still inside the couplet, growing it to three lines
|
|
143
|
+
* and, on the next Enter, four, and so on — so that's handled here
|
|
144
|
+
* instead, reusing or creating a plain paragraph after the whole couplet.
|
|
145
|
+
* Intercepts Enter at *any* caret position inside the couplet (not just
|
|
146
|
+
* at an edge) specifically to prevent that growth; returns false only
|
|
147
|
+
* when the selection isn't inside a couplet at all.
|
|
144
148
|
*/
|
|
145
149
|
export function $exitPoetryOnEnter() {
|
|
146
150
|
const selection = $getSelection();
|
|
@@ -150,16 +154,16 @@ export function $exitPoetryOnEnter() {
|
|
|
150
154
|
if (!couplet)
|
|
151
155
|
return false;
|
|
152
156
|
const misras = $getMisraParagraphs(couplet);
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
//
|
|
162
|
-
//
|
|
157
|
+
const anchorNode = selection.anchor.getNode();
|
|
158
|
+
const misraIndex = misras.findIndex((m) => m.getKey() === anchorNode.getKey() || m.isParentOf(anchorNode));
|
|
159
|
+
if (misraIndex !== -1 && misraIndex < misras.length - 1) {
|
|
160
|
+
misras[misraIndex + 1].selectEnd();
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
// On the last misra (or misraIndex === -1, e.g. the caret landed on the
|
|
164
|
+
// couplet's shadow-root boundary itself) — exit. $ensureTrailingParagraph
|
|
165
|
+
// already guarantees a paragraph after every couplet; reuse it rather
|
|
166
|
+
// than stacking a new empty one on repeated Enters.
|
|
163
167
|
const existing = couplet.getNextSibling();
|
|
164
168
|
const paragraph = $isParagraphNode(existing) ? existing : $createParagraphNode();
|
|
165
169
|
if (paragraph !== existing)
|