@inshapardaz/likhari-react 0.1.9-dev.99 → 0.1.10
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/EditorRoot.d.ts.map +1 -1
- package/dist/EditorRoot.js +1 -2
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/components/Toolbar.js +3 -9
- package/dist/i18n/strings.d.ts +0 -3
- package/dist/i18n/strings.d.ts.map +1 -1
- package/dist/i18n/strings.js +0 -6
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -2
- package/dist/theme/editor.css +0 -39
- package/dist/theme/editorTheme.d.ts.map +1 -1
- package/dist/theme/editorTheme.js +0 -1
- package/package.json +1 -1
- package/dist/blocks/PageBreakNode.d.ts +0 -30
- package/dist/blocks/PageBreakNode.d.ts.map +0 -1
- package/dist/blocks/PageBreakNode.js +0 -112
- package/dist/plugins/PageBreakPlugin.d.ts +0 -3
- package/dist/plugins/PageBreakPlugin.d.ts.map +0 -1
- package/dist/plugins/PageBreakPlugin.js +0 -19
package/dist/EditorRoot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorRoot.d.ts","sourceRoot":"","sources":["../src/EditorRoot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAY1D,OAAO,KAAK,EAAe,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAyB,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAwB,KAAK,mBAAmB,EAAE,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAKzH,OAAO,EAAyB,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"EditorRoot.d.ts","sourceRoot":"","sources":["../src/EditorRoot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE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Toolbar } from './components/Toolbar.js';
|
|
20
20
|
import { injectUrduWebFontsCss } from './fonts/index.js';
|
|
21
21
|
import { LinkPastePlugin } from './plugins/LinkPastePlugin.js';
|
|
22
|
-
import { PageBreakPlugin } from './plugins/PageBreakPlugin.js';
|
|
23
22
|
import { DraftRestore } from './components/DraftRestore.js';
|
|
24
23
|
import { LeaveDialog } from './components/LeaveDialog.js';
|
|
25
24
|
import { clearDraft, createDraftId, hasDraftContent, pruneDrafts, writeDraft, } from './persistence/draftStorage.js';
|
|
@@ -268,7 +267,7 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, initialCo
|
|
|
268
267
|
const portalTargetSelector = `#${CSS.escape(portalTargetId)}`;
|
|
269
268
|
return (_jsx(EditorThemeProvider, { theme: theme, colorScheme: colorScheme, accentColor: accentColor, scopeElementId: portalTargetId, children: _jsxs("div", { className: "likhari-root", dir: dir, ref: rootElementRef, "data-document-id": documentId, style: { height: typeof height === 'number' ? `${height}px` : height }, children: [_jsx("div", { id: portalTargetId, className: "likhari-portal-target" }), _jsx(PortalTargetContext.Provider, { value: portalTargetSelector, children: _jsxs(UiStringsContext.Provider, { value: strings, children: [_jsx(ImageOptionsContext.Provider, { value: imageOptions, children: _jsxs(LexicalComposer, { initialConfig: initialConfig, children: [_jsx(Toolbar, { config: config, onSave: handleSave, isDirty: isDirty, showSave: showSave, fontOptions: fontOptions, direction: dir, locale: locale, drafts: autosave
|
|
270
269
|
? { currentId: draftId, maxBytes: autosaveMaxBytes, adoptOnRestore: !documentId, onRestored: handleDraftRestored }
|
|
271
|
-
: undefined }), documentId && (_jsx(DraftRestore, { draftId: documentId, mode: restoreDraft, initialJson: initialContentJsonRef.current, locale: locale, onRestored: handleDraftRestored })), _jsx("div", { className: "likhari-canvas", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "likhari-content-editable", dir: dir, "aria-label": strings.editor.contentLabel }), placeholder: _jsx("div", { className: "likhari-placeholder", children: resolvedPlaceholder }), ErrorBoundary: LexicalErrorBoundary }) }), config.history && _jsx(HistoryPlugin, {}), (config.lists.bullet || config.lists.numbered || config.lists.check) && _jsx(ListPlugin, {}), config.lists.check && _jsx(CheckListPlugin, {}), config.links && _jsx(LinkPlugin, {}), config.links && _jsx(LinkPastePlugin, {}), config.
|
|
270
|
+
: undefined }), documentId && (_jsx(DraftRestore, { draftId: documentId, mode: restoreDraft, initialJson: initialContentJsonRef.current, locale: locale, onRestored: handleDraftRestored })), _jsx("div", { className: "likhari-canvas", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "likhari-content-editable", dir: dir, "aria-label": strings.editor.contentLabel }), placeholder: _jsx("div", { className: "likhari-placeholder", children: resolvedPlaceholder }), ErrorBoundary: LexicalErrorBoundary }) }), config.history && _jsx(HistoryPlugin, {}), (config.lists.bullet || config.lists.numbered || config.lists.check) && _jsx(ListPlugin, {}), config.lists.check && _jsx(CheckListPlugin, {}), config.links && _jsx(LinkPlugin, {}), config.links && _jsx(LinkPastePlugin, {}), config.tables && _jsx(TablePlugin, { hasCellMerge: false, hasTabHandler: true }), config.blocks.horizontalRule && _jsx(HorizontalRulePlugin, {}), _jsx(OnChangePlugin, { onChange: handleChange })] }) }), _jsx(LeaveDialog, { opened: leavePrompt !== null, canSave: Boolean(onSave), canSaveDraft: autosave || navigationGuard === 'save-draft', draftFailed: leavePrompt?.draftFailed ?? false, onSave: () => {
|
|
272
271
|
handleSave();
|
|
273
272
|
settleLeave(true);
|
|
274
273
|
}, onSaveDraft: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAsDA,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;AA8YvD,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,+BAo6BxJ"}
|
|
@@ -11,7 +11,6 @@ import { $findMatchingParent, $insertNodeToNearestRoot } from '@lexical/utils';
|
|
|
11
11
|
import { INSERT_HORIZONTAL_RULE_COMMAND } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
12
12
|
import { ImageDialog } from '../image/ImageDialog.js';
|
|
13
13
|
import { $createImageNode } from '../image/ImageNode.js';
|
|
14
|
-
import { INSERT_PAGE_BREAK_COMMAND } from '../blocks/PageBreakNode.js';
|
|
15
14
|
import { TableDialog } from './TableDialog.js';
|
|
16
15
|
import { $getTableCellNodeFromLexicalNode, $isTableSelection, INSERT_TABLE_COMMAND } from '@lexical/table';
|
|
17
16
|
import { $deleteTable, $deleteTableColumns, $deleteTableRows, $getTableSelectionSize, $insertTableColumns, $insertTableRows, } from '../table/tableActions.js';
|
|
@@ -23,7 +22,7 @@ import { CANVAS_FONT_DEFAULTS, DEFAULT_FONT_OPTIONS, FONT_SIZES_PX } from '../fo
|
|
|
23
22
|
import { setStyleProperty } from '../utils/style.js';
|
|
24
23
|
import { useStrings } from '../i18n/useStrings.js';
|
|
25
24
|
import { usePortalTarget } from '../PortalTargetContext.js';
|
|
26
|
-
import { IconAbc, IconAlignCenter, IconAlignJustified, IconAlignLeft, IconAlignRight, IconArrowBackUp, IconArrowForwardUp, IconBold, IconClearFormatting, IconDeviceFloppy, IconDots, IconHistory, IconExternalLink, IconFeather, IconH1, IconH2, IconH3, IconH4, IconH5, IconH6, IconIndentDecrease, IconIndentIncrease, IconItalic, IconLetterCase, IconLetterCaseLower, IconLetterCaseUpper, IconLink, IconLinkOff, IconList, IconListCheck, IconListNumbers,
|
|
25
|
+
import { IconAbc, IconAlignCenter, IconAlignJustified, IconAlignLeft, IconAlignRight, IconArrowBackUp, IconArrowForwardUp, IconBold, IconClearFormatting, IconDeviceFloppy, IconDots, IconHistory, IconExternalLink, IconFeather, IconH1, IconH2, IconH3, IconH4, IconH5, IconH6, IconIndentDecrease, IconIndentIncrease, IconItalic, IconLetterCase, IconLetterCaseLower, IconLetterCaseUpper, IconLink, IconLinkOff, IconList, IconListCheck, IconListNumbers, IconPencil, IconPhoto, IconPilcrow, IconQuote, IconSeparatorHorizontal, IconSparkles, IconStrikethrough, IconSubscript, IconSuperscript, IconColumnInsertLeft, IconColumnInsertRight, IconColumnRemove, IconRowInsertBottom, IconRowInsertTop, IconRowRemove, IconTable, IconTableMinus, IconTableOptions, IconTextSize, IconTypography, IconUnderline, IconWand, } from '@tabler/icons-react';
|
|
27
26
|
/** Sentinel for "no inline style": Lexical returns the default it is given when
|
|
28
27
|
* the selection has none, so this tells "unstyled" (show the canvas default)
|
|
29
28
|
* apart from "styled with a value the dropdown doesn't list" (show nothing). */
|
|
@@ -526,12 +525,7 @@ export function Toolbar({ config, onSave, isDirty, showSave, fontOptions = DEFAU
|
|
|
526
525
|
const showFormattingGroup = headingLevels.length > 0 || config.lists.bullet || config.lists.numbered || config.lists.check || config.blocks.quote;
|
|
527
526
|
const showInlineGroup = fmt.bold || fmt.italic || fmt.underline;
|
|
528
527
|
const showAlignGroup = config.alignment.start || config.alignment.center || config.alignment.justify || config.alignment.left || config.alignment.right;
|
|
529
|
-
const showStubInsertGroup = config.images.linked ||
|
|
530
|
-
config.images.embedded ||
|
|
531
|
-
config.tables ||
|
|
532
|
-
config.blocks.horizontalRule ||
|
|
533
|
-
config.blocks.pageBreak ||
|
|
534
|
-
config.poetry.enabled;
|
|
528
|
+
const showStubInsertGroup = config.images.linked || config.images.embedded || config.tables || config.blocks.horizontalRule || config.poetry.enabled;
|
|
535
529
|
const showLanguageGroup = config.language.autocorrect || config.language.textCleanup || config.language.spellCheck;
|
|
536
530
|
// The "script & cleanup" and "indent/outdent" groups (UI spec §3.3) render
|
|
537
531
|
// as normal inline toolbar groups whenever there's room, and only move
|
|
@@ -701,7 +695,7 @@ export function Toolbar({ config, onSave, isDirty, showSave, fontOptions = DEFAU
|
|
|
701
695
|
restoreSelection();
|
|
702
696
|
openLinkDialog();
|
|
703
697
|
}, onRemove: removeLink, strings: strings }) })] })) : (_jsx(ToolbarButton, { icon: IconLink, title: strings.toolbar.insertLink, onClick: openLinkDialog })) }, "link")),
|
|
704
|
-
showStubInsertGroup && (_jsxs("div", { className: "likhari-toolbar-group likhari-toolbar-group--collapse-tablet", children: [(config.images.linked || config.images.embedded) && (_jsx(ToolbarButton, { icon: IconPhoto, title: strings.toolbar.insertImage, onClick: openImageDialog })), config.
|
|
698
|
+
showStubInsertGroup && (_jsxs("div", { className: "likhari-toolbar-group likhari-toolbar-group--collapse-tablet", children: [(config.images.linked || config.images.embedded) && (_jsx(ToolbarButton, { icon: IconPhoto, title: strings.toolbar.insertImage, onClick: openImageDialog })), config.tables && _jsx(ToolbarButton, { icon: IconTable, title: strings.toolbar.insertTable, onClick: openTableDialog }), config.blocks.horizontalRule && (_jsx(ToolbarButton, { icon: IconSeparatorHorizontal, title: strings.toolbar.insertHorizontalRule, onClick: () => editor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, undefined) })), config.poetry.enabled && _jsx(StubButton, { icon: IconFeather, title: strings.toolbar.poetryBlocks, comingSoon: strings.toolbar.comingSoon })] }, "stubInsert")),
|
|
705
699
|
config.tables && state.inTable && (_jsx("div", { className: "likhari-toolbar-group", children: _jsxs(Menu, { position: "bottom-start", withinPortal: true, portalProps: { target: portalTarget }, shadow: "sm", width: 240, onOpen: snapshotSelection, children: [_jsx(Menu.Target, { children: _jsx("button", { type: "button", className: "likhari-toolbar-button", "data-active": "true", "aria-pressed": "true", "aria-haspopup": "menu", "aria-label": strings.toolbar.tableOptions, title: strings.toolbar.tableOptions, onMouseDown: (e) => e.preventDefault(), children: _jsx(IconTableOptions, { size: ICON_SIZE, stroke: ICON_STROKE }) }) }), _jsx(Menu.Dropdown, { children: _jsx(TableMenuItems, { strings: strings, direction: direction, rows: state.tableRows, columns: state.tableColumns, onAction: runTableAction }) })] }) }, "tableActions")),
|
|
706
700
|
showLanguageGroup && (_jsxs("div", { className: "likhari-toolbar-group likhari-toolbar-group--collapse-tablet", children: [config.language.autocorrect && _jsx(StubButton, { icon: IconWand, title: strings.toolbar.autocorrect, comingSoon: strings.toolbar.comingSoon }), config.language.textCleanup && _jsx(StubButton, { icon: IconSparkles, title: strings.toolbar.textCleanup, comingSoon: strings.toolbar.comingSoon }), config.language.spellCheck && _jsx(StubButton, { icon: IconAbc, title: strings.toolbar.spellChecker, comingSoon: strings.toolbar.comingSoon })] }, "language")),
|
|
707
701
|
];
|
package/dist/i18n/strings.d.ts
CHANGED
|
@@ -13,8 +13,6 @@ export interface Strings {
|
|
|
13
13
|
placeholder: string;
|
|
14
14
|
/** aria-label on the contenteditable itself. */
|
|
15
15
|
contentLabel: string;
|
|
16
|
-
/** Label shown on a page-break marker's dashed line while editing. */
|
|
17
|
-
pageBreakLabel: string;
|
|
18
16
|
};
|
|
19
17
|
common: {
|
|
20
18
|
cancel: string;
|
|
@@ -44,7 +42,6 @@ export interface Strings {
|
|
|
44
42
|
tableOptions: string;
|
|
45
43
|
insertLink: string;
|
|
46
44
|
insertImage: string;
|
|
47
|
-
insertPageBreak: string;
|
|
48
45
|
insertTable: string;
|
|
49
46
|
insertHorizontalRule: string;
|
|
50
47
|
poetryBlocks: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/i18n/strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;+DAC+D;AAC/D,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,cAAc,CAAC;AAElD,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE;QACN,mGAAmG;QACnG,WAAW,EAAE,MAAM,CAAC;QACpB,gDAAgD;QAChD,YAAY,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/i18n/strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;+DAC+D;AAC/D,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,cAAc,CAAC;AAElD,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE;QACN,mGAAmG;QACnG,WAAW,EAAE,MAAM,CAAC;QACpB,gDAAgD;QAChD,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE;QACP,gEAAgE;QAChE,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,0CAA0C;QAC1C,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,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,CAAC;QACxE,MAAM,EAAE;YACN,cAAc,EAAE,MAAM,CAAC;YACvB,YAAY,EAAE,MAAM,CAAC;YACrB,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;SAC3C,CAAC;KACH,CAAC;IACF,SAAS,EAAE;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAqkBD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAI3C,CAAC;AAEF;;sDAEsD;AACtD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElD"}
|
package/dist/i18n/strings.js
CHANGED
|
@@ -8,7 +8,6 @@ const en = {
|
|
|
8
8
|
editor: {
|
|
9
9
|
placeholder: 'Start writing…',
|
|
10
10
|
contentLabel: 'Editor content',
|
|
11
|
-
pageBreakLabel: 'Page break',
|
|
12
11
|
},
|
|
13
12
|
common: {
|
|
14
13
|
cancel: 'Cancel',
|
|
@@ -35,7 +34,6 @@ const en = {
|
|
|
35
34
|
tableOptions: 'Table options',
|
|
36
35
|
insertLink: 'Insert link (Ctrl+K)',
|
|
37
36
|
insertImage: 'Insert image',
|
|
38
|
-
insertPageBreak: 'Insert page break',
|
|
39
37
|
insertTable: 'Insert table',
|
|
40
38
|
insertHorizontalRule: 'Insert horizontal rule',
|
|
41
39
|
poetryBlocks: 'Poetry blocks',
|
|
@@ -201,7 +199,6 @@ const ur = {
|
|
|
201
199
|
editor: {
|
|
202
200
|
placeholder: 'لکھنا شروع کریں…',
|
|
203
201
|
contentLabel: 'ایڈیٹر کا مواد',
|
|
204
|
-
pageBreakLabel: 'صفحے کی تقسیم',
|
|
205
202
|
},
|
|
206
203
|
common: {
|
|
207
204
|
cancel: 'منسوخ کریں',
|
|
@@ -228,7 +225,6 @@ const ur = {
|
|
|
228
225
|
tableOptions: 'جدول کے اختیارات',
|
|
229
226
|
insertLink: 'لنک شامل کریں (Ctrl+K)',
|
|
230
227
|
insertImage: 'تصویر شامل کریں',
|
|
231
|
-
insertPageBreak: 'صفحے کی تقسیم شامل کریں',
|
|
232
228
|
insertTable: 'جدول شامل کریں',
|
|
233
229
|
insertHorizontalRule: 'افقی لکیر شامل کریں',
|
|
234
230
|
poetryBlocks: 'شاعری کے بلاکس',
|
|
@@ -394,7 +390,6 @@ const paShahmukhi = {
|
|
|
394
390
|
editor: {
|
|
395
391
|
placeholder: 'لکھنا شروع کرو…',
|
|
396
392
|
contentLabel: 'ایڈیٹر دی سامگری',
|
|
397
|
-
pageBreakLabel: 'صفحے دی ونڈ',
|
|
398
393
|
},
|
|
399
394
|
common: {
|
|
400
395
|
cancel: 'رد کرو',
|
|
@@ -421,7 +416,6 @@ const paShahmukhi = {
|
|
|
421
416
|
tableOptions: 'ٹیبل دے اختیار',
|
|
422
417
|
insertLink: 'لنک پاؤ (Ctrl+K)',
|
|
423
418
|
insertImage: 'تصویر پاؤ',
|
|
424
|
-
insertPageBreak: 'صفحے دی ونڈ پاؤ',
|
|
425
419
|
insertTable: 'ٹیبل پاؤ',
|
|
426
420
|
insertHorizontalRule: 'لیٹی لکیر پاؤ',
|
|
427
421
|
poetryBlocks: 'شاعری بلاک',
|
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;AAQlD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,EAW5C,CAAC"}
|
package/dist/nodes.js
CHANGED
|
@@ -4,7 +4,6 @@ import { LinkNode } from '@lexical/link';
|
|
|
4
4
|
import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
5
5
|
import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
6
6
|
import { ImageNode } from './image/ImageNode.js';
|
|
7
|
-
import { PageBreakNode } from './blocks/PageBreakNode.js';
|
|
8
7
|
/**
|
|
9
8
|
* Node types registered on the editor at construction time. Per
|
|
10
9
|
* editor-architecture-design.md §2, node registration cannot be conditional
|
|
@@ -25,5 +24,4 @@ export const EDITOR_NODES = [
|
|
|
25
24
|
TableRowNode,
|
|
26
25
|
TableCellNode,
|
|
27
26
|
ImageNode,
|
|
28
|
-
PageBreakNode,
|
|
29
27
|
];
|
package/dist/theme/editor.css
CHANGED
|
@@ -259,45 +259,6 @@
|
|
|
259
259
|
margin: 1.5em 0;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
/* Page break — a print/export concept with no visual meaning while editing
|
|
263
|
-
on screen, so it gets its own clearly-labeled dashed marker rather than
|
|
264
|
-
masquerading as a horizontal rule. The actual page-break behavior only
|
|
265
|
-
takes effect when printing (lexical-editor-spec.md §4.3/§4.6). */
|
|
266
|
-
.likhari-page-break {
|
|
267
|
-
display: flex;
|
|
268
|
-
align-items: center;
|
|
269
|
-
gap: 8px;
|
|
270
|
-
margin: 1.5em 0;
|
|
271
|
-
font-size: 12px;
|
|
272
|
-
cursor: default;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
.likhari-page-break-line {
|
|
276
|
-
flex: 1 1 auto;
|
|
277
|
-
border-top: 1px dashed var(--editor-line);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
.likhari-page-break-label {
|
|
281
|
-
color: var(--editor-ink-soft);
|
|
282
|
-
white-space: nowrap;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
.likhari-page-break-selected {
|
|
286
|
-
outline: 2px solid var(--editor-accent);
|
|
287
|
-
outline-offset: 2px;
|
|
288
|
-
border-radius: 4px;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
@media print {
|
|
292
|
-
.likhari-page-break {
|
|
293
|
-
page-break-after: always;
|
|
294
|
-
/* Hide the on-screen marker itself when actually printing — the
|
|
295
|
-
browser's own pagination (triggered by page-break-after) is what
|
|
296
|
-
matters there, not the editing-time label. */
|
|
297
|
-
visibility: hidden;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
262
|
/* Tables — cell merge/split is deliberately out of scope for now (a flagged
|
|
302
263
|
open risk, lexical-editor-spec.md §12 item 3, needing its own scope
|
|
303
264
|
decision); TablePlugin is configured with hasCellMerge={false} to keep
|
|
@@ -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,kBAmCzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
2
|
-
import { DecoratorNode, type DOMConversionMap, type DOMExportOutput, type EditorConfig, type LexicalCommand, type LexicalNode, type SerializedLexicalNode } from 'lexical';
|
|
3
|
-
export declare const INSERT_PAGE_BREAK_COMMAND: LexicalCommand<void>;
|
|
4
|
-
export type SerializedPageBreakNode = SerializedLexicalNode;
|
|
5
|
-
/**
|
|
6
|
-
* A manual page break — a print/paginated-export concept with no native
|
|
7
|
-
* Lexical node (lexical-editor-spec.md §4.3/§4.6). Renders as a visible
|
|
8
|
-
* dashed marker while editing, and as `page-break-after: always` both live
|
|
9
|
-
* (a print stylesheet, editor.css) and in exported HTML (`exportDOM`).
|
|
10
|
-
*
|
|
11
|
-
* Mirrors @lexical/react's HorizontalRuleNode pattern: `createDOM` returns
|
|
12
|
-
* the actual visible element (the click target `PageBreakComponent` wires
|
|
13
|
-
* selection/delete against), rather than `decorate()` rendering visuals.
|
|
14
|
-
*/
|
|
15
|
-
export declare class PageBreakNode extends DecoratorNode<ReactElement> {
|
|
16
|
-
static getType(): string;
|
|
17
|
-
static clone(node: PageBreakNode): PageBreakNode;
|
|
18
|
-
static importJSON(): PageBreakNode;
|
|
19
|
-
exportJSON(): SerializedPageBreakNode;
|
|
20
|
-
static importDOM(): DOMConversionMap | null;
|
|
21
|
-
exportDOM(): DOMExportOutput;
|
|
22
|
-
createDOM(config: EditorConfig): HTMLElement;
|
|
23
|
-
getTextContent(): string;
|
|
24
|
-
isInline(): false;
|
|
25
|
-
updateDOM(): boolean;
|
|
26
|
-
decorate(): import("react").JSX.Element;
|
|
27
|
-
}
|
|
28
|
-
export declare function $createPageBreakNode(): PageBreakNode;
|
|
29
|
-
export declare function $isPageBreakNode(node: LexicalNode | null | undefined): node is PageBreakNode;
|
|
30
|
-
//# sourceMappingURL=PageBreakNode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PageBreakNode.d.ts","sourceRoot":"","sources":["../../src/blocks/PageBreakNode.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAKlE,OAAO,EAOL,aAAa,EAGb,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,qBAAqB,EAC3B,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,yBAAyB,EAAE,cAAc,CAAC,IAAI,CAA8C,CAAC;AAE1G,MAAM,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AA6D5D;;;;;;;;;GASG;AACH,qBAAa,aAAc,SAAQ,aAAa,CAAC,YAAY,CAAC;IAC5D,MAAM,CAAC,OAAO,IAAI,MAAM;IAIxB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa;IAIhD,MAAM,CAAC,UAAU,IAAI,aAAa;IAIlC,UAAU,IAAI,uBAAuB;IAIrC,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAS3C,SAAS,IAAI,eAAe;IAO5B,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAM5C,cAAc,IAAI,MAAM;IAIxB,QAAQ,IAAI,KAAK;IAIjB,SAAS,IAAI,OAAO;IAIpB,QAAQ;CAGT;AAED,wBAAgB,oBAAoB,IAAI,aAAa,CAEpD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,aAAa,CAE5F"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect } from 'react';
|
|
3
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
|
-
import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
|
|
5
|
-
import { addClassNamesToElement, mergeRegister, removeClassNamesFromElement } from '@lexical/utils';
|
|
6
|
-
import { useUiStrings } from '../i18n/useStrings.js';
|
|
7
|
-
import { $applyNodeReplacement, $getSelection, $isNodeSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, createCommand, DecoratorNode, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, } from 'lexical';
|
|
8
|
-
export const INSERT_PAGE_BREAK_COMMAND = createCommand('INSERT_PAGE_BREAK_COMMAND');
|
|
9
|
-
const SELECTED_CLASS_NAME = 'likhari-page-break-selected';
|
|
10
|
-
function PageBreakComponent({ nodeKey }) {
|
|
11
|
-
const [editor] = useLexicalComposerContext();
|
|
12
|
-
const strings = useUiStrings();
|
|
13
|
-
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
14
|
-
const onDelete = useCallback((event) => {
|
|
15
|
-
const selection = $getSelection();
|
|
16
|
-
if (isSelected && $isNodeSelection(selection)) {
|
|
17
|
-
event.preventDefault();
|
|
18
|
-
editor.update(() => {
|
|
19
|
-
selection.getNodes().forEach((node) => {
|
|
20
|
-
if ($isPageBreakNode(node))
|
|
21
|
-
node.remove();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}, [editor, isSelected]);
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
return mergeRegister(editor.registerCommand(CLICK_COMMAND, (event) => {
|
|
29
|
-
const element = editor.getElementByKey(nodeKey);
|
|
30
|
-
// The marker is made of child spans (the label and two lines), so a
|
|
31
|
-
// click almost never lands on the outer element itself.
|
|
32
|
-
if (!element || !element.contains(event.target))
|
|
33
|
-
return false;
|
|
34
|
-
if (!event.shiftKey)
|
|
35
|
-
clearSelection();
|
|
36
|
-
setSelected(!isSelected);
|
|
37
|
-
return true;
|
|
38
|
-
}, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW));
|
|
39
|
-
}, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected]);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
const element = editor.getElementByKey(nodeKey);
|
|
42
|
-
if (!element)
|
|
43
|
-
return;
|
|
44
|
-
if (isSelected)
|
|
45
|
-
addClassNamesToElement(element, SELECTED_CLASS_NAME);
|
|
46
|
-
else
|
|
47
|
-
removeClassNamesFromElement(element, SELECTED_CLASS_NAME);
|
|
48
|
-
}, [editor, isSelected, nodeKey]);
|
|
49
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "likhari-page-break-line", "aria-hidden": "true" }), _jsx("span", { className: "likhari-page-break-label", children: strings.editor.pageBreakLabel }), _jsx("span", { className: "likhari-page-break-line", "aria-hidden": "true" })] }));
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* A manual page break — a print/paginated-export concept with no native
|
|
53
|
-
* Lexical node (lexical-editor-spec.md §4.3/§4.6). Renders as a visible
|
|
54
|
-
* dashed marker while editing, and as `page-break-after: always` both live
|
|
55
|
-
* (a print stylesheet, editor.css) and in exported HTML (`exportDOM`).
|
|
56
|
-
*
|
|
57
|
-
* Mirrors @lexical/react's HorizontalRuleNode pattern: `createDOM` returns
|
|
58
|
-
* the actual visible element (the click target `PageBreakComponent` wires
|
|
59
|
-
* selection/delete against), rather than `decorate()` rendering visuals.
|
|
60
|
-
*/
|
|
61
|
-
export class PageBreakNode extends DecoratorNode {
|
|
62
|
-
static getType() {
|
|
63
|
-
return 'page-break';
|
|
64
|
-
}
|
|
65
|
-
static clone(node) {
|
|
66
|
-
return new PageBreakNode(node.__key);
|
|
67
|
-
}
|
|
68
|
-
static importJSON() {
|
|
69
|
-
return $createPageBreakNode();
|
|
70
|
-
}
|
|
71
|
-
exportJSON() {
|
|
72
|
-
return { type: 'page-break', version: 1 };
|
|
73
|
-
}
|
|
74
|
-
static importDOM() {
|
|
75
|
-
return {
|
|
76
|
-
div: (domNode) => {
|
|
77
|
-
if (!domNode.hasAttribute('data-likhari-page-break'))
|
|
78
|
-
return null;
|
|
79
|
-
return { conversion: () => ({ node: $createPageBreakNode() }), priority: 2 };
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
exportDOM() {
|
|
84
|
-
const element = document.createElement('div');
|
|
85
|
-
element.setAttribute('data-likhari-page-break', '');
|
|
86
|
-
element.style.pageBreakAfter = 'always';
|
|
87
|
-
return { element };
|
|
88
|
-
}
|
|
89
|
-
createDOM(config) {
|
|
90
|
-
const element = document.createElement('div');
|
|
91
|
-
addClassNamesToElement(element, config.theme.pageBreak ?? 'likhari-page-break');
|
|
92
|
-
return element;
|
|
93
|
-
}
|
|
94
|
-
getTextContent() {
|
|
95
|
-
return '\n';
|
|
96
|
-
}
|
|
97
|
-
isInline() {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
updateDOM() {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
decorate() {
|
|
104
|
-
return _jsx(PageBreakComponent, { nodeKey: this.__key });
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
export function $createPageBreakNode() {
|
|
108
|
-
return $applyNodeReplacement(new PageBreakNode());
|
|
109
|
-
}
|
|
110
|
-
export function $isPageBreakNode(node) {
|
|
111
|
-
return node instanceof PageBreakNode;
|
|
112
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PageBreakPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/PageBreakPlugin.tsx"],"names":[],"mappings":"AAMA,+FAA+F;AAC/F,wBAAgB,eAAe,SAiB9B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
-
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
4
|
-
import { $insertNodeToNearestRoot } from '@lexical/utils';
|
|
5
|
-
import { $createPageBreakNode, INSERT_PAGE_BREAK_COMMAND } from '../blocks/PageBreakNode.js';
|
|
6
|
-
/** Registers INSERT_PAGE_BREAK_COMMAND — mirrors @lexical/react's own HorizontalRulePlugin. */
|
|
7
|
-
export function PageBreakPlugin() {
|
|
8
|
-
const [editor] = useLexicalComposerContext();
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
return editor.registerCommand(INSERT_PAGE_BREAK_COMMAND, () => {
|
|
11
|
-
const selection = $getSelection();
|
|
12
|
-
if (!$isRangeSelection(selection))
|
|
13
|
-
return false;
|
|
14
|
-
$insertNodeToNearestRoot($createPageBreakNode());
|
|
15
|
-
return true;
|
|
16
|
-
}, COMMAND_PRIORITY_EDITOR);
|
|
17
|
-
}, [editor]);
|
|
18
|
-
return null;
|
|
19
|
-
}
|