@inshapardaz/likhari-react 0.1.18-dev.144 → 0.1.18-dev.148
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":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAiEA,OAAO,EAAgB,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAA6D,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAItG,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,iBAAiB,CAAC;AA4evD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,2BAA2B,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,wFAAwF;IACxF,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC1B,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kGAAkG;IAClG,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAkC,EAAE,SAAiB,EAAE,MAAa,EAAE,MAAM,EAAE,EAAE,YAAY,+
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAiEA,OAAO,EAAgB,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAA6D,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAItG,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,iBAAiB,CAAC;AA4evD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,2BAA2B,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,wFAAwF;IACxF,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC1B,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kGAAkG;IAClG,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAkC,EAAE,SAAiB,EAAE,MAAa,EAAE,MAAM,EAAE,EAAE,YAAY,+BA+jCxJ"}
|
|
@@ -14,6 +14,7 @@ import { $createImageNode } from '../image/ImageNode.js';
|
|
|
14
14
|
import { INSERT_PAGE_BREAK_COMMAND } from '../blocks/PageBreakNode.js';
|
|
15
15
|
import { INSERT_LAYOUT_COMMAND } from '../blocks/LayoutNode.js';
|
|
16
16
|
import { INSERT_FOOTNOTE_COMMAND } from '../blocks/FootnoteNode.js';
|
|
17
|
+
import { $isPoetryBlockNode } from '../blocks/PoetryNode.js';
|
|
17
18
|
import { $deletePoetryCouplet, $getPoetryBlockFromSelection, $setPoetryLayout } from '../blocks/poetryActions.js';
|
|
18
19
|
import { INSERT_POETRY_COUPLET_COMMAND } from '../plugins/PoetryPlugin.js';
|
|
19
20
|
import { TableDialog } from './TableDialog.js';
|
|
@@ -532,6 +533,38 @@ export function Toolbar({ config, onSave, isDirty, showSave, fontOptions = DEFAU
|
|
|
532
533
|
root?.addEventListener('contextmenu', onContextMenu);
|
|
533
534
|
});
|
|
534
535
|
}, [editor, config.tables]);
|
|
536
|
+
// Right-clicking a poetry couplet opens the same options menu at the pointer.
|
|
537
|
+
const [poetryContext, setPoetryContext] = useState(null);
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
if (!config.poetry.enabled)
|
|
540
|
+
return;
|
|
541
|
+
const onContextMenu = (event) => {
|
|
542
|
+
if (event.defaultPrevented)
|
|
543
|
+
return; // a link inside the couplet already took it
|
|
544
|
+
const coupletElement = event.target?.closest?.('.likhari-poetry');
|
|
545
|
+
if (!coupletElement)
|
|
546
|
+
return;
|
|
547
|
+
let handled = false;
|
|
548
|
+
editor.update(() => {
|
|
549
|
+
const node = $getNearestNodeFromDOMNode(coupletElement);
|
|
550
|
+
const couplet = node ? $findMatchingParent(node, $isPoetryBlockNode) : null;
|
|
551
|
+
if (!couplet)
|
|
552
|
+
return;
|
|
553
|
+
handled = true;
|
|
554
|
+
if (!$getPoetryBlockFromSelection())
|
|
555
|
+
couplet.selectStart();
|
|
556
|
+
}, { discrete: true });
|
|
557
|
+
if (!handled)
|
|
558
|
+
return;
|
|
559
|
+
event.preventDefault();
|
|
560
|
+
snapshotSelectionRef.current();
|
|
561
|
+
setPoetryContext({ x: event.clientX, y: event.clientY });
|
|
562
|
+
};
|
|
563
|
+
return editor.registerRootListener((root, previous) => {
|
|
564
|
+
previous?.removeEventListener('contextmenu', onContextMenu);
|
|
565
|
+
root?.addEventListener('contextmenu', onContextMenu);
|
|
566
|
+
});
|
|
567
|
+
}, [editor, config.poetry.enabled]);
|
|
535
568
|
// Ctrl/Cmd+K opens the link dialog.
|
|
536
569
|
useEffect(() => {
|
|
537
570
|
if (!config.links)
|
|
@@ -789,7 +822,10 @@ export function Toolbar({ config, onSave, isDirty, showSave, fontOptions = DEFAU
|
|
|
789
822
|
}, onRemove: removeLink, strings: strings }) })] })), config.tables && (_jsxs(Menu, { opened: tableContext !== null, onChange: (opened) => {
|
|
790
823
|
if (!opened)
|
|
791
824
|
setTableContext(null);
|
|
792
|
-
}, position: "bottom-start", withinPortal: true, portalProps: { target: portalTarget }, shadow: "sm", width: 240, children: [_jsx(Menu.Target, { children: _jsx("span", { "aria-hidden": "true", style: { position: 'fixed', left: tableContext?.x ?? -9999, top: tableContext?.y ?? -9999, width: 1, height: 1, pointerEvents: 'none' } }) }), _jsx(Menu.Dropdown, { children: _jsx(TableMenuItems, { strings: strings, direction: direction, rows: tableContext?.rows ?? 1, columns: tableContext?.columns ?? 1, canMergeCells: state.canMergeCells, canUnmergeCell: state.canUnmergeCell, onAction: runMenuAction }) })] })), _jsxs(
|
|
825
|
+
}, position: "bottom-start", withinPortal: true, portalProps: { target: portalTarget }, shadow: "sm", width: 240, children: [_jsx(Menu.Target, { children: _jsx("span", { "aria-hidden": "true", style: { position: 'fixed', left: tableContext?.x ?? -9999, top: tableContext?.y ?? -9999, width: 1, height: 1, pointerEvents: 'none' } }) }), _jsx(Menu.Dropdown, { children: _jsx(TableMenuItems, { strings: strings, direction: direction, rows: tableContext?.rows ?? 1, columns: tableContext?.columns ?? 1, canMergeCells: state.canMergeCells, canUnmergeCell: state.canUnmergeCell, onAction: runMenuAction }) })] })), config.poetry.enabled && (_jsxs(Menu, { opened: poetryContext !== null, onChange: (opened) => {
|
|
826
|
+
if (!opened)
|
|
827
|
+
setPoetryContext(null);
|
|
828
|
+
}, position: "bottom-start", withinPortal: true, portalProps: { target: portalTarget }, shadow: "sm", width: 200, children: [_jsx(Menu.Target, { children: _jsx("span", { "aria-hidden": "true", style: { position: 'fixed', left: poetryContext?.x ?? -9999, top: poetryContext?.y ?? -9999, width: 1, height: 1, pointerEvents: 'none' } }) }), _jsx(Menu.Dropdown, { children: _jsx(PoetryMenuItems, { strings: strings, alignIcons: ALIGN_ICONS, layout: state.poetryLayout, align: state.poetryAlign, onAction: runMenuAction }) })] })), _jsxs("div", { "aria-hidden": "true", ref: toolbarMeasureRef, style: {
|
|
793
829
|
position: 'absolute',
|
|
794
830
|
visibility: 'hidden',
|
|
795
831
|
pointerEvents: 'none',
|
package/dist/theme/editor.css
CHANGED
|
@@ -404,6 +404,15 @@
|
|
|
404
404
|
line-height: 2.1;
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
+
/* Misra lines sit tight against each other within a couplet — the generic
|
|
408
|
+
.likhari-paragraph margin would otherwise add the same gap between a
|
|
409
|
+
couplet's own two lines as between separate couplets, losing the pairing
|
|
410
|
+
entirely. The couplet's own margin-bottom (above) is the only gap that
|
|
411
|
+
should read as "extra space", and it falls after every second line. */
|
|
412
|
+
.likhari-poetry .likhari-paragraph {
|
|
413
|
+
margin: 0;
|
|
414
|
+
}
|
|
415
|
+
|
|
407
416
|
.likhari-poetry--two-column .likhari-layout-container {
|
|
408
417
|
margin: 0;
|
|
409
418
|
/* No grid gap — the divider below sits exactly on the track boundary, so
|