@textbus/xnote 0.1.2 → 0.2.0
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/bundles/components/dropdown/dropdown-menu.d.ts +2 -1
- package/bundles/components/dropdown/dropdown.d.ts +1 -0
- package/bundles/fonts/textbus.svg +4 -3
- package/bundles/fonts/textbus.ttf +0 -0
- package/bundles/fonts/textbus.woff +0 -0
- package/bundles/index.css +2 -2
- package/bundles/index.esm.css +2 -2
- package/bundles/index.esm.js +989 -485
- package/bundles/index.js +1003 -483
- package/bundles/plugins/_api.d.ts +8 -4
- package/bundles/plugins/inline-toolbar/inline-toolbar.d.ts +4 -0
- package/bundles/plugins/inline-toolbar/inline-toolbar.plugin.d.ts +12 -0
- package/bundles/plugins/static-toolbar/static-toolbar.d.ts +4 -0
- package/bundles/plugins/static-toolbar/static-toolbar.plugin.d.ts +14 -0
- package/bundles/plugins/suspension-toolbar/suspension-toolbar.d.ts +4 -0
- package/bundles/plugins/suspension-toolbar/suspension-toolbar.plugin.d.ts +13 -0
- package/bundles/plugins/{_common → tools}/_api.d.ts +8 -0
- package/bundles/plugins/tools/_common/common-state.d.ts +1 -0
- package/bundles/plugins/tools/_common/split-line.d.ts +1 -0
- package/bundles/plugins/tools/_common/tool.service.d.ts +14 -0
- package/bundles/plugins/tools/clean-formats.tool.d.ts +1 -0
- package/bundles/plugins/{left-toolbar/insert-tool.d.ts → tools/insert-menu.d.ts} +1 -1
- package/bundles/plugins/tools/insert.tool.d.ts +1 -0
- package/bundles/plugins/tools/redo.tool.d.ts +1 -0
- package/bundles/plugins/tools/subscript.tool.d.ts +1 -0
- package/bundles/plugins/tools/superscript.tool.d.ts +1 -0
- package/bundles/plugins/tools/table/help.d.ts +5 -0
- package/bundles/plugins/tools/undo.tool.d.ts +1 -0
- package/bundles/textbus/components/table/table.component.d.ts +1 -0
- package/bundles/textbus/formatters/_api.d.ts +2 -0
- package/bundles/textbus/formatters/subscript.d.ts +4 -0
- package/bundles/textbus/formatters/superscript.d.ts +4 -0
- package/package.json +10 -10
- package/bundles/plugins/toolbar/toolbar.d.ts +0 -1
- package/bundles/plugins/toolbar/toolbar.plugin.d.ts +0 -7
- /package/bundles/plugins/{_common → tools}/attr.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/block.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/bold.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/code.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/color.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/font-family.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/font-size.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/italic.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/link.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/strike-through.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/table/_api.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/table/cell-align.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/table/cell-background.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/table/merge-cells.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/table/split-cells.tool.d.ts +0 -0
- /package/bundles/plugins/{_common → tools}/underline.tool.d.ts +0 -0
package/bundles/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var Katex = require('katex');
|
|
|
14
14
|
var adapterViewfly = require('@textbus/adapter-viewfly');
|
|
15
15
|
var collaborate = require('@textbus/collaborate');
|
|
16
16
|
|
|
17
|
-
var scopedId$
|
|
17
|
+
var scopedId$r = "vf-7d288d";
|
|
18
18
|
|
|
19
19
|
/******************************************************************************
|
|
20
20
|
Copyright (c) Microsoft Corporation.
|
|
@@ -147,7 +147,7 @@ function Button(props) {
|
|
|
147
147
|
subscription.unsubscribe();
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
150
|
+
return scopedCss.withScopedCSS(scopedId$r, () => {
|
|
151
151
|
return (jsxRuntime.jsxs("button", Object.assign({ type: "button" }, props, { class: [
|
|
152
152
|
'btn',
|
|
153
153
|
{
|
|
@@ -159,7 +159,7 @@ function Button(props) {
|
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
var scopedId$
|
|
162
|
+
var scopedId$q = "vf-d552b9";
|
|
163
163
|
|
|
164
164
|
class Picker {
|
|
165
165
|
set hex(color$1) {
|
|
@@ -448,7 +448,7 @@ function ColorPicker(props) {
|
|
|
448
448
|
props.onSelected(picker);
|
|
449
449
|
addRecentColor();
|
|
450
450
|
}
|
|
451
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
451
|
+
return scopedCss.withScopedCSS(scopedId$q, () => {
|
|
452
452
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
453
453
|
return (jsxRuntime.jsxs("div", { onMousedown: ev => {
|
|
454
454
|
ev.stopPropagation();
|
|
@@ -499,10 +499,10 @@ function ColorPicker(props) {
|
|
|
499
499
|
});
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
var scopedId$
|
|
502
|
+
var scopedId$p = "vf-ac7e8d";
|
|
503
503
|
|
|
504
504
|
function ComponentToolbar(props) {
|
|
505
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
505
|
+
return scopedCss.withScopedCSS(scopedId$p, () => {
|
|
506
506
|
return (jsxRuntime.jsx("div", { class: "component-toolbar", style: props.style, children: jsxRuntime.jsx("div", { class: [
|
|
507
507
|
'toolbar',
|
|
508
508
|
{
|
|
@@ -512,15 +512,15 @@ function ComponentToolbar(props) {
|
|
|
512
512
|
});
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
-
var scopedId$
|
|
515
|
+
var scopedId$o = "vf-ede279";
|
|
516
516
|
|
|
517
517
|
function Divider() {
|
|
518
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
518
|
+
return scopedCss.withScopedCSS(scopedId$o, () => {
|
|
519
519
|
return jsxRuntime.jsx("div", { class: "divider" });
|
|
520
520
|
});
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
-
var scopedId$
|
|
523
|
+
var scopedId$n = "vf-d91ad6";
|
|
524
524
|
|
|
525
525
|
function DragResize(props) {
|
|
526
526
|
const isShow = core.createSignal(false);
|
|
@@ -629,24 +629,25 @@ function DragResize(props) {
|
|
|
629
629
|
});
|
|
630
630
|
}
|
|
631
631
|
const sizeText = core.createSignal(`${component.state.width}*${component.state.height}`);
|
|
632
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
632
|
+
return scopedCss.withScopedCSS(scopedId$n, () => {
|
|
633
633
|
return (jsxRuntime.jsxs("div", { class: "drag-resize", onClick: selectComponent, children: [jsxRuntime.jsx("div", { class: "container", ref: ref, children: props.children }), jsxRuntime.jsxs("div", { class: ['resize-tool', {
|
|
634
634
|
active: isShow()
|
|
635
635
|
}], children: [jsxRuntime.jsx("div", { class: "mask", ref: mask, children: sizeText() }), jsxRuntime.jsxs("div", { class: "btn-group", ref: btnGroup, onMousedown: drag, children: [jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" })] })] })] }));
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
-
var scopedId$
|
|
639
|
+
var scopedId$m = "vf-a99c5e";
|
|
640
640
|
|
|
641
|
-
var scopedId$
|
|
641
|
+
var scopedId$l = "vf-8a05e9";
|
|
642
642
|
|
|
643
|
+
const DropdownMenuContainer = new core.InjectionToken('DropdownMenuContainer');
|
|
643
644
|
const DropdownMenuPortal = core.withAnnotation({
|
|
644
645
|
providers: [
|
|
645
646
|
exports.DropdownService
|
|
646
647
|
]
|
|
647
648
|
}, function DropdownMenuPortal(props) {
|
|
648
649
|
const dropdownContextService = core.inject(exports.DropdownContextService);
|
|
649
|
-
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
650
|
+
const container = core.inject(DropdownMenuContainer, core.inject(platformBrowser.VIEW_CONTAINER));
|
|
650
651
|
const menuRef = core.createRef();
|
|
651
652
|
let timer = null;
|
|
652
653
|
const delay = 10;
|
|
@@ -736,7 +737,7 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
736
737
|
function stopPropagation(ev) {
|
|
737
738
|
ev.stopPropagation();
|
|
738
739
|
}
|
|
739
|
-
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$
|
|
740
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$l, () => {
|
|
740
741
|
return (jsxRuntime.jsx("div", { onMouseenter: onEnter, onMousedown: stopPropagation, onMouseleave: onLeave, ref: menuRef, style: {
|
|
741
742
|
width: props.width
|
|
742
743
|
}, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content", style: {
|
|
@@ -751,6 +752,9 @@ const Dropdown = core.withAnnotation({
|
|
|
751
752
|
const isShow = core.createSignal(false);
|
|
752
753
|
const dropdownContextService = core.inject(exports.DropdownContextService);
|
|
753
754
|
const toggle = () => {
|
|
755
|
+
if (props.disabled) {
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
754
758
|
if (dropdownContextService.isOpen) {
|
|
755
759
|
dropdownContextService.hide(false);
|
|
756
760
|
}
|
|
@@ -780,11 +784,17 @@ const Dropdown = core.withAnnotation({
|
|
|
780
784
|
let leaveSub;
|
|
781
785
|
const bindLeave = function () {
|
|
782
786
|
leaveSub = core$1.fromEvent(dropdownRef.current, 'mouseleave').subscribe(() => {
|
|
787
|
+
if (props.disabled) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
783
790
|
dropdownContextService.hide();
|
|
784
791
|
});
|
|
785
792
|
};
|
|
786
793
|
bindLeave();
|
|
787
794
|
subscription.add(core$1.fromEvent(dropdownRef.current, 'mouseenter').subscribe(() => {
|
|
795
|
+
if (props.disabled) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
788
798
|
if (leaveSub) {
|
|
789
799
|
leaveSub.unsubscribe();
|
|
790
800
|
}
|
|
@@ -804,7 +814,7 @@ const Dropdown = core.withAnnotation({
|
|
|
804
814
|
dropdownContextService.hide(false);
|
|
805
815
|
}
|
|
806
816
|
},
|
|
807
|
-
$render: scopedCss.withScopedCSS(scopedId$
|
|
817
|
+
$render: scopedCss.withScopedCSS(scopedId$m, () => {
|
|
808
818
|
return (jsxRuntime.jsxs("div", { class: ['dropdown', props.class], style: props.style, ref: dropdownRef, children: [jsxRuntime.jsxs("div", { class: "dropdown-btn", ref: triggerRef, children: [jsxRuntime.jsx("div", { class: "dropdown-btn-inner", children: props.children }), jsxRuntime.jsx("div", { class: "dropdown-btn-arrow" })] }), isShow() &&
|
|
809
819
|
jsxRuntime.jsx(DropdownMenuPortal, { toLeft: props.toLeft, padding: props.padding, noTrigger: props.trigger === 'none', width: props.width, abreast: props.abreast, triggerRef: triggerRef, children: Array.isArray(props.menu) ?
|
|
810
820
|
props.menu.map(menu => {
|
|
@@ -821,7 +831,7 @@ const Dropdown = core.withAnnotation({
|
|
|
821
831
|
};
|
|
822
832
|
});
|
|
823
833
|
|
|
824
|
-
var scopedId$
|
|
834
|
+
var scopedId$k = "vf-c32a7b";
|
|
825
835
|
|
|
826
836
|
function Keymap(props) {
|
|
827
837
|
const arr = [];
|
|
@@ -855,20 +865,20 @@ function Keymap(props) {
|
|
|
855
865
|
arr.push(jsxRuntime.jsx("span", { children: keymap.key }));
|
|
856
866
|
}
|
|
857
867
|
}
|
|
858
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
868
|
+
return scopedCss.withScopedCSS(scopedId$k, () => {
|
|
859
869
|
return (jsxRuntime.jsx("span", { class: "keymap", children: arr }));
|
|
860
870
|
});
|
|
861
871
|
}
|
|
862
872
|
|
|
863
|
-
var scopedId$
|
|
873
|
+
var scopedId$j = "vf-acaa5f";
|
|
864
874
|
|
|
865
875
|
function MenuHeading(props) {
|
|
866
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
876
|
+
return scopedCss.withScopedCSS(scopedId$j, () => {
|
|
867
877
|
return (jsxRuntime.jsx("div", { class: "menu-heading", children: props.children }));
|
|
868
878
|
});
|
|
869
879
|
}
|
|
870
880
|
|
|
871
|
-
var scopedId$
|
|
881
|
+
var scopedId$i = "vf-c3b9dc";
|
|
872
882
|
|
|
873
883
|
function MenuItem(props) {
|
|
874
884
|
const dropdownContextService = core.inject(exports.DropdownContextService, null);
|
|
@@ -888,7 +898,7 @@ function MenuItem(props) {
|
|
|
888
898
|
}
|
|
889
899
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
|
|
890
900
|
}
|
|
891
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
901
|
+
return scopedCss.withScopedCSS(scopedId$i, () => {
|
|
892
902
|
return (jsxRuntime.jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxRuntime.jsxs("div", { class: "menu-item-content", children: [jsxRuntime.jsxs("div", { children: [props.icon && jsxRuntime.jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), jsxRuntime.jsx("div", { children: props.desc })] }), props.arrow ?
|
|
893
903
|
jsxRuntime.jsx("div", { class: "arrow", children: jsxRuntime.jsx("span", { class: "xnote-icon-arrow-right" }) }) :
|
|
894
904
|
jsxRuntime.jsx("div", { class: [
|
|
@@ -898,11 +908,11 @@ function MenuItem(props) {
|
|
|
898
908
|
});
|
|
899
909
|
}
|
|
900
910
|
|
|
901
|
-
var scopedId$
|
|
911
|
+
var scopedId$h = "vf-a23c47";
|
|
902
912
|
|
|
903
913
|
function Popup(props) {
|
|
904
914
|
const host = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
905
|
-
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$
|
|
915
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$h, () => {
|
|
906
916
|
return (jsxRuntime.jsx("div", { class: "popup", style: {
|
|
907
917
|
left: props.left + 'px',
|
|
908
918
|
top: props.top + 'px'
|
|
@@ -910,15 +920,15 @@ function Popup(props) {
|
|
|
910
920
|
}), host);
|
|
911
921
|
}
|
|
912
922
|
|
|
913
|
-
var scopedId$
|
|
923
|
+
var scopedId$g = "vf-cd4d99";
|
|
914
924
|
|
|
915
925
|
function ToolbarItem(props) {
|
|
916
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
926
|
+
return scopedCss.withScopedCSS(scopedId$g, () => {
|
|
917
927
|
return (jsxRuntime.jsx("div", { class: "toolbar-item", children: props.children }));
|
|
918
928
|
});
|
|
919
929
|
}
|
|
920
930
|
|
|
921
|
-
var scopedId$
|
|
931
|
+
var scopedId$f = "vf-2a8a65";
|
|
922
932
|
|
|
923
933
|
exports.RefreshService = class RefreshService {
|
|
924
934
|
constructor() {
|
|
@@ -2219,6 +2229,37 @@ function registerTextIndentShortcut(textbus) {
|
|
|
2219
2229
|
});
|
|
2220
2230
|
}
|
|
2221
2231
|
|
|
2232
|
+
let ToolService = class ToolService {
|
|
2233
|
+
constructor(selection, controller) {
|
|
2234
|
+
this.selection = selection;
|
|
2235
|
+
this.controller = controller;
|
|
2236
|
+
const [state, updateState] = hooks.useProduce({
|
|
2237
|
+
inSourceCode: false,
|
|
2238
|
+
readonly: controller.readonly
|
|
2239
|
+
});
|
|
2240
|
+
this.state = state;
|
|
2241
|
+
this.sub = core$1.merge(selection.onChange, controller.onReadonlyStateChange).subscribe(() => {
|
|
2242
|
+
updateState(draft => {
|
|
2243
|
+
draft.readonly = controller.readonly;
|
|
2244
|
+
draft.inSourceCode = selection.commonAncestorComponent instanceof SourceCodeComponent;
|
|
2245
|
+
});
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
destroy() {
|
|
2249
|
+
this.sub.unsubscribe();
|
|
2250
|
+
}
|
|
2251
|
+
};
|
|
2252
|
+
ToolService = __decorate([
|
|
2253
|
+
core.Injectable(),
|
|
2254
|
+
__metadata("design:paramtypes", [core$1.Selection,
|
|
2255
|
+
core$1.Controller])
|
|
2256
|
+
], ToolService);
|
|
2257
|
+
|
|
2258
|
+
function useCommonState() {
|
|
2259
|
+
const toolService = core.inject(ToolService);
|
|
2260
|
+
return toolService.state;
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2222
2263
|
function AttrTool(props) {
|
|
2223
2264
|
const commander = core.inject(core$1.Commander);
|
|
2224
2265
|
const selection = core.inject(core$1.Selection);
|
|
@@ -2295,9 +2336,11 @@ function AttrTool(props) {
|
|
|
2295
2336
|
break;
|
|
2296
2337
|
}
|
|
2297
2338
|
}
|
|
2298
|
-
|
|
2339
|
+
const commonState = useCommonState();
|
|
2340
|
+
return scopedCss.withScopedCSS(scopedId$f, () => {
|
|
2299
2341
|
const states = checkStates();
|
|
2300
|
-
|
|
2342
|
+
const b = commonState().inSourceCode || commonState().readonly;
|
|
2343
|
+
return (jsxRuntime.jsx(Dropdown, { disabled: b, width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
|
|
2301
2344
|
{
|
|
2302
2345
|
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'L', modKey: true } }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
|
|
2303
2346
|
value: 't-l'
|
|
@@ -2320,7 +2363,7 @@ function AttrTool(props) {
|
|
|
2320
2363
|
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'Tab', shiftKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
|
|
2321
2364
|
value: 'i-'
|
|
2322
2365
|
}
|
|
2323
|
-
], children: props.children || jsxRuntime.jsx(Button, { arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${states.textAlign || 'left'} icon` }) }) }));
|
|
2366
|
+
], children: props.children || jsxRuntime.jsx(Button, { disabled: b, arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${states.textAlign || 'left'} icon` }) }) }));
|
|
2324
2367
|
});
|
|
2325
2368
|
}
|
|
2326
2369
|
|
|
@@ -2502,6 +2545,17 @@ class TableComponent extends core$1.Component {
|
|
|
2502
2545
|
}
|
|
2503
2546
|
}
|
|
2504
2547
|
}
|
|
2548
|
+
splitCellBySlot(slot) {
|
|
2549
|
+
const slots = this.getNormalizedData();
|
|
2550
|
+
for (const item of slots) {
|
|
2551
|
+
for (const cell of item.cells) {
|
|
2552
|
+
if (cell.raw.slot === slot) {
|
|
2553
|
+
Reflect.deleteProperty(this.state.mergeConfig, cell.raw.id);
|
|
2554
|
+
return;
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2505
2559
|
getMaxRectangle(startSlot, endSlot) {
|
|
2506
2560
|
let index1 = -1;
|
|
2507
2561
|
let index2 = -1;
|
|
@@ -3573,7 +3627,8 @@ function useBlockTransform() {
|
|
|
3573
3627
|
function BlockTool() {
|
|
3574
3628
|
const checkStates = useActiveBlock();
|
|
3575
3629
|
const transform = useBlockTransform();
|
|
3576
|
-
|
|
3630
|
+
const commonState = useCommonState();
|
|
3631
|
+
return scopedCss.withScopedCSS(scopedId$f, () => {
|
|
3577
3632
|
const states = checkStates();
|
|
3578
3633
|
const types = [
|
|
3579
3634
|
[states.paragraph, 'xnote-icon-pilcrow'],
|
|
@@ -3597,7 +3652,8 @@ function BlockTool() {
|
|
|
3597
3652
|
break;
|
|
3598
3653
|
}
|
|
3599
3654
|
}
|
|
3600
|
-
|
|
3655
|
+
const b = commonState().inSourceCode || commonState().readonly;
|
|
3656
|
+
return (jsxRuntime.jsx(Dropdown, { disabled: b, width: 'auto', onCheck: transform, trigger: 'hover', menu: [
|
|
3601
3657
|
{
|
|
3602
3658
|
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
3603
3659
|
modKey: true,
|
|
@@ -3662,7 +3718,7 @@ function BlockTool() {
|
|
|
3662
3718
|
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-hightlight-box" }), checked: states.highlightBox, children: "\u9AD8\u4EAE\u5757" }),
|
|
3663
3719
|
value: 'highlightBox'
|
|
3664
3720
|
}
|
|
3665
|
-
], children: jsxRuntime.jsx(Button, { arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: currentType }) }) }));
|
|
3721
|
+
], children: jsxRuntime.jsx(Button, { disabled: b, arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: currentType }) }) }));
|
|
3666
3722
|
});
|
|
3667
3723
|
}
|
|
3668
3724
|
|
|
@@ -3840,6 +3896,40 @@ const linkFormatLoader = {
|
|
|
3840
3896
|
}
|
|
3841
3897
|
};
|
|
3842
3898
|
|
|
3899
|
+
const subscriptFormatter = new core$1.Formatter('sub', {
|
|
3900
|
+
render(children) {
|
|
3901
|
+
return core$1.createVNode('sub', null, children);
|
|
3902
|
+
}
|
|
3903
|
+
});
|
|
3904
|
+
const subscriptFormatLoader = {
|
|
3905
|
+
match(element) {
|
|
3906
|
+
return element.tagName === 'SUB';
|
|
3907
|
+
},
|
|
3908
|
+
read() {
|
|
3909
|
+
return {
|
|
3910
|
+
formatter: subscriptFormatter,
|
|
3911
|
+
value: true
|
|
3912
|
+
};
|
|
3913
|
+
}
|
|
3914
|
+
};
|
|
3915
|
+
|
|
3916
|
+
const superscriptFormatter = new core$1.Formatter('super', {
|
|
3917
|
+
render(children) {
|
|
3918
|
+
return core$1.createVNode('sup', null, children);
|
|
3919
|
+
}
|
|
3920
|
+
});
|
|
3921
|
+
const superscriptFormatLoader = {
|
|
3922
|
+
match(element) {
|
|
3923
|
+
return element.tagName === 'SUP';
|
|
3924
|
+
},
|
|
3925
|
+
read() {
|
|
3926
|
+
return {
|
|
3927
|
+
formatter: superscriptFormatter,
|
|
3928
|
+
value: true
|
|
3929
|
+
};
|
|
3930
|
+
}
|
|
3931
|
+
};
|
|
3932
|
+
|
|
3843
3933
|
const underlineFormatter = new core$1.Formatter('underline', {
|
|
3844
3934
|
columned: true,
|
|
3845
3935
|
render(children) {
|
|
@@ -3889,9 +3979,9 @@ function BoldTool() {
|
|
|
3889
3979
|
const query = core.inject(core$1.Query);
|
|
3890
3980
|
const textbus = core.inject(core$1.Textbus);
|
|
3891
3981
|
const refreshService = core.inject(exports.RefreshService);
|
|
3982
|
+
const commonState = useCommonState();
|
|
3892
3983
|
const [viewModel, update] = hooks.useProduce({
|
|
3893
3984
|
highlight: false,
|
|
3894
|
-
disabled: false,
|
|
3895
3985
|
});
|
|
3896
3986
|
function toggle() {
|
|
3897
3987
|
toggleBold(textbus);
|
|
@@ -3907,7 +3997,20 @@ function BoldTool() {
|
|
|
3907
3997
|
});
|
|
3908
3998
|
return () => {
|
|
3909
3999
|
const vm = viewModel();
|
|
3910
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled:
|
|
4000
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-bold" }) });
|
|
4001
|
+
};
|
|
4002
|
+
}
|
|
4003
|
+
|
|
4004
|
+
function CleanFormatsTool() {
|
|
4005
|
+
const commonState = useCommonState();
|
|
4006
|
+
const commander = core.inject(core$1.Commander);
|
|
4007
|
+
function clean() {
|
|
4008
|
+
commander.cleanFormats([
|
|
4009
|
+
linkFormatter
|
|
4010
|
+
]);
|
|
4011
|
+
}
|
|
4012
|
+
return () => {
|
|
4013
|
+
return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly, onClick: clean, children: jsxRuntime.jsx("span", { class: "xnote-icon-clear-formatting" }) }));
|
|
3911
4014
|
};
|
|
3912
4015
|
}
|
|
3913
4016
|
|
|
@@ -3915,9 +4018,9 @@ function CodeTool() {
|
|
|
3915
4018
|
const query = core.inject(core$1.Query);
|
|
3916
4019
|
const refreshService = core.inject(exports.RefreshService);
|
|
3917
4020
|
const textbus = core.inject(core$1.Textbus);
|
|
4021
|
+
const commonState = useCommonState();
|
|
3918
4022
|
const [viewModel, update] = hooks.useProduce({
|
|
3919
4023
|
highlight: false,
|
|
3920
|
-
disabled: false,
|
|
3921
4024
|
});
|
|
3922
4025
|
function toggle() {
|
|
3923
4026
|
toggleCode(textbus);
|
|
@@ -3933,11 +4036,11 @@ function CodeTool() {
|
|
|
3933
4036
|
});
|
|
3934
4037
|
return () => {
|
|
3935
4038
|
const vm = viewModel();
|
|
3936
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled:
|
|
4039
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-code" }) });
|
|
3937
4040
|
};
|
|
3938
4041
|
}
|
|
3939
4042
|
|
|
3940
|
-
var scopedId$
|
|
4043
|
+
var scopedId$e = "vf-accb31";
|
|
3941
4044
|
|
|
3942
4045
|
function ColorTool(props) {
|
|
3943
4046
|
const query = core.inject(core$1.Query);
|
|
@@ -3948,7 +4051,6 @@ function ColorTool(props) {
|
|
|
3948
4051
|
const backgroundColor = core.createSignal('');
|
|
3949
4052
|
const [viewModel] = hooks.useProduce({
|
|
3950
4053
|
highlight: false,
|
|
3951
|
-
disabled: false,
|
|
3952
4054
|
});
|
|
3953
4055
|
function updateCheckState() {
|
|
3954
4056
|
if (!props.slot && !selection.isSelected) {
|
|
@@ -4000,9 +4102,10 @@ function ColorTool(props) {
|
|
|
4000
4102
|
'#90a0e5',
|
|
4001
4103
|
'#c596e0',
|
|
4002
4104
|
];
|
|
4003
|
-
|
|
4105
|
+
const commonState = useCommonState();
|
|
4106
|
+
return scopedCss.withScopedCSS(scopedId$e, () => {
|
|
4004
4107
|
const vm = viewModel();
|
|
4005
|
-
return (jsxRuntime.jsx(Dropdown, { style: props.style, width: '180px', abreast: props.abreast, trigger: 'hover', menu: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "text-colors", children: [jsxRuntime.jsx("div", { class: {
|
|
4108
|
+
return (jsxRuntime.jsx(Dropdown, { disabled: commonState().readonly || commonState().inSourceCode, style: props.style, width: '180px', abreast: props.abreast, trigger: 'hover', menu: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "text-colors", children: [jsxRuntime.jsx("div", { class: {
|
|
4006
4109
|
'no-background': true,
|
|
4007
4110
|
active: textColor() === ''
|
|
4008
4111
|
}, onClick: () => {
|
|
@@ -4032,7 +4135,7 @@ function ColorTool(props) {
|
|
|
4032
4135
|
(_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
4033
4136
|
commander.applyFormat(backgroundColorFormatter, c);
|
|
4034
4137
|
}, style: { backgroundColor: c }, children: "A" });
|
|
4035
|
-
})] })] }), children: props.children || jsxRuntime.jsx(Button, { highlight: vm.highlight, arrow: true, disabled:
|
|
4138
|
+
})] })] }), children: props.children || jsxRuntime.jsx(Button, { highlight: vm.highlight, arrow: true, disabled: commonState().readonly || commonState().inSourceCode, children: jsxRuntime.jsx("span", { class: "background", children: jsxRuntime.jsx("span", { style: {
|
|
4036
4139
|
backgroundColor: backgroundColor(),
|
|
4037
4140
|
color: textColor()
|
|
4038
4141
|
}, children: jsxRuntime.jsx("span", { class: "xnote-icon-color" }) }) }) }) }));
|
|
@@ -4132,16 +4235,18 @@ function FontFamilyTool() {
|
|
|
4132
4235
|
core.onUnmounted(() => {
|
|
4133
4236
|
subscription.unsubscribe();
|
|
4134
4237
|
});
|
|
4238
|
+
const commonState = useCommonState();
|
|
4135
4239
|
return () => {
|
|
4136
4240
|
var _a;
|
|
4137
|
-
|
|
4241
|
+
const b = commonState().inSourceCode || commonState().readonly;
|
|
4242
|
+
return (jsxRuntime.jsx(Dropdown, { disabled: b, onCheck: check, menu: fontFamilyOptions.map(i => {
|
|
4138
4243
|
const disabled = i.value ? !i.value.split(',').map(i => isSupportFont(i.trim())).some(v => v) : false;
|
|
4139
4244
|
return {
|
|
4140
4245
|
label: jsxRuntime.jsx(MenuItem, { disabled: disabled, checked: currentFontFamily() === i.value, children: i.label }),
|
|
4141
4246
|
disabled,
|
|
4142
4247
|
value: i.value,
|
|
4143
4248
|
};
|
|
4144
|
-
}), children: jsxRuntime.jsx(Button, { arrow: true, highlight: highlight(), children: ((_a = fontFamilyOptions.find(v => {
|
|
4249
|
+
}), children: jsxRuntime.jsx(Button, { disabled: b, arrow: true, highlight: highlight(), children: ((_a = fontFamilyOptions.find(v => {
|
|
4145
4250
|
return v.value === currentFontFamily();
|
|
4146
4251
|
})) === null || _a === void 0 ? void 0 : _a.label) || '默认' }) }));
|
|
4147
4252
|
};
|
|
@@ -4186,408 +4291,62 @@ function FontSizeTool() {
|
|
|
4186
4291
|
core.onUnmounted(() => {
|
|
4187
4292
|
subscription.unsubscribe();
|
|
4188
4293
|
});
|
|
4294
|
+
const commonState = useCommonState();
|
|
4189
4295
|
return () => {
|
|
4190
|
-
|
|
4296
|
+
const b = commonState().inSourceCode || commonState().readonly;
|
|
4297
|
+
return (jsxRuntime.jsx(Dropdown, { disabled: b, onCheck: check, menu: fontSizeOptions.map(i => {
|
|
4191
4298
|
return {
|
|
4192
4299
|
label: jsxRuntime.jsx(MenuItem, { checked: currentFontSize() === i, children: i || '默认' }),
|
|
4193
4300
|
value: i
|
|
4194
4301
|
};
|
|
4195
|
-
}), children: jsxRuntime.jsxs(Button, { arrow: true, highlight: highlight(), children: [jsxRuntime.jsx("span", { class: "xnote-icon-font-size" }), jsxRuntime.jsx("span", { children: currentFontSize() || '默认' })] }) }));
|
|
4196
|
-
};
|
|
4197
|
-
}
|
|
4198
|
-
|
|
4199
|
-
function ItalicTool() {
|
|
4200
|
-
const query = core.inject(core$1.Query);
|
|
4201
|
-
const refreshService = core.inject(exports.RefreshService);
|
|
4202
|
-
const textbus = core.inject(core$1.Textbus);
|
|
4203
|
-
const [viewModel, update] = hooks.useProduce({
|
|
4204
|
-
highlight: false,
|
|
4205
|
-
disabled: false,
|
|
4206
|
-
});
|
|
4207
|
-
function toggle() {
|
|
4208
|
-
toggleItalic(textbus);
|
|
4209
|
-
}
|
|
4210
|
-
const sub = refreshService.onRefresh.subscribe(() => {
|
|
4211
|
-
const state = query.queryFormat(italicFormatter);
|
|
4212
|
-
update(draft => {
|
|
4213
|
-
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
4214
|
-
});
|
|
4215
|
-
});
|
|
4216
|
-
core.onUnmounted(() => {
|
|
4217
|
-
sub.unsubscribe();
|
|
4218
|
-
});
|
|
4219
|
-
return () => {
|
|
4220
|
-
const vm = viewModel();
|
|
4221
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
|
|
4302
|
+
}), children: jsxRuntime.jsxs(Button, { disabled: b, arrow: true, highlight: highlight(), children: [jsxRuntime.jsx("span", { class: "xnote-icon-font-size" }), jsxRuntime.jsx("span", { children: currentFontSize() || '默认' })] }) }));
|
|
4222
4303
|
};
|
|
4223
4304
|
}
|
|
4224
4305
|
|
|
4225
|
-
var scopedId$
|
|
4226
|
-
|
|
4227
|
-
exports.EditorService = class EditorService {
|
|
4228
|
-
constructor() {
|
|
4229
|
-
this.hideInlineToolbar = false;
|
|
4230
|
-
this.canShowLeftToolbar = true;
|
|
4231
|
-
this.onLeftToolbarCanVisibleChange = new core$1.Subject();
|
|
4232
|
-
}
|
|
4233
|
-
changeLeftToolbarVisible(b) {
|
|
4234
|
-
this.canShowLeftToolbar = b;
|
|
4235
|
-
this.onLeftToolbarCanVisibleChange.next();
|
|
4236
|
-
}
|
|
4237
|
-
};
|
|
4238
|
-
exports.EditorService = __decorate([
|
|
4239
|
-
core.Injectable({
|
|
4240
|
-
provideIn: 'root'
|
|
4241
|
-
})
|
|
4242
|
-
], exports.EditorService);
|
|
4306
|
+
var scopedId$d = "vf-cf8e1c";
|
|
4243
4307
|
|
|
4244
|
-
|
|
4245
|
-
const selectionBridge = core.inject(platformBrowser.SelectionBridge);
|
|
4246
|
-
const selection = core.inject(core$1.Selection);
|
|
4247
|
-
const commander = core.inject(core$1.Commander);
|
|
4248
|
-
const editorService = core.inject(exports.EditorService);
|
|
4249
|
-
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
4250
|
-
const isShow = core.createSignal(false);
|
|
4251
|
-
const value = core.createSignal('');
|
|
4252
|
-
function setLink(ev) {
|
|
4253
|
-
ev.preventDefault();
|
|
4254
|
-
commander.applyFormat(linkFormatter, {
|
|
4255
|
-
href: value(),
|
|
4256
|
-
target: '_blanK'
|
|
4257
|
-
});
|
|
4258
|
-
isShow.set(false);
|
|
4259
|
-
}
|
|
4260
|
-
let isClickFromSelf = false;
|
|
4261
|
-
const sub = core$1.fromEvent(document, 'click').subscribe(() => {
|
|
4262
|
-
if (isClickFromSelf) {
|
|
4263
|
-
isClickFromSelf = false;
|
|
4264
|
-
return;
|
|
4265
|
-
}
|
|
4266
|
-
editorService.hideInlineToolbar = false;
|
|
4267
|
-
isShow.set(false);
|
|
4268
|
-
});
|
|
4269
|
-
core.onUnmounted(() => {
|
|
4270
|
-
sub.unsubscribe();
|
|
4271
|
-
});
|
|
4272
|
-
return scopedCss.withScopedCSS(scopedId$a, () => {
|
|
4273
|
-
const containerRect = container.getBoundingClientRect();
|
|
4274
|
-
const rect = isShow() ? selectionBridge.getRect({
|
|
4275
|
-
slot: selection.focusSlot,
|
|
4276
|
-
offset: selection.focusOffset
|
|
4277
|
-
}) : {};
|
|
4278
|
-
return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { onClick: () => {
|
|
4279
|
-
var _a;
|
|
4280
|
-
isShow.set(true);
|
|
4281
|
-
isClickFromSelf = true;
|
|
4282
|
-
(_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
4283
|
-
}, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
|
|
4284
|
-
jsxRuntime.jsx(Popup, { left: rect.left - containerRect.left, top: rect.top + rect.height - containerRect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
|
|
4285
|
-
isClickFromSelf = true;
|
|
4286
|
-
}, class: "input-group", children: [jsxRuntime.jsx("input", { onChange: ev => {
|
|
4287
|
-
value.set(ev.target.value);
|
|
4288
|
-
}, placeholder: "\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740", type: "text" }), jsxRuntime.jsx(Button, { type: "submit", children: "\u786E\u5B9A" })] }) })] }));
|
|
4289
|
-
});
|
|
4308
|
+
class FileUploader {
|
|
4290
4309
|
}
|
|
4291
4310
|
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
const textbus = core.inject(core$1.Textbus);
|
|
4296
|
-
const [viewModel, update] = hooks.useProduce({
|
|
4297
|
-
highlight: false,
|
|
4298
|
-
disabled: false,
|
|
4299
|
-
});
|
|
4300
|
-
function toggle() {
|
|
4301
|
-
toggleStrikeThrough(textbus);
|
|
4311
|
+
class ImageComponent extends core$1.Component {
|
|
4312
|
+
static fromJSON(textbus, json) {
|
|
4313
|
+
return new ImageComponent(textbus, Object.assign({}, json));
|
|
4302
4314
|
}
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
update(draft => {
|
|
4306
|
-
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
4307
|
-
});
|
|
4308
|
-
});
|
|
4309
|
-
core.onUnmounted(() => {
|
|
4310
|
-
sub.unsubscribe();
|
|
4311
|
-
});
|
|
4312
|
-
return () => {
|
|
4313
|
-
const vm = viewModel();
|
|
4314
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
|
|
4315
|
-
};
|
|
4316
|
-
}
|
|
4317
|
-
|
|
4318
|
-
function UnderlineTool() {
|
|
4319
|
-
const query = core.inject(core$1.Query);
|
|
4320
|
-
const refreshService = core.inject(exports.RefreshService);
|
|
4321
|
-
const textbus = core.inject(core$1.Textbus);
|
|
4322
|
-
const [viewModel, update] = hooks.useProduce({
|
|
4323
|
-
highlight: false,
|
|
4324
|
-
disabled: false,
|
|
4325
|
-
});
|
|
4326
|
-
function toggle() {
|
|
4327
|
-
toggleUnderline(textbus);
|
|
4315
|
+
getSlots() {
|
|
4316
|
+
return [];
|
|
4328
4317
|
}
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
});
|
|
4318
|
+
}
|
|
4319
|
+
ImageComponent.type = core$1.ContentType.InlineComponent;
|
|
4320
|
+
ImageComponent.componentName = 'ImageComponent';
|
|
4321
|
+
function ImageView(props) {
|
|
4322
|
+
const { name, state } = props.component;
|
|
4323
|
+
const imageRef = core.createRef();
|
|
4324
|
+
const readonly = useReadonly();
|
|
4325
|
+
const output = useOutput();
|
|
4338
4326
|
return () => {
|
|
4339
|
-
|
|
4340
|
-
|
|
4327
|
+
if (readonly() || output()) {
|
|
4328
|
+
return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
|
|
4329
|
+
width: state.width,
|
|
4330
|
+
height: state.height
|
|
4331
|
+
} }) }));
|
|
4332
|
+
}
|
|
4333
|
+
return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx(DragResize, { source: imageRef, component: props.component, children: jsxRuntime.jsx("img", { alt: "", ref: imageRef, src: state.src, style: {
|
|
4334
|
+
width: state.width,
|
|
4335
|
+
height: state.height
|
|
4336
|
+
} }) }) }));
|
|
4341
4337
|
};
|
|
4342
4338
|
}
|
|
4343
|
-
|
|
4344
|
-
const cellAlignAttr = new core$1.Attribute('cellAlign', {
|
|
4345
|
-
render(node, formatValue) {
|
|
4346
|
-
node.styles.set('verticalAlign', formatValue);
|
|
4347
|
-
}
|
|
4348
|
-
});
|
|
4349
|
-
const cellAlignAttrLoader = {
|
|
4339
|
+
const imageComponentLoader = {
|
|
4350
4340
|
match(element) {
|
|
4351
|
-
return element
|
|
4341
|
+
return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
|
|
4352
4342
|
},
|
|
4353
|
-
read(element) {
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
};
|
|
4360
|
-
|
|
4361
|
-
function CellAlignTool() {
|
|
4362
|
-
const currentValue = core.createSignal('');
|
|
4363
|
-
const selection = core.inject(core$1.Selection);
|
|
4364
|
-
function check(v) {
|
|
4365
|
-
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
4366
|
-
if (commonAncestorComponent instanceof TableComponent) {
|
|
4367
|
-
const slots = commonAncestorComponent.getSelectedNormalizedSlots();
|
|
4368
|
-
slots.forEach(item => {
|
|
4369
|
-
item.cells.forEach(cell => {
|
|
4370
|
-
if (cell.visible) {
|
|
4371
|
-
cell.raw.slot.setAttribute(cellAlignAttr, v);
|
|
4372
|
-
}
|
|
4373
|
-
});
|
|
4374
|
-
});
|
|
4375
|
-
}
|
|
4376
|
-
}
|
|
4377
|
-
const refreshService = core.inject(exports.RefreshService);
|
|
4378
|
-
const query = core.inject(core$1.Query);
|
|
4379
|
-
const highlight = core.createSignal(false);
|
|
4380
|
-
const subscription = refreshService.onRefresh.subscribe(() => {
|
|
4381
|
-
const result = query.queryAttribute(cellAlignAttr);
|
|
4382
|
-
const isHighlight = result.state === core$1.QueryStateType.Enabled;
|
|
4383
|
-
highlight.set(isHighlight);
|
|
4384
|
-
currentValue.set(isHighlight ? result.value : 'middle');
|
|
4385
|
-
});
|
|
4386
|
-
core.onUnmounted(() => {
|
|
4387
|
-
subscription.unsubscribe();
|
|
4388
|
-
});
|
|
4389
|
-
return () => {
|
|
4390
|
-
return (jsxRuntime.jsx(Dropdown, { onCheck: check, menu: [
|
|
4391
|
-
{
|
|
4392
|
-
label: jsxRuntime.jsx(MenuItem, { checked: currentValue() === 'top', icon: jsxRuntime.jsx("span", { class: "xnote-icon-align-top" }), children: "\u9876\u90E8\u5BF9\u9F50" }),
|
|
4393
|
-
value: 'top'
|
|
4394
|
-
},
|
|
4395
|
-
{
|
|
4396
|
-
label: jsxRuntime.jsx(MenuItem, { checked: currentValue() === 'middle', icon: jsxRuntime.jsx("span", { class: "xnote-icon-align-middle" }), children: "\u5782\u76F4\u5C45\u4E2D" }),
|
|
4397
|
-
value: 'middle'
|
|
4398
|
-
},
|
|
4399
|
-
{
|
|
4400
|
-
label: jsxRuntime.jsx(MenuItem, { checked: currentValue() === 'bottom', icon: jsxRuntime.jsx("span", { class: "xnote-icon-align-bottom" }), children: "\u5E95\u90E8\u5BF9\u9F50" }),
|
|
4401
|
-
value: 'bottom'
|
|
4402
|
-
}
|
|
4403
|
-
], children: jsxRuntime.jsx(Button, { arrow: true, highlight: highlight(), children: jsxRuntime.jsx("span", { class: 'xnote-icon-align-' + (currentValue() || 'middle') }) }) }));
|
|
4404
|
-
};
|
|
4405
|
-
}
|
|
4406
|
-
|
|
4407
|
-
const cellBackgroundAttr = new core$1.Attribute('cellBackground', {
|
|
4408
|
-
render(node, formatValue) {
|
|
4409
|
-
const rgba = color.parseCss(formatValue);
|
|
4410
|
-
if (rgba) {
|
|
4411
|
-
const hsl = color.rgb2Hsl(rgba);
|
|
4412
|
-
if (hsl.l > 50) {
|
|
4413
|
-
hsl.l -= 10;
|
|
4414
|
-
}
|
|
4415
|
-
else {
|
|
4416
|
-
hsl.l += Math.max((50 - hsl.l) * 0.55, 10);
|
|
4417
|
-
}
|
|
4418
|
-
hsl.s *= 0.7;
|
|
4419
|
-
const newRgba = color.hsl2Rgb(hsl);
|
|
4420
|
-
node.styles.set('borderColor', `rgba(${newRgba.r}, ${newRgba.g}, ${newRgba.b}, ${rgba.a || 1})`);
|
|
4421
|
-
}
|
|
4422
|
-
node.styles.set('backgroundColor', formatValue);
|
|
4423
|
-
}
|
|
4424
|
-
});
|
|
4425
|
-
const cellBackgroundAttrLoader = {
|
|
4426
|
-
match(element) {
|
|
4427
|
-
return (element.tagName === 'TD' || element.tagName === 'TH') && !!element.style.backgroundColor;
|
|
4428
|
-
},
|
|
4429
|
-
read(element) {
|
|
4430
|
-
return {
|
|
4431
|
-
attribute: cellBackgroundAttr,
|
|
4432
|
-
value: element.style.backgroundColor
|
|
4433
|
-
};
|
|
4434
|
-
}
|
|
4435
|
-
};
|
|
4436
|
-
|
|
4437
|
-
function CellBackgroundTool() {
|
|
4438
|
-
const refreshService = core.inject(exports.RefreshService);
|
|
4439
|
-
const selection = core.inject(core$1.Selection);
|
|
4440
|
-
const [viewModel, update] = hooks.useProduce({
|
|
4441
|
-
highlight: false,
|
|
4442
|
-
disabled: false,
|
|
4443
|
-
});
|
|
4444
|
-
function setColor(picker) {
|
|
4445
|
-
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
4446
|
-
if (commonAncestorComponent instanceof TableComponent) {
|
|
4447
|
-
const slots = commonAncestorComponent.getSelectedNormalizedSlots();
|
|
4448
|
-
if (slots) {
|
|
4449
|
-
slots.map(i => {
|
|
4450
|
-
return i.cells.filter(t => t.visible).map(i => i.raw.slot);
|
|
4451
|
-
}).flat().forEach(slot => {
|
|
4452
|
-
const rgba = picker.rgba;
|
|
4453
|
-
if (rgba) {
|
|
4454
|
-
slot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`);
|
|
4455
|
-
}
|
|
4456
|
-
else {
|
|
4457
|
-
slot.removeAttribute(cellBackgroundAttr);
|
|
4458
|
-
}
|
|
4459
|
-
});
|
|
4460
|
-
}
|
|
4461
|
-
}
|
|
4462
|
-
}
|
|
4463
|
-
const sub = refreshService.onRefresh.subscribe(() => {
|
|
4464
|
-
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
4465
|
-
update(draft => {
|
|
4466
|
-
draft.disabled = !(commonAncestorComponent instanceof TableComponent);
|
|
4467
|
-
});
|
|
4468
|
-
});
|
|
4469
|
-
core.onUnmounted(() => {
|
|
4470
|
-
sub.unsubscribe();
|
|
4471
|
-
});
|
|
4472
|
-
return () => {
|
|
4473
|
-
const vm = viewModel();
|
|
4474
|
-
return (jsxRuntime.jsx(Dropdown, { width: '177px', menu: jsxRuntime.jsx(ColorPicker, { onSelected: setColor }), trigger: 'hover', children: jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, children: jsxRuntime.jsx("span", { class: "xnote-icon-palette" }) }) }));
|
|
4475
|
-
};
|
|
4476
|
-
}
|
|
4477
|
-
|
|
4478
|
-
function MergeCellsTool() {
|
|
4479
|
-
const refreshService = core.inject(exports.RefreshService);
|
|
4480
|
-
const selection = core.inject(core$1.Selection);
|
|
4481
|
-
const [viewModel, update] = hooks.useProduce({
|
|
4482
|
-
highlight: false,
|
|
4483
|
-
disabled: false,
|
|
4484
|
-
});
|
|
4485
|
-
function merge() {
|
|
4486
|
-
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
4487
|
-
if (commonAncestorComponent instanceof TableComponent) {
|
|
4488
|
-
commonAncestorComponent.mergeCellBySelection();
|
|
4489
|
-
}
|
|
4490
|
-
}
|
|
4491
|
-
const sub = refreshService.onRefresh.subscribe(() => {
|
|
4492
|
-
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
4493
|
-
update(draft => {
|
|
4494
|
-
draft.disabled = !(commonAncestorComponent instanceof TableComponent);
|
|
4495
|
-
});
|
|
4496
|
-
});
|
|
4497
|
-
core.onUnmounted(() => {
|
|
4498
|
-
sub.unsubscribe();
|
|
4499
|
-
});
|
|
4500
|
-
return () => {
|
|
4501
|
-
const vm = viewModel();
|
|
4502
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: merge, children: jsxRuntime.jsx("span", { class: "xnote-icon-merge-cells" }) });
|
|
4503
|
-
};
|
|
4504
|
-
}
|
|
4505
|
-
|
|
4506
|
-
function SplitCellsTool() {
|
|
4507
|
-
const refreshService = core.inject(exports.RefreshService);
|
|
4508
|
-
const selection = core.inject(core$1.Selection);
|
|
4509
|
-
const [viewModel, update] = hooks.useProduce({
|
|
4510
|
-
highlight: false,
|
|
4511
|
-
disabled: false,
|
|
4512
|
-
});
|
|
4513
|
-
function split() {
|
|
4514
|
-
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
4515
|
-
if (commonAncestorComponent instanceof TableComponent) {
|
|
4516
|
-
commonAncestorComponent.splitCellsBySelection();
|
|
4517
|
-
}
|
|
4518
|
-
}
|
|
4519
|
-
const sub = refreshService.onRefresh.subscribe(() => {
|
|
4520
|
-
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
4521
|
-
update(draft => {
|
|
4522
|
-
if (commonAncestorComponent instanceof TableComponent) {
|
|
4523
|
-
const slots = commonAncestorComponent.getSelectedNormalizedSlots();
|
|
4524
|
-
if (slots) {
|
|
4525
|
-
for (const item of slots) {
|
|
4526
|
-
for (const cell of item.cells) {
|
|
4527
|
-
if (cell.visible && cell.colspan > 1 || cell.colspan > 1) {
|
|
4528
|
-
draft.disabled = false;
|
|
4529
|
-
return;
|
|
4530
|
-
}
|
|
4531
|
-
}
|
|
4532
|
-
}
|
|
4533
|
-
}
|
|
4534
|
-
}
|
|
4535
|
-
draft.disabled = true;
|
|
4536
|
-
});
|
|
4537
|
-
});
|
|
4538
|
-
core.onUnmounted(() => {
|
|
4539
|
-
sub.unsubscribe();
|
|
4540
|
-
});
|
|
4541
|
-
return () => {
|
|
4542
|
-
const vm = viewModel();
|
|
4543
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: split, children: jsxRuntime.jsx("span", { class: "xnote-icon-split-cells" }) });
|
|
4544
|
-
};
|
|
4545
|
-
}
|
|
4546
|
-
|
|
4547
|
-
var scopedId$9 = "vf-cf8e1c";
|
|
4548
|
-
|
|
4549
|
-
class FileUploader {
|
|
4550
|
-
}
|
|
4551
|
-
|
|
4552
|
-
class ImageComponent extends core$1.Component {
|
|
4553
|
-
static fromJSON(textbus, json) {
|
|
4554
|
-
return new ImageComponent(textbus, Object.assign({}, json));
|
|
4555
|
-
}
|
|
4556
|
-
getSlots() {
|
|
4557
|
-
return [];
|
|
4558
|
-
}
|
|
4559
|
-
}
|
|
4560
|
-
ImageComponent.type = core$1.ContentType.InlineComponent;
|
|
4561
|
-
ImageComponent.componentName = 'ImageComponent';
|
|
4562
|
-
function ImageView(props) {
|
|
4563
|
-
const { name, state } = props.component;
|
|
4564
|
-
const imageRef = core.createRef();
|
|
4565
|
-
const readonly = useReadonly();
|
|
4566
|
-
const output = useOutput();
|
|
4567
|
-
return () => {
|
|
4568
|
-
if (readonly() || output()) {
|
|
4569
|
-
return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
|
|
4570
|
-
width: state.width,
|
|
4571
|
-
height: state.height
|
|
4572
|
-
} }) }));
|
|
4573
|
-
}
|
|
4574
|
-
return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx(DragResize, { source: imageRef, component: props.component, children: jsxRuntime.jsx("img", { alt: "", ref: imageRef, src: state.src, style: {
|
|
4575
|
-
width: state.width,
|
|
4576
|
-
height: state.height
|
|
4577
|
-
} }) }) }));
|
|
4578
|
-
};
|
|
4579
|
-
}
|
|
4580
|
-
const imageComponentLoader = {
|
|
4581
|
-
match(element) {
|
|
4582
|
-
return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
|
|
4583
|
-
},
|
|
4584
|
-
read(element, textbus) {
|
|
4585
|
-
const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
|
|
4586
|
-
return new ImageComponent(textbus, {
|
|
4587
|
-
src: img.src,
|
|
4588
|
-
width: img.style.width || 'auto',
|
|
4589
|
-
height: img.style.height || 'auto'
|
|
4590
|
-
});
|
|
4343
|
+
read(element, textbus) {
|
|
4344
|
+
const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
|
|
4345
|
+
return new ImageComponent(textbus, {
|
|
4346
|
+
src: img.src,
|
|
4347
|
+
width: img.style.width || 'auto',
|
|
4348
|
+
height: img.style.height || 'auto'
|
|
4349
|
+
});
|
|
4591
4350
|
}
|
|
4592
4351
|
};
|
|
4593
4352
|
|
|
@@ -4788,7 +4547,7 @@ const katexComponentLoader = {
|
|
|
4788
4547
|
}
|
|
4789
4548
|
};
|
|
4790
4549
|
|
|
4791
|
-
function
|
|
4550
|
+
function InsertMenu(props) {
|
|
4792
4551
|
const commander = core.inject(core$1.Commander);
|
|
4793
4552
|
const selection = core.inject(core$1.Selection);
|
|
4794
4553
|
const textbus = core.inject(core$1.Textbus);
|
|
@@ -4917,45 +4676,642 @@ function InsertTool(props) {
|
|
|
4917
4676
|
insertComponent(comp);
|
|
4918
4677
|
selection.setPosition(p.state.slot, 0);
|
|
4919
4678
|
}
|
|
4920
|
-
break;
|
|
4921
|
-
case 'katex':
|
|
4922
|
-
{
|
|
4923
|
-
const p = new ParagraphComponent(textbus);
|
|
4924
|
-
const comp = new KatexComponent(textbus);
|
|
4925
|
-
p.state.slot.insert(comp);
|
|
4926
|
-
insertComponent(p);
|
|
4927
|
-
selection.selectComponent(comp);
|
|
4679
|
+
break;
|
|
4680
|
+
case 'katex':
|
|
4681
|
+
{
|
|
4682
|
+
const p = new ParagraphComponent(textbus);
|
|
4683
|
+
const comp = new KatexComponent(textbus);
|
|
4684
|
+
p.state.slot.insert(comp);
|
|
4685
|
+
insertComponent(p);
|
|
4686
|
+
selection.selectComponent(comp);
|
|
4687
|
+
}
|
|
4688
|
+
break;
|
|
4689
|
+
case 'step':
|
|
4690
|
+
{
|
|
4691
|
+
const step = new StepComponent(textbus, {
|
|
4692
|
+
step: 0,
|
|
4693
|
+
items: [createStepItem(textbus)]
|
|
4694
|
+
});
|
|
4695
|
+
insertComponent(step);
|
|
4696
|
+
selection.selectFirstPosition(step, false, true);
|
|
4697
|
+
}
|
|
4698
|
+
break;
|
|
4699
|
+
case 'timeline': {
|
|
4700
|
+
const timeline = new TimelineComponent(textbus, {
|
|
4701
|
+
items: [createTimelineItem(textbus, '#296eff')]
|
|
4702
|
+
});
|
|
4703
|
+
insertComponent(timeline);
|
|
4704
|
+
selection.selectFirstPosition(timeline, false, true);
|
|
4705
|
+
break;
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
return scopedCss.withScopedCSS(scopedId$d, () => {
|
|
4710
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.hideTitle ? null : jsxRuntime.jsx(MenuHeading, { children: props.replace ? '替换为' : '在下面添加' }), jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h5'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h6'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(MenuItem, { onClick: () => insert('table'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-table" }), children: "\u8868\u683C" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('todolist'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }), children: "\u5F85\u529E\u5217\u8868" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('image'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-image" }), children: "\u56FE\u7247" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('video'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-video" }), children: "\u89C6\u9891" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('highlightBox'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-hightlight-box" }), children: "\u9AD8\u4EAE\u5757" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('katex'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-function" }), children: "\u6570\u5B66\u516C\u5F0F" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('step'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-step" }), children: "\u6B65\u9AA4\u6761" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('timeline'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-timeline" }), children: "\u65F6\u95F4\u8F74" })] });
|
|
4711
|
+
});
|
|
4712
|
+
}
|
|
4713
|
+
|
|
4714
|
+
function InsertTool() {
|
|
4715
|
+
const selection = core.inject(core$1.Selection);
|
|
4716
|
+
const instance = core.getCurrentInstance();
|
|
4717
|
+
const sub = selection.onChange.subscribe(() => {
|
|
4718
|
+
instance.markAsDirtied();
|
|
4719
|
+
});
|
|
4720
|
+
core.onUnmounted(() => {
|
|
4721
|
+
sub.unsubscribe();
|
|
4722
|
+
});
|
|
4723
|
+
const commonState = useCommonState();
|
|
4724
|
+
return () => {
|
|
4725
|
+
const b = commonState().readonly;
|
|
4726
|
+
return (jsxRuntime.jsx(Dropdown, { disabled: b, menu: jsxRuntime.jsx(InsertMenu, { replace: false, hideTitle: true, slot: selection.focusSlot }), children: jsxRuntime.jsx(Button, { disabled: b, arrow: true, children: "\u63D2\u5165" }) }));
|
|
4727
|
+
};
|
|
4728
|
+
}
|
|
4729
|
+
|
|
4730
|
+
function ItalicTool() {
|
|
4731
|
+
const query = core.inject(core$1.Query);
|
|
4732
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
4733
|
+
const textbus = core.inject(core$1.Textbus);
|
|
4734
|
+
const [viewModel, update] = hooks.useProduce({
|
|
4735
|
+
highlight: false,
|
|
4736
|
+
});
|
|
4737
|
+
function toggle() {
|
|
4738
|
+
toggleItalic(textbus);
|
|
4739
|
+
}
|
|
4740
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
4741
|
+
const state = query.queryFormat(italicFormatter);
|
|
4742
|
+
update(draft => {
|
|
4743
|
+
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
4744
|
+
});
|
|
4745
|
+
});
|
|
4746
|
+
core.onUnmounted(() => {
|
|
4747
|
+
sub.unsubscribe();
|
|
4748
|
+
});
|
|
4749
|
+
const commonState = useCommonState();
|
|
4750
|
+
return () => {
|
|
4751
|
+
const vm = viewModel();
|
|
4752
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
|
|
4753
|
+
};
|
|
4754
|
+
}
|
|
4755
|
+
|
|
4756
|
+
var scopedId$c = "vf-e74208";
|
|
4757
|
+
|
|
4758
|
+
exports.EditorService = class EditorService {
|
|
4759
|
+
constructor() {
|
|
4760
|
+
this.hideInlineToolbar = false;
|
|
4761
|
+
this.canShowLeftToolbar = true;
|
|
4762
|
+
this.onLeftToolbarCanVisibleChange = new core$1.Subject();
|
|
4763
|
+
}
|
|
4764
|
+
changeLeftToolbarVisible(b) {
|
|
4765
|
+
this.canShowLeftToolbar = b;
|
|
4766
|
+
this.onLeftToolbarCanVisibleChange.next();
|
|
4767
|
+
}
|
|
4768
|
+
};
|
|
4769
|
+
exports.EditorService = __decorate([
|
|
4770
|
+
core.Injectable({
|
|
4771
|
+
provideIn: 'root'
|
|
4772
|
+
})
|
|
4773
|
+
], exports.EditorService);
|
|
4774
|
+
|
|
4775
|
+
function LinkTool(props) {
|
|
4776
|
+
const selectionBridge = core.inject(platformBrowser.SelectionBridge);
|
|
4777
|
+
const selection = core.inject(core$1.Selection);
|
|
4778
|
+
const commander = core.inject(core$1.Commander);
|
|
4779
|
+
const editorService = core.inject(exports.EditorService);
|
|
4780
|
+
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
4781
|
+
const isShow = core.createSignal(false);
|
|
4782
|
+
const value = core.createSignal('');
|
|
4783
|
+
function setLink(ev) {
|
|
4784
|
+
ev.preventDefault();
|
|
4785
|
+
commander.applyFormat(linkFormatter, {
|
|
4786
|
+
href: value(),
|
|
4787
|
+
target: '_blanK'
|
|
4788
|
+
});
|
|
4789
|
+
isShow.set(false);
|
|
4790
|
+
}
|
|
4791
|
+
let isClickFromSelf = false;
|
|
4792
|
+
const sub = core$1.fromEvent(document, 'click').subscribe(() => {
|
|
4793
|
+
if (isClickFromSelf) {
|
|
4794
|
+
isClickFromSelf = false;
|
|
4795
|
+
return;
|
|
4796
|
+
}
|
|
4797
|
+
editorService.hideInlineToolbar = false;
|
|
4798
|
+
isShow.set(false);
|
|
4799
|
+
});
|
|
4800
|
+
core.onUnmounted(() => {
|
|
4801
|
+
sub.unsubscribe();
|
|
4802
|
+
});
|
|
4803
|
+
const commonState = useCommonState();
|
|
4804
|
+
return scopedCss.withScopedCSS(scopedId$c, () => {
|
|
4805
|
+
const containerRect = container.getBoundingClientRect();
|
|
4806
|
+
const rect = isShow() ? selectionBridge.getRect({
|
|
4807
|
+
slot: selection.focusSlot,
|
|
4808
|
+
offset: selection.focusOffset
|
|
4809
|
+
}) : {};
|
|
4810
|
+
return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly, onClick: () => {
|
|
4811
|
+
var _a;
|
|
4812
|
+
isShow.set(true);
|
|
4813
|
+
isClickFromSelf = true;
|
|
4814
|
+
(_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
4815
|
+
}, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
|
|
4816
|
+
jsxRuntime.jsx(Popup, { left: rect.left - containerRect.left, top: rect.top + rect.height - containerRect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
|
|
4817
|
+
isClickFromSelf = true;
|
|
4818
|
+
}, class: "input-group", children: [jsxRuntime.jsx("input", { onChange: ev => {
|
|
4819
|
+
value.set(ev.target.value);
|
|
4820
|
+
}, placeholder: "\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740", type: "text" }), jsxRuntime.jsx(Button, { type: "submit", children: "\u786E\u5B9A" })] }) })] }));
|
|
4821
|
+
});
|
|
4822
|
+
}
|
|
4823
|
+
|
|
4824
|
+
function RedoTool() {
|
|
4825
|
+
const history = core.inject(core$1.History);
|
|
4826
|
+
const instance = core.getCurrentInstance();
|
|
4827
|
+
function redo() {
|
|
4828
|
+
history.forward();
|
|
4829
|
+
}
|
|
4830
|
+
const sub = history.onChange.subscribe(() => {
|
|
4831
|
+
instance.markAsDirtied();
|
|
4832
|
+
});
|
|
4833
|
+
core.onUnmounted(() => {
|
|
4834
|
+
sub.unsubscribe();
|
|
4835
|
+
});
|
|
4836
|
+
const commonState = useCommonState();
|
|
4837
|
+
return () => {
|
|
4838
|
+
return jsxRuntime.jsx(Button, { disabled: !history.canForward || commonState().readonly, onClick: redo, children: jsxRuntime.jsx("span", { class: "xnote-icon-history-forward" }) });
|
|
4839
|
+
};
|
|
4840
|
+
}
|
|
4841
|
+
|
|
4842
|
+
function StrikeThroughTool() {
|
|
4843
|
+
const query = core.inject(core$1.Query);
|
|
4844
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
4845
|
+
const textbus = core.inject(core$1.Textbus);
|
|
4846
|
+
const [viewModel, update] = hooks.useProduce({
|
|
4847
|
+
highlight: false,
|
|
4848
|
+
});
|
|
4849
|
+
function toggle() {
|
|
4850
|
+
toggleStrikeThrough(textbus);
|
|
4851
|
+
}
|
|
4852
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
4853
|
+
const state = query.queryFormat(strikeThroughFormatter);
|
|
4854
|
+
update(draft => {
|
|
4855
|
+
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
4856
|
+
});
|
|
4857
|
+
});
|
|
4858
|
+
core.onUnmounted(() => {
|
|
4859
|
+
sub.unsubscribe();
|
|
4860
|
+
});
|
|
4861
|
+
const commonState = useCommonState();
|
|
4862
|
+
return () => {
|
|
4863
|
+
const vm = viewModel();
|
|
4864
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
|
|
4865
|
+
};
|
|
4866
|
+
}
|
|
4867
|
+
|
|
4868
|
+
function SubscriptTool() {
|
|
4869
|
+
const query = core.inject(core$1.Query);
|
|
4870
|
+
const selection = core.inject(core$1.Selection);
|
|
4871
|
+
const commander = core.inject(core$1.Commander);
|
|
4872
|
+
const [state, updateState] = hooks.useProduce({
|
|
4873
|
+
highlight: false
|
|
4874
|
+
});
|
|
4875
|
+
const sub = selection.onChange.subscribe(() => {
|
|
4876
|
+
updateState(draft => {
|
|
4877
|
+
draft.highlight = getState();
|
|
4878
|
+
});
|
|
4879
|
+
});
|
|
4880
|
+
function getState() {
|
|
4881
|
+
const s = query.queryFormat(subscriptFormatter);
|
|
4882
|
+
return s.state === core$1.QueryStateType.Enabled;
|
|
4883
|
+
}
|
|
4884
|
+
core.onUnmounted(() => {
|
|
4885
|
+
sub.unsubscribe();
|
|
4886
|
+
});
|
|
4887
|
+
function apply() {
|
|
4888
|
+
const is = getState();
|
|
4889
|
+
if (is) {
|
|
4890
|
+
commander.unApplyFormat(subscriptFormatter);
|
|
4891
|
+
}
|
|
4892
|
+
else {
|
|
4893
|
+
commander.unApplyFormat(superscriptFormatter);
|
|
4894
|
+
commander.applyFormat(subscriptFormatter, true);
|
|
4895
|
+
}
|
|
4896
|
+
}
|
|
4897
|
+
const commonState = useCommonState();
|
|
4898
|
+
return () => {
|
|
4899
|
+
return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly, highlight: state().highlight, onClick: apply, children: jsxRuntime.jsx("span", { class: "xnote-icon-subscript" }) }));
|
|
4900
|
+
};
|
|
4901
|
+
}
|
|
4902
|
+
|
|
4903
|
+
function SuperscriptTool() {
|
|
4904
|
+
const query = core.inject(core$1.Query);
|
|
4905
|
+
const selection = core.inject(core$1.Selection);
|
|
4906
|
+
const commander = core.inject(core$1.Commander);
|
|
4907
|
+
const [state, updateState] = hooks.useProduce({
|
|
4908
|
+
highlight: false
|
|
4909
|
+
});
|
|
4910
|
+
const sub = selection.onChange.subscribe(() => {
|
|
4911
|
+
updateState(draft => {
|
|
4912
|
+
draft.highlight = getState();
|
|
4913
|
+
});
|
|
4914
|
+
});
|
|
4915
|
+
function getState() {
|
|
4916
|
+
const s = query.queryFormat(superscriptFormatter);
|
|
4917
|
+
return s.state === core$1.QueryStateType.Enabled;
|
|
4918
|
+
}
|
|
4919
|
+
core.onUnmounted(() => {
|
|
4920
|
+
sub.unsubscribe();
|
|
4921
|
+
});
|
|
4922
|
+
function apply() {
|
|
4923
|
+
const is = getState();
|
|
4924
|
+
if (is) {
|
|
4925
|
+
commander.unApplyFormat(superscriptFormatter);
|
|
4926
|
+
}
|
|
4927
|
+
else {
|
|
4928
|
+
commander.unApplyFormat(subscriptFormatter);
|
|
4929
|
+
commander.applyFormat(superscriptFormatter, true);
|
|
4930
|
+
}
|
|
4931
|
+
}
|
|
4932
|
+
const commonState = useCommonState();
|
|
4933
|
+
return () => {
|
|
4934
|
+
return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly, highlight: state().highlight, onClick: apply, children: jsxRuntime.jsx("span", { class: "xnote-icon-superscript" }) }));
|
|
4935
|
+
};
|
|
4936
|
+
}
|
|
4937
|
+
|
|
4938
|
+
function UnderlineTool() {
|
|
4939
|
+
const query = core.inject(core$1.Query);
|
|
4940
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
4941
|
+
const textbus = core.inject(core$1.Textbus);
|
|
4942
|
+
const [viewModel, update] = hooks.useProduce({
|
|
4943
|
+
highlight: false,
|
|
4944
|
+
});
|
|
4945
|
+
function toggle() {
|
|
4946
|
+
toggleUnderline(textbus);
|
|
4947
|
+
}
|
|
4948
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
4949
|
+
const state = query.queryFormat(underlineFormatter);
|
|
4950
|
+
update(draft => {
|
|
4951
|
+
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
4952
|
+
});
|
|
4953
|
+
});
|
|
4954
|
+
core.onUnmounted(() => {
|
|
4955
|
+
sub.unsubscribe();
|
|
4956
|
+
});
|
|
4957
|
+
const commonState = useCommonState();
|
|
4958
|
+
return () => {
|
|
4959
|
+
const vm = viewModel();
|
|
4960
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-underline" }) });
|
|
4961
|
+
};
|
|
4962
|
+
}
|
|
4963
|
+
|
|
4964
|
+
function UndoTool() {
|
|
4965
|
+
const history = core.inject(core$1.History);
|
|
4966
|
+
const instance = core.getCurrentInstance();
|
|
4967
|
+
function undo() {
|
|
4968
|
+
history.back();
|
|
4969
|
+
}
|
|
4970
|
+
const sub = history.onChange.subscribe(() => {
|
|
4971
|
+
instance.markAsDirtied();
|
|
4972
|
+
});
|
|
4973
|
+
core.onUnmounted(() => {
|
|
4974
|
+
sub.unsubscribe();
|
|
4975
|
+
});
|
|
4976
|
+
const commonState = useCommonState();
|
|
4977
|
+
return () => {
|
|
4978
|
+
return jsxRuntime.jsx(Button, { disabled: !history.canBack || commonState().readonly, onClick: undo, children: jsxRuntime.jsx("span", { class: "xnote-icon-history-back" }) });
|
|
4979
|
+
};
|
|
4980
|
+
}
|
|
4981
|
+
|
|
4982
|
+
const cellAlignAttr = new core$1.Attribute('cellAlign', {
|
|
4983
|
+
render(node, formatValue) {
|
|
4984
|
+
node.styles.set('verticalAlign', formatValue);
|
|
4985
|
+
}
|
|
4986
|
+
});
|
|
4987
|
+
const cellAlignAttrLoader = {
|
|
4988
|
+
match(element) {
|
|
4989
|
+
return element instanceof HTMLTableCellElement && !!element.style.verticalAlign;
|
|
4990
|
+
},
|
|
4991
|
+
read(element) {
|
|
4992
|
+
return {
|
|
4993
|
+
attribute: cellAlignAttr,
|
|
4994
|
+
value: element.style.verticalAlign
|
|
4995
|
+
};
|
|
4996
|
+
}
|
|
4997
|
+
};
|
|
4998
|
+
|
|
4999
|
+
function isInTable(selection) {
|
|
5000
|
+
if (selection.commonAncestorComponent instanceof TableComponent) {
|
|
5001
|
+
return true;
|
|
5002
|
+
}
|
|
5003
|
+
if (selection.isCollapsed) {
|
|
5004
|
+
let slot = selection.commonAncestorSlot;
|
|
5005
|
+
while (slot) {
|
|
5006
|
+
if (slot.parent instanceof TableComponent) {
|
|
5007
|
+
return true;
|
|
5008
|
+
}
|
|
5009
|
+
slot = slot.parentSlot;
|
|
5010
|
+
}
|
|
5011
|
+
return false;
|
|
5012
|
+
}
|
|
5013
|
+
const startTable = getParentTable(selection.startSlot);
|
|
5014
|
+
const endTable = getParentTable(selection.endSlot);
|
|
5015
|
+
if (startTable && endTable) {
|
|
5016
|
+
return startTable === endTable;
|
|
5017
|
+
}
|
|
5018
|
+
return false;
|
|
5019
|
+
}
|
|
5020
|
+
function getParentTable(slot) {
|
|
5021
|
+
while (slot) {
|
|
5022
|
+
if (slot.parent instanceof TableComponent) {
|
|
5023
|
+
return slot.parent;
|
|
5024
|
+
}
|
|
5025
|
+
slot = slot.parentSlot;
|
|
5026
|
+
}
|
|
5027
|
+
return null;
|
|
5028
|
+
}
|
|
5029
|
+
function getTableSlotBySlot(slot) {
|
|
5030
|
+
while (slot) {
|
|
5031
|
+
if (slot.parent instanceof TableComponent) {
|
|
5032
|
+
return slot;
|
|
5033
|
+
}
|
|
5034
|
+
slot = slot.parentSlot;
|
|
5035
|
+
}
|
|
5036
|
+
return null;
|
|
5037
|
+
}
|
|
5038
|
+
|
|
5039
|
+
function CellAlignTool() {
|
|
5040
|
+
const currentValue = core.createSignal('');
|
|
5041
|
+
const selection = core.inject(core$1.Selection);
|
|
5042
|
+
function check(v) {
|
|
5043
|
+
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
5044
|
+
if (commonAncestorComponent instanceof TableComponent) {
|
|
5045
|
+
const slots = commonAncestorComponent.getSelectedNormalizedSlots();
|
|
5046
|
+
slots.forEach(item => {
|
|
5047
|
+
item.cells.forEach(cell => {
|
|
5048
|
+
if (cell.visible) {
|
|
5049
|
+
cell.raw.slot.setAttribute(cellAlignAttr, v);
|
|
5050
|
+
}
|
|
5051
|
+
});
|
|
5052
|
+
});
|
|
5053
|
+
}
|
|
5054
|
+
else {
|
|
5055
|
+
const is = isInTable(selection);
|
|
5056
|
+
if (is) {
|
|
5057
|
+
let parentSlot = selection.commonAncestorSlot;
|
|
5058
|
+
while (parentSlot) {
|
|
5059
|
+
if (parentSlot.parent instanceof TableComponent) {
|
|
5060
|
+
const slots = parentSlot.parent.getNormalizedData();
|
|
5061
|
+
for (const item of slots) {
|
|
5062
|
+
for (const cell of item.cells) {
|
|
5063
|
+
if (cell.visible && cell.raw.slot === parentSlot) {
|
|
5064
|
+
cell.raw.slot.setAttribute(cellAlignAttr, v);
|
|
5065
|
+
return;
|
|
5066
|
+
}
|
|
5067
|
+
}
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
5070
|
+
parentSlot = parentSlot.parentSlot;
|
|
5071
|
+
}
|
|
5072
|
+
}
|
|
5073
|
+
}
|
|
5074
|
+
}
|
|
5075
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
5076
|
+
const query = core.inject(core$1.Query);
|
|
5077
|
+
const highlight = core.createSignal(false);
|
|
5078
|
+
const subscription = refreshService.onRefresh.subscribe(() => {
|
|
5079
|
+
if (!isInTable(selection)) {
|
|
5080
|
+
highlight.set(false);
|
|
5081
|
+
currentValue.set('middle');
|
|
5082
|
+
return;
|
|
5083
|
+
}
|
|
5084
|
+
const result = query.queryAttribute(cellAlignAttr);
|
|
5085
|
+
const isHighlight = result.state === core$1.QueryStateType.Enabled;
|
|
5086
|
+
highlight.set(isHighlight);
|
|
5087
|
+
currentValue.set(isHighlight ? result.value : 'middle');
|
|
5088
|
+
});
|
|
5089
|
+
core.onUnmounted(() => {
|
|
5090
|
+
subscription.unsubscribe();
|
|
5091
|
+
});
|
|
5092
|
+
return () => {
|
|
5093
|
+
return (jsxRuntime.jsx(Dropdown, { onCheck: check, menu: [
|
|
5094
|
+
{
|
|
5095
|
+
label: jsxRuntime.jsx(MenuItem, { checked: currentValue() === 'top', icon: jsxRuntime.jsx("span", { class: "xnote-icon-align-top" }), children: "\u9876\u90E8\u5BF9\u9F50" }),
|
|
5096
|
+
value: 'top'
|
|
5097
|
+
},
|
|
5098
|
+
{
|
|
5099
|
+
label: jsxRuntime.jsx(MenuItem, { checked: currentValue() === 'middle', icon: jsxRuntime.jsx("span", { class: "xnote-icon-align-middle" }), children: "\u5782\u76F4\u5C45\u4E2D" }),
|
|
5100
|
+
value: 'middle'
|
|
5101
|
+
},
|
|
5102
|
+
{
|
|
5103
|
+
label: jsxRuntime.jsx(MenuItem, { checked: currentValue() === 'bottom', icon: jsxRuntime.jsx("span", { class: "xnote-icon-align-bottom" }), children: "\u5E95\u90E8\u5BF9\u9F50" }),
|
|
5104
|
+
value: 'bottom'
|
|
5105
|
+
}
|
|
5106
|
+
], children: jsxRuntime.jsx(Button, { arrow: true, highlight: highlight(), children: jsxRuntime.jsx("span", { class: 'xnote-icon-align-' + (currentValue() || 'middle') }) }) }));
|
|
5107
|
+
};
|
|
5108
|
+
}
|
|
5109
|
+
|
|
5110
|
+
const cellBackgroundAttr = new core$1.Attribute('cellBackground', {
|
|
5111
|
+
render(node, formatValue) {
|
|
5112
|
+
const rgba = color.parseCss(formatValue);
|
|
5113
|
+
if (rgba) {
|
|
5114
|
+
const hsl = color.rgb2Hsl(rgba);
|
|
5115
|
+
if (hsl.l > 50) {
|
|
5116
|
+
hsl.l -= 10;
|
|
5117
|
+
}
|
|
5118
|
+
else {
|
|
5119
|
+
hsl.l += Math.max((50 - hsl.l) * 0.55, 10);
|
|
5120
|
+
}
|
|
5121
|
+
hsl.s *= 0.7;
|
|
5122
|
+
const newRgba = color.hsl2Rgb(hsl);
|
|
5123
|
+
node.styles.set('borderColor', `rgba(${newRgba.r}, ${newRgba.g}, ${newRgba.b}, ${rgba.a || 1})`);
|
|
5124
|
+
}
|
|
5125
|
+
node.styles.set('backgroundColor', formatValue);
|
|
5126
|
+
}
|
|
5127
|
+
});
|
|
5128
|
+
const cellBackgroundAttrLoader = {
|
|
5129
|
+
match(element) {
|
|
5130
|
+
return (element.tagName === 'TD' || element.tagName === 'TH') && !!element.style.backgroundColor;
|
|
5131
|
+
},
|
|
5132
|
+
read(element) {
|
|
5133
|
+
return {
|
|
5134
|
+
attribute: cellBackgroundAttr,
|
|
5135
|
+
value: element.style.backgroundColor
|
|
5136
|
+
};
|
|
5137
|
+
}
|
|
5138
|
+
};
|
|
5139
|
+
|
|
5140
|
+
function CellBackgroundTool() {
|
|
5141
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
5142
|
+
const selection = core.inject(core$1.Selection);
|
|
5143
|
+
const [viewModel, update] = hooks.useProduce({
|
|
5144
|
+
highlight: false,
|
|
5145
|
+
disabled: false,
|
|
5146
|
+
});
|
|
5147
|
+
function setColor(picker) {
|
|
5148
|
+
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
5149
|
+
if (commonAncestorComponent instanceof TableComponent) {
|
|
5150
|
+
const slots = commonAncestorComponent.getSelectedNormalizedSlots();
|
|
5151
|
+
if (slots) {
|
|
5152
|
+
slots.map(i => {
|
|
5153
|
+
return i.cells.filter(t => t.visible).map(i => i.raw.slot);
|
|
5154
|
+
}).flat().forEach(slot => {
|
|
5155
|
+
const rgba = picker.rgba;
|
|
5156
|
+
if (rgba) {
|
|
5157
|
+
slot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`);
|
|
5158
|
+
}
|
|
5159
|
+
else {
|
|
5160
|
+
slot.removeAttribute(cellBackgroundAttr);
|
|
5161
|
+
}
|
|
5162
|
+
});
|
|
5163
|
+
}
|
|
5164
|
+
}
|
|
5165
|
+
else {
|
|
5166
|
+
let parentSlot = selection.commonAncestorSlot;
|
|
5167
|
+
while (parentSlot) {
|
|
5168
|
+
if (parentSlot.parent instanceof TableComponent) {
|
|
5169
|
+
const rgba = picker.rgba;
|
|
5170
|
+
if (rgba) {
|
|
5171
|
+
parentSlot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`);
|
|
5172
|
+
}
|
|
5173
|
+
else {
|
|
5174
|
+
parentSlot.removeAttribute(cellBackgroundAttr);
|
|
5175
|
+
}
|
|
5176
|
+
return;
|
|
5177
|
+
}
|
|
5178
|
+
parentSlot = parentSlot.parentSlot;
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
}
|
|
5182
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
5183
|
+
update(draft => {
|
|
5184
|
+
draft.disabled = !isInTable(selection);
|
|
5185
|
+
});
|
|
5186
|
+
});
|
|
5187
|
+
core.onUnmounted(() => {
|
|
5188
|
+
sub.unsubscribe();
|
|
5189
|
+
});
|
|
5190
|
+
return () => {
|
|
5191
|
+
const vm = viewModel();
|
|
5192
|
+
return (jsxRuntime.jsx(Dropdown, { width: '177px', menu: jsxRuntime.jsx(ColorPicker, { onSelected: setColor }), trigger: 'hover', children: jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, children: jsxRuntime.jsx("span", { class: "xnote-icon-palette" }) }) }));
|
|
5193
|
+
};
|
|
5194
|
+
}
|
|
5195
|
+
|
|
5196
|
+
function MergeCellsTool() {
|
|
5197
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
5198
|
+
const selection = core.inject(core$1.Selection);
|
|
5199
|
+
const [viewModel, update] = hooks.useProduce({
|
|
5200
|
+
highlight: false,
|
|
5201
|
+
disabled: false,
|
|
5202
|
+
});
|
|
5203
|
+
function merge() {
|
|
5204
|
+
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
5205
|
+
if (commonAncestorComponent instanceof TableComponent) {
|
|
5206
|
+
commonAncestorComponent.mergeCellBySelection();
|
|
5207
|
+
}
|
|
5208
|
+
}
|
|
5209
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
5210
|
+
update(draft => {
|
|
5211
|
+
const is = isInTable(selection);
|
|
5212
|
+
if (is) {
|
|
5213
|
+
const p1 = getTableSlotBySlot(selection.startSlot);
|
|
5214
|
+
const p2 = getTableSlotBySlot(selection.endSlot);
|
|
5215
|
+
if (p1 && p2) {
|
|
5216
|
+
draft.disabled = p1 === p2;
|
|
5217
|
+
return;
|
|
4928
5218
|
}
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
5219
|
+
}
|
|
5220
|
+
draft.disabled = true;
|
|
5221
|
+
});
|
|
5222
|
+
});
|
|
5223
|
+
core.onUnmounted(() => {
|
|
5224
|
+
sub.unsubscribe();
|
|
5225
|
+
});
|
|
5226
|
+
return () => {
|
|
5227
|
+
const vm = viewModel();
|
|
5228
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: merge, children: jsxRuntime.jsx("span", { class: "xnote-icon-merge-cells" }) });
|
|
5229
|
+
};
|
|
5230
|
+
}
|
|
5231
|
+
|
|
5232
|
+
function SplitCellsTool() {
|
|
5233
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
5234
|
+
const selection = core.inject(core$1.Selection);
|
|
5235
|
+
const [viewModel, update] = hooks.useProduce({
|
|
5236
|
+
highlight: false,
|
|
5237
|
+
disabled: false,
|
|
5238
|
+
});
|
|
5239
|
+
function split() {
|
|
5240
|
+
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
5241
|
+
if (commonAncestorComponent instanceof TableComponent) {
|
|
5242
|
+
commonAncestorComponent.splitCellsBySelection();
|
|
5243
|
+
return;
|
|
5244
|
+
}
|
|
5245
|
+
let parentSlot = selection.commonAncestorSlot;
|
|
5246
|
+
while (parentSlot) {
|
|
5247
|
+
if (parentSlot.parent instanceof TableComponent) {
|
|
5248
|
+
if (parentSlot.parent === commonAncestorComponent) {
|
|
5249
|
+
parentSlot.parent.splitCellsBySelection();
|
|
5250
|
+
return;
|
|
4938
5251
|
}
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
const timeline = new TimelineComponent(textbus, {
|
|
4942
|
-
items: [createTimelineItem(textbus, '#296eff')]
|
|
4943
|
-
});
|
|
4944
|
-
insertComponent(timeline);
|
|
4945
|
-
selection.selectFirstPosition(timeline, false, true);
|
|
4946
|
-
break;
|
|
5252
|
+
parentSlot.parent.splitCellBySlot(parentSlot);
|
|
5253
|
+
return;
|
|
4947
5254
|
}
|
|
5255
|
+
parentSlot = parentSlot.parentSlot;
|
|
4948
5256
|
}
|
|
4949
5257
|
}
|
|
4950
|
-
|
|
4951
|
-
|
|
5258
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
5259
|
+
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
5260
|
+
update(draft => {
|
|
5261
|
+
if (commonAncestorComponent instanceof TableComponent) {
|
|
5262
|
+
const slots = commonAncestorComponent.getSelectedNormalizedSlots();
|
|
5263
|
+
if (slots) {
|
|
5264
|
+
for (const item of slots) {
|
|
5265
|
+
for (const cell of item.cells) {
|
|
5266
|
+
if (cell.visible && cell.colspan > 1 || cell.colspan > 1) {
|
|
5267
|
+
draft.disabled = false;
|
|
5268
|
+
return;
|
|
5269
|
+
}
|
|
5270
|
+
}
|
|
5271
|
+
}
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5274
|
+
else {
|
|
5275
|
+
let parentSlot = selection.commonAncestorSlot;
|
|
5276
|
+
while (parentSlot) {
|
|
5277
|
+
if (parentSlot.parent instanceof TableComponent) {
|
|
5278
|
+
const slots = parentSlot.parent.getNormalizedData();
|
|
5279
|
+
for (const item of slots) {
|
|
5280
|
+
for (const cell of item.cells) {
|
|
5281
|
+
if (cell.raw.slot === parentSlot) {
|
|
5282
|
+
draft.disabled = !(cell.colspan > 1 || cell.colspan > 1);
|
|
5283
|
+
return;
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
parentSlot = parentSlot.parentSlot;
|
|
5289
|
+
}
|
|
5290
|
+
}
|
|
5291
|
+
draft.disabled = true;
|
|
5292
|
+
});
|
|
5293
|
+
});
|
|
5294
|
+
core.onUnmounted(() => {
|
|
5295
|
+
sub.unsubscribe();
|
|
5296
|
+
});
|
|
5297
|
+
return () => {
|
|
5298
|
+
const vm = viewModel();
|
|
5299
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: split, children: jsxRuntime.jsx("span", { class: "xnote-icon-split-cells" }) });
|
|
5300
|
+
};
|
|
5301
|
+
}
|
|
5302
|
+
|
|
5303
|
+
var scopedId$b = "vf-669084";
|
|
5304
|
+
|
|
5305
|
+
function SplitLine() {
|
|
5306
|
+
return scopedCss.withScopedCSS(scopedId$b, () => {
|
|
5307
|
+
return jsxRuntime.jsx("div", { class: "split-line" });
|
|
4952
5308
|
});
|
|
4953
5309
|
}
|
|
4954
5310
|
|
|
4955
|
-
var scopedId$
|
|
5311
|
+
var scopedId$a = "vf-b05292";
|
|
4956
5312
|
|
|
4957
5313
|
const LeftToolbar = core.withAnnotation({
|
|
4958
|
-
providers: [exports.RefreshService]
|
|
5314
|
+
providers: [exports.RefreshService, ToolService]
|
|
4959
5315
|
}, function LeftToolbar() {
|
|
4960
5316
|
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
4961
5317
|
const textbus = core.inject(core$1.Textbus);
|
|
@@ -5116,7 +5472,7 @@ const LeftToolbar = core.withAnnotation({
|
|
|
5116
5472
|
function changeIgnoreMove(b) {
|
|
5117
5473
|
isIgnoreMove = b;
|
|
5118
5474
|
}
|
|
5119
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
5475
|
+
return scopedCss.withScopedCSS(scopedId$a, () => {
|
|
5120
5476
|
var _a;
|
|
5121
5477
|
const position = positionSignal();
|
|
5122
5478
|
const slot = activeSlot();
|
|
@@ -5156,9 +5512,9 @@ const LeftToolbar = core.withAnnotation({
|
|
|
5156
5512
|
right: 0,
|
|
5157
5513
|
top: 0
|
|
5158
5514
|
}, menu: isEmptyBlock() ?
|
|
5159
|
-
jsxRuntime.jsx(
|
|
5515
|
+
jsxRuntime.jsx(InsertMenu, { replace: !needInsert, slot: activeSlot() })
|
|
5160
5516
|
:
|
|
5161
|
-
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, highlight: states.paragraph, onClick: () => transform('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h1, onClick: () => transform('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h2, onClick: () => transform('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h3, onClick: () => transform('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h4, onClick: () => transform('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.todolist, onClick: () => transform('todolist'), children: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.orderedList, onClick: () => transform('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.unorderedList, onClick: () => transform('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.blockquote, onClick: () => transform('blockquote'), children: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.sourceCode, onClick: () => transform('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(AttrTool, { style: { display: 'block' }, abreast: true, slot: slot, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u7F29\u8FDB\u548C\u5BF9\u9F50" }) }), jsxRuntime.jsx(ColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-color" }), children: "\u989C\u8272" }) }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(MenuItem, { onClick: copy, icon: jsxRuntime.jsx("span", { class: "xnote-icon-copy" }), children: "\u590D\u5236" }), jsxRuntime.jsx(MenuItem, { onClick: remove, icon: jsxRuntime.jsx("span", { class: "xnote-icon-bin" }), children: "\u5220\u9664" }), jsxRuntime.jsx(MenuItem, { onClick: cut, icon: jsxRuntime.jsx("span", { class: "xnote-icon-cut" }), children: "\u526A\u5207" }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(Dropdown, { style: { display: 'block' }, abreast: true, menu: jsxRuntime.jsx(
|
|
5517
|
+
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, highlight: states.paragraph, onClick: () => transform('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h1, onClick: () => transform('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h2, onClick: () => transform('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h3, onClick: () => transform('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h4, onClick: () => transform('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.todolist, onClick: () => transform('todolist'), children: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.orderedList, onClick: () => transform('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.unorderedList, onClick: () => transform('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.blockquote, onClick: () => transform('blockquote'), children: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.sourceCode, onClick: () => transform('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(AttrTool, { style: { display: 'block' }, abreast: true, slot: slot, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u7F29\u8FDB\u548C\u5BF9\u9F50" }) }), jsxRuntime.jsx(ColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-color" }), children: "\u989C\u8272" }) }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(MenuItem, { onClick: copy, icon: jsxRuntime.jsx("span", { class: "xnote-icon-copy" }), children: "\u590D\u5236" }), jsxRuntime.jsx(MenuItem, { onClick: remove, icon: jsxRuntime.jsx("span", { class: "xnote-icon-bin" }), children: "\u5220\u9664" }), jsxRuntime.jsx(MenuItem, { onClick: cut, icon: jsxRuntime.jsx("span", { class: "xnote-icon-cut" }), children: "\u526A\u5207" }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(Dropdown, { style: { display: 'block' }, abreast: true, menu: jsxRuntime.jsx(InsertMenu, { hideTitle: true, slot: activeSlot() }), children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-plus" }), children: "\u5728\u4E0B\u9762\u6DFB\u52A0" }) })] }), children: jsxRuntime.jsx("button", { type: "button", class: "left-toolbar-btn", children: isEmptyBlock() ?
|
|
5162
5518
|
jsxRuntime.jsx("span", { children: jsxRuntime.jsx("i", { class: "xnote-icon-plus" }) })
|
|
5163
5519
|
:
|
|
5164
5520
|
jsxRuntime.jsxs("span", { children: [activeNode, jsxRuntime.jsx("i", { style: "font-size: 12px", class: "xnote-icon-more" })] }) }) }) }) }));
|
|
@@ -5193,7 +5549,7 @@ class LeftToolbarPlugin {
|
|
|
5193
5549
|
}
|
|
5194
5550
|
}
|
|
5195
5551
|
|
|
5196
|
-
var scopedId$
|
|
5552
|
+
var scopedId$9 = "vf-3073ba";
|
|
5197
5553
|
|
|
5198
5554
|
function LinkJump() {
|
|
5199
5555
|
const selection = core.inject(core$1.Selection);
|
|
@@ -5247,25 +5603,26 @@ function LinkJump() {
|
|
|
5247
5603
|
}
|
|
5248
5604
|
});
|
|
5249
5605
|
}
|
|
5250
|
-
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$
|
|
5606
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$9, () => {
|
|
5251
5607
|
return (jsxRuntime.jsxs("div", { ref: ref, class: "link-jump-plugin", style: { display: isShow() ? '' : 'none' }, children: [jsxRuntime.jsx("span", { onClick: cleanLink, children: "\u6E05\u9664" }), jsxRuntime.jsx("a", { target: "_blank", href: href(), children: "\u8DF3\u8F6C" })] }));
|
|
5252
5608
|
}), container);
|
|
5253
5609
|
}
|
|
5254
5610
|
|
|
5255
|
-
var scopedId$
|
|
5611
|
+
var scopedId$8 = "vf-33b3ca";
|
|
5256
5612
|
|
|
5257
5613
|
function sum(numbers) {
|
|
5258
5614
|
return numbers.reduce((a, b) => a + b, 0);
|
|
5259
5615
|
}
|
|
5260
5616
|
|
|
5261
|
-
const
|
|
5262
|
-
providers: [exports.RefreshService]
|
|
5263
|
-
}, function Toolbar() {
|
|
5617
|
+
const InlineToolbar = core.withAnnotation({
|
|
5618
|
+
providers: [exports.RefreshService, ToolService]
|
|
5619
|
+
}, function Toolbar(props) {
|
|
5264
5620
|
const selection = core.inject(core$1.Selection);
|
|
5265
5621
|
const viewDocument = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
5266
5622
|
const rootComponentRef = core.inject(core$1.RootComponentRef);
|
|
5267
5623
|
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
5268
5624
|
const bridge = core.inject(platformBrowser.SelectionBridge);
|
|
5625
|
+
const query = core.inject(core$1.Query);
|
|
5269
5626
|
const textbus = core.inject(core$1.Textbus);
|
|
5270
5627
|
const editorService = core.inject(exports.EditorService);
|
|
5271
5628
|
const refreshService = core.inject(exports.RefreshService);
|
|
@@ -5388,28 +5745,29 @@ const Toolbar = core.withAnnotation({
|
|
|
5388
5745
|
mousedownSubscription.unsubscribe();
|
|
5389
5746
|
mouseupSubscription.unsubscribe();
|
|
5390
5747
|
});
|
|
5391
|
-
return scopedCss.withScopedCSS(scopedId$
|
|
5748
|
+
return scopedCss.withScopedCSS(scopedId$8, () => {
|
|
5392
5749
|
const p = viewPosition();
|
|
5393
|
-
return (jsxRuntime.jsxs("div", { class:
|
|
5750
|
+
return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme], ref: toolbarRef, style: {
|
|
5394
5751
|
left: p.left + 'px',
|
|
5395
5752
|
top: p.top + 'px',
|
|
5396
5753
|
pointerEvents: p.isHide ? 'none' : 'initial',
|
|
5397
5754
|
opacity: p.opacity,
|
|
5398
5755
|
display: editorService.hideInlineToolbar ? 'none' : '',
|
|
5399
5756
|
transitionDuration: p.transitionDuration + 's'
|
|
5400
|
-
}, children: [
|
|
5757
|
+
}, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
|
|
5401
5758
|
});
|
|
5402
5759
|
});
|
|
5403
5760
|
|
|
5404
|
-
class
|
|
5405
|
-
constructor() {
|
|
5761
|
+
class InlineToolbarPlugin {
|
|
5762
|
+
constructor(config = {}) {
|
|
5763
|
+
this.config = config;
|
|
5406
5764
|
this.app = null;
|
|
5407
5765
|
}
|
|
5408
5766
|
setup(injector) {
|
|
5409
|
-
const App =
|
|
5767
|
+
const App = () => {
|
|
5410
5768
|
const readonly = useReadonly();
|
|
5411
5769
|
return () => {
|
|
5412
|
-
return readonly() ? null : jsxRuntime.jsx(
|
|
5770
|
+
return readonly() ? null : jsxRuntime.jsx(InlineToolbar, { theme: this.config.theme });
|
|
5413
5771
|
};
|
|
5414
5772
|
};
|
|
5415
5773
|
this.app = platformBrowser$1.createApp(jsxRuntime.jsx(App, {}), {
|
|
@@ -5426,6 +5784,133 @@ class ToolbarPlugin {
|
|
|
5426
5784
|
}
|
|
5427
5785
|
}
|
|
5428
5786
|
|
|
5787
|
+
var scopedId$7 = "vf-42c12d";
|
|
5788
|
+
|
|
5789
|
+
const StaticToolbar = core.withAnnotation({
|
|
5790
|
+
providers: [exports.RefreshService, ToolService]
|
|
5791
|
+
}, function Toolbar(props) {
|
|
5792
|
+
const selection = core.inject(core$1.Selection);
|
|
5793
|
+
const textbus = core.inject(core$1.Textbus);
|
|
5794
|
+
const query = core.inject(core$1.Query);
|
|
5795
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
5796
|
+
const instance = core.getCurrentInstance();
|
|
5797
|
+
const subscription = core$1.merge(textbus.onChange, selection.onChange).pipe(core$1.debounceTime(20)).subscribe(() => {
|
|
5798
|
+
refreshService.onRefresh.next();
|
|
5799
|
+
instance.markAsDirtied();
|
|
5800
|
+
});
|
|
5801
|
+
core.onUnmounted(() => {
|
|
5802
|
+
subscription.unsubscribe();
|
|
5803
|
+
});
|
|
5804
|
+
return scopedCss.withScopedCSS(scopedId$7, () => {
|
|
5805
|
+
return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme], children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UndoTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(RedoTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(InsertTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
|
|
5806
|
+
});
|
|
5807
|
+
});
|
|
5808
|
+
|
|
5809
|
+
class StaticToolbarPlugin {
|
|
5810
|
+
constructor(options) {
|
|
5811
|
+
this.options = options;
|
|
5812
|
+
this.app = null;
|
|
5813
|
+
this.container = null;
|
|
5814
|
+
}
|
|
5815
|
+
setup(injector) {
|
|
5816
|
+
const container = document.createElement('div');
|
|
5817
|
+
container.style.position = 'relative';
|
|
5818
|
+
container.style.borderRadius = 'inherit';
|
|
5819
|
+
this.app = platformBrowser$1.createApp(jsxRuntime.jsx(core.Context, { providers: [{
|
|
5820
|
+
provide: DropdownMenuContainer,
|
|
5821
|
+
useValue: container
|
|
5822
|
+
}], children: jsxRuntime.jsx(StaticToolbar, { theme: this.options.theme }) }), {
|
|
5823
|
+
context: injector
|
|
5824
|
+
});
|
|
5825
|
+
this.options.host.appendChild(container);
|
|
5826
|
+
this.container = container;
|
|
5827
|
+
this.app.mount(container);
|
|
5828
|
+
}
|
|
5829
|
+
onDestroy() {
|
|
5830
|
+
var _a, _b;
|
|
5831
|
+
(_a = this.container) === null || _a === void 0 ? void 0 : _a.remove();
|
|
5832
|
+
(_b = this.app) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
5833
|
+
}
|
|
5834
|
+
}
|
|
5835
|
+
|
|
5836
|
+
var scopedId$6 = "vf-25fd9c";
|
|
5837
|
+
|
|
5838
|
+
const SuspensionToolbar = core.withAnnotation({
|
|
5839
|
+
providers: [exports.RefreshService, ToolService]
|
|
5840
|
+
}, function Toolbar(props) {
|
|
5841
|
+
const selection = core.inject(core$1.Selection);
|
|
5842
|
+
const textbus = core.inject(core$1.Textbus);
|
|
5843
|
+
const query = core.inject(core$1.Query);
|
|
5844
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
5845
|
+
const viewDocument = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
5846
|
+
const instance = core.getCurrentInstance();
|
|
5847
|
+
const subscription = core$1.merge(textbus.onChange, selection.onChange).pipe(core$1.debounceTime(20)).subscribe(() => {
|
|
5848
|
+
refreshService.onRefresh.next();
|
|
5849
|
+
instance.markAsDirtied();
|
|
5850
|
+
});
|
|
5851
|
+
core.onUnmounted(() => {
|
|
5852
|
+
subscription.unsubscribe();
|
|
5853
|
+
});
|
|
5854
|
+
const [styles, updateStyles] = hooks.useProduce({
|
|
5855
|
+
top: 0,
|
|
5856
|
+
opacity: 1,
|
|
5857
|
+
});
|
|
5858
|
+
subscription.add(core$1.fromEvent(document, 'scroll').pipe(core$1.tap(() => {
|
|
5859
|
+
updateStyles(draft => {
|
|
5860
|
+
draft.opacity = 0;
|
|
5861
|
+
});
|
|
5862
|
+
}), core$1.debounceTime(100), core$1.tap(() => {
|
|
5863
|
+
const rect = viewDocument.getBoundingClientRect();
|
|
5864
|
+
if (rect.top < 10) {
|
|
5865
|
+
updateStyles(draft => {
|
|
5866
|
+
draft.top = Math.min(-rect.top + 10, rect.height - 100);
|
|
5867
|
+
});
|
|
5868
|
+
}
|
|
5869
|
+
else {
|
|
5870
|
+
updateStyles(draft => {
|
|
5871
|
+
draft.top = 0;
|
|
5872
|
+
});
|
|
5873
|
+
}
|
|
5874
|
+
}), core$1.delay(100)).subscribe(() => {
|
|
5875
|
+
updateStyles(draft => {
|
|
5876
|
+
draft.opacity = 1;
|
|
5877
|
+
});
|
|
5878
|
+
}));
|
|
5879
|
+
return scopedCss.withScopedCSS(scopedId$6, () => {
|
|
5880
|
+
const s = styles();
|
|
5881
|
+
return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme, {
|
|
5882
|
+
suspension: s.top === 0 ? '' : 'suspension'
|
|
5883
|
+
}], style: {
|
|
5884
|
+
top: s.top + 'px',
|
|
5885
|
+
opacity: s.opacity,
|
|
5886
|
+
pointerEvents: s.opacity === 0 ? 'none' : 'initial',
|
|
5887
|
+
}, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UndoTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(RedoTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(InsertTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
|
|
5888
|
+
});
|
|
5889
|
+
});
|
|
5890
|
+
|
|
5891
|
+
class SuspensionToolbarPlugin {
|
|
5892
|
+
constructor(options = {}) {
|
|
5893
|
+
this.options = options;
|
|
5894
|
+
this.app = null;
|
|
5895
|
+
this.container = null;
|
|
5896
|
+
}
|
|
5897
|
+
setup(injector) {
|
|
5898
|
+
const host = injector.get(platformBrowser.VIEW_CONTAINER);
|
|
5899
|
+
const container = document.createElement('div');
|
|
5900
|
+
this.app = platformBrowser$1.createApp(jsxRuntime.jsx(SuspensionToolbar, { theme: this.options.theme }), {
|
|
5901
|
+
context: injector
|
|
5902
|
+
});
|
|
5903
|
+
host.prepend(container);
|
|
5904
|
+
this.container = container;
|
|
5905
|
+
this.app.mount(container);
|
|
5906
|
+
}
|
|
5907
|
+
onDestroy() {
|
|
5908
|
+
var _a, _b;
|
|
5909
|
+
(_a = this.container) === null || _a === void 0 ? void 0 : _a.remove();
|
|
5910
|
+
(_b = this.app) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
5911
|
+
}
|
|
5912
|
+
}
|
|
5913
|
+
|
|
5429
5914
|
class Matcher {
|
|
5430
5915
|
constructor(target, rule) {
|
|
5431
5916
|
this.target = target;
|
|
@@ -5526,6 +6011,10 @@ class Matcher {
|
|
|
5526
6011
|
class Organization {
|
|
5527
6012
|
}
|
|
5528
6013
|
function registerAtShortcut(textbus) {
|
|
6014
|
+
const organization = textbus.get(Organization, null);
|
|
6015
|
+
if (!organization) {
|
|
6016
|
+
return;
|
|
6017
|
+
}
|
|
5529
6018
|
const keyboard = textbus.get(core$1.Keyboard);
|
|
5530
6019
|
const selection = textbus.get(core$1.Selection);
|
|
5531
6020
|
const commander = textbus.get(core$1.Commander);
|
|
@@ -5776,8 +6265,11 @@ class RootComponent extends core$1.Component {
|
|
|
5776
6265
|
lastContent instanceof TodolistComponent) {
|
|
5777
6266
|
return;
|
|
5778
6267
|
}
|
|
6268
|
+
const selection = this.textbus.get(core$1.Selection);
|
|
5779
6269
|
content.retain(content.length);
|
|
5780
|
-
|
|
6270
|
+
const newParagraph = new ParagraphComponent(this.textbus);
|
|
6271
|
+
content.insert(newParagraph);
|
|
6272
|
+
selection.setPosition(newParagraph.state.slot, 0);
|
|
5781
6273
|
}
|
|
5782
6274
|
}
|
|
5783
6275
|
RootComponent.componentName = 'RootComponent';
|
|
@@ -5792,14 +6284,22 @@ function RootView(props) {
|
|
|
5792
6284
|
sub.unsubscribe();
|
|
5793
6285
|
};
|
|
5794
6286
|
});
|
|
5795
|
-
core.
|
|
5796
|
-
props.component.afterCheck();
|
|
5797
|
-
});
|
|
6287
|
+
const containerRef = core.createRef();
|
|
5798
6288
|
const readonly = useReadonly();
|
|
5799
6289
|
const output = useOutput();
|
|
6290
|
+
function checkContent(ev) {
|
|
6291
|
+
if (ev.target === containerRef.current) {
|
|
6292
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
6293
|
+
if (rect.bottom - ev.clientY < 40) {
|
|
6294
|
+
props.component.afterCheck();
|
|
6295
|
+
}
|
|
6296
|
+
}
|
|
6297
|
+
}
|
|
5800
6298
|
return () => {
|
|
5801
6299
|
const { rootRef } = props;
|
|
5802
|
-
return (jsxRuntime.jsx("div", { class: "xnote-root",
|
|
6300
|
+
return (jsxRuntime.jsx("div", { class: "xnote-root", onClick: checkContent, style: !readonly() ? {
|
|
6301
|
+
paddingBottom: '40px'
|
|
6302
|
+
} : {}, dir: "auto", ref: [rootRef, containerRef, ref], "data-component": props.component.name, children: jsxRuntime.jsx(SlotRender, { slot: content, tag: "div", class: "xnote-content", "data-placeholder": content.isEmpty ? '请输入内容' : '', renderEnv: readonly() || output() }) }));
|
|
5803
6303
|
};
|
|
5804
6304
|
}
|
|
5805
6305
|
const rootComponentLoader = {
|
|
@@ -6849,7 +7349,9 @@ class Editor extends core$1.Textbus {
|
|
|
6849
7349
|
italicFormatLoader,
|
|
6850
7350
|
linkFormatLoader,
|
|
6851
7351
|
strikeThroughFormatLoader,
|
|
6852
|
-
underlineFormatLoader
|
|
7352
|
+
underlineFormatLoader,
|
|
7353
|
+
subscriptFormatLoader,
|
|
7354
|
+
superscriptFormatLoader
|
|
6853
7355
|
], attributeLoaders: [
|
|
6854
7356
|
cellBackgroundAttrLoader,
|
|
6855
7357
|
cellAlignAttrLoader,
|
|
@@ -6937,7 +7439,9 @@ class Editor extends core$1.Textbus {
|
|
|
6937
7439
|
italicFormatter,
|
|
6938
7440
|
linkFormatter,
|
|
6939
7441
|
strikeThroughFormatter,
|
|
6940
|
-
underlineFormatter
|
|
7442
|
+
underlineFormatter,
|
|
7443
|
+
subscriptFormatter,
|
|
7444
|
+
superscriptFormatter
|
|
6941
7445
|
], attributes: [
|
|
6942
7446
|
cellBackgroundAttr,
|
|
6943
7447
|
cellAlignAttr,
|
|
@@ -6946,7 +7450,7 @@ class Editor extends core$1.Textbus {
|
|
|
6946
7450
|
textIndentAttr
|
|
6947
7451
|
], plugins: [
|
|
6948
7452
|
new LeftToolbarPlugin(),
|
|
6949
|
-
new
|
|
7453
|
+
new InlineToolbarPlugin()
|
|
6950
7454
|
], onAfterStartup(textbus) {
|
|
6951
7455
|
registerBoldShortcut(textbus);
|
|
6952
7456
|
registerCodeShortcut(textbus);
|
|
@@ -7010,6 +7514,7 @@ exports.BoldTool = BoldTool;
|
|
|
7010
7514
|
exports.Button = Button;
|
|
7011
7515
|
exports.CellAlignTool = CellAlignTool;
|
|
7012
7516
|
exports.CellBackgroundTool = CellBackgroundTool;
|
|
7517
|
+
exports.CleanFormatsTool = CleanFormatsTool;
|
|
7013
7518
|
exports.CodeTool = CodeTool;
|
|
7014
7519
|
exports.ColorPicker = ColorPicker;
|
|
7015
7520
|
exports.ColorTool = ColorTool;
|
|
@@ -7017,6 +7522,7 @@ exports.ComponentToolbar = ComponentToolbar;
|
|
|
7017
7522
|
exports.Divider = Divider;
|
|
7018
7523
|
exports.DragResize = DragResize;
|
|
7019
7524
|
exports.Dropdown = Dropdown;
|
|
7525
|
+
exports.DropdownMenuContainer = DropdownMenuContainer;
|
|
7020
7526
|
exports.DropdownMenuPortal = DropdownMenuPortal;
|
|
7021
7527
|
exports.Editor = Editor;
|
|
7022
7528
|
exports.FileUploader = FileUploader;
|
|
@@ -7026,6 +7532,9 @@ exports.HighlightBoxComponent = HighlightBoxComponent;
|
|
|
7026
7532
|
exports.HighlightBoxView = HighlightBoxView;
|
|
7027
7533
|
exports.ImageComponent = ImageComponent;
|
|
7028
7534
|
exports.ImageView = ImageView;
|
|
7535
|
+
exports.InlineToolbar = InlineToolbar;
|
|
7536
|
+
exports.InlineToolbarPlugin = InlineToolbarPlugin;
|
|
7537
|
+
exports.InsertMenu = InsertMenu;
|
|
7029
7538
|
exports.InsertTool = InsertTool;
|
|
7030
7539
|
exports.ItalicTool = ItalicTool;
|
|
7031
7540
|
exports.KatexComponent = KatexComponent;
|
|
@@ -7047,20 +7556,27 @@ exports.ParagraphComponent = ParagraphComponent;
|
|
|
7047
7556
|
exports.ParagraphView = ParagraphView;
|
|
7048
7557
|
exports.Picker = Picker;
|
|
7049
7558
|
exports.Popup = Popup;
|
|
7559
|
+
exports.RedoTool = RedoTool;
|
|
7050
7560
|
exports.RootComponent = RootComponent;
|
|
7051
7561
|
exports.RootView = RootView;
|
|
7052
7562
|
exports.SourceCodeComponent = SourceCodeComponent;
|
|
7053
7563
|
exports.SourceCodeView = SourceCodeView;
|
|
7054
7564
|
exports.SplitCellsTool = SplitCellsTool;
|
|
7565
|
+
exports.SplitLine = SplitLine;
|
|
7566
|
+
exports.StaticToolbar = StaticToolbar;
|
|
7567
|
+
exports.StaticToolbarPlugin = StaticToolbarPlugin;
|
|
7055
7568
|
exports.StrikeThroughTool = StrikeThroughTool;
|
|
7569
|
+
exports.SubscriptTool = SubscriptTool;
|
|
7570
|
+
exports.SuperscriptTool = SuperscriptTool;
|
|
7571
|
+
exports.SuspensionToolbar = SuspensionToolbar;
|
|
7572
|
+
exports.SuspensionToolbarPlugin = SuspensionToolbarPlugin;
|
|
7056
7573
|
exports.TableComponent = TableComponent;
|
|
7057
7574
|
exports.TableComponentView = TableComponentView;
|
|
7058
7575
|
exports.TodolistComponent = TodolistComponent;
|
|
7059
7576
|
exports.TodolistView = TodolistView;
|
|
7060
|
-
exports.Toolbar = Toolbar;
|
|
7061
7577
|
exports.ToolbarItem = ToolbarItem;
|
|
7062
|
-
exports.ToolbarPlugin = ToolbarPlugin;
|
|
7063
7578
|
exports.UnderlineTool = UnderlineTool;
|
|
7579
|
+
exports.UndoTool = UndoTool;
|
|
7064
7580
|
exports.VideoComponent = VideoComponent;
|
|
7065
7581
|
exports.VideoView = VideoView;
|
|
7066
7582
|
exports.XNoteMessageBug = XNoteMessageBug;
|
|
@@ -7112,6 +7628,10 @@ exports.sourceCodeComponentLoader = sourceCodeComponentLoader;
|
|
|
7112
7628
|
exports.sourceCodeThemes = sourceCodeThemes;
|
|
7113
7629
|
exports.strikeThroughFormatLoader = strikeThroughFormatLoader;
|
|
7114
7630
|
exports.strikeThroughFormatter = strikeThroughFormatter;
|
|
7631
|
+
exports.subscriptFormatLoader = subscriptFormatLoader;
|
|
7632
|
+
exports.subscriptFormatter = subscriptFormatter;
|
|
7633
|
+
exports.superscriptFormatLoader = superscriptFormatLoader;
|
|
7634
|
+
exports.superscriptFormatter = superscriptFormatter;
|
|
7115
7635
|
exports.tableComponentLoader = tableComponentLoader;
|
|
7116
7636
|
exports.textAlignAttr = textAlignAttr;
|
|
7117
7637
|
exports.textAlignAttrLoader = textAlignAttrLoader;
|