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