@inshapardaz/likhari-react 0.1.18-dev.156 → 0.1.18-dev.158
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/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -2
- package/dist/plugins/PoetryPlugin.d.ts.map +1 -1
- package/dist/plugins/PoetryPlugin.js +2 -3
- package/dist/theme/editorTheme.d.ts.map +1 -1
- package/dist/theme/editorTheme.js +0 -1
- package/package.json +1 -1
- package/dist/blocks/PoetryCoupletNode.d.ts +0 -36
- package/dist/blocks/PoetryCoupletNode.d.ts.map +0 -1
- package/dist/blocks/PoetryCoupletNode.js +0 -85
package/dist/nodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAalD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,EAkB5C,CAAC"}
|
package/dist/nodes.js
CHANGED
|
@@ -9,7 +9,6 @@ import { LayoutContainerNode, LayoutItemNode } from './blocks/LayoutNode.js';
|
|
|
9
9
|
import { FootnoteReferenceNode } from './blocks/FootnoteNode.js';
|
|
10
10
|
import { FootnoteItemNode, FootnoteListNode } from './blocks/FootnoteListNode.js';
|
|
11
11
|
import { PoetryBlockNode } from './blocks/PoetryNode.js';
|
|
12
|
-
import { PoetryCoupletNode } from './blocks/PoetryCoupletNode.js';
|
|
13
12
|
/**
|
|
14
13
|
* Node types registered on the editor at construction time. Per
|
|
15
14
|
* editor-architecture-design.md §2, node registration cannot be conditional
|
|
@@ -37,5 +36,4 @@ export const EDITOR_NODES = [
|
|
|
37
36
|
FootnoteListNode,
|
|
38
37
|
FootnoteItemNode,
|
|
39
38
|
PoetryBlockNode,
|
|
40
|
-
PoetryCoupletNode,
|
|
41
39
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoetryPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/PoetryPlugin.tsx"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"PoetryPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/PoetryPlugin.tsx"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG5F,eAAO,MAAM,6BAA6B,EAAE,cAAc,CAAC;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAEtG,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,SA4C3B"}
|
|
@@ -3,7 +3,6 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
|
|
|
3
3
|
import { COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, KEY_BACKSPACE_COMMAND, KEY_ENTER_COMMAND, createCommand, } from 'lexical';
|
|
4
4
|
import { mergeRegister } from '@lexical/utils';
|
|
5
5
|
import { LayoutContainerNode, LayoutItemNode } from '../blocks/LayoutNode.js';
|
|
6
|
-
import { PoetryCoupletNode } from '../blocks/PoetryCoupletNode.js';
|
|
7
6
|
import { PoetryBlockNode } from '../blocks/PoetryNode.js';
|
|
8
7
|
import { $deletePoetryOnBackspace, $ensureTrailingParagraph, $exitPoetryOnEnter, $insertPoetryCouplet } from '../blocks/poetryActions.js';
|
|
9
8
|
export const INSERT_POETRY_COUPLET_COMMAND = createCommand('INSERT_POETRY_COUPLET_COMMAND');
|
|
@@ -22,8 +21,8 @@ export const INSERT_POETRY_COUPLET_COMMAND = createCommand('INSERT_POETRY_COUPLE
|
|
|
22
21
|
export function PoetryPlugin() {
|
|
23
22
|
const [editor] = useLexicalComposerContext();
|
|
24
23
|
useEffect(() => {
|
|
25
|
-
if (!editor.hasNodes([PoetryBlockNode,
|
|
26
|
-
throw new Error('PoetryPlugin: PoetryBlockNode
|
|
24
|
+
if (!editor.hasNodes([PoetryBlockNode, LayoutContainerNode, LayoutItemNode])) {
|
|
25
|
+
throw new Error('PoetryPlugin: PoetryBlockNode (and the columns nodes it composes) not registered on the editor');
|
|
27
26
|
}
|
|
28
27
|
return mergeRegister(editor.registerCommand(INSERT_POETRY_COUPLET_COMMAND, ({ layout, align }) => $insertPoetryCouplet(layout, align), COMMAND_PRIORITY_EDITOR), editor.registerNodeTransform(PoetryBlockNode, (node) => {
|
|
29
28
|
if (node.getChildrenSize() === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editorTheme.d.ts","sourceRoot":"","sources":["../../src/theme/editorTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"editorTheme.d.ts","sourceRoot":"","sources":["../../src/theme/editorTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,kBAgDzB,CAAC"}
|
|
@@ -46,7 +46,6 @@ export const editorTheme = {
|
|
|
46
46
|
footnoteList: 'likhari-footnote-list',
|
|
47
47
|
footnoteItem: 'likhari-footnote-item',
|
|
48
48
|
poetry: 'likhari-poetry',
|
|
49
|
-
poetryCouplet: 'likhari-poetry-couplet',
|
|
50
49
|
table: 'likhari-table',
|
|
51
50
|
tableRow: 'likhari-table-row',
|
|
52
51
|
tableCell: 'likhari-table-cell',
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, type LexicalNode, type NodeKey, type SerializedElementNode, type Spread, ElementNode } from 'lexical';
|
|
2
|
-
export type SerializedPoetryCoupletNode = Spread<{
|
|
3
|
-
centered: boolean;
|
|
4
|
-
}, SerializedElementNode>;
|
|
5
|
-
/**
|
|
6
|
-
* One couplet's two misra lines, wrapped so each couplet can carry its own
|
|
7
|
-
* rendering override independent of its PoetryBlockNode's overall layout —
|
|
8
|
-
* currently just `centered` (a narrower box, centered on the page, instead
|
|
9
|
-
* of the block's default width): "two columns with a couplet that is
|
|
10
|
-
* single, aligned centered" mixes LayoutContainerNode rows (two-column
|
|
11
|
-
* couplets) with centered PoetryCoupletNodes in the same block, each
|
|
12
|
-
* couplet choosing independently.
|
|
13
|
-
*
|
|
14
|
-
* Used for single-column and alternating block layouts; a two-column
|
|
15
|
-
* couplet uses LayoutContainerNode instead (its own two-item row already
|
|
16
|
-
* gives it a natural per-couplet box, so it doesn't need this wrapper).
|
|
17
|
-
*/
|
|
18
|
-
export declare class PoetryCoupletNode extends ElementNode {
|
|
19
|
-
__centered: boolean;
|
|
20
|
-
constructor(centered?: boolean, key?: NodeKey);
|
|
21
|
-
static getType(): string;
|
|
22
|
-
static clone(node: PoetryCoupletNode): PoetryCoupletNode;
|
|
23
|
-
getCentered(): boolean;
|
|
24
|
-
setCentered(centered: boolean): this;
|
|
25
|
-
static importJSON(serializedNode: SerializedPoetryCoupletNode): PoetryCoupletNode;
|
|
26
|
-
exportJSON(): SerializedPoetryCoupletNode;
|
|
27
|
-
static importDOM(): DOMConversionMap | null;
|
|
28
|
-
exportDOM(): DOMExportOutput;
|
|
29
|
-
createDOM(config: EditorConfig): HTMLElement;
|
|
30
|
-
updateDOM(prevNode: PoetryCoupletNode, dom: HTMLElement, config: EditorConfig): boolean;
|
|
31
|
-
canBeEmpty(): false;
|
|
32
|
-
canIndent(): false;
|
|
33
|
-
}
|
|
34
|
-
export declare function $createPoetryCoupletNode(centered?: boolean): PoetryCoupletNode;
|
|
35
|
-
export declare function $isPoetryCoupletNode(node: LexicalNode | null | undefined): node is PoetryCoupletNode;
|
|
36
|
-
//# sourceMappingURL=PoetryCoupletNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PoetryCoupletNode.d.ts","sourceRoot":"","sources":["../../src/blocks/PoetryCoupletNode.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,2BAA2B,GAAG,MAAM,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,EAAE,qBAAqB,CAAC,CAAC;AAE/F;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,UAAU,EAAE,OAAO,CAAC;gBAER,QAAQ,UAAQ,EAAE,GAAG,CAAC,EAAE,OAAO;IAK3C,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,iBAAiB,GAAG,iBAAiB;IAIxD,WAAW,IAAI,OAAO;IAItB,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAMpC,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,2BAA2B,GAAG,iBAAiB;IAIjF,UAAU,IAAI,2BAA2B;IAIzC,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAU3C,SAAS,IAAI,eAAe;IAO5B,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAQ5C,SAAS,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO;IAQvF,UAAU,IAAI,KAAK;IAInB,SAAS,IAAI,KAAK;CAGnB;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,UAAQ,GAAG,iBAAiB,CAE5E;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,iBAAiB,CAEpG"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { addClassNamesToElement } from '@lexical/utils';
|
|
2
|
-
import { $applyNodeReplacement, ElementNode, } from 'lexical';
|
|
3
|
-
/**
|
|
4
|
-
* One couplet's two misra lines, wrapped so each couplet can carry its own
|
|
5
|
-
* rendering override independent of its PoetryBlockNode's overall layout —
|
|
6
|
-
* currently just `centered` (a narrower box, centered on the page, instead
|
|
7
|
-
* of the block's default width): "two columns with a couplet that is
|
|
8
|
-
* single, aligned centered" mixes LayoutContainerNode rows (two-column
|
|
9
|
-
* couplets) with centered PoetryCoupletNodes in the same block, each
|
|
10
|
-
* couplet choosing independently.
|
|
11
|
-
*
|
|
12
|
-
* Used for single-column and alternating block layouts; a two-column
|
|
13
|
-
* couplet uses LayoutContainerNode instead (its own two-item row already
|
|
14
|
-
* gives it a natural per-couplet box, so it doesn't need this wrapper).
|
|
15
|
-
*/
|
|
16
|
-
export class PoetryCoupletNode extends ElementNode {
|
|
17
|
-
constructor(centered = false, key) {
|
|
18
|
-
super(key);
|
|
19
|
-
this.__centered = centered;
|
|
20
|
-
}
|
|
21
|
-
static getType() {
|
|
22
|
-
return 'poetry-couplet';
|
|
23
|
-
}
|
|
24
|
-
static clone(node) {
|
|
25
|
-
return new PoetryCoupletNode(node.__centered, node.__key);
|
|
26
|
-
}
|
|
27
|
-
getCentered() {
|
|
28
|
-
return this.getLatest().__centered;
|
|
29
|
-
}
|
|
30
|
-
setCentered(centered) {
|
|
31
|
-
const writable = this.getWritable();
|
|
32
|
-
writable.__centered = centered;
|
|
33
|
-
return writable;
|
|
34
|
-
}
|
|
35
|
-
static importJSON(serializedNode) {
|
|
36
|
-
return $createPoetryCoupletNode(serializedNode.centered);
|
|
37
|
-
}
|
|
38
|
-
exportJSON() {
|
|
39
|
-
return { ...super.exportJSON(), type: 'poetry-couplet', version: 1, centered: this.getCentered() };
|
|
40
|
-
}
|
|
41
|
-
static importDOM() {
|
|
42
|
-
return {
|
|
43
|
-
div: (domNode) => {
|
|
44
|
-
if (!domNode.hasAttribute('data-likhari-poetry-couplet'))
|
|
45
|
-
return null;
|
|
46
|
-
const centered = domNode.getAttribute('data-likhari-poetry-couplet-centered') === 'true';
|
|
47
|
-
return { conversion: () => ({ node: $createPoetryCoupletNode(centered) }), priority: 2 };
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
exportDOM() {
|
|
52
|
-
const element = document.createElement('div');
|
|
53
|
-
element.setAttribute('data-likhari-poetry-couplet', '');
|
|
54
|
-
if (this.getCentered())
|
|
55
|
-
element.setAttribute('data-likhari-poetry-couplet-centered', 'true');
|
|
56
|
-
return { element };
|
|
57
|
-
}
|
|
58
|
-
createDOM(config) {
|
|
59
|
-
const element = document.createElement('div');
|
|
60
|
-
const base = config.theme.poetryCouplet ?? 'likhari-poetry-couplet';
|
|
61
|
-
addClassNamesToElement(element, base);
|
|
62
|
-
if (this.__centered)
|
|
63
|
-
element.classList.add(`${base}--centered`);
|
|
64
|
-
return element;
|
|
65
|
-
}
|
|
66
|
-
updateDOM(prevNode, dom, config) {
|
|
67
|
-
if (prevNode.__centered !== this.__centered) {
|
|
68
|
-
const base = config.theme.poetryCouplet ?? 'likhari-poetry-couplet';
|
|
69
|
-
dom.classList.toggle(`${base}--centered`, this.__centered);
|
|
70
|
-
}
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
canBeEmpty() {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
canIndent() {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
export function $createPoetryCoupletNode(centered = false) {
|
|
81
|
-
return $applyNodeReplacement(new PoetryCoupletNode(centered));
|
|
82
|
-
}
|
|
83
|
-
export function $isPoetryCoupletNode(node) {
|
|
84
|
-
return node instanceof PoetryCoupletNode;
|
|
85
|
-
}
|