@textbus/xnote 0.0.1-alpha.3 → 0.0.1-alpha.4
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/editor.d.ts +4 -1
- package/bundles/index.esm.js +224 -471
- package/bundles/index.js +222 -469
- package/package.json +5 -5
package/bundles/index.esm.js
CHANGED
|
@@ -3,13 +3,13 @@ import { withScopedCSS } from '@viewfly/scoped-css';
|
|
|
3
3
|
import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, createRef, withAnnotation, onMounted, InjectionToken, viewfly, createDynamicRef, onUpdated, getCurrentInstance, watch, ReflectiveInjector } from '@viewfly/core';
|
|
4
4
|
import { Subject, Selection, fromEvent, Subscription, Attribute, Keyboard, Commander, Controller, ContentType, Component, Registry, Slot, useContext, onBreak, createVNode, BehaviorSubject, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, Query, QueryStateType, onContentInsert, onFocusIn, onFocusOut, onGetRanges, Formatter, onParentSlotUpdated, Textbus, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, merge, debounceTime, throttleTime, delay, onCompositionStart } from '@textbus/core';
|
|
5
5
|
import { VIEW_CONTAINER, DomAdapter, Input, SelectionBridge, VIEW_DOCUMENT, BrowserModule, Parser } from '@textbus/platform-browser';
|
|
6
|
-
import { createPortal, DomRenderer, createApp } from '@viewfly/platform-browser';
|
|
6
|
+
import { createPortal, DomRenderer, createApp, HTMLRenderer, OutputTranslator } from '@viewfly/platform-browser';
|
|
7
7
|
import { useProduce } from '@viewfly/hooks';
|
|
8
8
|
import highlightjs from 'highlight.js';
|
|
9
|
-
import {
|
|
9
|
+
import { ViewflyAdapter, ViewflyVDomAdapter } from '@textbus/adapter-viewfly';
|
|
10
10
|
import { CollaborateModule } from '@textbus/collaborate';
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var css$j = undefined;
|
|
13
13
|
|
|
14
14
|
/******************************************************************************
|
|
15
15
|
Copyright (c) Microsoft Corporation.
|
|
@@ -56,18 +56,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
56
56
|
|
|
57
57
|
let DropdownService = class DropdownService {
|
|
58
58
|
constructor() {
|
|
59
|
-
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: void 0
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(this, "siblingOpenEvent", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: new Subject()
|
|
70
|
-
});
|
|
59
|
+
this.siblingOpenEvent = new Subject();
|
|
71
60
|
this.onSiblingOpen = this.siblingOpenEvent.asObservable();
|
|
72
61
|
}
|
|
73
62
|
notify(id) {
|
|
@@ -85,60 +74,14 @@ var DropdownContextService_1;
|
|
|
85
74
|
let i = 0;
|
|
86
75
|
let DropdownContextService = DropdownContextService_1 = class DropdownContextService {
|
|
87
76
|
constructor(dropdownService, injector) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
configurable: true,
|
|
97
|
-
writable: true,
|
|
98
|
-
value: injector
|
|
99
|
-
});
|
|
100
|
-
Object.defineProperty(this, "id", {
|
|
101
|
-
enumerable: true,
|
|
102
|
-
configurable: true,
|
|
103
|
-
writable: true,
|
|
104
|
-
value: i
|
|
105
|
-
});
|
|
106
|
-
Object.defineProperty(this, "isOpen", {
|
|
107
|
-
enumerable: true,
|
|
108
|
-
configurable: true,
|
|
109
|
-
writable: true,
|
|
110
|
-
value: false
|
|
111
|
-
});
|
|
112
|
-
Object.defineProperty(this, "onOpenStateChange", {
|
|
113
|
-
enumerable: true,
|
|
114
|
-
configurable: true,
|
|
115
|
-
writable: true,
|
|
116
|
-
value: void 0
|
|
117
|
-
});
|
|
118
|
-
Object.defineProperty(this, "canHide", {
|
|
119
|
-
enumerable: true,
|
|
120
|
-
configurable: true,
|
|
121
|
-
writable: true,
|
|
122
|
-
value: true
|
|
123
|
-
});
|
|
124
|
-
Object.defineProperty(this, "openStateChangeEvent", {
|
|
125
|
-
enumerable: true,
|
|
126
|
-
configurable: true,
|
|
127
|
-
writable: true,
|
|
128
|
-
value: new Subject()
|
|
129
|
-
});
|
|
130
|
-
Object.defineProperty(this, "timer", {
|
|
131
|
-
enumerable: true,
|
|
132
|
-
configurable: true,
|
|
133
|
-
writable: true,
|
|
134
|
-
value: null
|
|
135
|
-
});
|
|
136
|
-
Object.defineProperty(this, "parentDropdownContextService", {
|
|
137
|
-
enumerable: true,
|
|
138
|
-
configurable: true,
|
|
139
|
-
writable: true,
|
|
140
|
-
value: this.injector.get(DropdownContextService_1, InjectFlags.SkipSelf, null)
|
|
141
|
-
});
|
|
77
|
+
this.dropdownService = dropdownService;
|
|
78
|
+
this.injector = injector;
|
|
79
|
+
this.id = i;
|
|
80
|
+
this.isOpen = false;
|
|
81
|
+
this.canHide = true;
|
|
82
|
+
this.openStateChangeEvent = new Subject();
|
|
83
|
+
this.timer = null;
|
|
84
|
+
this.parentDropdownContextService = this.injector.get(DropdownContextService_1, InjectFlags.SkipSelf, null);
|
|
142
85
|
this.onOpenStateChange = this.openStateChangeEvent.asObservable();
|
|
143
86
|
dropdownService.onSiblingOpen.subscribe(id => {
|
|
144
87
|
if (id === this.id) {
|
|
@@ -197,7 +140,7 @@ function Button(props) {
|
|
|
197
140
|
subscription.unsubscribe();
|
|
198
141
|
});
|
|
199
142
|
}
|
|
200
|
-
return withScopedCSS(
|
|
143
|
+
return withScopedCSS(css$j, () => {
|
|
201
144
|
return (jsxs("button", Object.assign({ type: "button" }, props, { class: [
|
|
202
145
|
'btn',
|
|
203
146
|
{
|
|
@@ -209,10 +152,10 @@ function Button(props) {
|
|
|
209
152
|
});
|
|
210
153
|
}
|
|
211
154
|
|
|
212
|
-
var
|
|
155
|
+
var css$i = undefined;
|
|
213
156
|
|
|
214
157
|
function ComponentToolbar(props) {
|
|
215
|
-
return withScopedCSS(
|
|
158
|
+
return withScopedCSS(css$i, () => {
|
|
216
159
|
return (jsx("div", { class: "component-toolbar", style: props.style, children: jsx("div", { class: [
|
|
217
160
|
'toolbar',
|
|
218
161
|
{
|
|
@@ -222,15 +165,15 @@ function ComponentToolbar(props) {
|
|
|
222
165
|
});
|
|
223
166
|
}
|
|
224
167
|
|
|
225
|
-
var
|
|
168
|
+
var css$h = undefined;
|
|
226
169
|
|
|
227
170
|
function Divider() {
|
|
228
|
-
return withScopedCSS(
|
|
171
|
+
return withScopedCSS(css$h, () => {
|
|
229
172
|
return jsx("div", { class: "divider" });
|
|
230
173
|
});
|
|
231
174
|
}
|
|
232
175
|
|
|
233
|
-
var
|
|
176
|
+
var style = undefined;
|
|
234
177
|
|
|
235
178
|
function DragResize(props) {
|
|
236
179
|
const isShow = createSignal(false);
|
|
@@ -338,16 +281,16 @@ function DragResize(props) {
|
|
|
338
281
|
unUp.unsubscribe();
|
|
339
282
|
});
|
|
340
283
|
}
|
|
341
|
-
return withScopedCSS(
|
|
284
|
+
return withScopedCSS(style, () => {
|
|
342
285
|
return (jsxs("div", { class: "drag-resize", onClick: selectComponent, children: [jsx("div", { class: "container", ref: ref, children: props.children }), jsxs("div", { class: ['resize-tool', {
|
|
343
286
|
active: isShow()
|
|
344
287
|
}], children: [jsxs("div", { class: "mask", ref: mask, children: [component.state.width, "*", component.state.height] }), 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" })] })] })] }));
|
|
345
288
|
});
|
|
346
289
|
}
|
|
347
290
|
|
|
348
|
-
var
|
|
291
|
+
var css$g = undefined;
|
|
349
292
|
|
|
350
|
-
var
|
|
293
|
+
var css$f = undefined;
|
|
351
294
|
|
|
352
295
|
const DropdownMenuPortal = withAnnotation({
|
|
353
296
|
providers: [
|
|
@@ -430,7 +373,7 @@ const DropdownMenuPortal = withAnnotation({
|
|
|
430
373
|
dropdownContextService.canHide = true;
|
|
431
374
|
dropdownContextService.hide();
|
|
432
375
|
}
|
|
433
|
-
return createPortal(withScopedCSS(
|
|
376
|
+
return createPortal(withScopedCSS(css$f, () => {
|
|
434
377
|
return (jsx("div", { onMouseenter: onEnter, onMouseleave: onLeave, ref: menuRef, style: {
|
|
435
378
|
width: props.width
|
|
436
379
|
}, class: "dropdown-menu", children: jsx("div", { class: "dropdown-menu-content", children: props.children }) }));
|
|
@@ -491,7 +434,7 @@ const Dropdown = withAnnotation({
|
|
|
491
434
|
dropdownContextService.open();
|
|
492
435
|
}
|
|
493
436
|
},
|
|
494
|
-
$render: withScopedCSS(
|
|
437
|
+
$render: withScopedCSS(css$g, () => {
|
|
495
438
|
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() && jsx(DropdownMenuPortal, { width: props.width, abreast: props.abreast, triggerRef: triggerRef, children: Array.isArray(props.menu) ?
|
|
496
439
|
props.menu.map(menu => {
|
|
497
440
|
return (jsx("div", { class: "dropdown-menu-item", onClick: () => {
|
|
@@ -507,7 +450,7 @@ const Dropdown = withAnnotation({
|
|
|
507
450
|
};
|
|
508
451
|
});
|
|
509
452
|
|
|
510
|
-
var
|
|
453
|
+
var css$e = undefined;
|
|
511
454
|
|
|
512
455
|
function MenuItem(props) {
|
|
513
456
|
const dropdownContextService = inject(DropdownContextService, InjectFlags.Optional, null);
|
|
@@ -527,7 +470,7 @@ function MenuItem(props) {
|
|
|
527
470
|
}
|
|
528
471
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
|
|
529
472
|
}
|
|
530
|
-
return withScopedCSS(
|
|
473
|
+
return withScopedCSS(css$e, () => {
|
|
531
474
|
return (jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxs("div", { children: [props.icon && jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), props.arrow ?
|
|
532
475
|
jsx("div", { class: "arrow", children: jsx("span", { class: "xnote-icon-arrow-right" }) }) :
|
|
533
476
|
jsx("div", { class: [
|
|
@@ -537,11 +480,11 @@ function MenuItem(props) {
|
|
|
537
480
|
});
|
|
538
481
|
}
|
|
539
482
|
|
|
540
|
-
var
|
|
483
|
+
var css$d = undefined;
|
|
541
484
|
|
|
542
485
|
function Popup(props) {
|
|
543
486
|
const host = inject(VIEW_CONTAINER);
|
|
544
|
-
return createPortal(withScopedCSS(
|
|
487
|
+
return createPortal(withScopedCSS(css$d, () => {
|
|
545
488
|
return (jsx("div", { class: "popup", style: {
|
|
546
489
|
left: props.left + 'px',
|
|
547
490
|
top: props.top + 'px'
|
|
@@ -549,24 +492,19 @@ function Popup(props) {
|
|
|
549
492
|
}), host);
|
|
550
493
|
}
|
|
551
494
|
|
|
552
|
-
var
|
|
495
|
+
var css$c = undefined;
|
|
553
496
|
|
|
554
497
|
function ToolbarItem(props) {
|
|
555
|
-
return withScopedCSS(
|
|
498
|
+
return withScopedCSS(css$c, () => {
|
|
556
499
|
return (jsx("div", { class: "toolbar-item", children: props.children }));
|
|
557
500
|
});
|
|
558
501
|
}
|
|
559
502
|
|
|
560
|
-
var
|
|
503
|
+
var css$b = undefined;
|
|
561
504
|
|
|
562
505
|
let RefreshService = class RefreshService {
|
|
563
506
|
constructor() {
|
|
564
|
-
|
|
565
|
-
enumerable: true,
|
|
566
|
-
configurable: true,
|
|
567
|
-
writable: true,
|
|
568
|
-
value: new Subject()
|
|
569
|
-
});
|
|
507
|
+
this.onRefresh = new Subject();
|
|
570
508
|
}
|
|
571
509
|
};
|
|
572
510
|
RefreshService = __decorate([
|
|
@@ -648,18 +586,8 @@ class ParagraphComponent extends Component {
|
|
|
648
586
|
});
|
|
649
587
|
}
|
|
650
588
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
configurable: true,
|
|
654
|
-
writable: true,
|
|
655
|
-
value: 'ParagraphComponent'
|
|
656
|
-
});
|
|
657
|
-
Object.defineProperty(ParagraphComponent, "type", {
|
|
658
|
-
enumerable: true,
|
|
659
|
-
configurable: true,
|
|
660
|
-
writable: true,
|
|
661
|
-
value: ContentType.BlockComponent
|
|
662
|
-
});
|
|
589
|
+
ParagraphComponent.componentName = 'ParagraphComponent';
|
|
590
|
+
ParagraphComponent.type = ContentType.BlockComponent;
|
|
663
591
|
function ParagraphView(props) {
|
|
664
592
|
const adapter = inject(DomAdapter);
|
|
665
593
|
const readonly = useReadonly();
|
|
@@ -821,42 +749,27 @@ function createCodeSlot() {
|
|
|
821
749
|
class SourceCodeComponent extends Component {
|
|
822
750
|
constructor() {
|
|
823
751
|
super(...arguments);
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
writable: true,
|
|
834
|
-
value: () => {
|
|
835
|
-
const selection = this.textbus.get(Selection);
|
|
836
|
-
const slots = this.state.slots;
|
|
837
|
-
const { startSlot, endSlot } = selection;
|
|
838
|
-
let startIndex = slots.findIndex(i => i.slot === startSlot);
|
|
839
|
-
const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
|
|
840
|
-
for (; startIndex < endIndex; startIndex++) {
|
|
841
|
-
slots[startIndex].emphasize = false;
|
|
842
|
-
}
|
|
752
|
+
this.focus = new BehaviorSubject(false);
|
|
753
|
+
this.cancelEmphasize = () => {
|
|
754
|
+
const selection = this.textbus.get(Selection);
|
|
755
|
+
const slots = this.state.slots;
|
|
756
|
+
const { startSlot, endSlot } = selection;
|
|
757
|
+
let startIndex = slots.findIndex(i => i.slot === startSlot);
|
|
758
|
+
const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
|
|
759
|
+
for (; startIndex < endIndex; startIndex++) {
|
|
760
|
+
slots[startIndex].emphasize = false;
|
|
843
761
|
}
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
let startIndex = slots.findIndex(i => i.slot === startSlot);
|
|
854
|
-
const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
|
|
855
|
-
for (; startIndex < endIndex; startIndex++) {
|
|
856
|
-
slots[startIndex].emphasize = true;
|
|
857
|
-
}
|
|
762
|
+
};
|
|
763
|
+
this.emphasize = () => {
|
|
764
|
+
const selection = this.textbus.get(Selection);
|
|
765
|
+
const slots = this.state.slots;
|
|
766
|
+
const { startSlot, endSlot } = selection;
|
|
767
|
+
let startIndex = slots.findIndex(i => i.slot === startSlot);
|
|
768
|
+
const endIndex = slots.findIndex(i => i.slot === endSlot) + 1;
|
|
769
|
+
for (; startIndex < endIndex; startIndex++) {
|
|
770
|
+
slots[startIndex].emphasize = true;
|
|
858
771
|
}
|
|
859
|
-
}
|
|
772
|
+
};
|
|
860
773
|
}
|
|
861
774
|
static fromJSON(textbus, json) {
|
|
862
775
|
const registry = textbus.get(Registry);
|
|
@@ -1028,67 +941,52 @@ class SourceCodeComponent extends Component {
|
|
|
1028
941
|
});
|
|
1029
942
|
}
|
|
1030
943
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
configurable: true,
|
|
1046
|
-
writable: true,
|
|
1047
|
-
value: {
|
|
1048
|
-
key: 'Enter',
|
|
1049
|
-
match(c) {
|
|
1050
|
-
const matchString = languageList.map(i => i.label || i.value).concat('js', 'ts').join('|').replace(/\+/, '\\+');
|
|
1051
|
-
const reg = new RegExp(`^\`\`\`(${matchString})$`, 'i');
|
|
1052
|
-
return reg.test(c);
|
|
1053
|
-
},
|
|
1054
|
-
createState(content) {
|
|
1055
|
-
const matchString = content.replace(/`/g, '').replace(/\+/, '\\+');
|
|
1056
|
-
for (const item of languageList) {
|
|
1057
|
-
const reg = new RegExp(`^${matchString}$`, 'i');
|
|
1058
|
-
if (reg.test(item.label || item.value)) {
|
|
1059
|
-
return {
|
|
1060
|
-
lang: item.value,
|
|
1061
|
-
theme: '',
|
|
1062
|
-
lineNumber: true,
|
|
1063
|
-
slots: [createCodeSlot()]
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
if (/^js$/i.test(matchString)) {
|
|
1068
|
-
return {
|
|
1069
|
-
lang: 'JavaScript',
|
|
1070
|
-
theme: '',
|
|
1071
|
-
lineNumber: true,
|
|
1072
|
-
slots: [createCodeSlot()]
|
|
1073
|
-
};
|
|
1074
|
-
}
|
|
1075
|
-
if (/^ts$/i.test(matchString)) {
|
|
944
|
+
SourceCodeComponent.type = ContentType.BlockComponent;
|
|
945
|
+
SourceCodeComponent.componentName = 'SourceCodeComponent';
|
|
946
|
+
SourceCodeComponent.zenCoding = {
|
|
947
|
+
key: 'Enter',
|
|
948
|
+
match(c) {
|
|
949
|
+
const matchString = languageList.map(i => i.label || i.value).concat('js', 'ts').join('|').replace(/\+/, '\\+');
|
|
950
|
+
const reg = new RegExp(`^\`\`\`(${matchString})$`, 'i');
|
|
951
|
+
return reg.test(c);
|
|
952
|
+
},
|
|
953
|
+
createState(content) {
|
|
954
|
+
const matchString = content.replace(/`/g, '').replace(/\+/, '\\+');
|
|
955
|
+
for (const item of languageList) {
|
|
956
|
+
const reg = new RegExp(`^${matchString}$`, 'i');
|
|
957
|
+
if (reg.test(item.label || item.value)) {
|
|
1076
958
|
return {
|
|
1077
|
-
lang:
|
|
959
|
+
lang: item.value,
|
|
1078
960
|
theme: '',
|
|
1079
961
|
lineNumber: true,
|
|
1080
962
|
slots: [createCodeSlot()]
|
|
1081
963
|
};
|
|
1082
964
|
}
|
|
965
|
+
}
|
|
966
|
+
if (/^js$/i.test(matchString)) {
|
|
967
|
+
return {
|
|
968
|
+
lang: 'JavaScript',
|
|
969
|
+
theme: '',
|
|
970
|
+
lineNumber: true,
|
|
971
|
+
slots: [createCodeSlot()]
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
if (/^ts$/i.test(matchString)) {
|
|
1083
975
|
return {
|
|
1084
|
-
lang: '',
|
|
976
|
+
lang: 'TypeScript',
|
|
1085
977
|
theme: '',
|
|
1086
978
|
lineNumber: true,
|
|
1087
979
|
slots: [createCodeSlot()]
|
|
1088
980
|
};
|
|
1089
981
|
}
|
|
982
|
+
return {
|
|
983
|
+
lang: '',
|
|
984
|
+
theme: '',
|
|
985
|
+
lineNumber: true,
|
|
986
|
+
slots: [createCodeSlot()]
|
|
987
|
+
};
|
|
1090
988
|
}
|
|
1091
|
-
}
|
|
989
|
+
};
|
|
1092
990
|
function SourceCodeView(props) {
|
|
1093
991
|
const adapter = inject(DomAdapter);
|
|
1094
992
|
const isFocus = createSignal(false);
|
|
@@ -1180,7 +1078,7 @@ function SourceCodeView(props) {
|
|
|
1180
1078
|
'xnote-source-code': true,
|
|
1181
1079
|
'xnote-source-code-line-number': state.lineNumber,
|
|
1182
1080
|
[state.theme || 'github']: true
|
|
1183
|
-
}, lang: state.lang, "data-auto-break": state.autoBreak, "data-theme": state.theme || null, "data-line-number": state.lineNumber, children: [!readonly() || !output() && jsxs(ComponentToolbar, { visible: isFocus(), children: [jsx(ToolbarItem, { children: jsx(Dropdown, { onCheck: changeLang, trigger: 'hover', menu: languageList.map(item => {
|
|
1081
|
+
}, lang: state.lang, "data-auto-break": state.autoBreak, "data-theme": state.theme || null, "data-line-number": state.lineNumber, children: [(!readonly() || !output()) && jsxs(ComponentToolbar, { visible: isFocus(), children: [jsx(ToolbarItem, { children: jsx(Dropdown, { onCheck: changeLang, trigger: 'hover', menu: languageList.map(item => {
|
|
1184
1082
|
return {
|
|
1185
1083
|
label: jsx(MenuItem, { checked: state.lang === item.value, children: item.label || 'Plain Text' }),
|
|
1186
1084
|
value: item.value
|
|
@@ -1420,7 +1318,7 @@ function AttrTool(props) {
|
|
|
1420
1318
|
break;
|
|
1421
1319
|
}
|
|
1422
1320
|
}
|
|
1423
|
-
return withScopedCSS(
|
|
1321
|
+
return withScopedCSS(css$b, () => {
|
|
1424
1322
|
const states = checkStates();
|
|
1425
1323
|
return (jsx(Dropdown, { style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
|
|
1426
1324
|
{
|
|
@@ -1559,24 +1457,9 @@ class TableComponent extends Component {
|
|
|
1559
1457
|
})
|
|
1560
1458
|
}) {
|
|
1561
1459
|
super(textbus, state);
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
writable: true,
|
|
1566
|
-
value: this.textbus.get(Selection)
|
|
1567
|
-
});
|
|
1568
|
-
Object.defineProperty(this, "focus", {
|
|
1569
|
-
enumerable: true,
|
|
1570
|
-
configurable: true,
|
|
1571
|
-
writable: true,
|
|
1572
|
-
value: new Subject()
|
|
1573
|
-
});
|
|
1574
|
-
Object.defineProperty(this, "tableSelection", {
|
|
1575
|
-
enumerable: true,
|
|
1576
|
-
configurable: true,
|
|
1577
|
-
writable: true,
|
|
1578
|
-
value: createSignal(null)
|
|
1579
|
-
});
|
|
1460
|
+
this.selection = this.textbus.get(Selection);
|
|
1461
|
+
this.focus = new Subject();
|
|
1462
|
+
this.tableSelection = createSignal(null);
|
|
1580
1463
|
}
|
|
1581
1464
|
setup() {
|
|
1582
1465
|
onFocusIn(() => {
|
|
@@ -1701,18 +1584,8 @@ class TableComponent extends Component {
|
|
|
1701
1584
|
});
|
|
1702
1585
|
}
|
|
1703
1586
|
}
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
configurable: true,
|
|
1707
|
-
writable: true,
|
|
1708
|
-
value: 'TableComponent'
|
|
1709
|
-
});
|
|
1710
|
-
Object.defineProperty(TableComponent, "type", {
|
|
1711
|
-
enumerable: true,
|
|
1712
|
-
configurable: true,
|
|
1713
|
-
writable: true,
|
|
1714
|
-
value: ContentType.BlockComponent
|
|
1715
|
-
});
|
|
1587
|
+
TableComponent.componentName = 'TableComponent';
|
|
1588
|
+
TableComponent.type = ContentType.BlockComponent;
|
|
1716
1589
|
|
|
1717
1590
|
const strikeThroughFormatter = new Formatter('strike', {
|
|
1718
1591
|
columned: true,
|
|
@@ -1817,37 +1690,22 @@ class TodolistComponent extends Component {
|
|
|
1817
1690
|
});
|
|
1818
1691
|
}
|
|
1819
1692
|
}
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
configurable: true,
|
|
1835
|
-
writable: true,
|
|
1836
|
-
value: {
|
|
1837
|
-
match: /^\[(x|\s)?\]$/,
|
|
1838
|
-
key: ' ',
|
|
1839
|
-
createState(content) {
|
|
1840
|
-
const isChecked = content.charAt(1) === 'x';
|
|
1841
|
-
return {
|
|
1842
|
-
checked: isChecked,
|
|
1843
|
-
slot: new Slot([
|
|
1844
|
-
ContentType.InlineComponent,
|
|
1845
|
-
ContentType.Text
|
|
1846
|
-
])
|
|
1847
|
-
};
|
|
1848
|
-
}
|
|
1693
|
+
TodolistComponent.type = ContentType.BlockComponent;
|
|
1694
|
+
TodolistComponent.componentName = 'TodoListComponent';
|
|
1695
|
+
TodolistComponent.zenCoding = {
|
|
1696
|
+
match: /^\[(x|\s)?\]$/,
|
|
1697
|
+
key: ' ',
|
|
1698
|
+
createState(content) {
|
|
1699
|
+
const isChecked = content.charAt(1) === 'x';
|
|
1700
|
+
return {
|
|
1701
|
+
checked: isChecked,
|
|
1702
|
+
slot: new Slot([
|
|
1703
|
+
ContentType.InlineComponent,
|
|
1704
|
+
ContentType.Text
|
|
1705
|
+
])
|
|
1706
|
+
};
|
|
1849
1707
|
}
|
|
1850
|
-
}
|
|
1708
|
+
};
|
|
1851
1709
|
function TodolistView(props) {
|
|
1852
1710
|
const adapter = inject(DomAdapter);
|
|
1853
1711
|
const component = props.component;
|
|
@@ -1921,36 +1779,21 @@ class BlockquoteComponent extends Component {
|
|
|
1921
1779
|
useBlockContent(this.state.slot);
|
|
1922
1780
|
}
|
|
1923
1781
|
}
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
enumerable: true,
|
|
1938
|
-
configurable: true,
|
|
1939
|
-
writable: true,
|
|
1940
|
-
value: {
|
|
1941
|
-
key: ' ',
|
|
1942
|
-
match: /^>$/,
|
|
1943
|
-
createState() {
|
|
1944
|
-
return {
|
|
1945
|
-
slot: new Slot([
|
|
1946
|
-
ContentType.Text,
|
|
1947
|
-
ContentType.InlineComponent,
|
|
1948
|
-
ContentType.BlockComponent
|
|
1949
|
-
])
|
|
1950
|
-
};
|
|
1951
|
-
}
|
|
1782
|
+
BlockquoteComponent.type = ContentType.BlockComponent;
|
|
1783
|
+
BlockquoteComponent.componentName = 'BlockquoteComponent';
|
|
1784
|
+
BlockquoteComponent.zenCoding = {
|
|
1785
|
+
key: ' ',
|
|
1786
|
+
match: /^>$/,
|
|
1787
|
+
createState() {
|
|
1788
|
+
return {
|
|
1789
|
+
slot: new Slot([
|
|
1790
|
+
ContentType.Text,
|
|
1791
|
+
ContentType.InlineComponent,
|
|
1792
|
+
ContentType.BlockComponent
|
|
1793
|
+
])
|
|
1794
|
+
};
|
|
1952
1795
|
}
|
|
1953
|
-
}
|
|
1796
|
+
};
|
|
1954
1797
|
function BlockquoteView(props) {
|
|
1955
1798
|
const adapter = inject(DomAdapter);
|
|
1956
1799
|
const readonly = useReadonly();
|
|
@@ -2067,37 +1910,22 @@ class ListComponent extends Component {
|
|
|
2067
1910
|
});
|
|
2068
1911
|
}
|
|
2069
1912
|
}
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
configurable: true,
|
|
2085
|
-
writable: true,
|
|
2086
|
-
value: {
|
|
2087
|
-
key: ' ',
|
|
2088
|
-
match: /^([1-9]\.|[+*])$/,
|
|
2089
|
-
createState(content) {
|
|
2090
|
-
return {
|
|
2091
|
-
type: /[-+*]/.test(content) ? 'UnorderedList' : 'OrderedList',
|
|
2092
|
-
reorder: true,
|
|
2093
|
-
slot: new Slot([
|
|
2094
|
-
ContentType.InlineComponent,
|
|
2095
|
-
ContentType.Text
|
|
2096
|
-
])
|
|
2097
|
-
};
|
|
2098
|
-
}
|
|
1913
|
+
ListComponent.componentName = 'ListComponent';
|
|
1914
|
+
ListComponent.type = ContentType.BlockComponent;
|
|
1915
|
+
ListComponent.zenCoding = {
|
|
1916
|
+
key: ' ',
|
|
1917
|
+
match: /^([1-9]\.|[+*])$/,
|
|
1918
|
+
createState(content) {
|
|
1919
|
+
return {
|
|
1920
|
+
type: /[-+*]/.test(content) ? 'UnorderedList' : 'OrderedList',
|
|
1921
|
+
reorder: true,
|
|
1922
|
+
slot: new Slot([
|
|
1923
|
+
ContentType.InlineComponent,
|
|
1924
|
+
ContentType.Text
|
|
1925
|
+
])
|
|
1926
|
+
};
|
|
2099
1927
|
}
|
|
2100
|
-
}
|
|
1928
|
+
};
|
|
2101
1929
|
const step = 26;
|
|
2102
1930
|
const chars = Array.from({ length: step }).map((_, index) => String.fromCharCode(96 + index + 1));
|
|
2103
1931
|
function numberToLetter(num) {
|
|
@@ -2187,7 +2015,7 @@ function ListComponentView(props) {
|
|
|
2187
2015
|
}, children: jsxs("li", { style: {
|
|
2188
2016
|
justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
|
|
2189
2017
|
textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0
|
|
2190
|
-
}, children: [jsx("div", { class: "xnote-list-type", children: component.state.type === 'UnorderedList' || readonly() || output() ?
|
|
2018
|
+
}, children: [jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
|
|
2191
2019
|
jsx("span", { class: "xnote-order-btn", children: icon })
|
|
2192
2020
|
:
|
|
2193
2021
|
jsx(Dropdown, { menu: jsxs(Fragment, { children: [jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }), adapter.slotRender(component.state.slot, children => {
|
|
@@ -2310,24 +2138,9 @@ class HighlightBoxComponent extends Component {
|
|
|
2310
2138
|
useBlockContent(this.state.slot);
|
|
2311
2139
|
}
|
|
2312
2140
|
}
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
writable: true,
|
|
2317
|
-
value: ['❤️', '💡', '📌', '✅', '❎', '👍', '🎉', '🚫', '❗']
|
|
2318
|
-
});
|
|
2319
|
-
Object.defineProperty(HighlightBoxComponent, "componentName", {
|
|
2320
|
-
enumerable: true,
|
|
2321
|
-
configurable: true,
|
|
2322
|
-
writable: true,
|
|
2323
|
-
value: 'HighlightBoxComponent'
|
|
2324
|
-
});
|
|
2325
|
-
Object.defineProperty(HighlightBoxComponent, "type", {
|
|
2326
|
-
enumerable: true,
|
|
2327
|
-
configurable: true,
|
|
2328
|
-
writable: true,
|
|
2329
|
-
value: ContentType.BlockComponent
|
|
2330
|
-
});
|
|
2141
|
+
HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '👍', '🎉', '🚫', '❗'];
|
|
2142
|
+
HighlightBoxComponent.componentName = 'HighlightBoxComponent';
|
|
2143
|
+
HighlightBoxComponent.type = ContentType.BlockComponent;
|
|
2331
2144
|
function HighlightBoxView(props) {
|
|
2332
2145
|
const adapter = inject(DomAdapter);
|
|
2333
2146
|
const readonly = useReadonly();
|
|
@@ -2599,7 +2412,7 @@ function useBlockTransform() {
|
|
|
2599
2412
|
function BlockTool() {
|
|
2600
2413
|
const checkStates = useActiveBlock();
|
|
2601
2414
|
const transform = useBlockTransform();
|
|
2602
|
-
return withScopedCSS(
|
|
2415
|
+
return withScopedCSS(css$b, () => {
|
|
2603
2416
|
const states = checkStates();
|
|
2604
2417
|
const types = [
|
|
2605
2418
|
[states.paragraph, 'xnote-icon-pilcrow'],
|
|
@@ -3030,7 +2843,7 @@ function CodeTool() {
|
|
|
3030
2843
|
};
|
|
3031
2844
|
}
|
|
3032
2845
|
|
|
3033
|
-
var
|
|
2846
|
+
var css$a = undefined;
|
|
3034
2847
|
|
|
3035
2848
|
function ColorTool(props) {
|
|
3036
2849
|
const query = inject(Query);
|
|
@@ -3078,7 +2891,7 @@ function ColorTool(props) {
|
|
|
3078
2891
|
'#90a0e5',
|
|
3079
2892
|
'#c596e0',
|
|
3080
2893
|
];
|
|
3081
|
-
return withScopedCSS(
|
|
2894
|
+
return withScopedCSS(css$a, () => {
|
|
3082
2895
|
const vm = viewModel();
|
|
3083
2896
|
return (jsx(Dropdown, { style: props.style, 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: {
|
|
3084
2897
|
active: textColor() === ''
|
|
@@ -3286,7 +3099,7 @@ function ItalicTool() {
|
|
|
3286
3099
|
};
|
|
3287
3100
|
}
|
|
3288
3101
|
|
|
3289
|
-
var
|
|
3102
|
+
var css$9 = undefined;
|
|
3290
3103
|
|
|
3291
3104
|
function LinkTool(props) {
|
|
3292
3105
|
const selectionBridge = inject(SelectionBridge);
|
|
@@ -3317,7 +3130,7 @@ function LinkTool(props) {
|
|
|
3317
3130
|
onUnmounted(() => {
|
|
3318
3131
|
sub.unsubscribe();
|
|
3319
3132
|
});
|
|
3320
|
-
return withScopedCSS(
|
|
3133
|
+
return withScopedCSS(css$9, () => {
|
|
3321
3134
|
const containerRect = container.getBoundingClientRect();
|
|
3322
3135
|
const rect = isShow() ? selectionBridge.getRect({
|
|
3323
3136
|
slot: selection.focusSlot,
|
|
@@ -3386,7 +3199,7 @@ function UnderlineTool() {
|
|
|
3386
3199
|
};
|
|
3387
3200
|
}
|
|
3388
3201
|
|
|
3389
|
-
var
|
|
3202
|
+
var css$8 = undefined;
|
|
3390
3203
|
|
|
3391
3204
|
function InsertTool(props) {
|
|
3392
3205
|
const commander = inject(Commander);
|
|
@@ -3490,12 +3303,12 @@ function InsertTool(props) {
|
|
|
3490
3303
|
break;
|
|
3491
3304
|
}
|
|
3492
3305
|
}
|
|
3493
|
-
return withScopedCSS(
|
|
3306
|
+
return withScopedCSS(css$8, () => {
|
|
3494
3307
|
return jsxs(Fragment, { children: [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-warning" }), children: "\u9AD8\u4EAE\u5757" })] });
|
|
3495
3308
|
});
|
|
3496
3309
|
}
|
|
3497
3310
|
|
|
3498
|
-
var
|
|
3311
|
+
var css$7 = undefined;
|
|
3499
3312
|
|
|
3500
3313
|
const LeftToolbar = withAnnotation({
|
|
3501
3314
|
providers: [RefreshService]
|
|
@@ -3654,7 +3467,7 @@ const LeftToolbar = withAnnotation({
|
|
|
3654
3467
|
}
|
|
3655
3468
|
}
|
|
3656
3469
|
const isEmptyBlock = createSignal(true);
|
|
3657
|
-
return withScopedCSS(
|
|
3470
|
+
return withScopedCSS(css$7, () => {
|
|
3658
3471
|
const position = positionSignal();
|
|
3659
3472
|
const slot = activeSlot();
|
|
3660
3473
|
let activeNode = jsx("span", { class: "xnote-icon-pilcrow" });
|
|
@@ -3699,12 +3512,7 @@ const LeftToolbar = withAnnotation({
|
|
|
3699
3512
|
|
|
3700
3513
|
class LeftToolbarPlugin {
|
|
3701
3514
|
constructor() {
|
|
3702
|
-
|
|
3703
|
-
enumerable: true,
|
|
3704
|
-
configurable: true,
|
|
3705
|
-
writable: true,
|
|
3706
|
-
value: null
|
|
3707
|
-
});
|
|
3515
|
+
this.app = null;
|
|
3708
3516
|
}
|
|
3709
3517
|
setup(injector) {
|
|
3710
3518
|
const App = function () {
|
|
@@ -3730,16 +3538,11 @@ class LeftToolbarPlugin {
|
|
|
3730
3538
|
}
|
|
3731
3539
|
}
|
|
3732
3540
|
|
|
3733
|
-
var
|
|
3541
|
+
var css$6 = undefined;
|
|
3734
3542
|
|
|
3735
3543
|
let EditorService = class EditorService {
|
|
3736
3544
|
constructor() {
|
|
3737
|
-
|
|
3738
|
-
enumerable: true,
|
|
3739
|
-
configurable: true,
|
|
3740
|
-
writable: true,
|
|
3741
|
-
value: false
|
|
3742
|
-
});
|
|
3545
|
+
this.hideInlineToolbar = false;
|
|
3743
3546
|
}
|
|
3744
3547
|
};
|
|
3745
3548
|
EditorService = __decorate([
|
|
@@ -3845,7 +3648,7 @@ const Toolbar = withAnnotation({
|
|
|
3845
3648
|
mousedownSubscription.unsubscribe();
|
|
3846
3649
|
mouseupSubscription.unsubscribe();
|
|
3847
3650
|
});
|
|
3848
|
-
return withScopedCSS(
|
|
3651
|
+
return withScopedCSS(css$6, () => {
|
|
3849
3652
|
const p = viewPosition();
|
|
3850
3653
|
return (jsxs("div", { class: "toolbar", ref: toolbarRef, style: {
|
|
3851
3654
|
left: p.left + 'px',
|
|
@@ -3860,12 +3663,7 @@ const Toolbar = withAnnotation({
|
|
|
3860
3663
|
|
|
3861
3664
|
class ToolbarPlugin {
|
|
3862
3665
|
constructor() {
|
|
3863
|
-
|
|
3864
|
-
enumerable: true,
|
|
3865
|
-
configurable: true,
|
|
3866
|
-
writable: true,
|
|
3867
|
-
value: null
|
|
3868
|
-
});
|
|
3666
|
+
this.app = null;
|
|
3869
3667
|
}
|
|
3870
3668
|
setup(injector) {
|
|
3871
3669
|
const App = function () {
|
|
@@ -3890,30 +3688,10 @@ class ToolbarPlugin {
|
|
|
3890
3688
|
|
|
3891
3689
|
class Matcher {
|
|
3892
3690
|
constructor(target, rule) {
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
value: target
|
|
3898
|
-
});
|
|
3899
|
-
Object.defineProperty(this, "rule", {
|
|
3900
|
-
enumerable: true,
|
|
3901
|
-
configurable: true,
|
|
3902
|
-
writable: true,
|
|
3903
|
-
value: rule
|
|
3904
|
-
});
|
|
3905
|
-
Object.defineProperty(this, "validators", {
|
|
3906
|
-
enumerable: true,
|
|
3907
|
-
configurable: true,
|
|
3908
|
-
writable: true,
|
|
3909
|
-
value: []
|
|
3910
|
-
});
|
|
3911
|
-
Object.defineProperty(this, "excludeValidators", {
|
|
3912
|
-
enumerable: true,
|
|
3913
|
-
configurable: true,
|
|
3914
|
-
writable: true,
|
|
3915
|
-
value: []
|
|
3916
|
-
});
|
|
3691
|
+
this.target = target;
|
|
3692
|
+
this.rule = rule;
|
|
3693
|
+
this.validators = [];
|
|
3694
|
+
this.excludeValidators = [];
|
|
3917
3695
|
if (rule.tags) {
|
|
3918
3696
|
this.validators.push(this.makeTagsMatcher(rule.tags));
|
|
3919
3697
|
}
|
|
@@ -4010,18 +3788,8 @@ class ImageComponent extends Component {
|
|
|
4010
3788
|
return new ImageComponent(textbus, Object.assign({}, json));
|
|
4011
3789
|
}
|
|
4012
3790
|
}
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
configurable: true,
|
|
4016
|
-
writable: true,
|
|
4017
|
-
value: ContentType.InlineComponent
|
|
4018
|
-
});
|
|
4019
|
-
Object.defineProperty(ImageComponent, "componentName", {
|
|
4020
|
-
enumerable: true,
|
|
4021
|
-
configurable: true,
|
|
4022
|
-
writable: true,
|
|
4023
|
-
value: 'ImageComponent'
|
|
4024
|
-
});
|
|
3791
|
+
ImageComponent.type = ContentType.InlineComponent;
|
|
3792
|
+
ImageComponent.componentName = 'ImageComponent';
|
|
4025
3793
|
function ImageView(props) {
|
|
4026
3794
|
const { name, state } = props.component;
|
|
4027
3795
|
const imageRef = createRef();
|
|
@@ -4055,12 +3823,7 @@ const imageComponentLoader = {
|
|
|
4055
3823
|
class RootComponent extends Component {
|
|
4056
3824
|
constructor() {
|
|
4057
3825
|
super(...arguments);
|
|
4058
|
-
|
|
4059
|
-
enumerable: true,
|
|
4060
|
-
configurable: true,
|
|
4061
|
-
writable: true,
|
|
4062
|
-
value: new Subject()
|
|
4063
|
-
});
|
|
3826
|
+
this.onCompositionStart = new Subject();
|
|
4064
3827
|
}
|
|
4065
3828
|
static fromJSON(textbus, json) {
|
|
4066
3829
|
const heading = textbus.get(Registry).createSlot(json.heading);
|
|
@@ -4103,18 +3866,8 @@ class RootComponent extends Component {
|
|
|
4103
3866
|
content.insert(new ParagraphComponent(this.textbus));
|
|
4104
3867
|
}
|
|
4105
3868
|
}
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
configurable: true,
|
|
4109
|
-
writable: true,
|
|
4110
|
-
value: 'RootComponent'
|
|
4111
|
-
});
|
|
4112
|
-
Object.defineProperty(RootComponent, "type", {
|
|
4113
|
-
enumerable: true,
|
|
4114
|
-
configurable: true,
|
|
4115
|
-
writable: true,
|
|
4116
|
-
value: ContentType.BlockComponent
|
|
4117
|
-
});
|
|
3869
|
+
RootComponent.componentName = 'RootComponent';
|
|
3870
|
+
RootComponent.type = ContentType.BlockComponent;
|
|
4118
3871
|
function RootView(props) {
|
|
4119
3872
|
const adapter = inject(DomAdapter);
|
|
4120
3873
|
const { heading, content } = props.component.state;
|
|
@@ -4172,40 +3925,15 @@ const rootComponentLoader = {
|
|
|
4172
3925
|
}
|
|
4173
3926
|
};
|
|
4174
3927
|
|
|
4175
|
-
var
|
|
3928
|
+
var css$5 = undefined;
|
|
4176
3929
|
|
|
4177
3930
|
let TableService = class TableService {
|
|
4178
3931
|
constructor() {
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
});
|
|
4185
|
-
Object.defineProperty(this, "onInsertColumnBefore", {
|
|
4186
|
-
enumerable: true,
|
|
4187
|
-
configurable: true,
|
|
4188
|
-
writable: true,
|
|
4189
|
-
value: new Subject()
|
|
4190
|
-
});
|
|
4191
|
-
Object.defineProperty(this, "onSelectColumns", {
|
|
4192
|
-
enumerable: true,
|
|
4193
|
-
configurable: true,
|
|
4194
|
-
writable: true,
|
|
4195
|
-
value: new Subject()
|
|
4196
|
-
});
|
|
4197
|
-
Object.defineProperty(this, "onSelectRows", {
|
|
4198
|
-
enumerable: true,
|
|
4199
|
-
configurable: true,
|
|
4200
|
-
writable: true,
|
|
4201
|
-
value: new Subject()
|
|
4202
|
-
});
|
|
4203
|
-
Object.defineProperty(this, "onScroll", {
|
|
4204
|
-
enumerable: true,
|
|
4205
|
-
configurable: true,
|
|
4206
|
-
writable: true,
|
|
4207
|
-
value: new Subject()
|
|
4208
|
-
});
|
|
3932
|
+
this.onInsertRowBefore = new Subject();
|
|
3933
|
+
this.onInsertColumnBefore = new Subject();
|
|
3934
|
+
this.onSelectColumns = new Subject();
|
|
3935
|
+
this.onSelectRows = new Subject();
|
|
3936
|
+
this.onScroll = new Subject();
|
|
4209
3937
|
}
|
|
4210
3938
|
};
|
|
4211
3939
|
TableService = __decorate([
|
|
@@ -4284,12 +4012,12 @@ function ResizeColumn(props) {
|
|
|
4284
4012
|
});
|
|
4285
4013
|
return () => sub.unsubscribe();
|
|
4286
4014
|
});
|
|
4287
|
-
return withScopedCSS(
|
|
4015
|
+
return withScopedCSS(css$5, () => {
|
|
4288
4016
|
return jsx("div", { ref: dragLineRef, class: ['drag-line'] });
|
|
4289
4017
|
});
|
|
4290
4018
|
}
|
|
4291
4019
|
|
|
4292
|
-
var
|
|
4020
|
+
var css$4 = undefined;
|
|
4293
4021
|
|
|
4294
4022
|
function TopBar(props) {
|
|
4295
4023
|
const editorService = inject(EditorService);
|
|
@@ -4357,7 +4085,7 @@ function TopBar(props) {
|
|
|
4357
4085
|
s.unsubscribe();
|
|
4358
4086
|
});
|
|
4359
4087
|
const deleteIndex = createSignal(null);
|
|
4360
|
-
return withScopedCSS(
|
|
4088
|
+
return withScopedCSS(css$4, () => {
|
|
4361
4089
|
const { state, tableSelection } = props.component;
|
|
4362
4090
|
const position = tableSelection();
|
|
4363
4091
|
return (jsx("div", { class: ['top-bar', {
|
|
@@ -4410,7 +4138,7 @@ function TopBar(props) {
|
|
|
4410
4138
|
});
|
|
4411
4139
|
}
|
|
4412
4140
|
|
|
4413
|
-
var
|
|
4141
|
+
var css$3 = undefined;
|
|
4414
4142
|
|
|
4415
4143
|
function Scroll(props) {
|
|
4416
4144
|
const scrollRef = createRef();
|
|
@@ -4442,7 +4170,7 @@ function Scroll(props) {
|
|
|
4442
4170
|
draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
|
|
4443
4171
|
});
|
|
4444
4172
|
});
|
|
4445
|
-
return withScopedCSS(
|
|
4173
|
+
return withScopedCSS(css$3, () => {
|
|
4446
4174
|
return jsx("div", { ref: [scrollRef, props.scrollRef], class: ['scroll-container', {
|
|
4447
4175
|
'left-end': showShadow().leftEnd,
|
|
4448
4176
|
'right-end': showShadow().rightEnd,
|
|
@@ -4454,7 +4182,7 @@ function Scroll(props) {
|
|
|
4454
4182
|
});
|
|
4455
4183
|
}
|
|
4456
4184
|
|
|
4457
|
-
var
|
|
4185
|
+
var css$2 = undefined;
|
|
4458
4186
|
|
|
4459
4187
|
function LeftBar(props) {
|
|
4460
4188
|
const editorService = inject(EditorService);
|
|
@@ -4528,7 +4256,7 @@ function LeftBar(props) {
|
|
|
4528
4256
|
textbus.focus();
|
|
4529
4257
|
});
|
|
4530
4258
|
}
|
|
4531
|
-
return withScopedCSS(
|
|
4259
|
+
return withScopedCSS(css$2, () => {
|
|
4532
4260
|
const { state, tableSelection } = props.component;
|
|
4533
4261
|
const position = tableSelection();
|
|
4534
4262
|
return (jsxs("div", { class: ['left-bar', { active: props.isFocus() }], children: [jsx("div", { class: "insert-bar", children: jsx("table", { ref: insertBarRef, children: jsx("tbody", { children: state.rows.map((_, index) => {
|
|
@@ -4576,7 +4304,7 @@ function LeftBar(props) {
|
|
|
4576
4304
|
});
|
|
4577
4305
|
}
|
|
4578
4306
|
|
|
4579
|
-
var
|
|
4307
|
+
var css$1 = undefined;
|
|
4580
4308
|
|
|
4581
4309
|
function sum(numbers) {
|
|
4582
4310
|
return numbers.reduce((a, b) => a + b, 0);
|
|
@@ -4609,7 +4337,7 @@ function ResizeRow(props) {
|
|
|
4609
4337
|
});
|
|
4610
4338
|
return () => sub.unsubscribe();
|
|
4611
4339
|
});
|
|
4612
|
-
return withScopedCSS(
|
|
4340
|
+
return withScopedCSS(css$1, () => {
|
|
4613
4341
|
return jsx("div", { ref: dragLineRef, style: {
|
|
4614
4342
|
display: styles().visible ? 'block' : 'none',
|
|
4615
4343
|
top: styles().top + 'px',
|
|
@@ -4618,7 +4346,7 @@ function ResizeRow(props) {
|
|
|
4618
4346
|
});
|
|
4619
4347
|
}
|
|
4620
4348
|
|
|
4621
|
-
var
|
|
4349
|
+
var css = undefined;
|
|
4622
4350
|
|
|
4623
4351
|
function SelectionMask(props) {
|
|
4624
4352
|
const [styles, updateStyles] = useProduce({
|
|
@@ -4671,7 +4399,7 @@ function SelectionMask(props) {
|
|
|
4671
4399
|
onUnmounted(() => {
|
|
4672
4400
|
s.unsubscribe();
|
|
4673
4401
|
});
|
|
4674
|
-
return withScopedCSS(
|
|
4402
|
+
return withScopedCSS(css, () => {
|
|
4675
4403
|
const style = styles();
|
|
4676
4404
|
return (jsx("div", { class: "mask", style: {
|
|
4677
4405
|
display: style.visible ? 'block' : 'none',
|
|
@@ -4977,18 +4705,8 @@ class VideoComponent extends Component {
|
|
|
4977
4705
|
//
|
|
4978
4706
|
}
|
|
4979
4707
|
}
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
configurable: true,
|
|
4983
|
-
writable: true,
|
|
4984
|
-
value: ContentType.InlineComponent
|
|
4985
|
-
});
|
|
4986
|
-
Object.defineProperty(VideoComponent, "componentName", {
|
|
4987
|
-
enumerable: true,
|
|
4988
|
-
configurable: true,
|
|
4989
|
-
writable: true,
|
|
4990
|
-
value: 'VideoComponent'
|
|
4991
|
-
});
|
|
4708
|
+
VideoComponent.type = ContentType.InlineComponent;
|
|
4709
|
+
VideoComponent.componentName = 'VideoComponent';
|
|
4992
4710
|
function VideoView(props) {
|
|
4993
4711
|
const { name, state } = props.component;
|
|
4994
4712
|
const videoRef = createRef();
|
|
@@ -5019,9 +4737,9 @@ const videoComponentLoader = {
|
|
|
5019
4737
|
}
|
|
5020
4738
|
};
|
|
5021
4739
|
|
|
5022
|
-
function createXNote(
|
|
5023
|
-
return __awaiter(this,
|
|
5024
|
-
const adapter = new
|
|
4740
|
+
function createXNote(host_1) {
|
|
4741
|
+
return __awaiter(this, arguments, void 0, function* (host, config = {}) {
|
|
4742
|
+
const adapter = new ViewflyAdapter({
|
|
5025
4743
|
[ParagraphComponent.componentName]: ParagraphView,
|
|
5026
4744
|
[RootComponent.componentName]: RootView,
|
|
5027
4745
|
[BlockquoteComponent.componentName]: BlockquoteView,
|
|
@@ -5032,8 +4750,8 @@ function createXNote(host, config = {}) {
|
|
|
5032
4750
|
[ListComponent.componentName]: ListComponentView,
|
|
5033
4751
|
[ImageComponent.componentName]: ImageView,
|
|
5034
4752
|
[VideoComponent.componentName]: VideoView
|
|
5035
|
-
}, (host, root) => {
|
|
5036
|
-
const appInjector = new ReflectiveInjector(
|
|
4753
|
+
}, (host, root, injector) => {
|
|
4754
|
+
const appInjector = new ReflectiveInjector(injector, [{
|
|
5037
4755
|
provide: OutputInjectionToken,
|
|
5038
4756
|
useValue: false
|
|
5039
4757
|
}]);
|
|
@@ -5044,6 +4762,35 @@ function createXNote(host, config = {}) {
|
|
|
5044
4762
|
app.destroy();
|
|
5045
4763
|
};
|
|
5046
4764
|
});
|
|
4765
|
+
const vDomAdapter = new ViewflyVDomAdapter({
|
|
4766
|
+
[ParagraphComponent.componentName]: ParagraphView,
|
|
4767
|
+
[RootComponent.componentName]: RootView,
|
|
4768
|
+
[BlockquoteComponent.componentName]: BlockquoteView,
|
|
4769
|
+
[TodolistComponent.componentName]: TodolistView,
|
|
4770
|
+
[SourceCodeComponent.componentName]: SourceCodeView,
|
|
4771
|
+
[TableComponent.componentName]: TableComponentView,
|
|
4772
|
+
[HighlightBoxComponent.componentName]: HighlightBoxView,
|
|
4773
|
+
[ListComponent.componentName]: ListComponentView,
|
|
4774
|
+
[ImageComponent.componentName]: ImageView,
|
|
4775
|
+
[VideoComponent.componentName]: VideoView
|
|
4776
|
+
}, (host, root, injector) => {
|
|
4777
|
+
const appInjector = new ReflectiveInjector(injector, [{
|
|
4778
|
+
provide: OutputInjectionToken,
|
|
4779
|
+
useValue: true
|
|
4780
|
+
}, {
|
|
4781
|
+
provide: DomAdapter,
|
|
4782
|
+
useFactory() {
|
|
4783
|
+
return vDomAdapter;
|
|
4784
|
+
}
|
|
4785
|
+
}]);
|
|
4786
|
+
const app = createApp(root, {
|
|
4787
|
+
context: appInjector,
|
|
4788
|
+
nativeRenderer: new HTMLRenderer()
|
|
4789
|
+
}).mount(host);
|
|
4790
|
+
return () => {
|
|
4791
|
+
app.destroy();
|
|
4792
|
+
};
|
|
4793
|
+
});
|
|
5047
4794
|
const browserModule = new BrowserModule({
|
|
5048
4795
|
renderTo() {
|
|
5049
4796
|
return host;
|
|
@@ -5083,6 +4830,7 @@ function createXNote(host, config = {}) {
|
|
|
5083
4830
|
modules.push(new CollaborateModule(config.collaborateConfig));
|
|
5084
4831
|
}
|
|
5085
4832
|
const textbus = new Textbus({
|
|
4833
|
+
additionalAdapters: [vDomAdapter],
|
|
5086
4834
|
zenCoding: true,
|
|
5087
4835
|
readonly: config.readonly,
|
|
5088
4836
|
imports: modules,
|
|
@@ -5147,8 +4895,13 @@ function createXNote(host, config = {}) {
|
|
|
5147
4895
|
});
|
|
5148
4896
|
}
|
|
5149
4897
|
yield textbus.render(rootComp);
|
|
5150
|
-
|
|
5151
|
-
return
|
|
4898
|
+
const translator = new OutputTranslator();
|
|
4899
|
+
return {
|
|
4900
|
+
textbus,
|
|
4901
|
+
getHTML() {
|
|
4902
|
+
return translator.transform(vDomAdapter.host);
|
|
4903
|
+
}
|
|
4904
|
+
};
|
|
5152
4905
|
});
|
|
5153
4906
|
}
|
|
5154
4907
|
|