@codee-sh/medusa-plugin-notification-emails 1.0.0 → 1.0.2
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/.medusa/server/medusa-config.js +20 -0
- package/.medusa/server/src/admin/index.js +1460 -1460
- package/.medusa/server/src/admin/index.mjs +1462 -1462
- package/.medusa/server/src/modules/mpn-builder/service.js +26 -4
- package/.medusa/server/src/modules/mpn-builder/services-local/slack-template-service.js +9 -9
- package/.medusa/server/src/templates/emails/contact-form/config.js +3 -3
- package/.medusa/server/src/templates/emails/inventory-level/config.js +4 -4
- package/.medusa/server/src/templates/emails/order/completed/config.js +7 -7
- package/.medusa/server/src/templates/emails/order/placed/config.js +7 -7
- package/.medusa/server/src/templates/emails/order/updated/config.js +7 -7
- package/.medusa/server/src/templates/slack/inventory-level/config.js +2 -2
- package/.medusa/server/src/workflows/mpn-builder-services/steps/email-service.js +6 -4
- package/.medusa/server/src/workflows/mpn-builder-services/steps/slack-service.js +10 -5
- package/README.md +40 -103
- package/package.json +13 -4
|
@@ -5,8 +5,9 @@ import { useTranslation, Trans } from "react-i18next";
|
|
|
5
5
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import Medusa from "@medusajs/js-sdk";
|
|
7
7
|
import * as React from "react";
|
|
8
|
-
import React__default, { useState, useMemo,
|
|
9
|
-
import { InformationCircleSolid,
|
|
8
|
+
import React__default, { useState, useMemo, createContext, useContext, useReducer, useEffect, Fragment as Fragment$1, useRef, forwardRef, Suspense, createElement, useCallback, useLayoutEffect, useId, useInsertionEffect, Children, isValidElement, Component, useImperativeHandle } from "react";
|
|
9
|
+
import { InformationCircleSolid, ArrowUpRightOnBox, XMarkMini, TriangleDownMini, Check, SquareTwoStack, Plus, PuzzleSolid, ListBullet, Pencil, Trash, ChatBubbleLeftRight } from "@medusajs/icons";
|
|
10
|
+
import { Outlet, useNavigate, useParams } from "react-router-dom";
|
|
10
11
|
import { LexicalExtensionComposer } from "@lexical/react/LexicalExtensionComposer";
|
|
11
12
|
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
12
13
|
import { DecoratorNode, $getNodeByKey, $getRoot, FORMAT_TEXT_COMMAND, createCommand, defineExtension, $createParagraphNode, $insertNodes, COMMAND_PRIORITY_LOW } from "lexical";
|
|
@@ -14,7 +15,6 @@ import { RichTextExtension } from "@lexical/rich-text";
|
|
|
14
15
|
import { HistoryExtension } from "@lexical/history";
|
|
15
16
|
import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
|
|
16
17
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
17
|
-
import { Outlet, useNavigate, useParams } from "react-router-dom";
|
|
18
18
|
import "@react-email/components";
|
|
19
19
|
import "@react-email/render";
|
|
20
20
|
import { KeyboardCode, closestCorners, getFirstCollision, getScrollableAncestors, useDndContext, useDroppable, useDraggable, getClientRect, DndContext, closestCenter, useSensors, useSensor, PointerSensor, KeyboardSensor } from "@dnd-kit/core";
|
|
@@ -426,1252 +426,563 @@ const OrderNotificationActivityWidget = ({
|
|
|
426
426
|
defineWidgetConfig({
|
|
427
427
|
zone: "order.details.after"
|
|
428
428
|
});
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
return new VariableNode(node.__variableName, node.__key);
|
|
435
|
-
}
|
|
436
|
-
constructor(variableName, key) {
|
|
437
|
-
super(key);
|
|
438
|
-
this.__variableName = variableName;
|
|
439
|
-
}
|
|
440
|
-
createDOM() {
|
|
441
|
-
const span = document.createElement("span");
|
|
442
|
-
span.className = "variable-node";
|
|
443
|
-
return span;
|
|
444
|
-
}
|
|
445
|
-
updateDOM() {
|
|
446
|
-
return false;
|
|
447
|
-
}
|
|
448
|
-
exportDOM() {
|
|
449
|
-
const element = document.createElement("span");
|
|
450
|
-
element.textContent = `{{${this.__variableName}}}`;
|
|
451
|
-
element.className = "variable";
|
|
452
|
-
return { element };
|
|
453
|
-
}
|
|
454
|
-
static importJSON(serializedNode) {
|
|
455
|
-
return $createVariableNode(serializedNode.variableName);
|
|
456
|
-
}
|
|
457
|
-
exportJSON() {
|
|
458
|
-
return {
|
|
459
|
-
type: "variable",
|
|
460
|
-
version: 1,
|
|
461
|
-
variableName: this.__variableName
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
isInline() {
|
|
465
|
-
return true;
|
|
466
|
-
}
|
|
467
|
-
getVariableName() {
|
|
468
|
-
return this.__variableName;
|
|
469
|
-
}
|
|
470
|
-
getTextContent() {
|
|
471
|
-
return `{{${this.__variableName}}}`;
|
|
472
|
-
}
|
|
473
|
-
decorate() {
|
|
474
|
-
return /* @__PURE__ */ jsx(VariableComponent, { variableName: this.__variableName });
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
function $createVariableNode(variableName) {
|
|
478
|
-
return new VariableNode(variableName);
|
|
479
|
-
}
|
|
480
|
-
function VariableComponent({ variableName }) {
|
|
481
|
-
return /* @__PURE__ */ jsx(
|
|
482
|
-
"span",
|
|
483
|
-
{
|
|
484
|
-
className: "inline-flex items-center px-1.5 py-0.5 mx-0.5 rounded text-xs font-mono bg-violet-100 text-violet-700 border border-violet-200",
|
|
485
|
-
contentEditable: false,
|
|
486
|
-
children: `{{${variableName}}}`
|
|
429
|
+
function _extends() {
|
|
430
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n2) {
|
|
431
|
+
for (var e2 = 1; e2 < arguments.length; e2++) {
|
|
432
|
+
var t2 = arguments[e2];
|
|
433
|
+
for (var r in t2) ({}).hasOwnProperty.call(t2, r) && (n2[r] = t2[r]);
|
|
487
434
|
}
|
|
488
|
-
|
|
435
|
+
return n2;
|
|
436
|
+
}, _extends.apply(null, arguments);
|
|
489
437
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
constructor(key) {
|
|
498
|
-
super(key);
|
|
499
|
-
}
|
|
500
|
-
createDOM() {
|
|
501
|
-
const div = document.createElement("div");
|
|
502
|
-
div.className = "editor-divider";
|
|
503
|
-
div.setAttribute("data-lexical-decorator", "true");
|
|
504
|
-
div.setAttribute("contenteditable", "false");
|
|
505
|
-
return div;
|
|
506
|
-
}
|
|
507
|
-
updateDOM() {
|
|
508
|
-
return false;
|
|
509
|
-
}
|
|
510
|
-
exportDOM() {
|
|
511
|
-
const element = document.createElement("hr");
|
|
512
|
-
return { element };
|
|
513
|
-
}
|
|
514
|
-
static importJSON() {
|
|
515
|
-
return $createDividerBlockNode();
|
|
516
|
-
}
|
|
517
|
-
exportJSON() {
|
|
518
|
-
return {
|
|
519
|
-
type: "divider-block",
|
|
520
|
-
version: 1
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
isInline() {
|
|
524
|
-
return false;
|
|
525
|
-
}
|
|
526
|
-
decorate() {
|
|
527
|
-
return /* @__PURE__ */ jsx(DividerBlockComponent, { nodeKey: this.__key });
|
|
438
|
+
function _objectWithoutPropertiesLoose(r, e2) {
|
|
439
|
+
if (null == r) return {};
|
|
440
|
+
var t2 = {};
|
|
441
|
+
for (var n2 in r) if ({}.hasOwnProperty.call(r, n2)) {
|
|
442
|
+
if (-1 !== e2.indexOf(n2)) continue;
|
|
443
|
+
t2[n2] = r[n2];
|
|
528
444
|
}
|
|
445
|
+
return t2;
|
|
529
446
|
}
|
|
530
|
-
|
|
531
|
-
|
|
447
|
+
var initialState$5 = {};
|
|
448
|
+
var Context$6 = /* @__PURE__ */ createContext(initialState$5);
|
|
449
|
+
var reducer$5 = (state, action) => _extends({}, state, action);
|
|
450
|
+
var useShowToolsStore = () => {
|
|
451
|
+
return useContext(Context$6);
|
|
452
|
+
};
|
|
453
|
+
var DispatchShowTools = /* @__PURE__ */ createContext(() => {
|
|
454
|
+
});
|
|
455
|
+
DispatchShowTools.displayName = "JVR.DispatchShowTools";
|
|
456
|
+
function useShowTools() {
|
|
457
|
+
return useReducer(reducer$5, initialState$5);
|
|
532
458
|
}
|
|
533
|
-
function
|
|
534
|
-
return
|
|
535
|
-
"div",
|
|
536
|
-
{
|
|
537
|
-
className: "editor-block py-4 cursor-pointer",
|
|
538
|
-
"data-block-key": nodeKey,
|
|
539
|
-
"data-block-type": "divider",
|
|
540
|
-
children: [
|
|
541
|
-
/* @__PURE__ */ jsx("div", { className: "text-xs text-ui-fg-muted mb-1 uppercase tracking-wide", children: "Divider" }),
|
|
542
|
-
/* @__PURE__ */ jsx("hr", { className: "border-t-2 border-ui-border-base" })
|
|
543
|
-
]
|
|
544
|
-
}
|
|
545
|
-
);
|
|
459
|
+
function useShowToolsDispatch() {
|
|
460
|
+
return useContext(DispatchShowTools);
|
|
546
461
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
element.className = "button";
|
|
574
|
-
return { element };
|
|
575
|
-
}
|
|
576
|
-
static importJSON(serializedNode) {
|
|
577
|
-
return $createButtonBlockNode(serializedNode.text, serializedNode.url);
|
|
578
|
-
}
|
|
579
|
-
exportJSON() {
|
|
580
|
-
return {
|
|
581
|
-
type: "button-block",
|
|
582
|
-
version: 1,
|
|
583
|
-
text: this.__text,
|
|
584
|
-
url: this.__url
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
isInline() {
|
|
588
|
-
return false;
|
|
589
|
-
}
|
|
590
|
-
getText() {
|
|
591
|
-
return this.__text;
|
|
592
|
-
}
|
|
593
|
-
getUrl() {
|
|
594
|
-
return this.__url;
|
|
595
|
-
}
|
|
596
|
-
setText(text) {
|
|
597
|
-
const writable = this.getWritable();
|
|
598
|
-
writable.__text = text;
|
|
599
|
-
}
|
|
600
|
-
setUrl(url) {
|
|
601
|
-
const writable = this.getWritable();
|
|
602
|
-
writable.__url = url;
|
|
603
|
-
}
|
|
604
|
-
decorate() {
|
|
605
|
-
return /* @__PURE__ */ jsx(ButtonBlockComponent, { nodeKey: this.__key, text: this.__text, url: this.__url });
|
|
606
|
-
}
|
|
462
|
+
var ShowTools = (_ref) => {
|
|
463
|
+
var {
|
|
464
|
+
initial,
|
|
465
|
+
dispatch,
|
|
466
|
+
children
|
|
467
|
+
} = _ref;
|
|
468
|
+
return /* @__PURE__ */ jsx(Context$6.Provider, {
|
|
469
|
+
value: initial,
|
|
470
|
+
children: /* @__PURE__ */ jsx(DispatchShowTools.Provider, {
|
|
471
|
+
value: dispatch,
|
|
472
|
+
children
|
|
473
|
+
})
|
|
474
|
+
});
|
|
475
|
+
};
|
|
476
|
+
ShowTools.displayName = "JVR.ShowTools";
|
|
477
|
+
var initialState$4 = {};
|
|
478
|
+
var Context$5 = /* @__PURE__ */ createContext(initialState$4);
|
|
479
|
+
var reducer$4 = (state, action) => _extends({}, state, action);
|
|
480
|
+
var useExpandsStore = () => {
|
|
481
|
+
return useContext(Context$5);
|
|
482
|
+
};
|
|
483
|
+
var DispatchExpands = /* @__PURE__ */ createContext(() => {
|
|
484
|
+
});
|
|
485
|
+
DispatchExpands.displayName = "JVR.DispatchExpands";
|
|
486
|
+
function useExpands() {
|
|
487
|
+
return useReducer(reducer$4, initialState$4);
|
|
607
488
|
}
|
|
608
|
-
function
|
|
609
|
-
return
|
|
489
|
+
function useExpandsDispatch() {
|
|
490
|
+
return useContext(DispatchExpands);
|
|
610
491
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
492
|
+
var Expands = (_ref) => {
|
|
493
|
+
var {
|
|
494
|
+
initial,
|
|
495
|
+
dispatch,
|
|
496
|
+
children
|
|
497
|
+
} = _ref;
|
|
498
|
+
return /* @__PURE__ */ jsx(Context$5.Provider, {
|
|
499
|
+
value: initial,
|
|
500
|
+
children: /* @__PURE__ */ jsx(DispatchExpands.Provider, {
|
|
501
|
+
value: dispatch,
|
|
502
|
+
children
|
|
503
|
+
})
|
|
504
|
+
});
|
|
505
|
+
};
|
|
506
|
+
Expands.displayName = "JVR.Expands";
|
|
507
|
+
var initialState$3 = {
|
|
508
|
+
Str: {
|
|
509
|
+
as: "span",
|
|
510
|
+
"data-type": "string",
|
|
511
|
+
style: {
|
|
512
|
+
color: "var(--w-rjv-type-string-color, #cb4b16)"
|
|
513
|
+
},
|
|
514
|
+
className: "w-rjv-type",
|
|
515
|
+
children: "string"
|
|
516
|
+
},
|
|
517
|
+
Url: {
|
|
518
|
+
as: "a",
|
|
519
|
+
style: {
|
|
520
|
+
color: "var(--w-rjv-type-url-color, #0969da)"
|
|
521
|
+
},
|
|
522
|
+
"data-type": "url",
|
|
523
|
+
className: "w-rjv-type",
|
|
524
|
+
children: "url"
|
|
525
|
+
},
|
|
526
|
+
Undefined: {
|
|
527
|
+
style: {
|
|
528
|
+
color: "var(--w-rjv-type-undefined-color, #586e75)"
|
|
529
|
+
},
|
|
530
|
+
as: "span",
|
|
531
|
+
"data-type": "undefined",
|
|
532
|
+
className: "w-rjv-type",
|
|
533
|
+
children: "undefined"
|
|
534
|
+
},
|
|
535
|
+
Null: {
|
|
536
|
+
style: {
|
|
537
|
+
color: "var(--w-rjv-type-null-color, #d33682)"
|
|
538
|
+
},
|
|
539
|
+
as: "span",
|
|
540
|
+
"data-type": "null",
|
|
541
|
+
className: "w-rjv-type",
|
|
542
|
+
children: "null"
|
|
543
|
+
},
|
|
544
|
+
Map: {
|
|
545
|
+
style: {
|
|
546
|
+
color: "var(--w-rjv-type-map-color, #268bd2)",
|
|
547
|
+
marginRight: 3
|
|
548
|
+
},
|
|
549
|
+
as: "span",
|
|
550
|
+
"data-type": "map",
|
|
551
|
+
className: "w-rjv-type",
|
|
552
|
+
children: "Map"
|
|
553
|
+
},
|
|
554
|
+
Nan: {
|
|
555
|
+
style: {
|
|
556
|
+
color: "var(--w-rjv-type-nan-color, #859900)"
|
|
557
|
+
},
|
|
558
|
+
as: "span",
|
|
559
|
+
"data-type": "nan",
|
|
560
|
+
className: "w-rjv-type",
|
|
561
|
+
children: "NaN"
|
|
562
|
+
},
|
|
563
|
+
Bigint: {
|
|
564
|
+
style: {
|
|
565
|
+
color: "var(--w-rjv-type-bigint-color, #268bd2)"
|
|
566
|
+
},
|
|
567
|
+
as: "span",
|
|
568
|
+
"data-type": "bigint",
|
|
569
|
+
className: "w-rjv-type",
|
|
570
|
+
children: "bigint"
|
|
571
|
+
},
|
|
572
|
+
Int: {
|
|
573
|
+
style: {
|
|
574
|
+
color: "var(--w-rjv-type-int-color, #268bd2)"
|
|
575
|
+
},
|
|
576
|
+
as: "span",
|
|
577
|
+
"data-type": "int",
|
|
578
|
+
className: "w-rjv-type",
|
|
579
|
+
children: "int"
|
|
580
|
+
},
|
|
581
|
+
Set: {
|
|
582
|
+
style: {
|
|
583
|
+
color: "var(--w-rjv-type-set-color, #268bd2)",
|
|
584
|
+
marginRight: 3
|
|
585
|
+
},
|
|
586
|
+
as: "span",
|
|
587
|
+
"data-type": "set",
|
|
588
|
+
className: "w-rjv-type",
|
|
589
|
+
children: "Set"
|
|
590
|
+
},
|
|
591
|
+
Float: {
|
|
592
|
+
style: {
|
|
593
|
+
color: "var(--w-rjv-type-float-color, #859900)"
|
|
594
|
+
},
|
|
595
|
+
as: "span",
|
|
596
|
+
"data-type": "float",
|
|
597
|
+
className: "w-rjv-type",
|
|
598
|
+
children: "float"
|
|
599
|
+
},
|
|
600
|
+
True: {
|
|
601
|
+
style: {
|
|
602
|
+
color: "var(--w-rjv-type-boolean-color, #2aa198)"
|
|
603
|
+
},
|
|
604
|
+
as: "span",
|
|
605
|
+
"data-type": "bool",
|
|
606
|
+
className: "w-rjv-type",
|
|
607
|
+
children: "bool"
|
|
608
|
+
},
|
|
609
|
+
False: {
|
|
610
|
+
style: {
|
|
611
|
+
color: "var(--w-rjv-type-boolean-color, #2aa198)"
|
|
612
|
+
},
|
|
613
|
+
as: "span",
|
|
614
|
+
"data-type": "bool",
|
|
615
|
+
className: "w-rjv-type",
|
|
616
|
+
children: "bool"
|
|
617
|
+
},
|
|
618
|
+
Date: {
|
|
619
|
+
style: {
|
|
620
|
+
color: "var(--w-rjv-type-date-color, #268bd2)"
|
|
621
|
+
},
|
|
622
|
+
as: "span",
|
|
623
|
+
"data-type": "date",
|
|
624
|
+
className: "w-rjv-type",
|
|
625
|
+
children: "date"
|
|
670
626
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
] });
|
|
627
|
+
};
|
|
628
|
+
var Context$4 = /* @__PURE__ */ createContext(initialState$3);
|
|
629
|
+
var reducer$3 = (state, action) => _extends({}, state, action);
|
|
630
|
+
var useTypesStore = () => {
|
|
631
|
+
return useContext(Context$4);
|
|
632
|
+
};
|
|
633
|
+
var DispatchTypes = /* @__PURE__ */ createContext(() => {
|
|
634
|
+
});
|
|
635
|
+
DispatchTypes.displayName = "JVR.DispatchTypes";
|
|
636
|
+
function useTypes() {
|
|
637
|
+
return useReducer(reducer$3, initialState$3);
|
|
683
638
|
}
|
|
684
|
-
function
|
|
685
|
-
|
|
686
|
-
const handleMoveUp = () => {
|
|
687
|
-
if (!hoveredBlock) return;
|
|
688
|
-
editor.update(() => {
|
|
689
|
-
const node = $getNodeByKey(hoveredBlock.key);
|
|
690
|
-
if (node) {
|
|
691
|
-
const prevSibling = node.getPreviousSibling();
|
|
692
|
-
if (prevSibling) {
|
|
693
|
-
prevSibling.insertBefore(node);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
});
|
|
697
|
-
};
|
|
698
|
-
const handleMoveDown = () => {
|
|
699
|
-
if (!hoveredBlock) return;
|
|
700
|
-
editor.update(() => {
|
|
701
|
-
const node = $getNodeByKey(hoveredBlock.key);
|
|
702
|
-
if (node) {
|
|
703
|
-
const nextSibling = node.getNextSibling();
|
|
704
|
-
if (nextSibling) {
|
|
705
|
-
nextSibling.insertAfter(node);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
});
|
|
709
|
-
};
|
|
710
|
-
const handleDelete = () => {
|
|
711
|
-
if (!hoveredBlock) return;
|
|
712
|
-
editor.update(() => {
|
|
713
|
-
const node = $getNodeByKey(hoveredBlock.key);
|
|
714
|
-
if (node) {
|
|
715
|
-
node.remove();
|
|
716
|
-
}
|
|
717
|
-
});
|
|
718
|
-
};
|
|
719
|
-
const isVisible = hoveredBlock && hoveredBlock.type !== "variable";
|
|
720
|
-
return /* @__PURE__ */ jsx(
|
|
721
|
-
"div",
|
|
722
|
-
{
|
|
723
|
-
className: `pointer-events-auto absolute z-[100] transition-opacity duration-150 ${isVisible ? "opacity-100" : "opacity-0 pointer-events-none"}`,
|
|
724
|
-
style: {
|
|
725
|
-
top: (hoveredBlock == null ? void 0 : hoveredBlock.top) ?? 0,
|
|
726
|
-
left: 8
|
|
727
|
-
},
|
|
728
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
729
|
-
/* @__PURE__ */ jsx(
|
|
730
|
-
"button",
|
|
731
|
-
{
|
|
732
|
-
onClick: handleMoveUp,
|
|
733
|
-
className: "w-6 h-6 flex items-center justify-center bg-ui-bg-base hover:bg-ui-bg-base-hover rounded text-ui-fg-muted border border-ui-border-base text-xs",
|
|
734
|
-
title: "Przesuń w górę",
|
|
735
|
-
children: "↑"
|
|
736
|
-
}
|
|
737
|
-
),
|
|
738
|
-
/* @__PURE__ */ jsx(
|
|
739
|
-
"button",
|
|
740
|
-
{
|
|
741
|
-
onClick: handleMoveDown,
|
|
742
|
-
className: "w-6 h-6 flex items-center justify-center bg-ui-bg-base hover:bg-ui-bg-base-hover rounded text-ui-fg-muted border border-ui-border-base text-xs",
|
|
743
|
-
title: "Przesuń w dół",
|
|
744
|
-
children: "↓"
|
|
745
|
-
}
|
|
746
|
-
),
|
|
747
|
-
/* @__PURE__ */ jsx(
|
|
748
|
-
"button",
|
|
749
|
-
{
|
|
750
|
-
onClick: handleDelete,
|
|
751
|
-
className: "w-6 h-6 flex items-center justify-center bg-ui-bg-base hover:bg-ui-bg-base-hover rounded text-ui-fg-muted hover:text-ui-fg-error border border-ui-border-base text-xs",
|
|
752
|
-
title: "Usuń",
|
|
753
|
-
children: "✕"
|
|
754
|
-
}
|
|
755
|
-
)
|
|
756
|
-
] })
|
|
757
|
-
}
|
|
758
|
-
);
|
|
639
|
+
function useTypesDispatch() {
|
|
640
|
+
return useContext(DispatchTypes);
|
|
759
641
|
}
|
|
760
|
-
function
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (customBlock) {
|
|
774
|
-
blockElement = customBlock;
|
|
775
|
-
nodeKey = customBlock.dataset.blockKey || null;
|
|
776
|
-
blockType = customBlock.dataset.blockType || null;
|
|
777
|
-
}
|
|
778
|
-
if (!blockElement) {
|
|
779
|
-
const paragraph = target.closest("p.editor-paragraph");
|
|
780
|
-
if (paragraph) {
|
|
781
|
-
blockElement = paragraph;
|
|
782
|
-
blockType = "paragraph";
|
|
783
|
-
editor.getEditorState().read(() => {
|
|
784
|
-
const root = $getRoot();
|
|
785
|
-
const children2 = root.getChildren();
|
|
786
|
-
for (const child of children2) {
|
|
787
|
-
const childElement = editor.getElementByKey(child.getKey());
|
|
788
|
-
if (childElement === paragraph) {
|
|
789
|
-
nodeKey = child.getKey();
|
|
790
|
-
break;
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
if (blockElement && nodeKey) {
|
|
797
|
-
const containerRect = container.getBoundingClientRect();
|
|
798
|
-
const blockRect = blockElement.getBoundingClientRect();
|
|
799
|
-
setHoveredBlock({
|
|
800
|
-
key: nodeKey,
|
|
801
|
-
top: blockRect.top - containerRect.top,
|
|
802
|
-
type: blockType || "unknown"
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
const handleMouseLeave = () => {
|
|
807
|
-
setHoveredBlock(null);
|
|
808
|
-
};
|
|
809
|
-
container.addEventListener("mousemove", handleMouseMove, { capture: true });
|
|
810
|
-
container.addEventListener("mouseleave", handleMouseLeave);
|
|
811
|
-
return () => {
|
|
812
|
-
container.removeEventListener("mousemove", handleMouseMove, { capture: true });
|
|
813
|
-
container.removeEventListener("mouseleave", handleMouseLeave);
|
|
814
|
-
};
|
|
815
|
-
}, [editor]);
|
|
816
|
-
return /* @__PURE__ */ jsxs(
|
|
817
|
-
"div",
|
|
818
|
-
{
|
|
819
|
-
ref: containerRef,
|
|
820
|
-
className: "editor-inner relative pl-12 py-4 pr-4",
|
|
821
|
-
children: [
|
|
822
|
-
/* @__PURE__ */ jsx(FloatingBlockToolbar, { hoveredBlock }),
|
|
823
|
-
children
|
|
824
|
-
]
|
|
825
|
-
}
|
|
826
|
-
);
|
|
642
|
+
function Types(_ref) {
|
|
643
|
+
var {
|
|
644
|
+
initial,
|
|
645
|
+
dispatch,
|
|
646
|
+
children
|
|
647
|
+
} = _ref;
|
|
648
|
+
return /* @__PURE__ */ jsx(Context$4.Provider, {
|
|
649
|
+
value: initial,
|
|
650
|
+
children: /* @__PURE__ */ jsx(DispatchTypes.Provider, {
|
|
651
|
+
value: dispatch,
|
|
652
|
+
children
|
|
653
|
+
})
|
|
654
|
+
});
|
|
827
655
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
656
|
+
Types.displayName = "JVR.Types";
|
|
657
|
+
var _excluded$a = ["style"];
|
|
658
|
+
function TriangleArrow(props) {
|
|
659
|
+
var {
|
|
660
|
+
style
|
|
661
|
+
} = props, reset = _objectWithoutPropertiesLoose(props, _excluded$a);
|
|
662
|
+
var defaultStyle = _extends({
|
|
663
|
+
cursor: "pointer",
|
|
664
|
+
height: "1em",
|
|
665
|
+
width: "1em",
|
|
666
|
+
userSelect: "none",
|
|
667
|
+
display: "inline-flex"
|
|
668
|
+
}, style);
|
|
669
|
+
return /* @__PURE__ */ jsx("svg", _extends({
|
|
670
|
+
viewBox: "0 0 24 24",
|
|
671
|
+
fill: "var(--w-rjv-arrow-color, currentColor)",
|
|
672
|
+
style: defaultStyle
|
|
673
|
+
}, reset, {
|
|
674
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
675
|
+
d: "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"
|
|
676
|
+
})
|
|
677
|
+
}));
|
|
678
|
+
}
|
|
679
|
+
TriangleArrow.displayName = "JVR.TriangleArrow";
|
|
680
|
+
var initialState$2 = {
|
|
681
|
+
Arrow: {
|
|
682
|
+
as: "span",
|
|
683
|
+
className: "w-rjv-arrow",
|
|
684
|
+
style: {
|
|
685
|
+
transform: "rotate(0deg)",
|
|
686
|
+
transition: "all 0.3s"
|
|
687
|
+
},
|
|
688
|
+
children: /* @__PURE__ */ jsx(TriangleArrow, {})
|
|
689
|
+
},
|
|
690
|
+
Colon: {
|
|
691
|
+
as: "span",
|
|
692
|
+
style: {
|
|
693
|
+
color: "var(--w-rjv-colon-color, var(--w-rjv-color))",
|
|
694
|
+
marginLeft: 0,
|
|
695
|
+
marginRight: 2
|
|
696
|
+
},
|
|
697
|
+
className: "w-rjv-colon",
|
|
698
|
+
children: ":"
|
|
699
|
+
},
|
|
700
|
+
Quote: {
|
|
701
|
+
as: "span",
|
|
702
|
+
style: {
|
|
703
|
+
color: "var(--w-rjv-quotes-color, #236a7c)"
|
|
704
|
+
},
|
|
705
|
+
className: "w-rjv-quotes",
|
|
706
|
+
children: '"'
|
|
707
|
+
},
|
|
708
|
+
ValueQuote: {
|
|
709
|
+
as: "span",
|
|
710
|
+
style: {
|
|
711
|
+
color: "var(--w-rjv-quotes-string-color, #cb4b16)"
|
|
712
|
+
},
|
|
713
|
+
className: "w-rjv-quotes",
|
|
714
|
+
children: '"'
|
|
715
|
+
},
|
|
716
|
+
BracketsLeft: {
|
|
717
|
+
as: "span",
|
|
718
|
+
style: {
|
|
719
|
+
color: "var(--w-rjv-brackets-color, #236a7c)"
|
|
720
|
+
},
|
|
721
|
+
className: "w-rjv-brackets-start",
|
|
722
|
+
children: "["
|
|
723
|
+
},
|
|
724
|
+
BracketsRight: {
|
|
725
|
+
as: "span",
|
|
726
|
+
style: {
|
|
727
|
+
color: "var(--w-rjv-brackets-color, #236a7c)"
|
|
728
|
+
},
|
|
729
|
+
className: "w-rjv-brackets-end",
|
|
730
|
+
children: "]"
|
|
731
|
+
},
|
|
732
|
+
BraceLeft: {
|
|
733
|
+
as: "span",
|
|
734
|
+
style: {
|
|
735
|
+
color: "var(--w-rjv-curlybraces-color, #236a7c)"
|
|
736
|
+
},
|
|
737
|
+
className: "w-rjv-curlybraces-start",
|
|
738
|
+
children: "{"
|
|
739
|
+
},
|
|
740
|
+
BraceRight: {
|
|
741
|
+
as: "span",
|
|
742
|
+
style: {
|
|
743
|
+
color: "var(--w-rjv-curlybraces-color, #236a7c)"
|
|
744
|
+
},
|
|
745
|
+
className: "w-rjv-curlybraces-end",
|
|
746
|
+
children: "}"
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
var Context$3 = /* @__PURE__ */ createContext(initialState$2);
|
|
750
|
+
var reducer$2 = (state, action) => _extends({}, state, action);
|
|
751
|
+
var useSymbolsStore = () => {
|
|
752
|
+
return useContext(Context$3);
|
|
753
|
+
};
|
|
754
|
+
var DispatchSymbols = /* @__PURE__ */ createContext(() => {
|
|
755
|
+
});
|
|
756
|
+
DispatchSymbols.displayName = "JVR.DispatchSymbols";
|
|
757
|
+
function useSymbols() {
|
|
758
|
+
return useReducer(reducer$2, initialState$2);
|
|
759
|
+
}
|
|
760
|
+
function useSymbolsDispatch() {
|
|
761
|
+
return useContext(DispatchSymbols);
|
|
762
|
+
}
|
|
763
|
+
var Symbols = (_ref) => {
|
|
764
|
+
var {
|
|
765
|
+
initial,
|
|
766
|
+
dispatch,
|
|
767
|
+
children
|
|
768
|
+
} = _ref;
|
|
769
|
+
return /* @__PURE__ */ jsx(Context$3.Provider, {
|
|
770
|
+
value: initial,
|
|
771
|
+
children: /* @__PURE__ */ jsx(DispatchSymbols.Provider, {
|
|
772
|
+
value: dispatch,
|
|
773
|
+
children
|
|
774
|
+
})
|
|
775
|
+
});
|
|
776
|
+
};
|
|
777
|
+
Symbols.displayName = "JVR.Symbols";
|
|
778
|
+
var initialState$1 = {
|
|
779
|
+
Copied: {
|
|
780
|
+
className: "w-rjv-copied",
|
|
781
|
+
style: {
|
|
782
|
+
height: "1em",
|
|
783
|
+
width: "1em",
|
|
784
|
+
cursor: "pointer",
|
|
785
|
+
verticalAlign: "middle",
|
|
786
|
+
marginLeft: 5
|
|
860
787
|
}
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
const newValue = currentValue.slice(0, selectionStart) + text + currentValue.slice(selectionEnd);
|
|
870
|
-
const nativeInputValueSetter = (_a = Object.getOwnPropertyDescriptor(
|
|
871
|
-
element instanceof HTMLTextAreaElement ? window.HTMLTextAreaElement.prototype : window.HTMLInputElement.prototype,
|
|
872
|
-
"value"
|
|
873
|
-
)) == null ? void 0 : _a.set;
|
|
874
|
-
nativeInputValueSetter == null ? void 0 : nativeInputValueSetter.call(element, newValue);
|
|
875
|
-
element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
876
|
-
setTimeout(() => {
|
|
877
|
-
element.focus();
|
|
878
|
-
element.setSelectionRange(selectionStart + text.length, selectionStart + text.length);
|
|
879
|
-
}, 0);
|
|
880
|
-
lastActiveFieldRef.current = null;
|
|
881
|
-
} else {
|
|
882
|
-
editor.dispatchCommand(INSERT_VARIABLE_COMMAND2, variable);
|
|
788
|
+
},
|
|
789
|
+
CountInfo: {
|
|
790
|
+
as: "span",
|
|
791
|
+
className: "w-rjv-object-size",
|
|
792
|
+
style: {
|
|
793
|
+
color: "var(--w-rjv-info-color, #0000004d)",
|
|
794
|
+
paddingLeft: 8,
|
|
795
|
+
fontStyle: "italic"
|
|
883
796
|
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex gap-1 p-2 border-b border-ui-border-base bg-ui-bg-subtle sticky top-0 z-10", children: [
|
|
899
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
900
|
-
/* @__PURE__ */ jsxs(
|
|
901
|
-
"button",
|
|
902
|
-
{
|
|
903
|
-
type: "button",
|
|
904
|
-
onClick: () => setShowBlockMenu(!showBlockMenu),
|
|
905
|
-
className: "flex items-center gap-1 px-2 py-1 hover:bg-ui-bg-base-hover rounded text-sm",
|
|
906
|
-
children: [
|
|
907
|
-
/* @__PURE__ */ jsx(Plus, { className: "w-4 h-4" }),
|
|
908
|
-
"Blok"
|
|
909
|
-
]
|
|
910
|
-
}
|
|
911
|
-
),
|
|
912
|
-
showBlockMenu && /* @__PURE__ */ jsxs("div", { className: "absolute top-full left-0 mt-1 bg-ui-bg-base border border-ui-border-base rounded shadow-lg z-20 min-w-[150px]", children: [
|
|
913
|
-
/* @__PURE__ */ jsxs(
|
|
914
|
-
"button",
|
|
915
|
-
{
|
|
916
|
-
type: "button",
|
|
917
|
-
onClick: insertParagraph,
|
|
918
|
-
className: "flex items-center gap-2 w-full text-left px-3 py-2 hover:bg-ui-bg-base-hover text-sm",
|
|
919
|
-
children: [
|
|
920
|
-
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "¶" }),
|
|
921
|
-
"Paragraph"
|
|
922
|
-
]
|
|
923
|
-
}
|
|
924
|
-
),
|
|
925
|
-
/* @__PURE__ */ jsxs(
|
|
926
|
-
"button",
|
|
927
|
-
{
|
|
928
|
-
type: "button",
|
|
929
|
-
onClick: insertDivider,
|
|
930
|
-
className: "flex items-center gap-2 w-full text-left px-3 py-2 hover:bg-ui-bg-base-hover text-sm",
|
|
931
|
-
children: [
|
|
932
|
-
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "―" }),
|
|
933
|
-
"Divider"
|
|
934
|
-
]
|
|
935
|
-
}
|
|
936
|
-
),
|
|
937
|
-
/* @__PURE__ */ jsxs(
|
|
938
|
-
"button",
|
|
939
|
-
{
|
|
940
|
-
type: "button",
|
|
941
|
-
onClick: insertButton,
|
|
942
|
-
className: "flex items-center gap-2 w-full text-left px-3 py-2 hover:bg-ui-bg-base-hover text-sm",
|
|
943
|
-
children: [
|
|
944
|
-
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "▢" }),
|
|
945
|
-
"Button"
|
|
946
|
-
]
|
|
947
|
-
}
|
|
948
|
-
)
|
|
949
|
-
] })
|
|
950
|
-
] }),
|
|
951
|
-
/* @__PURE__ */ jsx("div", { className: "w-px bg-ui-border-base mx-1" }),
|
|
952
|
-
/* @__PURE__ */ jsx(
|
|
953
|
-
"button",
|
|
954
|
-
{
|
|
955
|
-
type: "button",
|
|
956
|
-
onClick: formatBold,
|
|
957
|
-
className: "px-2 py-1 hover:bg-ui-bg-base-hover rounded text-sm font-bold",
|
|
958
|
-
title: "Pogrubienie",
|
|
959
|
-
children: "B"
|
|
960
|
-
}
|
|
961
|
-
),
|
|
962
|
-
/* @__PURE__ */ jsx(
|
|
963
|
-
"button",
|
|
964
|
-
{
|
|
965
|
-
type: "button",
|
|
966
|
-
onClick: formatItalic,
|
|
967
|
-
className: "px-2 py-1 hover:bg-ui-bg-base-hover rounded text-sm italic",
|
|
968
|
-
title: "Kursywa",
|
|
969
|
-
children: "I"
|
|
970
|
-
}
|
|
971
|
-
),
|
|
972
|
-
/* @__PURE__ */ jsx("div", { className: "w-px bg-ui-border-base mx-1" }),
|
|
973
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
974
|
-
/* @__PURE__ */ jsx(
|
|
975
|
-
"button",
|
|
976
|
-
{
|
|
977
|
-
type: "button",
|
|
978
|
-
onMouseDown: captureActiveField,
|
|
979
|
-
onClick: () => setShowVariables(!showVariables),
|
|
980
|
-
className: "px-2 py-1 hover:bg-ui-bg-base-hover rounded text-sm font-mono",
|
|
981
|
-
title: "Wstaw zmienną",
|
|
982
|
-
children: "{{ }}"
|
|
983
|
-
}
|
|
984
|
-
),
|
|
985
|
-
showVariables && /* @__PURE__ */ jsxs("div", { className: "absolute top-full left-0 mt-1 bg-ui-bg-base border border-ui-border-base rounded shadow-lg z-20 min-w-[220px] max-h-48 overflow-auto", children: [
|
|
986
|
-
/* @__PURE__ */ jsx("div", { className: "px-3 py-1 text-xs text-ui-fg-muted border-b border-ui-border-base", children: "Dostępne zmienne" }),
|
|
987
|
-
AVAILABLE_VARIABLES.map((v) => /* @__PURE__ */ jsx(
|
|
988
|
-
"button",
|
|
989
|
-
{
|
|
990
|
-
type: "button",
|
|
991
|
-
onClick: () => insertVariable(v),
|
|
992
|
-
className: "block w-full text-left px-3 py-2 hover:bg-ui-bg-base-hover text-sm font-mono",
|
|
993
|
-
children: `{{${v}}}`
|
|
994
|
-
},
|
|
995
|
-
v
|
|
996
|
-
))
|
|
997
|
-
] })
|
|
998
|
-
] })
|
|
999
|
-
] });
|
|
1000
|
-
}
|
|
1001
|
-
const INSERT_PARAGRAPH_BLOCK_COMMAND = createCommand("INSERT_PARAGRAPH_BLOCK");
|
|
1002
|
-
const INSERT_DIVIDER_COMMAND = createCommand("INSERT_DIVIDER");
|
|
1003
|
-
const INSERT_BUTTON_COMMAND = createCommand("INSERT_BUTTON");
|
|
1004
|
-
const INSERT_VARIABLE_COMMAND = createCommand("INSERT_VARIABLE");
|
|
1005
|
-
function registerBlockCommands(editor) {
|
|
1006
|
-
const unregisterParagraph = editor.registerCommand(
|
|
1007
|
-
INSERT_PARAGRAPH_BLOCK_COMMAND,
|
|
1008
|
-
() => {
|
|
1009
|
-
const paragraphNode = $createParagraphNode();
|
|
1010
|
-
$insertNodes([paragraphNode]);
|
|
1011
|
-
paragraphNode.select();
|
|
1012
|
-
return true;
|
|
1013
|
-
},
|
|
1014
|
-
COMMAND_PRIORITY_LOW
|
|
1015
|
-
);
|
|
1016
|
-
const unregisterDivider = editor.registerCommand(
|
|
1017
|
-
INSERT_DIVIDER_COMMAND,
|
|
1018
|
-
() => {
|
|
1019
|
-
const dividerNode = $createDividerBlockNode();
|
|
1020
|
-
$insertNodes([dividerNode]);
|
|
1021
|
-
return true;
|
|
1022
|
-
},
|
|
1023
|
-
COMMAND_PRIORITY_LOW
|
|
1024
|
-
);
|
|
1025
|
-
const unregisterButton = editor.registerCommand(
|
|
1026
|
-
INSERT_BUTTON_COMMAND,
|
|
1027
|
-
() => {
|
|
1028
|
-
const buttonNode = $createButtonBlockNode();
|
|
1029
|
-
$insertNodes([buttonNode]);
|
|
1030
|
-
return true;
|
|
1031
|
-
},
|
|
1032
|
-
COMMAND_PRIORITY_LOW
|
|
1033
|
-
);
|
|
1034
|
-
const unregisterVariable = editor.registerCommand(
|
|
1035
|
-
INSERT_VARIABLE_COMMAND,
|
|
1036
|
-
(variableName) => {
|
|
1037
|
-
const variableNode = $createVariableNode(variableName);
|
|
1038
|
-
$insertNodes([variableNode]);
|
|
1039
|
-
return true;
|
|
797
|
+
},
|
|
798
|
+
CountInfoExtra: {
|
|
799
|
+
as: "span",
|
|
800
|
+
className: "w-rjv-object-extra",
|
|
801
|
+
style: {
|
|
802
|
+
paddingLeft: 8
|
|
803
|
+
}
|
|
804
|
+
},
|
|
805
|
+
Ellipsis: {
|
|
806
|
+
as: "span",
|
|
807
|
+
style: {
|
|
808
|
+
cursor: "pointer",
|
|
809
|
+
color: "var(--w-rjv-ellipsis-color, #cb4b16)",
|
|
810
|
+
userSelect: "none"
|
|
1040
811
|
},
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
name: "@codee/builder-blocks",
|
|
1052
|
-
nodes: () => [VariableNode, DividerBlockNode, ButtonBlockNode],
|
|
1053
|
-
register: registerBlockCommands
|
|
1054
|
-
});
|
|
1055
|
-
const editorTheme = {
|
|
1056
|
-
paragraph: "editor-paragraph mb-1",
|
|
1057
|
-
text: {
|
|
1058
|
-
bold: "font-bold",
|
|
1059
|
-
italic: "italic",
|
|
1060
|
-
underline: "underline"
|
|
812
|
+
className: "w-rjv-ellipsis",
|
|
813
|
+
children: "..."
|
|
814
|
+
},
|
|
815
|
+
Row: {
|
|
816
|
+
as: "div",
|
|
817
|
+
className: "w-rjv-line"
|
|
818
|
+
},
|
|
819
|
+
KeyName: {
|
|
820
|
+
as: "span",
|
|
821
|
+
className: "w-rjv-object-key"
|
|
1061
822
|
}
|
|
1062
823
|
};
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
HistoryExtension,
|
|
1070
|
-
BuilderBlocksExtension
|
|
1071
|
-
]
|
|
824
|
+
var Context$2 = /* @__PURE__ */ createContext(initialState$1);
|
|
825
|
+
var reducer$1 = (state, action) => _extends({}, state, action);
|
|
826
|
+
var useSectionStore = () => {
|
|
827
|
+
return useContext(Context$2);
|
|
828
|
+
};
|
|
829
|
+
var DispatchSection = /* @__PURE__ */ createContext(() => {
|
|
1072
830
|
});
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
editorState.read(() => {
|
|
1077
|
-
const json = editorState.toJSON();
|
|
1078
|
-
setOutput(JSON.stringify(json, null, 2));
|
|
1079
|
-
});
|
|
1080
|
-
}, []);
|
|
1081
|
-
return /* @__PURE__ */ jsxs(Container$1, { className: "p-8", children: [
|
|
1082
|
-
/* @__PURE__ */ jsx(Heading, { level: "h1", className: "mb-6", children: "Builder - Template Editor (Extensions API)" }),
|
|
1083
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-8", children: [
|
|
1084
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1085
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-ui-fg-subtle", children: "Edytor" }),
|
|
1086
|
-
/* @__PURE__ */ jsx(
|
|
1087
|
-
LexicalExtensionComposer,
|
|
1088
|
-
{
|
|
1089
|
-
extension: BuilderEditorExtension,
|
|
1090
|
-
contentEditable: null,
|
|
1091
|
-
children: /* @__PURE__ */ jsxs("div", { className: "border border-ui-border-base rounded-lg bg-white", children: [
|
|
1092
|
-
/* @__PURE__ */ jsx(
|
|
1093
|
-
ToolbarPlugin,
|
|
1094
|
-
{
|
|
1095
|
-
INSERT_PARAGRAPH_BLOCK_COMMAND,
|
|
1096
|
-
INSERT_DIVIDER_COMMAND,
|
|
1097
|
-
INSERT_BUTTON_COMMAND,
|
|
1098
|
-
INSERT_VARIABLE_COMMAND
|
|
1099
|
-
}
|
|
1100
|
-
),
|
|
1101
|
-
/* @__PURE__ */ jsx(EditorInner, { children: /* @__PURE__ */ jsx(ContentEditable, { className: "min-h-[400px] outline-none" }) }),
|
|
1102
|
-
/* @__PURE__ */ jsx(OnChangePlugin, { onChange: handleChange })
|
|
1103
|
-
] })
|
|
1104
|
-
}
|
|
1105
|
-
)
|
|
1106
|
-
] }),
|
|
1107
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1108
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-ui-fg-subtle", children: "Output (Lexical State)" }),
|
|
1109
|
-
/* @__PURE__ */ jsx("div", { className: "border border-ui-border-base rounded-lg p-4 bg-ui-bg-subtle min-h-[400px] max-h-[600px] overflow-auto", children: /* @__PURE__ */ jsx("pre", { className: "text-xs font-mono whitespace-pre-wrap", children: output || "..." }) })
|
|
1110
|
-
] })
|
|
1111
|
-
] })
|
|
1112
|
-
] });
|
|
1113
|
-
};
|
|
1114
|
-
const config$6 = defineRouteConfig({
|
|
1115
|
-
label: "Builder - Lexical",
|
|
1116
|
-
icon: PuzzleSolid
|
|
1117
|
-
});
|
|
1118
|
-
function _extends() {
|
|
1119
|
-
return _extends = Object.assign ? Object.assign.bind() : function(n2) {
|
|
1120
|
-
for (var e2 = 1; e2 < arguments.length; e2++) {
|
|
1121
|
-
var t2 = arguments[e2];
|
|
1122
|
-
for (var r in t2) ({}).hasOwnProperty.call(t2, r) && (n2[r] = t2[r]);
|
|
1123
|
-
}
|
|
1124
|
-
return n2;
|
|
1125
|
-
}, _extends.apply(null, arguments);
|
|
1126
|
-
}
|
|
1127
|
-
function _objectWithoutPropertiesLoose(r, e2) {
|
|
1128
|
-
if (null == r) return {};
|
|
1129
|
-
var t2 = {};
|
|
1130
|
-
for (var n2 in r) if ({}.hasOwnProperty.call(r, n2)) {
|
|
1131
|
-
if (-1 !== e2.indexOf(n2)) continue;
|
|
1132
|
-
t2[n2] = r[n2];
|
|
1133
|
-
}
|
|
1134
|
-
return t2;
|
|
1135
|
-
}
|
|
1136
|
-
var initialState$5 = {};
|
|
1137
|
-
var Context$6 = /* @__PURE__ */ createContext(initialState$5);
|
|
1138
|
-
var reducer$5 = (state, action) => _extends({}, state, action);
|
|
1139
|
-
var useShowToolsStore = () => {
|
|
1140
|
-
return useContext(Context$6);
|
|
1141
|
-
};
|
|
1142
|
-
var DispatchShowTools = /* @__PURE__ */ createContext(() => {
|
|
1143
|
-
});
|
|
1144
|
-
DispatchShowTools.displayName = "JVR.DispatchShowTools";
|
|
1145
|
-
function useShowTools() {
|
|
1146
|
-
return useReducer(reducer$5, initialState$5);
|
|
831
|
+
DispatchSection.displayName = "JVR.DispatchSection";
|
|
832
|
+
function useSection() {
|
|
833
|
+
return useReducer(reducer$1, initialState$1);
|
|
1147
834
|
}
|
|
1148
|
-
function
|
|
1149
|
-
return useContext(
|
|
835
|
+
function useSectionDispatch() {
|
|
836
|
+
return useContext(DispatchSection);
|
|
1150
837
|
}
|
|
1151
|
-
var
|
|
838
|
+
var Section = (_ref) => {
|
|
1152
839
|
var {
|
|
1153
840
|
initial,
|
|
1154
841
|
dispatch,
|
|
1155
842
|
children
|
|
1156
843
|
} = _ref;
|
|
1157
|
-
return /* @__PURE__ */ jsx(Context$
|
|
844
|
+
return /* @__PURE__ */ jsx(Context$2.Provider, {
|
|
1158
845
|
value: initial,
|
|
1159
|
-
children: /* @__PURE__ */ jsx(
|
|
846
|
+
children: /* @__PURE__ */ jsx(DispatchSection.Provider, {
|
|
1160
847
|
value: dispatch,
|
|
1161
848
|
children
|
|
1162
849
|
})
|
|
1163
850
|
});
|
|
1164
851
|
};
|
|
1165
|
-
|
|
1166
|
-
var initialState
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
var useExpandsStore = () => {
|
|
1170
|
-
return useContext(Context$5);
|
|
852
|
+
Section.displayName = "JVR.Section";
|
|
853
|
+
var initialState = {
|
|
854
|
+
objectSortKeys: false,
|
|
855
|
+
indentWidth: 15
|
|
1171
856
|
};
|
|
1172
|
-
var
|
|
857
|
+
var Context$1 = /* @__PURE__ */ createContext(initialState);
|
|
858
|
+
Context$1.displayName = "JVR.Context";
|
|
859
|
+
var DispatchContext = /* @__PURE__ */ createContext(() => {
|
|
1173
860
|
});
|
|
1174
|
-
|
|
1175
|
-
function
|
|
1176
|
-
return
|
|
1177
|
-
}
|
|
1178
|
-
function useExpandsDispatch() {
|
|
1179
|
-
return useContext(DispatchExpands);
|
|
861
|
+
DispatchContext.displayName = "JVR.DispatchContext";
|
|
862
|
+
function reducer(state, action) {
|
|
863
|
+
return _extends({}, state, action);
|
|
1180
864
|
}
|
|
1181
|
-
var
|
|
865
|
+
var useStore = () => {
|
|
866
|
+
return useContext(Context$1);
|
|
867
|
+
};
|
|
868
|
+
var Provider = (_ref) => {
|
|
1182
869
|
var {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
870
|
+
children,
|
|
871
|
+
initialState: init,
|
|
872
|
+
initialTypes
|
|
1186
873
|
} = _ref;
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
874
|
+
var [state, dispatch] = useReducer(reducer, Object.assign({}, initialState, init));
|
|
875
|
+
var [showTools, showToolsDispatch] = useShowTools();
|
|
876
|
+
var [expands, expandsDispatch] = useExpands();
|
|
877
|
+
var [types, typesDispatch] = useTypes();
|
|
878
|
+
var [symbols, symbolsDispatch] = useSymbols();
|
|
879
|
+
var [section, sectionDispatch] = useSection();
|
|
880
|
+
useEffect(() => dispatch(_extends({}, init)), [init]);
|
|
881
|
+
return /* @__PURE__ */ jsx(Context$1.Provider, {
|
|
882
|
+
value: state,
|
|
883
|
+
children: /* @__PURE__ */ jsx(DispatchContext.Provider, {
|
|
1190
884
|
value: dispatch,
|
|
1191
|
-
children
|
|
885
|
+
children: /* @__PURE__ */ jsx(ShowTools, {
|
|
886
|
+
initial: showTools,
|
|
887
|
+
dispatch: showToolsDispatch,
|
|
888
|
+
children: /* @__PURE__ */ jsx(Expands, {
|
|
889
|
+
initial: expands,
|
|
890
|
+
dispatch: expandsDispatch,
|
|
891
|
+
children: /* @__PURE__ */ jsx(Types, {
|
|
892
|
+
initial: _extends({}, types, initialTypes),
|
|
893
|
+
dispatch: typesDispatch,
|
|
894
|
+
children: /* @__PURE__ */ jsx(Symbols, {
|
|
895
|
+
initial: symbols,
|
|
896
|
+
dispatch: symbolsDispatch,
|
|
897
|
+
children: /* @__PURE__ */ jsx(Section, {
|
|
898
|
+
initial: section,
|
|
899
|
+
dispatch: sectionDispatch,
|
|
900
|
+
children
|
|
901
|
+
})
|
|
902
|
+
})
|
|
903
|
+
})
|
|
904
|
+
})
|
|
905
|
+
})
|
|
1192
906
|
})
|
|
1193
907
|
});
|
|
1194
908
|
};
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
as: "span",
|
|
1199
|
-
"data-type": "string",
|
|
1200
|
-
style: {
|
|
1201
|
-
color: "var(--w-rjv-type-string-color, #cb4b16)"
|
|
1202
|
-
},
|
|
1203
|
-
className: "w-rjv-type",
|
|
1204
|
-
children: "string"
|
|
1205
|
-
},
|
|
1206
|
-
Url: {
|
|
1207
|
-
as: "a",
|
|
1208
|
-
style: {
|
|
1209
|
-
color: "var(--w-rjv-type-url-color, #0969da)"
|
|
1210
|
-
},
|
|
1211
|
-
"data-type": "url",
|
|
1212
|
-
className: "w-rjv-type",
|
|
1213
|
-
children: "url"
|
|
1214
|
-
},
|
|
1215
|
-
Undefined: {
|
|
1216
|
-
style: {
|
|
1217
|
-
color: "var(--w-rjv-type-undefined-color, #586e75)"
|
|
1218
|
-
},
|
|
1219
|
-
as: "span",
|
|
1220
|
-
"data-type": "undefined",
|
|
1221
|
-
className: "w-rjv-type",
|
|
1222
|
-
children: "undefined"
|
|
1223
|
-
},
|
|
1224
|
-
Null: {
|
|
1225
|
-
style: {
|
|
1226
|
-
color: "var(--w-rjv-type-null-color, #d33682)"
|
|
1227
|
-
},
|
|
1228
|
-
as: "span",
|
|
1229
|
-
"data-type": "null",
|
|
1230
|
-
className: "w-rjv-type",
|
|
1231
|
-
children: "null"
|
|
1232
|
-
},
|
|
1233
|
-
Map: {
|
|
1234
|
-
style: {
|
|
1235
|
-
color: "var(--w-rjv-type-map-color, #268bd2)",
|
|
1236
|
-
marginRight: 3
|
|
1237
|
-
},
|
|
1238
|
-
as: "span",
|
|
1239
|
-
"data-type": "map",
|
|
1240
|
-
className: "w-rjv-type",
|
|
1241
|
-
children: "Map"
|
|
1242
|
-
},
|
|
1243
|
-
Nan: {
|
|
1244
|
-
style: {
|
|
1245
|
-
color: "var(--w-rjv-type-nan-color, #859900)"
|
|
1246
|
-
},
|
|
1247
|
-
as: "span",
|
|
1248
|
-
"data-type": "nan",
|
|
1249
|
-
className: "w-rjv-type",
|
|
1250
|
-
children: "NaN"
|
|
1251
|
-
},
|
|
1252
|
-
Bigint: {
|
|
1253
|
-
style: {
|
|
1254
|
-
color: "var(--w-rjv-type-bigint-color, #268bd2)"
|
|
1255
|
-
},
|
|
1256
|
-
as: "span",
|
|
1257
|
-
"data-type": "bigint",
|
|
1258
|
-
className: "w-rjv-type",
|
|
1259
|
-
children: "bigint"
|
|
1260
|
-
},
|
|
1261
|
-
Int: {
|
|
1262
|
-
style: {
|
|
1263
|
-
color: "var(--w-rjv-type-int-color, #268bd2)"
|
|
1264
|
-
},
|
|
1265
|
-
as: "span",
|
|
1266
|
-
"data-type": "int",
|
|
1267
|
-
className: "w-rjv-type",
|
|
1268
|
-
children: "int"
|
|
1269
|
-
},
|
|
1270
|
-
Set: {
|
|
1271
|
-
style: {
|
|
1272
|
-
color: "var(--w-rjv-type-set-color, #268bd2)",
|
|
1273
|
-
marginRight: 3
|
|
1274
|
-
},
|
|
1275
|
-
as: "span",
|
|
1276
|
-
"data-type": "set",
|
|
1277
|
-
className: "w-rjv-type",
|
|
1278
|
-
children: "Set"
|
|
1279
|
-
},
|
|
1280
|
-
Float: {
|
|
1281
|
-
style: {
|
|
1282
|
-
color: "var(--w-rjv-type-float-color, #859900)"
|
|
1283
|
-
},
|
|
1284
|
-
as: "span",
|
|
1285
|
-
"data-type": "float",
|
|
1286
|
-
className: "w-rjv-type",
|
|
1287
|
-
children: "float"
|
|
1288
|
-
},
|
|
1289
|
-
True: {
|
|
1290
|
-
style: {
|
|
1291
|
-
color: "var(--w-rjv-type-boolean-color, #2aa198)"
|
|
1292
|
-
},
|
|
1293
|
-
as: "span",
|
|
1294
|
-
"data-type": "bool",
|
|
1295
|
-
className: "w-rjv-type",
|
|
1296
|
-
children: "bool"
|
|
1297
|
-
},
|
|
1298
|
-
False: {
|
|
1299
|
-
style: {
|
|
1300
|
-
color: "var(--w-rjv-type-boolean-color, #2aa198)"
|
|
1301
|
-
},
|
|
1302
|
-
as: "span",
|
|
1303
|
-
"data-type": "bool",
|
|
1304
|
-
className: "w-rjv-type",
|
|
1305
|
-
children: "bool"
|
|
1306
|
-
},
|
|
1307
|
-
Date: {
|
|
1308
|
-
style: {
|
|
1309
|
-
color: "var(--w-rjv-type-date-color, #268bd2)"
|
|
1310
|
-
},
|
|
1311
|
-
as: "span",
|
|
1312
|
-
"data-type": "date",
|
|
1313
|
-
className: "w-rjv-type",
|
|
1314
|
-
children: "date"
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
var Context$4 = /* @__PURE__ */ createContext(initialState$3);
|
|
1318
|
-
var reducer$3 = (state, action) => _extends({}, state, action);
|
|
1319
|
-
var useTypesStore = () => {
|
|
1320
|
-
return useContext(Context$4);
|
|
1321
|
-
};
|
|
1322
|
-
var DispatchTypes = /* @__PURE__ */ createContext(() => {
|
|
1323
|
-
});
|
|
1324
|
-
DispatchTypes.displayName = "JVR.DispatchTypes";
|
|
1325
|
-
function useTypes() {
|
|
1326
|
-
return useReducer(reducer$3, initialState$3);
|
|
1327
|
-
}
|
|
1328
|
-
function useTypesDispatch() {
|
|
1329
|
-
return useContext(DispatchTypes);
|
|
909
|
+
Provider.displayName = "JVR.Provider";
|
|
910
|
+
function _objectDestructuringEmpty(t2) {
|
|
911
|
+
if (null == t2) throw new TypeError("Cannot destructure " + t2);
|
|
1330
912
|
}
|
|
1331
|
-
|
|
913
|
+
var _excluded$9 = ["isNumber", "value", "parentValue", "keyName", "keys"], _excluded2$5 = ["as", "render"], _excluded3$1 = ["as", "render"], _excluded4$1 = ["as", "render"], _excluded5$1 = ["as", "style", "render"], _excluded6$1 = ["as", "render"], _excluded7$1 = ["as", "render"], _excluded8$1 = ["as", "render"], _excluded9$1 = ["as", "render"];
|
|
914
|
+
var Quote$1 = (props) => {
|
|
1332
915
|
var {
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
children
|
|
1336
|
-
} = _ref;
|
|
1337
|
-
return /* @__PURE__ */ jsx(Context$4.Provider, {
|
|
1338
|
-
value: initial,
|
|
1339
|
-
children: /* @__PURE__ */ jsx(DispatchTypes.Provider, {
|
|
1340
|
-
value: dispatch,
|
|
1341
|
-
children
|
|
1342
|
-
})
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
1345
|
-
Types.displayName = "JVR.Types";
|
|
1346
|
-
var _excluded$a = ["style"];
|
|
1347
|
-
function TriangleArrow(props) {
|
|
916
|
+
Quote: Comp = {}
|
|
917
|
+
} = useSymbolsStore();
|
|
1348
918
|
var {
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
})
|
|
1366
|
-
}));
|
|
1367
|
-
}
|
|
1368
|
-
TriangleArrow.displayName = "JVR.TriangleArrow";
|
|
1369
|
-
var initialState$2 = {
|
|
1370
|
-
Arrow: {
|
|
1371
|
-
as: "span",
|
|
1372
|
-
className: "w-rjv-arrow",
|
|
1373
|
-
style: {
|
|
1374
|
-
transform: "rotate(0deg)",
|
|
1375
|
-
transition: "all 0.3s"
|
|
1376
|
-
},
|
|
1377
|
-
children: /* @__PURE__ */ jsx(TriangleArrow, {})
|
|
1378
|
-
},
|
|
1379
|
-
Colon: {
|
|
1380
|
-
as: "span",
|
|
1381
|
-
style: {
|
|
1382
|
-
color: "var(--w-rjv-colon-color, var(--w-rjv-color))",
|
|
1383
|
-
marginLeft: 0,
|
|
1384
|
-
marginRight: 2
|
|
1385
|
-
},
|
|
1386
|
-
className: "w-rjv-colon",
|
|
1387
|
-
children: ":"
|
|
1388
|
-
},
|
|
1389
|
-
Quote: {
|
|
1390
|
-
as: "span",
|
|
1391
|
-
style: {
|
|
1392
|
-
color: "var(--w-rjv-quotes-color, #236a7c)"
|
|
1393
|
-
},
|
|
1394
|
-
className: "w-rjv-quotes",
|
|
1395
|
-
children: '"'
|
|
1396
|
-
},
|
|
1397
|
-
ValueQuote: {
|
|
1398
|
-
as: "span",
|
|
1399
|
-
style: {
|
|
1400
|
-
color: "var(--w-rjv-quotes-string-color, #cb4b16)"
|
|
1401
|
-
},
|
|
1402
|
-
className: "w-rjv-quotes",
|
|
1403
|
-
children: '"'
|
|
1404
|
-
},
|
|
1405
|
-
BracketsLeft: {
|
|
1406
|
-
as: "span",
|
|
1407
|
-
style: {
|
|
1408
|
-
color: "var(--w-rjv-brackets-color, #236a7c)"
|
|
1409
|
-
},
|
|
1410
|
-
className: "w-rjv-brackets-start",
|
|
1411
|
-
children: "["
|
|
1412
|
-
},
|
|
1413
|
-
BracketsRight: {
|
|
1414
|
-
as: "span",
|
|
1415
|
-
style: {
|
|
1416
|
-
color: "var(--w-rjv-brackets-color, #236a7c)"
|
|
1417
|
-
},
|
|
1418
|
-
className: "w-rjv-brackets-end",
|
|
1419
|
-
children: "]"
|
|
1420
|
-
},
|
|
1421
|
-
BraceLeft: {
|
|
1422
|
-
as: "span",
|
|
1423
|
-
style: {
|
|
1424
|
-
color: "var(--w-rjv-curlybraces-color, #236a7c)"
|
|
1425
|
-
},
|
|
1426
|
-
className: "w-rjv-curlybraces-start",
|
|
1427
|
-
children: "{"
|
|
1428
|
-
},
|
|
1429
|
-
BraceRight: {
|
|
1430
|
-
as: "span",
|
|
1431
|
-
style: {
|
|
1432
|
-
color: "var(--w-rjv-curlybraces-color, #236a7c)"
|
|
1433
|
-
},
|
|
1434
|
-
className: "w-rjv-curlybraces-end",
|
|
1435
|
-
children: "}"
|
|
919
|
+
isNumber,
|
|
920
|
+
value,
|
|
921
|
+
parentValue,
|
|
922
|
+
keyName,
|
|
923
|
+
keys
|
|
924
|
+
} = props, other = _objectWithoutPropertiesLoose(props, _excluded$9);
|
|
925
|
+
if (isNumber) return null;
|
|
926
|
+
var {
|
|
927
|
+
as,
|
|
928
|
+
render
|
|
929
|
+
} = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$5);
|
|
930
|
+
var Elm = as || "span";
|
|
931
|
+
var elmProps = _extends({}, other, reset);
|
|
932
|
+
if (typeof elmProps.children === "string") {
|
|
933
|
+
var trimmed = elmProps.children.trim();
|
|
934
|
+
elmProps.children = trimmed || void 0;
|
|
1436
935
|
}
|
|
936
|
+
var result = {
|
|
937
|
+
value,
|
|
938
|
+
parentValue,
|
|
939
|
+
keyName,
|
|
940
|
+
keys: keys || (keyName ? [keyName] : [])
|
|
941
|
+
};
|
|
942
|
+
var child = render && typeof render === "function" && render(elmProps, result);
|
|
943
|
+
if (child) return child;
|
|
944
|
+
return /* @__PURE__ */ jsx(Elm, _extends({}, elmProps));
|
|
1437
945
|
};
|
|
1438
|
-
|
|
1439
|
-
var
|
|
1440
|
-
var
|
|
1441
|
-
|
|
946
|
+
Quote$1.displayName = "JVR.Quote";
|
|
947
|
+
var ValueQuote$1 = (props) => {
|
|
948
|
+
var {
|
|
949
|
+
ValueQuote: Comp = {}
|
|
950
|
+
} = useSymbolsStore();
|
|
951
|
+
var other = _extends({}, (_objectDestructuringEmpty(props), props));
|
|
952
|
+
var {
|
|
953
|
+
as,
|
|
954
|
+
render
|
|
955
|
+
} = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded3$1);
|
|
956
|
+
var Elm = as || "span";
|
|
957
|
+
var elmProps = _extends({}, other, reset);
|
|
958
|
+
var child = render && typeof render === "function" && render(elmProps, {});
|
|
959
|
+
if (child) return child;
|
|
960
|
+
return /* @__PURE__ */ jsx(Elm, _extends({}, elmProps));
|
|
1442
961
|
};
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
DispatchSymbols.displayName = "JVR.DispatchSymbols";
|
|
1446
|
-
function useSymbols() {
|
|
1447
|
-
return useReducer(reducer$2, initialState$2);
|
|
1448
|
-
}
|
|
1449
|
-
function useSymbolsDispatch() {
|
|
1450
|
-
return useContext(DispatchSymbols);
|
|
1451
|
-
}
|
|
1452
|
-
var Symbols = (_ref) => {
|
|
962
|
+
ValueQuote$1.displayName = "JVR.ValueQuote";
|
|
963
|
+
var Colon$1 = (props) => {
|
|
1453
964
|
var {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
965
|
+
value,
|
|
966
|
+
parentValue,
|
|
967
|
+
keyName,
|
|
968
|
+
keys
|
|
969
|
+
} = props;
|
|
970
|
+
var {
|
|
971
|
+
Colon: Comp = {}
|
|
972
|
+
} = useSymbolsStore();
|
|
973
|
+
var {
|
|
974
|
+
as,
|
|
975
|
+
render
|
|
976
|
+
} = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded4$1);
|
|
977
|
+
var Elm = as || "span";
|
|
978
|
+
var child = render && typeof render === "function" && render(reset, {
|
|
979
|
+
value,
|
|
980
|
+
parentValue,
|
|
981
|
+
keyName,
|
|
982
|
+
keys: keys || (keyName ? [keyName] : [])
|
|
1464
983
|
});
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
var initialState$1 = {
|
|
1468
|
-
Copied: {
|
|
1469
|
-
className: "w-rjv-copied",
|
|
1470
|
-
style: {
|
|
1471
|
-
height: "1em",
|
|
1472
|
-
width: "1em",
|
|
1473
|
-
cursor: "pointer",
|
|
1474
|
-
verticalAlign: "middle",
|
|
1475
|
-
marginLeft: 5
|
|
1476
|
-
}
|
|
1477
|
-
},
|
|
1478
|
-
CountInfo: {
|
|
1479
|
-
as: "span",
|
|
1480
|
-
className: "w-rjv-object-size",
|
|
1481
|
-
style: {
|
|
1482
|
-
color: "var(--w-rjv-info-color, #0000004d)",
|
|
1483
|
-
paddingLeft: 8,
|
|
1484
|
-
fontStyle: "italic"
|
|
1485
|
-
}
|
|
1486
|
-
},
|
|
1487
|
-
CountInfoExtra: {
|
|
1488
|
-
as: "span",
|
|
1489
|
-
className: "w-rjv-object-extra",
|
|
1490
|
-
style: {
|
|
1491
|
-
paddingLeft: 8
|
|
1492
|
-
}
|
|
1493
|
-
},
|
|
1494
|
-
Ellipsis: {
|
|
1495
|
-
as: "span",
|
|
1496
|
-
style: {
|
|
1497
|
-
cursor: "pointer",
|
|
1498
|
-
color: "var(--w-rjv-ellipsis-color, #cb4b16)",
|
|
1499
|
-
userSelect: "none"
|
|
1500
|
-
},
|
|
1501
|
-
className: "w-rjv-ellipsis",
|
|
1502
|
-
children: "..."
|
|
1503
|
-
},
|
|
1504
|
-
Row: {
|
|
1505
|
-
as: "div",
|
|
1506
|
-
className: "w-rjv-line"
|
|
1507
|
-
},
|
|
1508
|
-
KeyName: {
|
|
1509
|
-
as: "span",
|
|
1510
|
-
className: "w-rjv-object-key"
|
|
1511
|
-
}
|
|
1512
|
-
};
|
|
1513
|
-
var Context$2 = /* @__PURE__ */ createContext(initialState$1);
|
|
1514
|
-
var reducer$1 = (state, action) => _extends({}, state, action);
|
|
1515
|
-
var useSectionStore = () => {
|
|
1516
|
-
return useContext(Context$2);
|
|
1517
|
-
};
|
|
1518
|
-
var DispatchSection = /* @__PURE__ */ createContext(() => {
|
|
1519
|
-
});
|
|
1520
|
-
DispatchSection.displayName = "JVR.DispatchSection";
|
|
1521
|
-
function useSection() {
|
|
1522
|
-
return useReducer(reducer$1, initialState$1);
|
|
1523
|
-
}
|
|
1524
|
-
function useSectionDispatch() {
|
|
1525
|
-
return useContext(DispatchSection);
|
|
1526
|
-
}
|
|
1527
|
-
var Section = (_ref) => {
|
|
1528
|
-
var {
|
|
1529
|
-
initial,
|
|
1530
|
-
dispatch,
|
|
1531
|
-
children
|
|
1532
|
-
} = _ref;
|
|
1533
|
-
return /* @__PURE__ */ jsx(Context$2.Provider, {
|
|
1534
|
-
value: initial,
|
|
1535
|
-
children: /* @__PURE__ */ jsx(DispatchSection.Provider, {
|
|
1536
|
-
value: dispatch,
|
|
1537
|
-
children
|
|
1538
|
-
})
|
|
1539
|
-
});
|
|
1540
|
-
};
|
|
1541
|
-
Section.displayName = "JVR.Section";
|
|
1542
|
-
var initialState = {
|
|
1543
|
-
objectSortKeys: false,
|
|
1544
|
-
indentWidth: 15
|
|
1545
|
-
};
|
|
1546
|
-
var Context$1 = /* @__PURE__ */ createContext(initialState);
|
|
1547
|
-
Context$1.displayName = "JVR.Context";
|
|
1548
|
-
var DispatchContext = /* @__PURE__ */ createContext(() => {
|
|
1549
|
-
});
|
|
1550
|
-
DispatchContext.displayName = "JVR.DispatchContext";
|
|
1551
|
-
function reducer(state, action) {
|
|
1552
|
-
return _extends({}, state, action);
|
|
1553
|
-
}
|
|
1554
|
-
var useStore = () => {
|
|
1555
|
-
return useContext(Context$1);
|
|
1556
|
-
};
|
|
1557
|
-
var Provider = (_ref) => {
|
|
1558
|
-
var {
|
|
1559
|
-
children,
|
|
1560
|
-
initialState: init,
|
|
1561
|
-
initialTypes
|
|
1562
|
-
} = _ref;
|
|
1563
|
-
var [state, dispatch] = useReducer(reducer, Object.assign({}, initialState, init));
|
|
1564
|
-
var [showTools, showToolsDispatch] = useShowTools();
|
|
1565
|
-
var [expands, expandsDispatch] = useExpands();
|
|
1566
|
-
var [types, typesDispatch] = useTypes();
|
|
1567
|
-
var [symbols, symbolsDispatch] = useSymbols();
|
|
1568
|
-
var [section, sectionDispatch] = useSection();
|
|
1569
|
-
useEffect(() => dispatch(_extends({}, init)), [init]);
|
|
1570
|
-
return /* @__PURE__ */ jsx(Context$1.Provider, {
|
|
1571
|
-
value: state,
|
|
1572
|
-
children: /* @__PURE__ */ jsx(DispatchContext.Provider, {
|
|
1573
|
-
value: dispatch,
|
|
1574
|
-
children: /* @__PURE__ */ jsx(ShowTools, {
|
|
1575
|
-
initial: showTools,
|
|
1576
|
-
dispatch: showToolsDispatch,
|
|
1577
|
-
children: /* @__PURE__ */ jsx(Expands, {
|
|
1578
|
-
initial: expands,
|
|
1579
|
-
dispatch: expandsDispatch,
|
|
1580
|
-
children: /* @__PURE__ */ jsx(Types, {
|
|
1581
|
-
initial: _extends({}, types, initialTypes),
|
|
1582
|
-
dispatch: typesDispatch,
|
|
1583
|
-
children: /* @__PURE__ */ jsx(Symbols, {
|
|
1584
|
-
initial: symbols,
|
|
1585
|
-
dispatch: symbolsDispatch,
|
|
1586
|
-
children: /* @__PURE__ */ jsx(Section, {
|
|
1587
|
-
initial: section,
|
|
1588
|
-
dispatch: sectionDispatch,
|
|
1589
|
-
children
|
|
1590
|
-
})
|
|
1591
|
-
})
|
|
1592
|
-
})
|
|
1593
|
-
})
|
|
1594
|
-
})
|
|
1595
|
-
})
|
|
1596
|
-
});
|
|
1597
|
-
};
|
|
1598
|
-
Provider.displayName = "JVR.Provider";
|
|
1599
|
-
function _objectDestructuringEmpty(t2) {
|
|
1600
|
-
if (null == t2) throw new TypeError("Cannot destructure " + t2);
|
|
1601
|
-
}
|
|
1602
|
-
var _excluded$9 = ["isNumber", "value", "parentValue", "keyName", "keys"], _excluded2$5 = ["as", "render"], _excluded3$1 = ["as", "render"], _excluded4$1 = ["as", "render"], _excluded5$1 = ["as", "style", "render"], _excluded6$1 = ["as", "render"], _excluded7$1 = ["as", "render"], _excluded8$1 = ["as", "render"], _excluded9$1 = ["as", "render"];
|
|
1603
|
-
var Quote$1 = (props) => {
|
|
1604
|
-
var {
|
|
1605
|
-
Quote: Comp = {}
|
|
1606
|
-
} = useSymbolsStore();
|
|
1607
|
-
var {
|
|
1608
|
-
isNumber,
|
|
1609
|
-
value,
|
|
1610
|
-
parentValue,
|
|
1611
|
-
keyName,
|
|
1612
|
-
keys
|
|
1613
|
-
} = props, other = _objectWithoutPropertiesLoose(props, _excluded$9);
|
|
1614
|
-
if (isNumber) return null;
|
|
1615
|
-
var {
|
|
1616
|
-
as,
|
|
1617
|
-
render
|
|
1618
|
-
} = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded2$5);
|
|
1619
|
-
var Elm = as || "span";
|
|
1620
|
-
var elmProps = _extends({}, other, reset);
|
|
1621
|
-
if (typeof elmProps.children === "string") {
|
|
1622
|
-
var trimmed = elmProps.children.trim();
|
|
1623
|
-
elmProps.children = trimmed || void 0;
|
|
1624
|
-
}
|
|
1625
|
-
var result = {
|
|
1626
|
-
value,
|
|
1627
|
-
parentValue,
|
|
1628
|
-
keyName,
|
|
1629
|
-
keys: keys || (keyName ? [keyName] : [])
|
|
1630
|
-
};
|
|
1631
|
-
var child = render && typeof render === "function" && render(elmProps, result);
|
|
1632
|
-
if (child) return child;
|
|
1633
|
-
return /* @__PURE__ */ jsx(Elm, _extends({}, elmProps));
|
|
1634
|
-
};
|
|
1635
|
-
Quote$1.displayName = "JVR.Quote";
|
|
1636
|
-
var ValueQuote$1 = (props) => {
|
|
1637
|
-
var {
|
|
1638
|
-
ValueQuote: Comp = {}
|
|
1639
|
-
} = useSymbolsStore();
|
|
1640
|
-
var other = _extends({}, (_objectDestructuringEmpty(props), props));
|
|
1641
|
-
var {
|
|
1642
|
-
as,
|
|
1643
|
-
render
|
|
1644
|
-
} = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded3$1);
|
|
1645
|
-
var Elm = as || "span";
|
|
1646
|
-
var elmProps = _extends({}, other, reset);
|
|
1647
|
-
var child = render && typeof render === "function" && render(elmProps, {});
|
|
1648
|
-
if (child) return child;
|
|
1649
|
-
return /* @__PURE__ */ jsx(Elm, _extends({}, elmProps));
|
|
1650
|
-
};
|
|
1651
|
-
ValueQuote$1.displayName = "JVR.ValueQuote";
|
|
1652
|
-
var Colon$1 = (props) => {
|
|
1653
|
-
var {
|
|
1654
|
-
value,
|
|
1655
|
-
parentValue,
|
|
1656
|
-
keyName,
|
|
1657
|
-
keys
|
|
1658
|
-
} = props;
|
|
1659
|
-
var {
|
|
1660
|
-
Colon: Comp = {}
|
|
1661
|
-
} = useSymbolsStore();
|
|
1662
|
-
var {
|
|
1663
|
-
as,
|
|
1664
|
-
render
|
|
1665
|
-
} = Comp, reset = _objectWithoutPropertiesLoose(Comp, _excluded4$1);
|
|
1666
|
-
var Elm = as || "span";
|
|
1667
|
-
var child = render && typeof render === "function" && render(reset, {
|
|
1668
|
-
value,
|
|
1669
|
-
parentValue,
|
|
1670
|
-
keyName,
|
|
1671
|
-
keys: keys || (keyName ? [keyName] : [])
|
|
1672
|
-
});
|
|
1673
|
-
if (child) return child;
|
|
1674
|
-
return /* @__PURE__ */ jsx(Elm, _extends({}, reset));
|
|
984
|
+
if (child) return child;
|
|
985
|
+
return /* @__PURE__ */ jsx(Elm, _extends({}, reset));
|
|
1675
986
|
};
|
|
1676
987
|
Colon$1.displayName = "JVR.Colon";
|
|
1677
988
|
var Arrow$1 = (props) => {
|
|
@@ -3480,249 +2791,938 @@ const JsonViewSection = ({
|
|
|
3480
2791
|
/* @__PURE__ */ jsx(Drawer.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
3481
2792
|
IconButton,
|
|
3482
2793
|
{
|
|
3483
|
-
size: "small",
|
|
3484
|
-
variant: "transparent",
|
|
3485
|
-
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
3486
|
-
children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, {})
|
|
2794
|
+
size: "small",
|
|
2795
|
+
variant: "transparent",
|
|
2796
|
+
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
2797
|
+
children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, {})
|
|
2798
|
+
}
|
|
2799
|
+
) }),
|
|
2800
|
+
/* @__PURE__ */ jsxs(Drawer.Content, { className: "bg-ui-contrast-bg-base text-ui-code-fg-subtle !shadow-elevation-commandbar overflow-hidden border border-none max-md:inset-x-2 max-md:max-w-[calc(100%-16px)]", children: [
|
|
2801
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-code-bg-base flex items-center justify-between px-6 py-4", children: [
|
|
2802
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
|
|
2803
|
+
/* @__PURE__ */ jsx(Drawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { className: "text-ui-contrast-fg-primary", children: /* @__PURE__ */ jsx(
|
|
2804
|
+
Trans,
|
|
2805
|
+
{
|
|
2806
|
+
i18nKey: "json.drawer.header",
|
|
2807
|
+
count: numberOfKeys,
|
|
2808
|
+
components: [
|
|
2809
|
+
/* @__PURE__ */ jsx(
|
|
2810
|
+
"span",
|
|
2811
|
+
{
|
|
2812
|
+
className: "text-ui-fg-subtle"
|
|
2813
|
+
},
|
|
2814
|
+
"count-span"
|
|
2815
|
+
)
|
|
2816
|
+
]
|
|
2817
|
+
}
|
|
2818
|
+
) }) }),
|
|
2819
|
+
/* @__PURE__ */ jsx(Drawer.Description, { className: "sr-only", children: t2("json.drawer.description") })
|
|
2820
|
+
] }),
|
|
2821
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
2822
|
+
/* @__PURE__ */ jsx(Kbd, { className: "bg-ui-contrast-bg-subtle border-ui-contrast-border-base text-ui-contrast-fg-secondary", children: "esc" }),
|
|
2823
|
+
/* @__PURE__ */ jsx(Drawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
2824
|
+
IconButton,
|
|
2825
|
+
{
|
|
2826
|
+
size: "small",
|
|
2827
|
+
variant: "transparent",
|
|
2828
|
+
className: "text-ui-contrast-fg-secondary hover:text-ui-contrast-fg-primary hover:bg-ui-contrast-bg-base-hover active:bg-ui-contrast-bg-base-pressed focus-visible:bg-ui-contrast-bg-base-hover focus-visible:shadow-borders-interactive-with-active",
|
|
2829
|
+
children: /* @__PURE__ */ jsx(XMarkMini, {})
|
|
2830
|
+
}
|
|
2831
|
+
) })
|
|
2832
|
+
] })
|
|
2833
|
+
] }),
|
|
2834
|
+
/* @__PURE__ */ jsx(Drawer.Body, { className: "flex flex-1 flex-col overflow-hidden px-[5px] py-0 pb-[5px]", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-contrast-bg-subtle flex-1 overflow-auto rounded-b-[4px] rounded-t-lg p-3", children: /* @__PURE__ */ jsx(
|
|
2835
|
+
Suspense,
|
|
2836
|
+
{
|
|
2837
|
+
fallback: /* @__PURE__ */ jsx("div", { className: "flex size-full flex-col" }),
|
|
2838
|
+
children: /* @__PURE__ */ jsxs(
|
|
2839
|
+
JsonView,
|
|
2840
|
+
{
|
|
2841
|
+
value: data,
|
|
2842
|
+
displayDataTypes: false,
|
|
2843
|
+
style: {
|
|
2844
|
+
"--w-rjv-font-family": "Roboto Mono, monospace",
|
|
2845
|
+
"--w-rjv-line-color": "var(--contrast-border-base)",
|
|
2846
|
+
"--w-rjv-curlybraces-color": "var(--contrast-fg-secondary)",
|
|
2847
|
+
"--w-rjv-brackets-color": "var(--contrast-fg-secondary)",
|
|
2848
|
+
"--w-rjv-key-string": "var(--contrast-fg-primary)",
|
|
2849
|
+
"--w-rjv-info-color": "var(--contrast-fg-secondary)",
|
|
2850
|
+
"--w-rjv-type-string-color": "var(--tag-green-icon)",
|
|
2851
|
+
"--w-rjv-quotes-string-color": "var(--tag-green-icon)",
|
|
2852
|
+
"--w-rjv-type-boolean-color": "var(--tag-orange-icon)",
|
|
2853
|
+
"--w-rjv-type-int-color": "var(--tag-orange-icon)",
|
|
2854
|
+
"--w-rjv-type-float-color": "var(--tag-orange-icon)",
|
|
2855
|
+
"--w-rjv-type-bigint-color": "var(--tag-orange-icon)",
|
|
2856
|
+
"--w-rjv-key-number": "var(--contrast-fg-secondary)",
|
|
2857
|
+
"--w-rjv-arrow-color": "var(--contrast-fg-secondary)",
|
|
2858
|
+
"--w-rjv-copied-color": "var(--contrast-fg-secondary)",
|
|
2859
|
+
"--w-rjv-copied-success-color": "var(--contrast-fg-primary)",
|
|
2860
|
+
"--w-rjv-colon-color": "var(--contrast-fg-primary)",
|
|
2861
|
+
"--w-rjv-ellipsis-color": "var(--contrast-fg-secondary)"
|
|
2862
|
+
},
|
|
2863
|
+
collapsed: 1,
|
|
2864
|
+
children: [
|
|
2865
|
+
/* @__PURE__ */ jsx(
|
|
2866
|
+
JsonView.Quote,
|
|
2867
|
+
{
|
|
2868
|
+
render: () => /* @__PURE__ */ jsx("span", {})
|
|
2869
|
+
}
|
|
2870
|
+
),
|
|
2871
|
+
/* @__PURE__ */ jsx(
|
|
2872
|
+
JsonView.Null,
|
|
2873
|
+
{
|
|
2874
|
+
render: () => /* @__PURE__ */ jsx("span", { className: "text-ui-tag-red-icon", children: "null" })
|
|
2875
|
+
}
|
|
2876
|
+
),
|
|
2877
|
+
/* @__PURE__ */ jsx(
|
|
2878
|
+
JsonView.Undefined,
|
|
2879
|
+
{
|
|
2880
|
+
render: () => /* @__PURE__ */ jsx("span", { className: "text-ui-tag-blue-icon", children: "undefined" })
|
|
2881
|
+
}
|
|
2882
|
+
),
|
|
2883
|
+
/* @__PURE__ */ jsx(
|
|
2884
|
+
JsonView.CountInfo,
|
|
2885
|
+
{
|
|
2886
|
+
render: (_props, { value }) => {
|
|
2887
|
+
return /* @__PURE__ */ jsx("span", { className: "text-ui-contrast-fg-secondary ml-2", children: t2("general.items", {
|
|
2888
|
+
count: Object.keys(
|
|
2889
|
+
value
|
|
2890
|
+
).length
|
|
2891
|
+
}) });
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
),
|
|
2895
|
+
/* @__PURE__ */ jsx(JsonView.Arrow, { children: /* @__PURE__ */ jsx(TriangleDownMini, { className: "text-ui-contrast-fg-secondary -ml-[0.5px]" }) }),
|
|
2896
|
+
/* @__PURE__ */ jsx(JsonView.Colon, { children: /* @__PURE__ */ jsx("span", { className: "mr-1", children: ":" }) }),
|
|
2897
|
+
/* @__PURE__ */ jsx(
|
|
2898
|
+
JsonView.Copied,
|
|
2899
|
+
{
|
|
2900
|
+
render: ({ style }, { value }) => {
|
|
2901
|
+
return /* @__PURE__ */ jsx(
|
|
2902
|
+
Copied,
|
|
2903
|
+
{
|
|
2904
|
+
style,
|
|
2905
|
+
value
|
|
2906
|
+
}
|
|
2907
|
+
);
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
)
|
|
2911
|
+
]
|
|
2912
|
+
}
|
|
2913
|
+
)
|
|
2914
|
+
}
|
|
2915
|
+
) }) })
|
|
2916
|
+
] })
|
|
2917
|
+
] })
|
|
2918
|
+
] });
|
|
2919
|
+
};
|
|
2920
|
+
const Copied = ({ style, value }) => {
|
|
2921
|
+
const [copied, setCopied] = useState(false);
|
|
2922
|
+
const handler = (e2) => {
|
|
2923
|
+
e2.stopPropagation();
|
|
2924
|
+
setCopied(true);
|
|
2925
|
+
if (typeof value === "string") {
|
|
2926
|
+
navigator.clipboard.writeText(value);
|
|
2927
|
+
} else {
|
|
2928
|
+
const json = JSON.stringify(value, null, 2);
|
|
2929
|
+
navigator.clipboard.writeText(json);
|
|
2930
|
+
}
|
|
2931
|
+
setTimeout(() => {
|
|
2932
|
+
setCopied(false);
|
|
2933
|
+
}, 2e3);
|
|
2934
|
+
};
|
|
2935
|
+
const styl = { whiteSpace: "nowrap", width: "20px" };
|
|
2936
|
+
if (copied) {
|
|
2937
|
+
return /* @__PURE__ */ jsx("span", { style: { ...style, ...styl }, children: /* @__PURE__ */ jsx(Check, { className: "text-ui-contrast-fg-primary" }) });
|
|
2938
|
+
}
|
|
2939
|
+
return /* @__PURE__ */ jsx("span", { style: { ...style, ...styl }, onClick: handler, children: /* @__PURE__ */ jsx(SquareTwoStack, { className: "text-ui-contrast-fg-secondary" }) });
|
|
2940
|
+
};
|
|
2941
|
+
const MetadataSection = ({
|
|
2942
|
+
data,
|
|
2943
|
+
onOpen
|
|
2944
|
+
}) => {
|
|
2945
|
+
const { t: t2 } = useTranslation();
|
|
2946
|
+
if (!data) {
|
|
2947
|
+
return null;
|
|
2948
|
+
}
|
|
2949
|
+
if (!("metadata" in data)) {
|
|
2950
|
+
return null;
|
|
2951
|
+
}
|
|
2952
|
+
const numberOfKeys = data.metadata ? Object.keys(data.metadata).length : 0;
|
|
2953
|
+
return /* @__PURE__ */ jsxs(Container$1, { className: "flex items-center justify-between", children: [
|
|
2954
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
2955
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: t2("metadata.header") }),
|
|
2956
|
+
/* @__PURE__ */ jsx(Badge, { size: "2xsmall", rounded: "full", children: t2("metadata.numberOfKeys", {
|
|
2957
|
+
count: numberOfKeys
|
|
2958
|
+
}) })
|
|
2959
|
+
] }),
|
|
2960
|
+
/* @__PURE__ */ jsx(
|
|
2961
|
+
IconButton,
|
|
2962
|
+
{
|
|
2963
|
+
size: "small",
|
|
2964
|
+
variant: "transparent",
|
|
2965
|
+
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
2966
|
+
onClick: onOpen,
|
|
2967
|
+
children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, {})
|
|
2968
|
+
}
|
|
2969
|
+
)
|
|
2970
|
+
] });
|
|
2971
|
+
};
|
|
2972
|
+
const SingleColumnPage = ({
|
|
2973
|
+
children,
|
|
2974
|
+
widgets,
|
|
2975
|
+
/**
|
|
2976
|
+
* Data of the page which is passed to Widgets, JSON view, and Metadata view.
|
|
2977
|
+
*/
|
|
2978
|
+
data,
|
|
2979
|
+
/**
|
|
2980
|
+
* Whether the page should render an outlet for children routes. Defaults to true.
|
|
2981
|
+
*/
|
|
2982
|
+
hasOutlet = true,
|
|
2983
|
+
/**
|
|
2984
|
+
* Whether to show JSON view of the data. Defaults to false.
|
|
2985
|
+
*/
|
|
2986
|
+
showJSON,
|
|
2987
|
+
/**
|
|
2988
|
+
* Whether to show metadata view of the data. Defaults to false.
|
|
2989
|
+
*/
|
|
2990
|
+
showMetadata
|
|
2991
|
+
}) => {
|
|
2992
|
+
const { before, after } = widgets;
|
|
2993
|
+
const widgetProps = { data };
|
|
2994
|
+
if (showJSON && !data) {
|
|
2995
|
+
if (process.env.NODE_ENV === "development") {
|
|
2996
|
+
console.warn(
|
|
2997
|
+
"`showJSON` is true but no data is provided. To display JSON, provide data prop."
|
|
2998
|
+
);
|
|
2999
|
+
}
|
|
3000
|
+
showJSON = false;
|
|
3001
|
+
}
|
|
3002
|
+
if (showMetadata && !data) {
|
|
3003
|
+
if (process.env.NODE_ENV === "development") {
|
|
3004
|
+
console.warn(
|
|
3005
|
+
"`showMetadata` is true but no data is provided. To display metadata, provide data prop."
|
|
3006
|
+
);
|
|
3007
|
+
}
|
|
3008
|
+
showMetadata = false;
|
|
3009
|
+
}
|
|
3010
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-3", children: [
|
|
3011
|
+
before.map((Component2, i2) => {
|
|
3012
|
+
return /* @__PURE__ */ createElement(Component2, { ...widgetProps, key: i2 });
|
|
3013
|
+
}),
|
|
3014
|
+
children,
|
|
3015
|
+
after.map((Component2, i2) => {
|
|
3016
|
+
return /* @__PURE__ */ createElement(Component2, { ...widgetProps, key: i2 });
|
|
3017
|
+
}),
|
|
3018
|
+
showMetadata && /* @__PURE__ */ jsx(MetadataSection, { data }),
|
|
3019
|
+
showJSON && /* @__PURE__ */ jsx(JsonViewSection, { data }),
|
|
3020
|
+
hasOutlet && /* @__PURE__ */ jsx(Outlet, {})
|
|
3021
|
+
] });
|
|
3022
|
+
};
|
|
3023
|
+
const ListPage$4 = () => {
|
|
3024
|
+
return /* @__PURE__ */ jsx(
|
|
3025
|
+
SingleColumnPage,
|
|
3026
|
+
{
|
|
3027
|
+
widgets: {
|
|
3028
|
+
before: [],
|
|
3029
|
+
after: []
|
|
3030
|
+
},
|
|
3031
|
+
children: "Notifications"
|
|
3032
|
+
}
|
|
3033
|
+
);
|
|
3034
|
+
};
|
|
3035
|
+
const config$6 = defineRouteConfig({
|
|
3036
|
+
label: "Notifications"
|
|
3037
|
+
});
|
|
3038
|
+
class VariableNode extends DecoratorNode {
|
|
3039
|
+
static getType() {
|
|
3040
|
+
return "variable";
|
|
3041
|
+
}
|
|
3042
|
+
static clone(node) {
|
|
3043
|
+
return new VariableNode(node.__variableName, node.__key);
|
|
3044
|
+
}
|
|
3045
|
+
constructor(variableName, key) {
|
|
3046
|
+
super(key);
|
|
3047
|
+
this.__variableName = variableName;
|
|
3048
|
+
}
|
|
3049
|
+
createDOM() {
|
|
3050
|
+
const span = document.createElement("span");
|
|
3051
|
+
span.className = "variable-node";
|
|
3052
|
+
return span;
|
|
3053
|
+
}
|
|
3054
|
+
updateDOM() {
|
|
3055
|
+
return false;
|
|
3056
|
+
}
|
|
3057
|
+
exportDOM() {
|
|
3058
|
+
const element = document.createElement("span");
|
|
3059
|
+
element.textContent = `{{${this.__variableName}}}`;
|
|
3060
|
+
element.className = "variable";
|
|
3061
|
+
return { element };
|
|
3062
|
+
}
|
|
3063
|
+
static importJSON(serializedNode) {
|
|
3064
|
+
return $createVariableNode(serializedNode.variableName);
|
|
3065
|
+
}
|
|
3066
|
+
exportJSON() {
|
|
3067
|
+
return {
|
|
3068
|
+
type: "variable",
|
|
3069
|
+
version: 1,
|
|
3070
|
+
variableName: this.__variableName
|
|
3071
|
+
};
|
|
3072
|
+
}
|
|
3073
|
+
isInline() {
|
|
3074
|
+
return true;
|
|
3075
|
+
}
|
|
3076
|
+
getVariableName() {
|
|
3077
|
+
return this.__variableName;
|
|
3078
|
+
}
|
|
3079
|
+
getTextContent() {
|
|
3080
|
+
return `{{${this.__variableName}}}`;
|
|
3081
|
+
}
|
|
3082
|
+
decorate() {
|
|
3083
|
+
return /* @__PURE__ */ jsx(VariableComponent, { variableName: this.__variableName });
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
function $createVariableNode(variableName) {
|
|
3087
|
+
return new VariableNode(variableName);
|
|
3088
|
+
}
|
|
3089
|
+
function VariableComponent({ variableName }) {
|
|
3090
|
+
return /* @__PURE__ */ jsx(
|
|
3091
|
+
"span",
|
|
3092
|
+
{
|
|
3093
|
+
className: "inline-flex items-center px-1.5 py-0.5 mx-0.5 rounded text-xs font-mono bg-violet-100 text-violet-700 border border-violet-200",
|
|
3094
|
+
contentEditable: false,
|
|
3095
|
+
children: `{{${variableName}}}`
|
|
3096
|
+
}
|
|
3097
|
+
);
|
|
3098
|
+
}
|
|
3099
|
+
class DividerBlockNode extends DecoratorNode {
|
|
3100
|
+
static getType() {
|
|
3101
|
+
return "divider-block";
|
|
3102
|
+
}
|
|
3103
|
+
static clone(node) {
|
|
3104
|
+
return new DividerBlockNode(node.__key);
|
|
3105
|
+
}
|
|
3106
|
+
constructor(key) {
|
|
3107
|
+
super(key);
|
|
3108
|
+
}
|
|
3109
|
+
createDOM() {
|
|
3110
|
+
const div = document.createElement("div");
|
|
3111
|
+
div.className = "editor-divider";
|
|
3112
|
+
div.setAttribute("data-lexical-decorator", "true");
|
|
3113
|
+
div.setAttribute("contenteditable", "false");
|
|
3114
|
+
return div;
|
|
3115
|
+
}
|
|
3116
|
+
updateDOM() {
|
|
3117
|
+
return false;
|
|
3118
|
+
}
|
|
3119
|
+
exportDOM() {
|
|
3120
|
+
const element = document.createElement("hr");
|
|
3121
|
+
return { element };
|
|
3122
|
+
}
|
|
3123
|
+
static importJSON() {
|
|
3124
|
+
return $createDividerBlockNode();
|
|
3125
|
+
}
|
|
3126
|
+
exportJSON() {
|
|
3127
|
+
return {
|
|
3128
|
+
type: "divider-block",
|
|
3129
|
+
version: 1
|
|
3130
|
+
};
|
|
3131
|
+
}
|
|
3132
|
+
isInline() {
|
|
3133
|
+
return false;
|
|
3134
|
+
}
|
|
3135
|
+
decorate() {
|
|
3136
|
+
return /* @__PURE__ */ jsx(DividerBlockComponent, { nodeKey: this.__key });
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
function $createDividerBlockNode() {
|
|
3140
|
+
return new DividerBlockNode();
|
|
3141
|
+
}
|
|
3142
|
+
function DividerBlockComponent({ nodeKey }) {
|
|
3143
|
+
return /* @__PURE__ */ jsxs(
|
|
3144
|
+
"div",
|
|
3145
|
+
{
|
|
3146
|
+
className: "editor-block py-4 cursor-pointer",
|
|
3147
|
+
"data-block-key": nodeKey,
|
|
3148
|
+
"data-block-type": "divider",
|
|
3149
|
+
children: [
|
|
3150
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-ui-fg-muted mb-1 uppercase tracking-wide", children: "Divider" }),
|
|
3151
|
+
/* @__PURE__ */ jsx("hr", { className: "border-t-2 border-ui-border-base" })
|
|
3152
|
+
]
|
|
3153
|
+
}
|
|
3154
|
+
);
|
|
3155
|
+
}
|
|
3156
|
+
class ButtonBlockNode extends DecoratorNode {
|
|
3157
|
+
static getType() {
|
|
3158
|
+
return "button-block";
|
|
3159
|
+
}
|
|
3160
|
+
static clone(node) {
|
|
3161
|
+
return new ButtonBlockNode(node.__text, node.__url, node.__key);
|
|
3162
|
+
}
|
|
3163
|
+
constructor(text = "Kliknij", url = "#", key) {
|
|
3164
|
+
super(key);
|
|
3165
|
+
this.__text = text;
|
|
3166
|
+
this.__url = url;
|
|
3167
|
+
}
|
|
3168
|
+
createDOM() {
|
|
3169
|
+
const div = document.createElement("div");
|
|
3170
|
+
div.className = "editor-button";
|
|
3171
|
+
div.setAttribute("data-lexical-decorator", "true");
|
|
3172
|
+
div.setAttribute("contenteditable", "false");
|
|
3173
|
+
return div;
|
|
3174
|
+
}
|
|
3175
|
+
updateDOM() {
|
|
3176
|
+
return false;
|
|
3177
|
+
}
|
|
3178
|
+
exportDOM() {
|
|
3179
|
+
const element = document.createElement("a");
|
|
3180
|
+
element.href = this.__url;
|
|
3181
|
+
element.textContent = this.__text;
|
|
3182
|
+
element.className = "button";
|
|
3183
|
+
return { element };
|
|
3184
|
+
}
|
|
3185
|
+
static importJSON(serializedNode) {
|
|
3186
|
+
return $createButtonBlockNode(serializedNode.text, serializedNode.url);
|
|
3187
|
+
}
|
|
3188
|
+
exportJSON() {
|
|
3189
|
+
return {
|
|
3190
|
+
type: "button-block",
|
|
3191
|
+
version: 1,
|
|
3192
|
+
text: this.__text,
|
|
3193
|
+
url: this.__url
|
|
3194
|
+
};
|
|
3195
|
+
}
|
|
3196
|
+
isInline() {
|
|
3197
|
+
return false;
|
|
3198
|
+
}
|
|
3199
|
+
getText() {
|
|
3200
|
+
return this.__text;
|
|
3201
|
+
}
|
|
3202
|
+
getUrl() {
|
|
3203
|
+
return this.__url;
|
|
3204
|
+
}
|
|
3205
|
+
setText(text) {
|
|
3206
|
+
const writable = this.getWritable();
|
|
3207
|
+
writable.__text = text;
|
|
3208
|
+
}
|
|
3209
|
+
setUrl(url) {
|
|
3210
|
+
const writable = this.getWritable();
|
|
3211
|
+
writable.__url = url;
|
|
3212
|
+
}
|
|
3213
|
+
decorate() {
|
|
3214
|
+
return /* @__PURE__ */ jsx(ButtonBlockComponent, { nodeKey: this.__key, text: this.__text, url: this.__url });
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
function $createButtonBlockNode(text, url) {
|
|
3218
|
+
return new ButtonBlockNode(text, url);
|
|
3219
|
+
}
|
|
3220
|
+
function ButtonBlockComponent({ nodeKey, text, url }) {
|
|
3221
|
+
const [editor] = useLexicalComposerContext();
|
|
3222
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
3223
|
+
const [editText, setEditText] = useState(text);
|
|
3224
|
+
const [editUrl, setEditUrl] = useState(url);
|
|
3225
|
+
const handleSave = () => {
|
|
3226
|
+
editor.update(() => {
|
|
3227
|
+
const node = $getNodeByKey(nodeKey);
|
|
3228
|
+
if (node) {
|
|
3229
|
+
node.setText(editText);
|
|
3230
|
+
node.setUrl(editUrl);
|
|
3231
|
+
}
|
|
3232
|
+
});
|
|
3233
|
+
setIsEditing(false);
|
|
3234
|
+
};
|
|
3235
|
+
if (isEditing) {
|
|
3236
|
+
return /* @__PURE__ */ jsx("div", { className: "editor-block py-2", "data-block-key": nodeKey, "data-block-type": "button", children: /* @__PURE__ */ jsxs("div", { className: "p-3 border border-ui-border-interactive rounded-lg bg-ui-bg-subtle", children: [
|
|
3237
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-ui-fg-muted mb-2 uppercase tracking-wide", children: "Button" }),
|
|
3238
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
3239
|
+
/* @__PURE__ */ jsx(
|
|
3240
|
+
"input",
|
|
3241
|
+
{
|
|
3242
|
+
type: "text",
|
|
3243
|
+
value: editText,
|
|
3244
|
+
onChange: (e2) => setEditText(e2.target.value),
|
|
3245
|
+
placeholder: "Tekst przycisku",
|
|
3246
|
+
className: "w-full px-3 py-2 text-sm border border-ui-border-base rounded-lg"
|
|
3247
|
+
}
|
|
3248
|
+
),
|
|
3249
|
+
/* @__PURE__ */ jsx(
|
|
3250
|
+
"input",
|
|
3251
|
+
{
|
|
3252
|
+
type: "text",
|
|
3253
|
+
value: editUrl,
|
|
3254
|
+
onChange: (e2) => setEditUrl(e2.target.value),
|
|
3255
|
+
placeholder: "URL (np. {{data.order.url}})",
|
|
3256
|
+
className: "w-full px-3 py-2 text-sm border border-ui-border-base rounded-lg font-mono"
|
|
3257
|
+
}
|
|
3258
|
+
),
|
|
3259
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3260
|
+
/* @__PURE__ */ jsx(
|
|
3261
|
+
"button",
|
|
3262
|
+
{
|
|
3263
|
+
onClick: handleSave,
|
|
3264
|
+
className: "px-4 py-2 text-sm bg-ui-button-neutral text-ui-fg-on-color rounded-lg hover:bg-ui-button-neutral-hover",
|
|
3265
|
+
children: "Zapisz"
|
|
3266
|
+
}
|
|
3267
|
+
),
|
|
3268
|
+
/* @__PURE__ */ jsx(
|
|
3269
|
+
"button",
|
|
3270
|
+
{
|
|
3271
|
+
onClick: () => setIsEditing(false),
|
|
3272
|
+
className: "px-4 py-2 text-sm border border-ui-border-base rounded-lg hover:bg-ui-bg-base-hover",
|
|
3273
|
+
children: "Anuluj"
|
|
3274
|
+
}
|
|
3275
|
+
)
|
|
3276
|
+
] })
|
|
3277
|
+
] })
|
|
3278
|
+
] }) });
|
|
3279
|
+
}
|
|
3280
|
+
return /* @__PURE__ */ jsxs("div", { className: "editor-block py-2 cursor-pointer", "data-block-key": nodeKey, "data-block-type": "button", children: [
|
|
3281
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-ui-fg-muted mb-1 uppercase tracking-wide", children: "Button" }),
|
|
3282
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-start", children: /* @__PURE__ */ jsx(
|
|
3283
|
+
"button",
|
|
3284
|
+
{
|
|
3285
|
+
onDoubleClick: () => setIsEditing(true),
|
|
3286
|
+
className: "px-6 py-2 bg-violet-600 text-white rounded-lg font-medium hover:bg-violet-700 transition-colors cursor-pointer",
|
|
3287
|
+
title: "Kliknij dwukrotnie aby edytować",
|
|
3288
|
+
children: text
|
|
3289
|
+
}
|
|
3290
|
+
) })
|
|
3291
|
+
] });
|
|
3292
|
+
}
|
|
3293
|
+
function FloatingBlockToolbar({ hoveredBlock }) {
|
|
3294
|
+
const [editor] = useLexicalComposerContext();
|
|
3295
|
+
const handleMoveUp = () => {
|
|
3296
|
+
if (!hoveredBlock) return;
|
|
3297
|
+
editor.update(() => {
|
|
3298
|
+
const node = $getNodeByKey(hoveredBlock.key);
|
|
3299
|
+
if (node) {
|
|
3300
|
+
const prevSibling = node.getPreviousSibling();
|
|
3301
|
+
if (prevSibling) {
|
|
3302
|
+
prevSibling.insertBefore(node);
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
});
|
|
3306
|
+
};
|
|
3307
|
+
const handleMoveDown = () => {
|
|
3308
|
+
if (!hoveredBlock) return;
|
|
3309
|
+
editor.update(() => {
|
|
3310
|
+
const node = $getNodeByKey(hoveredBlock.key);
|
|
3311
|
+
if (node) {
|
|
3312
|
+
const nextSibling = node.getNextSibling();
|
|
3313
|
+
if (nextSibling) {
|
|
3314
|
+
nextSibling.insertAfter(node);
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
});
|
|
3318
|
+
};
|
|
3319
|
+
const handleDelete = () => {
|
|
3320
|
+
if (!hoveredBlock) return;
|
|
3321
|
+
editor.update(() => {
|
|
3322
|
+
const node = $getNodeByKey(hoveredBlock.key);
|
|
3323
|
+
if (node) {
|
|
3324
|
+
node.remove();
|
|
3325
|
+
}
|
|
3326
|
+
});
|
|
3327
|
+
};
|
|
3328
|
+
const isVisible = hoveredBlock && hoveredBlock.type !== "variable";
|
|
3329
|
+
return /* @__PURE__ */ jsx(
|
|
3330
|
+
"div",
|
|
3331
|
+
{
|
|
3332
|
+
className: `pointer-events-auto absolute z-[100] transition-opacity duration-150 ${isVisible ? "opacity-100" : "opacity-0 pointer-events-none"}`,
|
|
3333
|
+
style: {
|
|
3334
|
+
top: (hoveredBlock == null ? void 0 : hoveredBlock.top) ?? 0,
|
|
3335
|
+
left: 8
|
|
3336
|
+
},
|
|
3337
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
3338
|
+
/* @__PURE__ */ jsx(
|
|
3339
|
+
"button",
|
|
3340
|
+
{
|
|
3341
|
+
onClick: handleMoveUp,
|
|
3342
|
+
className: "w-6 h-6 flex items-center justify-center bg-ui-bg-base hover:bg-ui-bg-base-hover rounded text-ui-fg-muted border border-ui-border-base text-xs",
|
|
3343
|
+
title: "Przesuń w górę",
|
|
3344
|
+
children: "↑"
|
|
3345
|
+
}
|
|
3346
|
+
),
|
|
3347
|
+
/* @__PURE__ */ jsx(
|
|
3348
|
+
"button",
|
|
3349
|
+
{
|
|
3350
|
+
onClick: handleMoveDown,
|
|
3351
|
+
className: "w-6 h-6 flex items-center justify-center bg-ui-bg-base hover:bg-ui-bg-base-hover rounded text-ui-fg-muted border border-ui-border-base text-xs",
|
|
3352
|
+
title: "Przesuń w dół",
|
|
3353
|
+
children: "↓"
|
|
3354
|
+
}
|
|
3355
|
+
),
|
|
3356
|
+
/* @__PURE__ */ jsx(
|
|
3357
|
+
"button",
|
|
3358
|
+
{
|
|
3359
|
+
onClick: handleDelete,
|
|
3360
|
+
className: "w-6 h-6 flex items-center justify-center bg-ui-bg-base hover:bg-ui-bg-base-hover rounded text-ui-fg-muted hover:text-ui-fg-error border border-ui-border-base text-xs",
|
|
3361
|
+
title: "Usuń",
|
|
3362
|
+
children: "✕"
|
|
3363
|
+
}
|
|
3364
|
+
)
|
|
3365
|
+
] })
|
|
3366
|
+
}
|
|
3367
|
+
);
|
|
3368
|
+
}
|
|
3369
|
+
function EditorInner({ children }) {
|
|
3370
|
+
const [editor] = useLexicalComposerContext();
|
|
3371
|
+
const [hoveredBlock, setHoveredBlock] = useState(null);
|
|
3372
|
+
const containerRef = useRef(null);
|
|
3373
|
+
useEffect(() => {
|
|
3374
|
+
const container = containerRef.current;
|
|
3375
|
+
if (!container) return;
|
|
3376
|
+
const handleMouseMove = (e2) => {
|
|
3377
|
+
const target = e2.target;
|
|
3378
|
+
let blockElement = null;
|
|
3379
|
+
let nodeKey = null;
|
|
3380
|
+
let blockType = null;
|
|
3381
|
+
const customBlock = target.closest(".editor-block");
|
|
3382
|
+
if (customBlock) {
|
|
3383
|
+
blockElement = customBlock;
|
|
3384
|
+
nodeKey = customBlock.dataset.blockKey || null;
|
|
3385
|
+
blockType = customBlock.dataset.blockType || null;
|
|
3386
|
+
}
|
|
3387
|
+
if (!blockElement) {
|
|
3388
|
+
const paragraph = target.closest("p.editor-paragraph");
|
|
3389
|
+
if (paragraph) {
|
|
3390
|
+
blockElement = paragraph;
|
|
3391
|
+
blockType = "paragraph";
|
|
3392
|
+
editor.getEditorState().read(() => {
|
|
3393
|
+
const root = $getRoot();
|
|
3394
|
+
const children2 = root.getChildren();
|
|
3395
|
+
for (const child of children2) {
|
|
3396
|
+
const childElement = editor.getElementByKey(child.getKey());
|
|
3397
|
+
if (childElement === paragraph) {
|
|
3398
|
+
nodeKey = child.getKey();
|
|
3399
|
+
break;
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
});
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
if (blockElement && nodeKey) {
|
|
3406
|
+
const containerRect = container.getBoundingClientRect();
|
|
3407
|
+
const blockRect = blockElement.getBoundingClientRect();
|
|
3408
|
+
setHoveredBlock({
|
|
3409
|
+
key: nodeKey,
|
|
3410
|
+
top: blockRect.top - containerRect.top,
|
|
3411
|
+
type: blockType || "unknown"
|
|
3412
|
+
});
|
|
3413
|
+
}
|
|
3414
|
+
};
|
|
3415
|
+
const handleMouseLeave = () => {
|
|
3416
|
+
setHoveredBlock(null);
|
|
3417
|
+
};
|
|
3418
|
+
container.addEventListener("mousemove", handleMouseMove, { capture: true });
|
|
3419
|
+
container.addEventListener("mouseleave", handleMouseLeave);
|
|
3420
|
+
return () => {
|
|
3421
|
+
container.removeEventListener("mousemove", handleMouseMove, { capture: true });
|
|
3422
|
+
container.removeEventListener("mouseleave", handleMouseLeave);
|
|
3423
|
+
};
|
|
3424
|
+
}, [editor]);
|
|
3425
|
+
return /* @__PURE__ */ jsxs(
|
|
3426
|
+
"div",
|
|
3427
|
+
{
|
|
3428
|
+
ref: containerRef,
|
|
3429
|
+
className: "editor-inner relative pl-12 py-4 pr-4",
|
|
3430
|
+
children: [
|
|
3431
|
+
/* @__PURE__ */ jsx(FloatingBlockToolbar, { hoveredBlock }),
|
|
3432
|
+
children
|
|
3433
|
+
]
|
|
3434
|
+
}
|
|
3435
|
+
);
|
|
3436
|
+
}
|
|
3437
|
+
const AVAILABLE_VARIABLES = [
|
|
3438
|
+
"data.order.id",
|
|
3439
|
+
"data.order.display_id",
|
|
3440
|
+
"data.order.email",
|
|
3441
|
+
"data.order.total",
|
|
3442
|
+
"data.customer.first_name",
|
|
3443
|
+
"data.customer.last_name"
|
|
3444
|
+
];
|
|
3445
|
+
function ToolbarPlugin({
|
|
3446
|
+
INSERT_PARAGRAPH_BLOCK_COMMAND: INSERT_PARAGRAPH_BLOCK_COMMAND2,
|
|
3447
|
+
INSERT_DIVIDER_COMMAND: INSERT_DIVIDER_COMMAND2,
|
|
3448
|
+
INSERT_BUTTON_COMMAND: INSERT_BUTTON_COMMAND2,
|
|
3449
|
+
INSERT_VARIABLE_COMMAND: INSERT_VARIABLE_COMMAND2
|
|
3450
|
+
}) {
|
|
3451
|
+
const [editor] = useLexicalComposerContext();
|
|
3452
|
+
const [showVariables, setShowVariables] = useState(false);
|
|
3453
|
+
const [showBlockMenu, setShowBlockMenu] = useState(false);
|
|
3454
|
+
const lastActiveFieldRef = useRef(null);
|
|
3455
|
+
const formatBold = () => {
|
|
3456
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, "bold");
|
|
3457
|
+
};
|
|
3458
|
+
const formatItalic = () => {
|
|
3459
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, "italic");
|
|
3460
|
+
};
|
|
3461
|
+
const captureActiveField = () => {
|
|
3462
|
+
const activeElement = document.activeElement;
|
|
3463
|
+
if (activeElement instanceof HTMLTextAreaElement || activeElement instanceof HTMLInputElement) {
|
|
3464
|
+
lastActiveFieldRef.current = {
|
|
3465
|
+
element: activeElement,
|
|
3466
|
+
selectionStart: activeElement.selectionStart || 0,
|
|
3467
|
+
selectionEnd: activeElement.selectionEnd || 0
|
|
3468
|
+
};
|
|
3469
|
+
}
|
|
3470
|
+
};
|
|
3471
|
+
const insertVariable = (variable) => {
|
|
3472
|
+
var _a;
|
|
3473
|
+
const text = `{{${variable}}}`;
|
|
3474
|
+
const lastField = lastActiveFieldRef.current;
|
|
3475
|
+
if (lastField && document.body.contains(lastField.element)) {
|
|
3476
|
+
const { element, selectionStart, selectionEnd } = lastField;
|
|
3477
|
+
const currentValue = element.value;
|
|
3478
|
+
const newValue = currentValue.slice(0, selectionStart) + text + currentValue.slice(selectionEnd);
|
|
3479
|
+
const nativeInputValueSetter = (_a = Object.getOwnPropertyDescriptor(
|
|
3480
|
+
element instanceof HTMLTextAreaElement ? window.HTMLTextAreaElement.prototype : window.HTMLInputElement.prototype,
|
|
3481
|
+
"value"
|
|
3482
|
+
)) == null ? void 0 : _a.set;
|
|
3483
|
+
nativeInputValueSetter == null ? void 0 : nativeInputValueSetter.call(element, newValue);
|
|
3484
|
+
element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
3485
|
+
setTimeout(() => {
|
|
3486
|
+
element.focus();
|
|
3487
|
+
element.setSelectionRange(selectionStart + text.length, selectionStart + text.length);
|
|
3488
|
+
}, 0);
|
|
3489
|
+
lastActiveFieldRef.current = null;
|
|
3490
|
+
} else {
|
|
3491
|
+
editor.dispatchCommand(INSERT_VARIABLE_COMMAND2, variable);
|
|
3492
|
+
}
|
|
3493
|
+
setShowVariables(false);
|
|
3494
|
+
};
|
|
3495
|
+
const insertParagraph = () => {
|
|
3496
|
+
editor.dispatchCommand(INSERT_PARAGRAPH_BLOCK_COMMAND2, void 0);
|
|
3497
|
+
setShowBlockMenu(false);
|
|
3498
|
+
};
|
|
3499
|
+
const insertDivider = () => {
|
|
3500
|
+
editor.dispatchCommand(INSERT_DIVIDER_COMMAND2, void 0);
|
|
3501
|
+
setShowBlockMenu(false);
|
|
3502
|
+
};
|
|
3503
|
+
const insertButton = () => {
|
|
3504
|
+
editor.dispatchCommand(INSERT_BUTTON_COMMAND2, void 0);
|
|
3505
|
+
setShowBlockMenu(false);
|
|
3506
|
+
};
|
|
3507
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-1 p-2 border-b border-ui-border-base bg-ui-bg-subtle sticky top-0 z-10", children: [
|
|
3508
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
3509
|
+
/* @__PURE__ */ jsxs(
|
|
3510
|
+
"button",
|
|
3511
|
+
{
|
|
3512
|
+
type: "button",
|
|
3513
|
+
onClick: () => setShowBlockMenu(!showBlockMenu),
|
|
3514
|
+
className: "flex items-center gap-1 px-2 py-1 hover:bg-ui-bg-base-hover rounded text-sm",
|
|
3515
|
+
children: [
|
|
3516
|
+
/* @__PURE__ */ jsx(Plus, { className: "w-4 h-4" }),
|
|
3517
|
+
"Blok"
|
|
3518
|
+
]
|
|
3487
3519
|
}
|
|
3488
|
-
)
|
|
3489
|
-
/* @__PURE__ */ jsxs(
|
|
3490
|
-
/* @__PURE__ */ jsxs(
|
|
3491
|
-
|
|
3492
|
-
/* @__PURE__ */ jsx(Drawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { className: "text-ui-contrast-fg-primary", children: /* @__PURE__ */ jsx(
|
|
3493
|
-
Trans,
|
|
3494
|
-
{
|
|
3495
|
-
i18nKey: "json.drawer.header",
|
|
3496
|
-
count: numberOfKeys,
|
|
3497
|
-
components: [
|
|
3498
|
-
/* @__PURE__ */ jsx(
|
|
3499
|
-
"span",
|
|
3500
|
-
{
|
|
3501
|
-
className: "text-ui-fg-subtle"
|
|
3502
|
-
},
|
|
3503
|
-
"count-span"
|
|
3504
|
-
)
|
|
3505
|
-
]
|
|
3506
|
-
}
|
|
3507
|
-
) }) }),
|
|
3508
|
-
/* @__PURE__ */ jsx(Drawer.Description, { className: "sr-only", children: t2("json.drawer.description") })
|
|
3509
|
-
] }),
|
|
3510
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
3511
|
-
/* @__PURE__ */ jsx(Kbd, { className: "bg-ui-contrast-bg-subtle border-ui-contrast-border-base text-ui-contrast-fg-secondary", children: "esc" }),
|
|
3512
|
-
/* @__PURE__ */ jsx(Drawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
3513
|
-
IconButton,
|
|
3514
|
-
{
|
|
3515
|
-
size: "small",
|
|
3516
|
-
variant: "transparent",
|
|
3517
|
-
className: "text-ui-contrast-fg-secondary hover:text-ui-contrast-fg-primary hover:bg-ui-contrast-bg-base-hover active:bg-ui-contrast-bg-base-pressed focus-visible:bg-ui-contrast-bg-base-hover focus-visible:shadow-borders-interactive-with-active",
|
|
3518
|
-
children: /* @__PURE__ */ jsx(XMarkMini, {})
|
|
3519
|
-
}
|
|
3520
|
-
) })
|
|
3521
|
-
] })
|
|
3522
|
-
] }),
|
|
3523
|
-
/* @__PURE__ */ jsx(Drawer.Body, { className: "flex flex-1 flex-col overflow-hidden px-[5px] py-0 pb-[5px]", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-contrast-bg-subtle flex-1 overflow-auto rounded-b-[4px] rounded-t-lg p-3", children: /* @__PURE__ */ jsx(
|
|
3524
|
-
Suspense,
|
|
3520
|
+
),
|
|
3521
|
+
showBlockMenu && /* @__PURE__ */ jsxs("div", { className: "absolute top-full left-0 mt-1 bg-ui-bg-base border border-ui-border-base rounded shadow-lg z-20 min-w-[150px]", children: [
|
|
3522
|
+
/* @__PURE__ */ jsxs(
|
|
3523
|
+
"button",
|
|
3525
3524
|
{
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
"--w-rjv-font-family": "Roboto Mono, monospace",
|
|
3534
|
-
"--w-rjv-line-color": "var(--contrast-border-base)",
|
|
3535
|
-
"--w-rjv-curlybraces-color": "var(--contrast-fg-secondary)",
|
|
3536
|
-
"--w-rjv-brackets-color": "var(--contrast-fg-secondary)",
|
|
3537
|
-
"--w-rjv-key-string": "var(--contrast-fg-primary)",
|
|
3538
|
-
"--w-rjv-info-color": "var(--contrast-fg-secondary)",
|
|
3539
|
-
"--w-rjv-type-string-color": "var(--tag-green-icon)",
|
|
3540
|
-
"--w-rjv-quotes-string-color": "var(--tag-green-icon)",
|
|
3541
|
-
"--w-rjv-type-boolean-color": "var(--tag-orange-icon)",
|
|
3542
|
-
"--w-rjv-type-int-color": "var(--tag-orange-icon)",
|
|
3543
|
-
"--w-rjv-type-float-color": "var(--tag-orange-icon)",
|
|
3544
|
-
"--w-rjv-type-bigint-color": "var(--tag-orange-icon)",
|
|
3545
|
-
"--w-rjv-key-number": "var(--contrast-fg-secondary)",
|
|
3546
|
-
"--w-rjv-arrow-color": "var(--contrast-fg-secondary)",
|
|
3547
|
-
"--w-rjv-copied-color": "var(--contrast-fg-secondary)",
|
|
3548
|
-
"--w-rjv-copied-success-color": "var(--contrast-fg-primary)",
|
|
3549
|
-
"--w-rjv-colon-color": "var(--contrast-fg-primary)",
|
|
3550
|
-
"--w-rjv-ellipsis-color": "var(--contrast-fg-secondary)"
|
|
3551
|
-
},
|
|
3552
|
-
collapsed: 1,
|
|
3553
|
-
children: [
|
|
3554
|
-
/* @__PURE__ */ jsx(
|
|
3555
|
-
JsonView.Quote,
|
|
3556
|
-
{
|
|
3557
|
-
render: () => /* @__PURE__ */ jsx("span", {})
|
|
3558
|
-
}
|
|
3559
|
-
),
|
|
3560
|
-
/* @__PURE__ */ jsx(
|
|
3561
|
-
JsonView.Null,
|
|
3562
|
-
{
|
|
3563
|
-
render: () => /* @__PURE__ */ jsx("span", { className: "text-ui-tag-red-icon", children: "null" })
|
|
3564
|
-
}
|
|
3565
|
-
),
|
|
3566
|
-
/* @__PURE__ */ jsx(
|
|
3567
|
-
JsonView.Undefined,
|
|
3568
|
-
{
|
|
3569
|
-
render: () => /* @__PURE__ */ jsx("span", { className: "text-ui-tag-blue-icon", children: "undefined" })
|
|
3570
|
-
}
|
|
3571
|
-
),
|
|
3572
|
-
/* @__PURE__ */ jsx(
|
|
3573
|
-
JsonView.CountInfo,
|
|
3574
|
-
{
|
|
3575
|
-
render: (_props, { value }) => {
|
|
3576
|
-
return /* @__PURE__ */ jsx("span", { className: "text-ui-contrast-fg-secondary ml-2", children: t2("general.items", {
|
|
3577
|
-
count: Object.keys(
|
|
3578
|
-
value
|
|
3579
|
-
).length
|
|
3580
|
-
}) });
|
|
3581
|
-
}
|
|
3582
|
-
}
|
|
3583
|
-
),
|
|
3584
|
-
/* @__PURE__ */ jsx(JsonView.Arrow, { children: /* @__PURE__ */ jsx(TriangleDownMini, { className: "text-ui-contrast-fg-secondary -ml-[0.5px]" }) }),
|
|
3585
|
-
/* @__PURE__ */ jsx(JsonView.Colon, { children: /* @__PURE__ */ jsx("span", { className: "mr-1", children: ":" }) }),
|
|
3586
|
-
/* @__PURE__ */ jsx(
|
|
3587
|
-
JsonView.Copied,
|
|
3588
|
-
{
|
|
3589
|
-
render: ({ style }, { value }) => {
|
|
3590
|
-
return /* @__PURE__ */ jsx(
|
|
3591
|
-
Copied,
|
|
3592
|
-
{
|
|
3593
|
-
style,
|
|
3594
|
-
value
|
|
3595
|
-
}
|
|
3596
|
-
);
|
|
3597
|
-
}
|
|
3598
|
-
}
|
|
3599
|
-
)
|
|
3600
|
-
]
|
|
3601
|
-
}
|
|
3602
|
-
)
|
|
3525
|
+
type: "button",
|
|
3526
|
+
onClick: insertParagraph,
|
|
3527
|
+
className: "flex items-center gap-2 w-full text-left px-3 py-2 hover:bg-ui-bg-base-hover text-sm",
|
|
3528
|
+
children: [
|
|
3529
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "¶" }),
|
|
3530
|
+
"Paragraph"
|
|
3531
|
+
]
|
|
3603
3532
|
}
|
|
3604
|
-
)
|
|
3533
|
+
),
|
|
3534
|
+
/* @__PURE__ */ jsxs(
|
|
3535
|
+
"button",
|
|
3536
|
+
{
|
|
3537
|
+
type: "button",
|
|
3538
|
+
onClick: insertDivider,
|
|
3539
|
+
className: "flex items-center gap-2 w-full text-left px-3 py-2 hover:bg-ui-bg-base-hover text-sm",
|
|
3540
|
+
children: [
|
|
3541
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "―" }),
|
|
3542
|
+
"Divider"
|
|
3543
|
+
]
|
|
3544
|
+
}
|
|
3545
|
+
),
|
|
3546
|
+
/* @__PURE__ */ jsxs(
|
|
3547
|
+
"button",
|
|
3548
|
+
{
|
|
3549
|
+
type: "button",
|
|
3550
|
+
onClick: insertButton,
|
|
3551
|
+
className: "flex items-center gap-2 w-full text-left px-3 py-2 hover:bg-ui-bg-base-hover text-sm",
|
|
3552
|
+
children: [
|
|
3553
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "▢" }),
|
|
3554
|
+
"Button"
|
|
3555
|
+
]
|
|
3556
|
+
}
|
|
3557
|
+
)
|
|
3558
|
+
] })
|
|
3559
|
+
] }),
|
|
3560
|
+
/* @__PURE__ */ jsx("div", { className: "w-px bg-ui-border-base mx-1" }),
|
|
3561
|
+
/* @__PURE__ */ jsx(
|
|
3562
|
+
"button",
|
|
3563
|
+
{
|
|
3564
|
+
type: "button",
|
|
3565
|
+
onClick: formatBold,
|
|
3566
|
+
className: "px-2 py-1 hover:bg-ui-bg-base-hover rounded text-sm font-bold",
|
|
3567
|
+
title: "Pogrubienie",
|
|
3568
|
+
children: "B"
|
|
3569
|
+
}
|
|
3570
|
+
),
|
|
3571
|
+
/* @__PURE__ */ jsx(
|
|
3572
|
+
"button",
|
|
3573
|
+
{
|
|
3574
|
+
type: "button",
|
|
3575
|
+
onClick: formatItalic,
|
|
3576
|
+
className: "px-2 py-1 hover:bg-ui-bg-base-hover rounded text-sm italic",
|
|
3577
|
+
title: "Kursywa",
|
|
3578
|
+
children: "I"
|
|
3579
|
+
}
|
|
3580
|
+
),
|
|
3581
|
+
/* @__PURE__ */ jsx("div", { className: "w-px bg-ui-border-base mx-1" }),
|
|
3582
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
3583
|
+
/* @__PURE__ */ jsx(
|
|
3584
|
+
"button",
|
|
3585
|
+
{
|
|
3586
|
+
type: "button",
|
|
3587
|
+
onMouseDown: captureActiveField,
|
|
3588
|
+
onClick: () => setShowVariables(!showVariables),
|
|
3589
|
+
className: "px-2 py-1 hover:bg-ui-bg-base-hover rounded text-sm font-mono",
|
|
3590
|
+
title: "Wstaw zmienną",
|
|
3591
|
+
children: "{{ }}"
|
|
3592
|
+
}
|
|
3593
|
+
),
|
|
3594
|
+
showVariables && /* @__PURE__ */ jsxs("div", { className: "absolute top-full left-0 mt-1 bg-ui-bg-base border border-ui-border-base rounded shadow-lg z-20 min-w-[220px] max-h-48 overflow-auto", children: [
|
|
3595
|
+
/* @__PURE__ */ jsx("div", { className: "px-3 py-1 text-xs text-ui-fg-muted border-b border-ui-border-base", children: "Dostępne zmienne" }),
|
|
3596
|
+
AVAILABLE_VARIABLES.map((v) => /* @__PURE__ */ jsx(
|
|
3597
|
+
"button",
|
|
3598
|
+
{
|
|
3599
|
+
type: "button",
|
|
3600
|
+
onClick: () => insertVariable(v),
|
|
3601
|
+
className: "block w-full text-left px-3 py-2 hover:bg-ui-bg-base-hover text-sm font-mono",
|
|
3602
|
+
children: `{{${v}}}`
|
|
3603
|
+
},
|
|
3604
|
+
v
|
|
3605
|
+
))
|
|
3605
3606
|
] })
|
|
3606
3607
|
] })
|
|
3607
3608
|
] });
|
|
3608
|
-
}
|
|
3609
|
-
const
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
const
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3609
|
+
}
|
|
3610
|
+
const INSERT_PARAGRAPH_BLOCK_COMMAND = createCommand("INSERT_PARAGRAPH_BLOCK");
|
|
3611
|
+
const INSERT_DIVIDER_COMMAND = createCommand("INSERT_DIVIDER");
|
|
3612
|
+
const INSERT_BUTTON_COMMAND = createCommand("INSERT_BUTTON");
|
|
3613
|
+
const INSERT_VARIABLE_COMMAND = createCommand("INSERT_VARIABLE");
|
|
3614
|
+
function registerBlockCommands(editor) {
|
|
3615
|
+
const unregisterParagraph = editor.registerCommand(
|
|
3616
|
+
INSERT_PARAGRAPH_BLOCK_COMMAND,
|
|
3617
|
+
() => {
|
|
3618
|
+
const paragraphNode = $createParagraphNode();
|
|
3619
|
+
$insertNodes([paragraphNode]);
|
|
3620
|
+
paragraphNode.select();
|
|
3621
|
+
return true;
|
|
3622
|
+
},
|
|
3623
|
+
COMMAND_PRIORITY_LOW
|
|
3624
|
+
);
|
|
3625
|
+
const unregisterDivider = editor.registerCommand(
|
|
3626
|
+
INSERT_DIVIDER_COMMAND,
|
|
3627
|
+
() => {
|
|
3628
|
+
const dividerNode = $createDividerBlockNode();
|
|
3629
|
+
$insertNodes([dividerNode]);
|
|
3630
|
+
return true;
|
|
3631
|
+
},
|
|
3632
|
+
COMMAND_PRIORITY_LOW
|
|
3633
|
+
);
|
|
3634
|
+
const unregisterButton = editor.registerCommand(
|
|
3635
|
+
INSERT_BUTTON_COMMAND,
|
|
3636
|
+
() => {
|
|
3637
|
+
const buttonNode = $createButtonBlockNode();
|
|
3638
|
+
$insertNodes([buttonNode]);
|
|
3639
|
+
return true;
|
|
3640
|
+
},
|
|
3641
|
+
COMMAND_PRIORITY_LOW
|
|
3642
|
+
);
|
|
3643
|
+
const unregisterVariable = editor.registerCommand(
|
|
3644
|
+
INSERT_VARIABLE_COMMAND,
|
|
3645
|
+
(variableName) => {
|
|
3646
|
+
const variableNode = $createVariableNode(variableName);
|
|
3647
|
+
$insertNodes([variableNode]);
|
|
3648
|
+
return true;
|
|
3649
|
+
},
|
|
3650
|
+
COMMAND_PRIORITY_LOW
|
|
3651
|
+
);
|
|
3652
|
+
return () => {
|
|
3653
|
+
unregisterParagraph();
|
|
3654
|
+
unregisterDivider();
|
|
3655
|
+
unregisterButton();
|
|
3656
|
+
unregisterVariable();
|
|
3623
3657
|
};
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
};
|
|
3630
|
-
const
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
return null;
|
|
3637
|
-
}
|
|
3638
|
-
if (!("metadata" in data)) {
|
|
3639
|
-
return null;
|
|
3658
|
+
}
|
|
3659
|
+
const BuilderBlocksExtension = defineExtension({
|
|
3660
|
+
name: "@codee/builder-blocks",
|
|
3661
|
+
nodes: () => [VariableNode, DividerBlockNode, ButtonBlockNode],
|
|
3662
|
+
register: registerBlockCommands
|
|
3663
|
+
});
|
|
3664
|
+
const editorTheme = {
|
|
3665
|
+
paragraph: "editor-paragraph mb-1",
|
|
3666
|
+
text: {
|
|
3667
|
+
bold: "font-bold",
|
|
3668
|
+
italic: "italic",
|
|
3669
|
+
underline: "underline"
|
|
3640
3670
|
}
|
|
3641
|
-
const numberOfKeys = data.metadata ? Object.keys(data.metadata).length : 0;
|
|
3642
|
-
return /* @__PURE__ */ jsxs(Container$1, { className: "flex items-center justify-between", children: [
|
|
3643
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
3644
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", children: t2("metadata.header") }),
|
|
3645
|
-
/* @__PURE__ */ jsx(Badge, { size: "2xsmall", rounded: "full", children: t2("metadata.numberOfKeys", {
|
|
3646
|
-
count: numberOfKeys
|
|
3647
|
-
}) })
|
|
3648
|
-
] }),
|
|
3649
|
-
/* @__PURE__ */ jsx(
|
|
3650
|
-
IconButton,
|
|
3651
|
-
{
|
|
3652
|
-
size: "small",
|
|
3653
|
-
variant: "transparent",
|
|
3654
|
-
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
3655
|
-
onClick: onOpen,
|
|
3656
|
-
children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, {})
|
|
3657
|
-
}
|
|
3658
|
-
)
|
|
3659
|
-
] });
|
|
3660
3671
|
};
|
|
3661
|
-
const
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3672
|
+
const BuilderEditorExtension = defineExtension({
|
|
3673
|
+
name: "@codee/builder-editor",
|
|
3674
|
+
namespace: "BuilderEditor",
|
|
3675
|
+
theme: editorTheme,
|
|
3676
|
+
dependencies: [
|
|
3677
|
+
RichTextExtension,
|
|
3678
|
+
HistoryExtension,
|
|
3679
|
+
BuilderBlocksExtension
|
|
3680
|
+
]
|
|
3681
|
+
});
|
|
3682
|
+
const BuilderPage = () => {
|
|
3683
|
+
const [output, setOutput] = useState("");
|
|
3684
|
+
const handleChange = useCallback((editorState) => {
|
|
3685
|
+
editorState.read(() => {
|
|
3686
|
+
const json = editorState.toJSON();
|
|
3687
|
+
setOutput(JSON.stringify(json, null, 2));
|
|
3688
|
+
});
|
|
3689
|
+
}, []);
|
|
3690
|
+
return /* @__PURE__ */ jsxs(Container$1, { className: "p-8", children: [
|
|
3691
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", className: "mb-6", children: "Builder - Template Editor (Extensions API)" }),
|
|
3692
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-8", children: [
|
|
3693
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3694
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-ui-fg-subtle", children: "Edytor" }),
|
|
3695
|
+
/* @__PURE__ */ jsx(
|
|
3696
|
+
LexicalExtensionComposer,
|
|
3697
|
+
{
|
|
3698
|
+
extension: BuilderEditorExtension,
|
|
3699
|
+
contentEditable: null,
|
|
3700
|
+
children: /* @__PURE__ */ jsxs("div", { className: "border border-ui-border-base rounded-lg bg-white", children: [
|
|
3701
|
+
/* @__PURE__ */ jsx(
|
|
3702
|
+
ToolbarPlugin,
|
|
3703
|
+
{
|
|
3704
|
+
INSERT_PARAGRAPH_BLOCK_COMMAND,
|
|
3705
|
+
INSERT_DIVIDER_COMMAND,
|
|
3706
|
+
INSERT_BUTTON_COMMAND,
|
|
3707
|
+
INSERT_VARIABLE_COMMAND
|
|
3708
|
+
}
|
|
3709
|
+
),
|
|
3710
|
+
/* @__PURE__ */ jsx(EditorInner, { children: /* @__PURE__ */ jsx(ContentEditable, { className: "min-h-[400px] outline-none" }) }),
|
|
3711
|
+
/* @__PURE__ */ jsx(OnChangePlugin, { onChange: handleChange })
|
|
3712
|
+
] })
|
|
3713
|
+
}
|
|
3714
|
+
)
|
|
3715
|
+
] }),
|
|
3716
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3717
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", className: "mb-4 text-ui-fg-subtle", children: "Output (Lexical State)" }),
|
|
3718
|
+
/* @__PURE__ */ jsx("div", { className: "border border-ui-border-base rounded-lg p-4 bg-ui-bg-subtle min-h-[400px] max-h-[600px] overflow-auto", children: /* @__PURE__ */ jsx("pre", { className: "text-xs font-mono whitespace-pre-wrap", children: output || "..." }) })
|
|
3719
|
+
] })
|
|
3720
|
+
] })
|
|
3710
3721
|
] });
|
|
3711
3722
|
};
|
|
3712
|
-
const ListPage$4 = () => {
|
|
3713
|
-
return /* @__PURE__ */ jsx(
|
|
3714
|
-
SingleColumnPage,
|
|
3715
|
-
{
|
|
3716
|
-
widgets: {
|
|
3717
|
-
before: [],
|
|
3718
|
-
after: []
|
|
3719
|
-
},
|
|
3720
|
-
children: "Notifications"
|
|
3721
|
-
}
|
|
3722
|
-
);
|
|
3723
|
-
};
|
|
3724
3723
|
const config$5 = defineRouteConfig({
|
|
3725
|
-
label: "
|
|
3724
|
+
label: "Builder - Lexical",
|
|
3725
|
+
icon: PuzzleSolid
|
|
3726
3726
|
});
|
|
3727
3727
|
const NotificationsFullList = () => {
|
|
3728
3728
|
const [pagination, setPagination] = useState({
|
|
@@ -10293,22 +10293,6 @@ const ListPage$2 = () => {
|
|
|
10293
10293
|
const config$3 = defineRouteConfig({
|
|
10294
10294
|
label: "Templates"
|
|
10295
10295
|
});
|
|
10296
|
-
const ListPage$1 = () => {
|
|
10297
|
-
return /* @__PURE__ */ jsx(
|
|
10298
|
-
SingleColumnPage,
|
|
10299
|
-
{
|
|
10300
|
-
widgets: {
|
|
10301
|
-
before: [],
|
|
10302
|
-
after: []
|
|
10303
|
-
},
|
|
10304
|
-
children: /* @__PURE__ */ jsx(NotificationsFullList, {})
|
|
10305
|
-
}
|
|
10306
|
-
);
|
|
10307
|
-
};
|
|
10308
|
-
const config$2 = defineRouteConfig({
|
|
10309
|
-
label: "List",
|
|
10310
|
-
icon: ListBullet
|
|
10311
|
-
});
|
|
10312
10296
|
const useOrders = (params = {}, options) => {
|
|
10313
10297
|
const {
|
|
10314
10298
|
limit = 100,
|
|
@@ -11013,10 +10997,26 @@ const PreviewTemplatePage = () => {
|
|
|
11013
10997
|
}
|
|
11014
10998
|
);
|
|
11015
10999
|
};
|
|
11016
|
-
const config$
|
|
11000
|
+
const config$2 = defineRouteConfig({
|
|
11017
11001
|
label: "Preview Template",
|
|
11018
11002
|
icon: ChatBubbleLeftRight
|
|
11019
11003
|
});
|
|
11004
|
+
const ListPage$1 = () => {
|
|
11005
|
+
return /* @__PURE__ */ jsx(
|
|
11006
|
+
SingleColumnPage,
|
|
11007
|
+
{
|
|
11008
|
+
widgets: {
|
|
11009
|
+
before: [],
|
|
11010
|
+
after: []
|
|
11011
|
+
},
|
|
11012
|
+
children: /* @__PURE__ */ jsx(NotificationsFullList, {})
|
|
11013
|
+
}
|
|
11014
|
+
);
|
|
11015
|
+
};
|
|
11016
|
+
const config$1 = defineRouteConfig({
|
|
11017
|
+
label: "List",
|
|
11018
|
+
icon: ListBullet
|
|
11019
|
+
});
|
|
11020
11020
|
const useAvailableTemplates = (params, options) => {
|
|
11021
11021
|
const {
|
|
11022
11022
|
limit = 100,
|
|
@@ -20238,14 +20238,14 @@ const widgetModule = { widgets: [
|
|
|
20238
20238
|
] };
|
|
20239
20239
|
const routeModule = {
|
|
20240
20240
|
routes: [
|
|
20241
|
-
{
|
|
20242
|
-
Component: BuilderPage,
|
|
20243
|
-
path: "/builder-lexical"
|
|
20244
|
-
},
|
|
20245
20241
|
{
|
|
20246
20242
|
Component: ListPage$4,
|
|
20247
20243
|
path: "/mpn"
|
|
20248
20244
|
},
|
|
20245
|
+
{
|
|
20246
|
+
Component: BuilderPage,
|
|
20247
|
+
path: "/builder-lexical"
|
|
20248
|
+
},
|
|
20249
20249
|
{
|
|
20250
20250
|
Component: ListPage$3,
|
|
20251
20251
|
path: "/mpn/notifications"
|
|
@@ -20254,14 +20254,14 @@ const routeModule = {
|
|
|
20254
20254
|
Component: ListPage$2,
|
|
20255
20255
|
path: "/mpn/templates"
|
|
20256
20256
|
},
|
|
20257
|
-
{
|
|
20258
|
-
Component: ListPage$1,
|
|
20259
|
-
path: "/mpn/notifications/list"
|
|
20260
|
-
},
|
|
20261
20257
|
{
|
|
20262
20258
|
Component: PreviewTemplatePage,
|
|
20263
20259
|
path: "/mpn/notifications/render"
|
|
20264
20260
|
},
|
|
20261
|
+
{
|
|
20262
|
+
Component: ListPage$1,
|
|
20263
|
+
path: "/mpn/notifications/list"
|
|
20264
|
+
},
|
|
20265
20265
|
{
|
|
20266
20266
|
Component: ListPage,
|
|
20267
20267
|
path: "/mpn/templates/:id/blocks"
|
|
@@ -20271,13 +20271,13 @@ const routeModule = {
|
|
|
20271
20271
|
const menuItemModule = {
|
|
20272
20272
|
menuItems: [
|
|
20273
20273
|
{
|
|
20274
|
-
label: config$
|
|
20275
|
-
icon: config$
|
|
20274
|
+
label: config$5.label,
|
|
20275
|
+
icon: config$5.icon,
|
|
20276
20276
|
path: "/builder-lexical",
|
|
20277
20277
|
nested: void 0
|
|
20278
20278
|
},
|
|
20279
20279
|
{
|
|
20280
|
-
label: config$
|
|
20280
|
+
label: config$6.label,
|
|
20281
20281
|
icon: void 0,
|
|
20282
20282
|
path: "/mpn",
|
|
20283
20283
|
nested: void 0
|
|
@@ -20297,13 +20297,13 @@ const menuItemModule = {
|
|
|
20297
20297
|
{
|
|
20298
20298
|
label: config$1.label,
|
|
20299
20299
|
icon: config$1.icon,
|
|
20300
|
-
path: "/mpn/notifications/
|
|
20300
|
+
path: "/mpn/notifications/list",
|
|
20301
20301
|
nested: void 0
|
|
20302
20302
|
},
|
|
20303
20303
|
{
|
|
20304
20304
|
label: config$2.label,
|
|
20305
20305
|
icon: config$2.icon,
|
|
20306
|
-
path: "/mpn/notifications/
|
|
20306
|
+
path: "/mpn/notifications/render",
|
|
20307
20307
|
nested: void 0
|
|
20308
20308
|
},
|
|
20309
20309
|
{
|