@textbus/xnote 0.0.1-alpha.4 → 0.0.1-alpha.40
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/README.md +26 -1
- package/bundles/components/_api.d.ts +2 -0
- package/bundles/components/dropdown/dropdown-menu.d.ts +4 -1
- package/bundles/components/dropdown/dropdown.d.ts +4 -1
- package/bundles/components/keymap/keymap.d.ts +5 -0
- package/bundles/components/menu-heading/menu-heading.d.ts +2 -0
- package/bundles/components/menu-item/menu-item.d.ts +2 -1
- package/bundles/components/popup/popup.d.ts +1 -1
- package/bundles/editor.d.ts +13 -6
- package/bundles/fonts/textbus.svg +3 -32
- 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 +1912 -1076
- package/bundles/index.js +1924 -1072
- package/bundles/interfaces.d.ts +3 -0
- package/bundles/plugins/_api.d.ts +1 -0
- package/bundles/plugins/_common/attr.tool.d.ts +2 -2
- package/bundles/plugins/_common/color.tool.d.ts +2 -2
- package/bundles/plugins/left-toolbar/insert-tool.d.ts +5 -2
- package/bundles/plugins/link-jump/link-jump.d.ts +4 -0
- package/bundles/public-api.d.ts +1 -0
- package/bundles/services/editor.service.d.ts +4 -0
- package/bundles/textbus/components/SlotRender.d.ts +14 -0
- package/bundles/textbus/components/_api.d.ts +3 -0
- package/bundles/textbus/components/at/at-component.view.d.ts +6 -0
- package/bundles/textbus/components/at/at.component.d.ts +34 -0
- package/bundles/textbus/components/blockqoute/blockquote.component.d.ts +3 -1
- package/bundles/textbus/components/katex/katex-editor.d.ts +7 -0
- package/bundles/textbus/components/katex/katex.component.d.ts +15 -0
- package/bundles/textbus/components/list/list.component.d.ts +2 -0
- package/bundles/textbus/components/root/root.component.d.ts +0 -1
- package/bundles/textbus/components/source-code/source-code.component.d.ts +2 -1
- package/bundles/textbus/components/table/components/resize-column.d.ts +2 -1
- package/bundles/textbus/components/table/components/scroll.d.ts +1 -2
- package/bundles/textbus/components/table/components/top-bar.d.ts +2 -2
- package/bundles/textbus/components/table/table-selection-awareness-delegate.d.ts +15 -0
- package/bundles/textbus/components/table/table.component.d.ts +0 -1
- package/package.json +36 -12
package/bundles/index.js
CHANGED
|
@@ -8,10 +8,12 @@ var platformBrowser = require('@textbus/platform-browser');
|
|
|
8
8
|
var platformBrowser$1 = require('@viewfly/platform-browser');
|
|
9
9
|
var hooks = require('@viewfly/hooks');
|
|
10
10
|
var highlightjs = require('highlight.js');
|
|
11
|
+
var Katex = require('katex');
|
|
11
12
|
var adapterViewfly = require('@textbus/adapter-viewfly');
|
|
13
|
+
var color = require('@tanbo/color');
|
|
12
14
|
var collaborate = require('@textbus/collaborate');
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var scopedId$n = "vf-d94b56";
|
|
15
17
|
|
|
16
18
|
/******************************************************************************
|
|
17
19
|
Copyright (c) Microsoft Corporation.
|
|
@@ -30,6 +32,18 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
30
32
|
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
31
33
|
|
|
32
34
|
|
|
35
|
+
function __rest(s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
+
t[p[i]] = s[p[i]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
}
|
|
46
|
+
|
|
33
47
|
function __decorate(decorators, target, key, desc) {
|
|
34
48
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35
49
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -41,16 +55,6 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
41
55
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
42
56
|
}
|
|
43
57
|
|
|
44
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
45
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
46
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
47
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
48
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
49
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
50
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
58
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
55
59
|
var e = new Error(message);
|
|
56
60
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -83,7 +87,7 @@ exports.DropdownContextService = DropdownContextService_1 = class DropdownContex
|
|
|
83
87
|
this.canHide = true;
|
|
84
88
|
this.openStateChangeEvent = new core$1.Subject();
|
|
85
89
|
this.timer = null;
|
|
86
|
-
this.parentDropdownContextService = this.injector.get(DropdownContextService_1, core.InjectFlags.SkipSelf
|
|
90
|
+
this.parentDropdownContextService = this.injector.get(DropdownContextService_1, null, core.InjectFlags.SkipSelf);
|
|
87
91
|
this.onOpenStateChange = this.openStateChangeEvent.asObservable();
|
|
88
92
|
dropdownService.onSiblingOpen.subscribe(id => {
|
|
89
93
|
if (id === this.id) {
|
|
@@ -132,7 +136,7 @@ exports.DropdownContextService = DropdownContextService_1 = __decorate([
|
|
|
132
136
|
], exports.DropdownContextService);
|
|
133
137
|
|
|
134
138
|
function Button(props) {
|
|
135
|
-
const dropdownContextService = core.inject(exports.DropdownContextService,
|
|
139
|
+
const dropdownContextService = core.inject(exports.DropdownContextService, null);
|
|
136
140
|
const isActive = core.createSignal((dropdownContextService === null || dropdownContextService === void 0 ? void 0 : dropdownContextService.isOpen) || false);
|
|
137
141
|
if (dropdownContextService) {
|
|
138
142
|
const subscription = dropdownContextService.onOpenStateChange.subscribe(b => {
|
|
@@ -142,7 +146,7 @@ function Button(props) {
|
|
|
142
146
|
subscription.unsubscribe();
|
|
143
147
|
});
|
|
144
148
|
}
|
|
145
|
-
return scopedCss.withScopedCSS(
|
|
149
|
+
return scopedCss.withScopedCSS(scopedId$n, () => {
|
|
146
150
|
return (jsxRuntime.jsxs("button", Object.assign({ type: "button" }, props, { class: [
|
|
147
151
|
'btn',
|
|
148
152
|
{
|
|
@@ -154,10 +158,10 @@ function Button(props) {
|
|
|
154
158
|
});
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
var
|
|
161
|
+
var scopedId$m = "vf-ac7e8d";
|
|
158
162
|
|
|
159
163
|
function ComponentToolbar(props) {
|
|
160
|
-
return scopedCss.withScopedCSS(
|
|
164
|
+
return scopedCss.withScopedCSS(scopedId$m, () => {
|
|
161
165
|
return (jsxRuntime.jsx("div", { class: "component-toolbar", style: props.style, children: jsxRuntime.jsx("div", { class: [
|
|
162
166
|
'toolbar',
|
|
163
167
|
{
|
|
@@ -167,15 +171,15 @@ function ComponentToolbar(props) {
|
|
|
167
171
|
});
|
|
168
172
|
}
|
|
169
173
|
|
|
170
|
-
var
|
|
174
|
+
var scopedId$l = "vf-ede279";
|
|
171
175
|
|
|
172
176
|
function Divider() {
|
|
173
|
-
return scopedCss.withScopedCSS(
|
|
177
|
+
return scopedCss.withScopedCSS(scopedId$l, () => {
|
|
174
178
|
return jsxRuntime.jsx("div", { class: "divider" });
|
|
175
179
|
});
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
var
|
|
182
|
+
var scopedId$k = "vf-90d534";
|
|
179
183
|
|
|
180
184
|
function DragResize(props) {
|
|
181
185
|
const isShow = core.createSignal(false);
|
|
@@ -283,16 +287,16 @@ function DragResize(props) {
|
|
|
283
287
|
unUp.unsubscribe();
|
|
284
288
|
});
|
|
285
289
|
}
|
|
286
|
-
return scopedCss.withScopedCSS(
|
|
290
|
+
return scopedCss.withScopedCSS(scopedId$k, () => {
|
|
287
291
|
return (jsxRuntime.jsxs("div", { class: "drag-resize", onClick: selectComponent, children: [jsxRuntime.jsx("div", { class: "container", ref: ref, children: props.children }), jsxRuntime.jsxs("div", { class: ['resize-tool', {
|
|
288
292
|
active: isShow()
|
|
289
293
|
}], children: [jsxRuntime.jsxs("div", { class: "mask", ref: mask, children: [component.state.width, "*", component.state.height] }), jsxRuntime.jsxs("div", { class: "btn-group", ref: btnGroup, onMousedown: drag, children: [jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" }), jsxRuntime.jsx("button", { type: "button" })] })] })] }));
|
|
290
294
|
});
|
|
291
295
|
}
|
|
292
296
|
|
|
293
|
-
var
|
|
297
|
+
var scopedId$j = "vf-a99c5e";
|
|
294
298
|
|
|
295
|
-
var
|
|
299
|
+
var scopedId$i = "vf-8a05e9";
|
|
296
300
|
|
|
297
301
|
const DropdownMenuPortal = core.withAnnotation({
|
|
298
302
|
providers: [
|
|
@@ -300,11 +304,14 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
300
304
|
]
|
|
301
305
|
}, function DropdownMenuPortal(props) {
|
|
302
306
|
const dropdownContextService = core.inject(exports.DropdownContextService);
|
|
307
|
+
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
303
308
|
const menuRef = core.createRef();
|
|
304
309
|
let timer = null;
|
|
305
310
|
const delay = 10;
|
|
306
|
-
|
|
311
|
+
function update() {
|
|
307
312
|
const menuElement = menuRef.current;
|
|
313
|
+
menuElement.style.height = 'auto';
|
|
314
|
+
const containerRect = container.getBoundingClientRect();
|
|
308
315
|
if (props.abreast) {
|
|
309
316
|
const btnEle = props.triggerRef.current;
|
|
310
317
|
const screenHeight = document.documentElement.clientHeight;
|
|
@@ -319,19 +326,19 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
319
326
|
else if (offsetTop + maxHeight > screenHeight - 10) {
|
|
320
327
|
offsetTop = screenHeight - 10 - maxHeight;
|
|
321
328
|
}
|
|
322
|
-
menuElement.style.top = offsetTop + 'px';
|
|
329
|
+
menuElement.style.top = offsetTop - containerRect.top + 'px';
|
|
323
330
|
const triggerRect = props.triggerRef.current.getBoundingClientRect();
|
|
324
331
|
const leftDistance = triggerRect.left;
|
|
325
332
|
const isToLeft = leftDistance >= menuElement.offsetWidth + 20;
|
|
326
|
-
if (isToLeft) {
|
|
327
|
-
menuElement.style.left = leftDistance - menuElement.offsetWidth - 20 + 'px';
|
|
333
|
+
if (isToLeft && props.toLeft) {
|
|
334
|
+
menuElement.style.left = leftDistance - menuElement.offsetWidth - 20 - containerRect.left + 'px';
|
|
328
335
|
timer = setTimeout(() => {
|
|
329
336
|
menuElement.style.transform = 'translateX(10px)';
|
|
330
337
|
menuElement.style.opacity = '1';
|
|
331
338
|
}, delay);
|
|
332
339
|
}
|
|
333
340
|
else {
|
|
334
|
-
menuElement.style.left = triggerRect.right + 20 + 'px';
|
|
341
|
+
menuElement.style.left = triggerRect.right + 20 - containerRect.left + 'px';
|
|
335
342
|
timer = setTimeout(() => {
|
|
336
343
|
menuElement.style.transform = 'translateX(-10px)';
|
|
337
344
|
menuElement.style.opacity = '1';
|
|
@@ -343,12 +350,12 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
343
350
|
const documentClientHeight = document.documentElement.clientHeight;
|
|
344
351
|
const bottomDistance = documentClientHeight - triggerRect.bottom;
|
|
345
352
|
const isToTop = bottomDistance < 200 && triggerRect.top > bottomDistance;
|
|
346
|
-
menuElement.style.left = triggerRect.left + 'px';
|
|
353
|
+
menuElement.style.left = triggerRect.left - containerRect.left + 'px';
|
|
347
354
|
if (isToTop) {
|
|
348
355
|
const maxHeight = Math.max(menuElement.scrollHeight, menuElement.offsetHeight);
|
|
349
|
-
const height = Math.min(triggerRect.top - 20, maxHeight);
|
|
356
|
+
const height = Math.min(triggerRect.top - 20, maxHeight, 400);
|
|
350
357
|
menuElement.style.height = height + 'px';
|
|
351
|
-
menuElement.style.top = triggerRect.top - 20 - height + 'px';
|
|
358
|
+
menuElement.style.top = triggerRect.top - 20 - height - containerRect.top + 'px';
|
|
352
359
|
timer = setTimeout(() => {
|
|
353
360
|
menuElement.style.transform = 'translateY(10px)';
|
|
354
361
|
menuElement.style.opacity = '1';
|
|
@@ -356,30 +363,41 @@ const DropdownMenuPortal = core.withAnnotation({
|
|
|
356
363
|
}
|
|
357
364
|
else {
|
|
358
365
|
menuElement.style.height = Math.min(bottomDistance - 20, menuElement.scrollHeight) + 'px';
|
|
359
|
-
menuElement.style.top = triggerRect.bottom + 20 + 'px';
|
|
366
|
+
menuElement.style.top = triggerRect.bottom + 20 - containerRect.top + 'px';
|
|
360
367
|
timer = setTimeout(() => {
|
|
361
368
|
menuElement.style.transform = 'translateY(-10px)';
|
|
362
369
|
menuElement.style.opacity = '1';
|
|
363
370
|
}, delay);
|
|
364
371
|
}
|
|
365
372
|
}
|
|
373
|
+
}
|
|
374
|
+
core.onUpdated(() => {
|
|
375
|
+
update();
|
|
366
376
|
});
|
|
367
377
|
core.onUnmounted(() => {
|
|
368
378
|
clearTimeout(timer);
|
|
369
379
|
});
|
|
370
380
|
function onEnter() {
|
|
381
|
+
if (props.noTrigger) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
371
384
|
dropdownContextService.canHide = false;
|
|
372
385
|
dropdownContextService.open();
|
|
373
386
|
}
|
|
374
387
|
function onLeave() {
|
|
388
|
+
if (props.noTrigger) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
375
391
|
dropdownContextService.canHide = true;
|
|
376
392
|
dropdownContextService.hide();
|
|
377
393
|
}
|
|
378
|
-
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(
|
|
394
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$i, () => {
|
|
379
395
|
return (jsxRuntime.jsx("div", { onMouseenter: onEnter, onMouseleave: onLeave, ref: menuRef, style: {
|
|
380
396
|
width: props.width
|
|
381
|
-
}, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content",
|
|
382
|
-
|
|
397
|
+
}, class: "dropdown-menu", children: jsxRuntime.jsx("div", { class: "dropdown-menu-content", style: {
|
|
398
|
+
padding: props.padding
|
|
399
|
+
}, children: props.children }) }));
|
|
400
|
+
}), container);
|
|
383
401
|
});
|
|
384
402
|
|
|
385
403
|
const Dropdown = core.withAnnotation({
|
|
@@ -399,12 +417,17 @@ const Dropdown = core.withAnnotation({
|
|
|
399
417
|
const dropdownRef = core.createRef();
|
|
400
418
|
core.onMounted(() => {
|
|
401
419
|
const sub = dropdownContextService.onOpenStateChange.subscribe(b => {
|
|
420
|
+
var _a;
|
|
421
|
+
(_a = props.onExpendStateChange) === null || _a === void 0 ? void 0 : _a.call(props, b);
|
|
402
422
|
isShow.set(b);
|
|
403
423
|
});
|
|
404
424
|
return () => sub.unsubscribe();
|
|
405
425
|
});
|
|
406
426
|
const subscription = new core$1.Subscription();
|
|
407
427
|
core.onMounted(() => {
|
|
428
|
+
if (props.trigger === 'none') {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
408
431
|
if (props.trigger === 'click') {
|
|
409
432
|
subscription.add(core$1.fromEvent(triggerRef.current, 'click').subscribe(toggle));
|
|
410
433
|
return;
|
|
@@ -430,14 +453,14 @@ const Dropdown = core.withAnnotation({
|
|
|
430
453
|
return {
|
|
431
454
|
isShow(b) {
|
|
432
455
|
if (b) {
|
|
433
|
-
dropdownContextService.
|
|
456
|
+
dropdownContextService.open();
|
|
434
457
|
}
|
|
435
458
|
else {
|
|
436
|
-
dropdownContextService.
|
|
459
|
+
dropdownContextService.hide(false);
|
|
437
460
|
}
|
|
438
461
|
},
|
|
439
|
-
$render: scopedCss.withScopedCSS(
|
|
440
|
-
return (jsxRuntime.jsxs("div", { class: ['dropdown', props.class], style: props.style, ref: dropdownRef, children: [jsxRuntime.jsxs("div", { class: "dropdown-btn", ref: triggerRef, children: [jsxRuntime.jsx("div", { class: "dropdown-btn-inner", children: props.children }), jsxRuntime.jsx("div", { class: "dropdown-btn-arrow" })] }), isShow() && jsxRuntime.jsx(DropdownMenuPortal, { width: props.width, abreast: props.abreast, triggerRef: triggerRef, children: Array.isArray(props.menu) ?
|
|
462
|
+
$render: scopedCss.withScopedCSS(scopedId$j, () => {
|
|
463
|
+
return (jsxRuntime.jsxs("div", { class: ['dropdown', props.class], style: props.style, ref: dropdownRef, children: [jsxRuntime.jsxs("div", { class: "dropdown-btn", ref: triggerRef, children: [jsxRuntime.jsx("div", { class: "dropdown-btn-inner", children: props.children }), jsxRuntime.jsx("div", { class: "dropdown-btn-arrow" })] }), isShow() && jsxRuntime.jsx(DropdownMenuPortal, { toLeft: props.toLeft, padding: props.padding, noTrigger: props.trigger === 'none', width: props.width, abreast: props.abreast, triggerRef: triggerRef, children: Array.isArray(props.menu) ?
|
|
441
464
|
props.menu.map(menu => {
|
|
442
465
|
return (jsxRuntime.jsx("div", { class: "dropdown-menu-item", onClick: () => {
|
|
443
466
|
var _a;
|
|
@@ -452,10 +475,54 @@ const Dropdown = core.withAnnotation({
|
|
|
452
475
|
};
|
|
453
476
|
});
|
|
454
477
|
|
|
455
|
-
var
|
|
478
|
+
var scopedId$h = "vf-c32a7b";
|
|
479
|
+
|
|
480
|
+
function Keymap(props) {
|
|
481
|
+
const arr = [];
|
|
482
|
+
const keymap = props.keymap;
|
|
483
|
+
if (keymap.ctrlKey) {
|
|
484
|
+
arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-command" }) : jsxRuntime.jsx("span", { children: "Ctrl" }));
|
|
485
|
+
}
|
|
486
|
+
if (keymap.shiftKey) {
|
|
487
|
+
if (arr.length) {
|
|
488
|
+
arr.push('+');
|
|
489
|
+
}
|
|
490
|
+
arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-shift" }) : jsxRuntime.jsx("span", { children: "Shift" }));
|
|
491
|
+
}
|
|
492
|
+
if (keymap.altKey) {
|
|
493
|
+
if (arr.length) {
|
|
494
|
+
arr.push('+');
|
|
495
|
+
}
|
|
496
|
+
arr.push(platformBrowser.isMac() ? jsxRuntime.jsx("span", { class: "xnote-icon-opt" }) : jsxRuntime.jsx("span", { children: "Alt" }));
|
|
497
|
+
}
|
|
498
|
+
if (keymap.key) {
|
|
499
|
+
if (arr.length) {
|
|
500
|
+
arr.push('+');
|
|
501
|
+
}
|
|
502
|
+
if (Array.isArray(keymap.key)) {
|
|
503
|
+
arr.push(jsxRuntime.jsx("span", { children: keymap.key.join('/') }));
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
arr.push(jsxRuntime.jsx("span", { children: keymap.key }));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return scopedCss.withScopedCSS(scopedId$h, () => {
|
|
510
|
+
return (jsxRuntime.jsx("span", { class: "keymap", children: arr }));
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
var scopedId$g = "vf-acaa5f";
|
|
515
|
+
|
|
516
|
+
function MenuHeading(props) {
|
|
517
|
+
return scopedCss.withScopedCSS(scopedId$g, () => {
|
|
518
|
+
return (jsxRuntime.jsx("div", { class: "menu-heading", children: props.children }));
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
var scopedId$f = "vf-c3b9dc";
|
|
456
523
|
|
|
457
524
|
function MenuItem(props) {
|
|
458
|
-
const dropdownContextService = core.inject(exports.DropdownContextService,
|
|
525
|
+
const dropdownContextService = core.inject(exports.DropdownContextService, null);
|
|
459
526
|
const isActive = core.createSignal((dropdownContextService === null || dropdownContextService === void 0 ? void 0 : dropdownContextService.isOpen) || false);
|
|
460
527
|
if (dropdownContextService) {
|
|
461
528
|
const subscription = dropdownContextService.onOpenStateChange.subscribe(b => {
|
|
@@ -472,8 +539,8 @@ function MenuItem(props) {
|
|
|
472
539
|
}
|
|
473
540
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, props.value);
|
|
474
541
|
}
|
|
475
|
-
return scopedCss.withScopedCSS(
|
|
476
|
-
return (jsxRuntime.jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxRuntime.jsxs("div", { children: [props.icon && jsxRuntime.jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), props.arrow ?
|
|
542
|
+
return scopedCss.withScopedCSS(scopedId$f, () => {
|
|
543
|
+
return (jsxRuntime.jsxs("div", { class: ['menu-item', { disabled: props.disabled, active: props.arrow && isActive() }], onClick: click, children: [jsxRuntime.jsxs("div", { class: "menu-item-content", children: [jsxRuntime.jsxs("div", { children: [props.icon && jsxRuntime.jsx("span", { class: "menu-icon", children: props.icon }), props.children] }), jsxRuntime.jsx("div", { children: props.desc })] }), props.arrow ?
|
|
477
544
|
jsxRuntime.jsx("div", { class: "arrow", children: jsxRuntime.jsx("span", { class: "xnote-icon-arrow-right" }) }) :
|
|
478
545
|
jsxRuntime.jsx("div", { class: [
|
|
479
546
|
'menu-check',
|
|
@@ -482,11 +549,11 @@ function MenuItem(props) {
|
|
|
482
549
|
});
|
|
483
550
|
}
|
|
484
551
|
|
|
485
|
-
var
|
|
552
|
+
var scopedId$e = "vf-a23c47";
|
|
486
553
|
|
|
487
554
|
function Popup(props) {
|
|
488
555
|
const host = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
489
|
-
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(
|
|
556
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$e, () => {
|
|
490
557
|
return (jsxRuntime.jsx("div", { class: "popup", style: {
|
|
491
558
|
left: props.left + 'px',
|
|
492
559
|
top: props.top + 'px'
|
|
@@ -494,15 +561,15 @@ function Popup(props) {
|
|
|
494
561
|
}), host);
|
|
495
562
|
}
|
|
496
563
|
|
|
497
|
-
var
|
|
564
|
+
var scopedId$d = "vf-216815";
|
|
498
565
|
|
|
499
566
|
function ToolbarItem(props) {
|
|
500
|
-
return scopedCss.withScopedCSS(
|
|
567
|
+
return scopedCss.withScopedCSS(scopedId$d, () => {
|
|
501
568
|
return (jsxRuntime.jsx("div", { class: "toolbar-item", children: props.children }));
|
|
502
569
|
});
|
|
503
570
|
}
|
|
504
571
|
|
|
505
|
-
var
|
|
572
|
+
var scopedId$c = "vf-2a8a65";
|
|
506
573
|
|
|
507
574
|
exports.RefreshService = class RefreshService {
|
|
508
575
|
constructor() {
|
|
@@ -558,110 +625,422 @@ function useReadonly() {
|
|
|
558
625
|
return is;
|
|
559
626
|
}
|
|
560
627
|
|
|
561
|
-
|
|
628
|
+
const OutputInjectionToken = new core.InjectionToken('OutputInjectionToken');
|
|
629
|
+
|
|
630
|
+
function useOutput() {
|
|
631
|
+
return core.createSignal(core.inject(OutputInjectionToken));
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
const headingAttr = new core$1.Attribute('Heading', {
|
|
635
|
+
render(node, formatValue) {
|
|
636
|
+
node.classes.add('xnote-' + formatValue);
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
const headingAttrLoader = {
|
|
640
|
+
match(element) {
|
|
641
|
+
return /H[1-6]/.test(element.tagName) || /(^|\s)xnote-h[1-6](\s|$)/.test(element.className);
|
|
642
|
+
},
|
|
643
|
+
read(element) {
|
|
644
|
+
if (/H[1-6]/.test(element.tagName)) {
|
|
645
|
+
return {
|
|
646
|
+
attribute: headingAttr,
|
|
647
|
+
value: element.tagName.toLowerCase()
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
return {
|
|
651
|
+
attribute: headingAttr,
|
|
652
|
+
value: element.className.substring(6)
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
function registerHeadingShortcut(textbus) {
|
|
657
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
658
|
+
const commander = textbus.get(core$1.Commander);
|
|
659
|
+
const selection = textbus.get(core$1.Selection);
|
|
660
|
+
keyboard.addShortcut({
|
|
661
|
+
keymap: {
|
|
662
|
+
key: '0123456'.split(''),
|
|
663
|
+
ctrlKey: true
|
|
664
|
+
},
|
|
665
|
+
action(key) {
|
|
666
|
+
if (key === '0') {
|
|
667
|
+
commander.unApplyAttribute(headingAttr);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
commander.applyAttribute(headingAttr, 'h' + key);
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
keyboard.addZenCodingInterceptor({
|
|
674
|
+
match(content) {
|
|
675
|
+
return /^#{1,6}$/.test(content);
|
|
676
|
+
},
|
|
677
|
+
try(key) {
|
|
678
|
+
return key === ' ';
|
|
679
|
+
},
|
|
680
|
+
action(content) {
|
|
681
|
+
if (selection.commonAncestorComponent instanceof SourceCodeComponent) {
|
|
682
|
+
return false;
|
|
683
|
+
}
|
|
684
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
685
|
+
commonAncestorSlot.cut();
|
|
686
|
+
commander.applyAttribute(headingAttr, 'h' + content.length);
|
|
687
|
+
selection.setPosition(commonAncestorSlot, 0);
|
|
688
|
+
return true;
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
function useBlockContent(slot) {
|
|
694
|
+
const textbus = core$1.useContext();
|
|
695
|
+
const selection = textbus.get(core$1.Selection);
|
|
696
|
+
core$1.onBreak(ev => {
|
|
697
|
+
if (typeof slot === 'function' ? slot(ev.target) : ev.target === slot) {
|
|
698
|
+
const p = new ParagraphComponent(textbus);
|
|
699
|
+
ev.target.insert(p);
|
|
700
|
+
selection.setPosition(p.state.slot, 0);
|
|
701
|
+
ev.preventDefault();
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
core$1.onContentInsert(ev => {
|
|
705
|
+
if ((typeof slot === 'function' ? slot(ev.target) : ev.target === slot) &&
|
|
706
|
+
(typeof ev.data.content === 'string' || ev.data.content.type !== core$1.ContentType.BlockComponent)) {
|
|
707
|
+
const p = new ParagraphComponent(textbus);
|
|
708
|
+
const childSlot = p.state.slot;
|
|
709
|
+
childSlot.insert(ev.data.content);
|
|
710
|
+
ev.target.insert(p);
|
|
711
|
+
selection.setPosition(childSlot, childSlot.index);
|
|
712
|
+
ev.preventDefault();
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
function SlotRender(props) {
|
|
718
|
+
const adaper = core.inject(platformBrowser.DomAdapter);
|
|
719
|
+
const instance = core.getCurrentInstance();
|
|
720
|
+
const sub = props.slot.__changeMarker__.onChange.subscribe(() => {
|
|
721
|
+
instance.markAsDirtied();
|
|
722
|
+
});
|
|
723
|
+
core.onUnmounted(() => {
|
|
724
|
+
sub.unsubscribe();
|
|
725
|
+
});
|
|
726
|
+
return () => {
|
|
727
|
+
const { slot, tag = 'div', renderEnv = false, elRef, elKey } = props, rest = __rest(props, ["slot", "tag", "renderEnv", "elRef", "elKey"]);
|
|
728
|
+
return adaper.slotRender(slot, children => {
|
|
729
|
+
return core$1.createVNode(tag, Object.assign({ ref: elRef, key: elKey }, rest), children);
|
|
730
|
+
}, renderEnv);
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
class BlockquoteComponent extends core$1.Component {
|
|
562
735
|
static fromJSON(textbus, json) {
|
|
563
736
|
const slot = textbus.get(core$1.Registry).createSlot(json.slot);
|
|
564
|
-
return new
|
|
737
|
+
return new BlockquoteComponent(textbus, {
|
|
565
738
|
slot
|
|
566
739
|
});
|
|
567
740
|
}
|
|
568
741
|
constructor(textbus, state = {
|
|
569
742
|
slot: new core$1.Slot([
|
|
570
|
-
core$1.ContentType.
|
|
571
|
-
core$1.ContentType.Text
|
|
743
|
+
core$1.ContentType.BlockComponent
|
|
572
744
|
])
|
|
573
745
|
}) {
|
|
574
746
|
super(textbus, state);
|
|
575
747
|
}
|
|
576
748
|
setup() {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
749
|
+
useBlockContent(this.state.slot);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
BlockquoteComponent.type = core$1.ContentType.BlockComponent;
|
|
753
|
+
BlockquoteComponent.componentName = 'BlockquoteComponent';
|
|
754
|
+
BlockquoteComponent.zenCoding = {
|
|
755
|
+
key: ' ',
|
|
756
|
+
match(content, textbus) {
|
|
757
|
+
const selection = textbus.get(core$1.Selection);
|
|
758
|
+
if (selection.commonAncestorComponent instanceof ParagraphComponent) {
|
|
759
|
+
return /^>$/.test(content);
|
|
760
|
+
}
|
|
761
|
+
return false;
|
|
762
|
+
},
|
|
763
|
+
createState(_, textbus) {
|
|
764
|
+
const selection = textbus.get(core$1.Selection);
|
|
765
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
766
|
+
const slot = new core$1.Slot([
|
|
767
|
+
core$1.ContentType.BlockComponent
|
|
768
|
+
]);
|
|
769
|
+
if (commonAncestorSlot === null || commonAncestorSlot === void 0 ? void 0 : commonAncestorSlot.hasAttribute(textIndentAttr)) {
|
|
770
|
+
slot.setAttribute(textIndentAttr, commonAncestorSlot.getAttribute(textIndentAttr));
|
|
771
|
+
}
|
|
772
|
+
return {
|
|
773
|
+
slot
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
function toBlockquote(textbus) {
|
|
778
|
+
const query = textbus.get(core$1.Query);
|
|
779
|
+
const commander = textbus.get(core$1.Commander);
|
|
780
|
+
const selection = textbus.get(core$1.Selection);
|
|
781
|
+
const state = query.queryComponent(BlockquoteComponent);
|
|
782
|
+
if (state.state === core$1.QueryStateType.Enabled) {
|
|
783
|
+
const current = state.value;
|
|
784
|
+
const parent = current.parent;
|
|
785
|
+
const index = parent.indexOf(current);
|
|
786
|
+
parent.retain(index);
|
|
787
|
+
commander.removeComponent(current);
|
|
788
|
+
current.__slots__.get(0).sliceContent().forEach(i => {
|
|
789
|
+
parent.insert(i);
|
|
588
790
|
});
|
|
589
791
|
}
|
|
792
|
+
else {
|
|
793
|
+
const block = new BlockquoteComponent(textbus);
|
|
794
|
+
const slot = block.state.slot;
|
|
795
|
+
if (selection.startSlot === selection.endSlot) {
|
|
796
|
+
const parentComponent = selection.startSlot.parent;
|
|
797
|
+
const parentSlot = parentComponent.parent;
|
|
798
|
+
const position = parentSlot.indexOf(parentComponent);
|
|
799
|
+
slot.insert(parentComponent);
|
|
800
|
+
parentSlot.retain(position);
|
|
801
|
+
parentSlot.insert(block);
|
|
802
|
+
}
|
|
803
|
+
else {
|
|
804
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
805
|
+
const scope = selection.getCommonAncestorSlotScope();
|
|
806
|
+
commonAncestorSlot.cut(scope.startOffset, scope.endOffset).sliceContent().forEach(i => {
|
|
807
|
+
slot.insert(i);
|
|
808
|
+
});
|
|
809
|
+
commonAncestorSlot.retain(scope.startOffset);
|
|
810
|
+
commonAncestorSlot.insert(block);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
590
813
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
814
|
+
function registerBlockquoteShortcut(textbus) {
|
|
815
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
816
|
+
keyboard.addShortcut({
|
|
817
|
+
keymap: {
|
|
818
|
+
ctrlKey: true,
|
|
819
|
+
key: '\''
|
|
820
|
+
},
|
|
821
|
+
action() {
|
|
822
|
+
toBlockquote(textbus);
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
function BlockquoteView(props) {
|
|
595
827
|
const readonly = useReadonly();
|
|
828
|
+
const output = useOutput();
|
|
596
829
|
return () => {
|
|
597
830
|
const slot = props.component.state.slot;
|
|
598
|
-
return (jsxRuntime.jsx("
|
|
599
|
-
return (core$1.createVNode('p', null, children));
|
|
600
|
-
}, readonly()) }));
|
|
831
|
+
return (jsxRuntime.jsx("blockquote", { class: "xnote-blockquote", ref: props.rootRef, "data-component": props.component.name, children: jsxRuntime.jsx(SlotRender, { slot: slot, renderEnv: readonly() || output() }) }));
|
|
601
832
|
};
|
|
602
833
|
}
|
|
603
|
-
const
|
|
604
|
-
match(element) {
|
|
605
|
-
return
|
|
834
|
+
const blockquoteComponentLoader = {
|
|
835
|
+
match(element, returnableContentTypes) {
|
|
836
|
+
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && element.tagName === 'BLOCKQUOTE';
|
|
606
837
|
},
|
|
607
838
|
read(element, textbus, slotParser) {
|
|
608
839
|
const delta = slotParser(new core$1.Slot([
|
|
609
|
-
core$1.ContentType.
|
|
840
|
+
core$1.ContentType.BlockComponent,
|
|
610
841
|
core$1.ContentType.InlineComponent,
|
|
611
|
-
core$1.ContentType.
|
|
612
|
-
]), element
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
return results[0];
|
|
616
|
-
}
|
|
617
|
-
const containerSlot = new core$1.Slot([
|
|
618
|
-
core$1.ContentType.BlockComponent
|
|
842
|
+
core$1.ContentType.Text
|
|
843
|
+
]), element).toDelta();
|
|
844
|
+
const slot = new core$1.Slot([
|
|
845
|
+
core$1.ContentType.BlockComponent,
|
|
619
846
|
]);
|
|
620
|
-
|
|
621
|
-
|
|
847
|
+
deltaToBlock(delta, textbus).forEach(i => {
|
|
848
|
+
slot.insert(i);
|
|
622
849
|
});
|
|
623
|
-
return
|
|
624
|
-
|
|
850
|
+
return new BlockquoteComponent(textbus, {
|
|
851
|
+
slot
|
|
852
|
+
});
|
|
853
|
+
},
|
|
625
854
|
};
|
|
626
|
-
function deltaToBlock(delta, textbus) {
|
|
627
|
-
const results = [];
|
|
628
|
-
let slot = null;
|
|
629
|
-
for (const item of delta) {
|
|
630
|
-
if (typeof item.insert === 'string' || item.insert.type === core$1.ContentType.InlineComponent) {
|
|
631
|
-
if (!slot) {
|
|
632
|
-
slot = new core$1.Slot([
|
|
633
|
-
core$1.ContentType.InlineComponent,
|
|
634
|
-
core$1.ContentType.Text
|
|
635
|
-
]);
|
|
636
|
-
delta.attributes.forEach((value, key) => {
|
|
637
|
-
slot.setAttribute(key, value);
|
|
638
|
-
});
|
|
639
|
-
results.push(new ParagraphComponent(textbus, {
|
|
640
|
-
slot
|
|
641
|
-
}));
|
|
642
|
-
}
|
|
643
|
-
slot.insert(item.insert, item.formats);
|
|
644
|
-
}
|
|
645
|
-
else {
|
|
646
|
-
results.push(item.insert);
|
|
647
|
-
slot = null;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
return results;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
const OutputInjectionToken = new core.InjectionToken('OutputInjectionToken');
|
|
654
|
-
|
|
655
|
-
function useOutput() {
|
|
656
|
-
return core.createSignal(core.inject(OutputInjectionToken));
|
|
657
|
-
}
|
|
658
855
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
856
|
+
class HighlightBoxComponent extends core$1.Component {
|
|
857
|
+
static fromJSON(textbus, json) {
|
|
858
|
+
return new HighlightBoxComponent(textbus, {
|
|
859
|
+
type: json.type,
|
|
860
|
+
slot: textbus.get(core$1.Registry).createSlot(json.slot)
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
constructor(textbus, state = {
|
|
864
|
+
type: '',
|
|
865
|
+
slot: new core$1.Slot([
|
|
866
|
+
core$1.ContentType.BlockComponent,
|
|
867
|
+
])
|
|
868
|
+
}) {
|
|
869
|
+
super(textbus, state);
|
|
870
|
+
}
|
|
871
|
+
setup() {
|
|
872
|
+
useBlockContent(this.state.slot);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '👍', '🎉', '🚫', '❗'];
|
|
876
|
+
HighlightBoxComponent.componentName = 'HighlightBoxComponent';
|
|
877
|
+
HighlightBoxComponent.type = core$1.ContentType.BlockComponent;
|
|
878
|
+
function HighlightBoxView(props) {
|
|
879
|
+
const readonly = useReadonly();
|
|
880
|
+
const output = useOutput();
|
|
881
|
+
const emoji = [];
|
|
882
|
+
for (let i = 0x1F600; i <= 0x1F64F; i++) {
|
|
883
|
+
emoji.push(i);
|
|
884
|
+
}
|
|
885
|
+
const dropdownRef = core.createRef();
|
|
886
|
+
function setType(type) {
|
|
887
|
+
var _a;
|
|
888
|
+
(_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(false);
|
|
889
|
+
props.component.state.type = type;
|
|
890
|
+
}
|
|
891
|
+
return () => {
|
|
892
|
+
const { state, name } = props.component;
|
|
893
|
+
if (readonly() || output()) {
|
|
894
|
+
return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }), jsxRuntime.jsx(SlotRender, { slot: state.slot, class: 'xnote-highlight-box-content', renderEnv: readonly() || output() })] }));
|
|
895
|
+
}
|
|
896
|
+
return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx(Dropdown, { trigger: "click", ref: dropdownRef, width: "282px", menu: jsxRuntime.jsxs("div", { class: "xnote-highlight-box-icons", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-heading", children: "\u5E38\u7528" }), HighlightBoxComponent.defaultTypes.map(icon => {
|
|
897
|
+
return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
|
|
898
|
+
}), jsxRuntime.jsx("div", { class: "xnote-highlight-box-heading", children: "\u66F4\u591A" }), emoji.map(i => {
|
|
899
|
+
const icon = String.fromCodePoint(i);
|
|
900
|
+
return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
|
|
901
|
+
})] }), children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), jsxRuntime.jsx(SlotRender, { slot: state.slot, class: 'xnote-highlight-box-content', renderEnv: readonly() || output() })] }));
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
const highlightBoxComponentLoader = {
|
|
905
|
+
match(element) {
|
|
906
|
+
return element.tagName === 'DIV' && element.dataset.component === HighlightBoxComponent.componentName;
|
|
907
|
+
},
|
|
908
|
+
read(element, textbus, slotParser) {
|
|
909
|
+
const delta = slotParser(new core$1.Slot([
|
|
910
|
+
core$1.ContentType.BlockComponent,
|
|
911
|
+
core$1.ContentType.InlineComponent,
|
|
912
|
+
core$1.ContentType.Text
|
|
913
|
+
]), element.querySelector('.xnote-highlight-box-content')).toDelta();
|
|
914
|
+
const slot = new core$1.Slot([
|
|
915
|
+
core$1.ContentType.BlockComponent,
|
|
916
|
+
]);
|
|
917
|
+
deltaToBlock(delta, textbus).forEach(i => {
|
|
918
|
+
slot.insert(i);
|
|
919
|
+
});
|
|
920
|
+
return new HighlightBoxComponent(textbus, {
|
|
921
|
+
type: element.dataset.icon || '',
|
|
922
|
+
slot
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
class ParagraphComponent extends core$1.Component {
|
|
928
|
+
static fromJSON(textbus, json) {
|
|
929
|
+
const slot = textbus.get(core$1.Registry).createSlot(json.slot);
|
|
930
|
+
return new ParagraphComponent(textbus, {
|
|
931
|
+
slot
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
constructor(textbus, state = {
|
|
935
|
+
slot: new core$1.Slot([
|
|
936
|
+
core$1.ContentType.InlineComponent,
|
|
937
|
+
core$1.ContentType.Text
|
|
938
|
+
])
|
|
939
|
+
}) {
|
|
940
|
+
super(textbus, state);
|
|
941
|
+
}
|
|
942
|
+
setup() {
|
|
943
|
+
const injector = core$1.useContext();
|
|
944
|
+
const commander = injector.get(core$1.Commander);
|
|
945
|
+
const selection = injector.get(core$1.Selection);
|
|
946
|
+
core$1.onBreak(ev => {
|
|
947
|
+
const isEmpty = this.state.slot.isEmpty;
|
|
948
|
+
const afterSlot = ev.target.cut(ev.data.index);
|
|
949
|
+
afterSlot.removeAttribute(headingAttr);
|
|
950
|
+
const nextParagraph = new ParagraphComponent(injector, {
|
|
951
|
+
slot: afterSlot
|
|
952
|
+
});
|
|
953
|
+
if (isEmpty && (this.parentComponent instanceof BlockquoteComponent ||
|
|
954
|
+
this.parentComponent instanceof HighlightBoxComponent)) {
|
|
955
|
+
commander.insertAfter(nextParagraph, this.parentComponent);
|
|
956
|
+
commander.removeComponent(this);
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
commander.insertAfter(nextParagraph, this);
|
|
960
|
+
}
|
|
961
|
+
selection.setPosition(afterSlot, 0);
|
|
962
|
+
ev.preventDefault();
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
ParagraphComponent.componentName = 'ParagraphComponent';
|
|
967
|
+
ParagraphComponent.type = core$1.ContentType.BlockComponent;
|
|
968
|
+
function ParagraphView(props) {
|
|
969
|
+
const readonly = useReadonly();
|
|
970
|
+
const output = useOutput();
|
|
971
|
+
return () => {
|
|
972
|
+
const slot = props.component.state.slot;
|
|
973
|
+
return (jsxRuntime.jsx(SlotRender, { tag: "div", slot: slot, class: "xnote-paragraph", elRef: props.rootRef, "data-component": ParagraphComponent.componentName, renderEnv: readonly() || output() }));
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
const paragraphComponentLoader = {
|
|
977
|
+
match(element, returnableContentTypes) {
|
|
978
|
+
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && (element.dataset.component === ParagraphComponent.componentName || /^P|H[1-6]$/.test(element.tagName));
|
|
979
|
+
},
|
|
980
|
+
read(element, textbus, slotParser) {
|
|
981
|
+
let content;
|
|
982
|
+
if (/^P|H[1-6]$/.test(element.tagName)) {
|
|
983
|
+
content = element;
|
|
984
|
+
}
|
|
985
|
+
else {
|
|
986
|
+
content = element.children[0];
|
|
987
|
+
if (!content) {
|
|
988
|
+
const p = document.createElement('p');
|
|
989
|
+
p.append(element.innerText);
|
|
990
|
+
content = p;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
const delta = slotParser(new core$1.Slot([
|
|
994
|
+
core$1.ContentType.Text,
|
|
995
|
+
core$1.ContentType.InlineComponent,
|
|
996
|
+
core$1.ContentType.BlockComponent
|
|
997
|
+
]), content).toDelta();
|
|
998
|
+
const results = deltaToBlock(delta, textbus);
|
|
999
|
+
if (results.length === 1) {
|
|
1000
|
+
return results[0];
|
|
1001
|
+
}
|
|
1002
|
+
const containerSlot = new core$1.Slot([
|
|
1003
|
+
core$1.ContentType.BlockComponent
|
|
1004
|
+
]);
|
|
1005
|
+
results.forEach(item => {
|
|
1006
|
+
containerSlot.insert(item);
|
|
1007
|
+
});
|
|
1008
|
+
return containerSlot;
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
function deltaToBlock(delta, textbus) {
|
|
1012
|
+
const results = [];
|
|
1013
|
+
let slot = null;
|
|
1014
|
+
for (const item of delta) {
|
|
1015
|
+
if (typeof item.insert === 'string' || item.insert.type === core$1.ContentType.InlineComponent) {
|
|
1016
|
+
if (!slot) {
|
|
1017
|
+
slot = new core$1.Slot([
|
|
1018
|
+
core$1.ContentType.InlineComponent,
|
|
1019
|
+
core$1.ContentType.Text
|
|
1020
|
+
]);
|
|
1021
|
+
delta.attributes.forEach((value, key) => {
|
|
1022
|
+
slot.setAttribute(key, value);
|
|
1023
|
+
});
|
|
1024
|
+
results.push(new ParagraphComponent(textbus, {
|
|
1025
|
+
slot
|
|
1026
|
+
}));
|
|
1027
|
+
}
|
|
1028
|
+
slot.insert(item.insert, item.formats);
|
|
1029
|
+
}
|
|
1030
|
+
else {
|
|
1031
|
+
results.push(item.insert);
|
|
1032
|
+
slot = null;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
return results;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
const languageList = [{
|
|
1039
|
+
label: 'JavaScript',
|
|
1040
|
+
value: 'JavaScript',
|
|
1041
|
+
}, {
|
|
1042
|
+
label: 'HTML',
|
|
1043
|
+
value: 'HTML',
|
|
665
1044
|
}, {
|
|
666
1045
|
label: 'CSS',
|
|
667
1046
|
value: 'CSS',
|
|
@@ -686,6 +1065,15 @@ const languageList = [{
|
|
|
686
1065
|
}, {
|
|
687
1066
|
label: 'Go',
|
|
688
1067
|
value: 'Go'
|
|
1068
|
+
}, {
|
|
1069
|
+
label: 'Kotlin',
|
|
1070
|
+
value: 'kotlin'
|
|
1071
|
+
}, {
|
|
1072
|
+
label: 'Python',
|
|
1073
|
+
value: 'python'
|
|
1074
|
+
}, {
|
|
1075
|
+
label: 'PHP',
|
|
1076
|
+
value: 'php'
|
|
689
1077
|
}, {
|
|
690
1078
|
label: 'JSON',
|
|
691
1079
|
value: 'JSON',
|
|
@@ -710,6 +1098,9 @@ const languageList = [{
|
|
|
710
1098
|
}, {
|
|
711
1099
|
label: 'Shell',
|
|
712
1100
|
value: 'shell',
|
|
1101
|
+
}, {
|
|
1102
|
+
label: 'Katex',
|
|
1103
|
+
value: 'latex',
|
|
713
1104
|
}, {
|
|
714
1105
|
label: 'Yaml',
|
|
715
1106
|
value: 'yaml',
|
|
@@ -728,11 +1119,16 @@ const languageList = [{
|
|
|
728
1119
|
}, {
|
|
729
1120
|
label: 'Dart',
|
|
730
1121
|
value: 'dart',
|
|
1122
|
+
}, {
|
|
1123
|
+
label: 'Rust',
|
|
1124
|
+
value: 'rust',
|
|
731
1125
|
}, {
|
|
732
1126
|
label: '',
|
|
733
1127
|
value: '',
|
|
734
1128
|
}];
|
|
735
1129
|
const sourceCodeThemes = [
|
|
1130
|
+
'xnote-dark',
|
|
1131
|
+
'xnote-dark-blue',
|
|
736
1132
|
'github',
|
|
737
1133
|
'atom-one-dark',
|
|
738
1134
|
'foundation',
|
|
@@ -793,7 +1189,9 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
793
1189
|
const selection = core$1.useContext(core$1.Selection);
|
|
794
1190
|
core$1.onBreak(ev => {
|
|
795
1191
|
const slots = this.state.slots;
|
|
796
|
-
|
|
1192
|
+
const parentComponent = selection.commonAncestorComponent;
|
|
1193
|
+
const parentSlot = parentComponent.parent;
|
|
1194
|
+
if (parentSlot && ev.target.isEmpty && ev.target === slots[slots.length - 1].slot) {
|
|
797
1195
|
const prevSlot = slots[slots.length - 2];
|
|
798
1196
|
if (prevSlot === null || prevSlot === void 0 ? void 0 : prevSlot.slot.isEmpty) {
|
|
799
1197
|
const slot = new core$1.Slot([
|
|
@@ -803,8 +1201,6 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
803
1201
|
const paragraph = new ParagraphComponent(textbus, {
|
|
804
1202
|
slot
|
|
805
1203
|
});
|
|
806
|
-
const parentComponent = selection.commonAncestorComponent;
|
|
807
|
-
const parentSlot = parentComponent.parent;
|
|
808
1204
|
const index = parentSlot.indexOf(parentComponent);
|
|
809
1205
|
parentSlot.retain(index + 1);
|
|
810
1206
|
slots.pop();
|
|
@@ -909,7 +1305,7 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
909
1305
|
},
|
|
910
1306
|
action() {
|
|
911
1307
|
if (selection.isCollapsed) {
|
|
912
|
-
commander.insert('
|
|
1308
|
+
commander.insert(' ');
|
|
913
1309
|
return;
|
|
914
1310
|
}
|
|
915
1311
|
const blocks = selection.getBlocks();
|
|
@@ -942,15 +1338,28 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
942
1338
|
}
|
|
943
1339
|
});
|
|
944
1340
|
}
|
|
1341
|
+
removeSlot(slot) {
|
|
1342
|
+
const slots = this.state.slots;
|
|
1343
|
+
const index = slots.findIndex(i => i.slot === slot);
|
|
1344
|
+
if (index > -1) {
|
|
1345
|
+
slots.splice(index, 1);
|
|
1346
|
+
return true;
|
|
1347
|
+
}
|
|
1348
|
+
return false;
|
|
1349
|
+
}
|
|
945
1350
|
}
|
|
946
1351
|
SourceCodeComponent.type = core$1.ContentType.BlockComponent;
|
|
947
1352
|
SourceCodeComponent.componentName = 'SourceCodeComponent';
|
|
948
1353
|
SourceCodeComponent.zenCoding = {
|
|
949
|
-
key: 'Enter',
|
|
950
|
-
match(c) {
|
|
951
|
-
const
|
|
952
|
-
|
|
953
|
-
|
|
1354
|
+
key: ['Enter', ' '],
|
|
1355
|
+
match(c, textbus) {
|
|
1356
|
+
const selection = textbus.get(core$1.Selection);
|
|
1357
|
+
if (selection.commonAncestorComponent instanceof ParagraphComponent) {
|
|
1358
|
+
const matchString = languageList.map(i => i.label || i.value).concat('js', 'ts').join('|').replace(/\+/, '\\+');
|
|
1359
|
+
const reg = new RegExp(`^\`\`\`(${matchString})$`, 'i');
|
|
1360
|
+
return reg.test(c);
|
|
1361
|
+
}
|
|
1362
|
+
return false;
|
|
954
1363
|
},
|
|
955
1364
|
createState(content) {
|
|
956
1365
|
const matchString = content.replace(/`/g, '').replace(/\+/, '\\+');
|
|
@@ -1017,7 +1426,7 @@ function SourceCodeView(props) {
|
|
|
1017
1426
|
}
|
|
1018
1427
|
const input = core.inject(platformBrowser.Input);
|
|
1019
1428
|
function updateCaret() {
|
|
1020
|
-
input.caret.refresh(
|
|
1429
|
+
input.caret.refresh();
|
|
1021
1430
|
}
|
|
1022
1431
|
const readonly = useReadonly();
|
|
1023
1432
|
const output = useOutput();
|
|
@@ -1054,33 +1463,11 @@ function SourceCodeView(props) {
|
|
|
1054
1463
|
}
|
|
1055
1464
|
}
|
|
1056
1465
|
}
|
|
1057
|
-
|
|
1058
|
-
return nodes.map(i => {
|
|
1059
|
-
const location = {
|
|
1060
|
-
slot,
|
|
1061
|
-
startIndex: index,
|
|
1062
|
-
endIndex: index + i.textContent.length
|
|
1063
|
-
};
|
|
1064
|
-
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
1065
|
-
const childNodes = Array.from(i.childNodes);
|
|
1066
|
-
const vEle = core$1.createVNode('span', {
|
|
1067
|
-
class: i.className
|
|
1068
|
-
}, nodesToVNodes(slot, childNodes, index));
|
|
1069
|
-
index = location.endIndex;
|
|
1070
|
-
vEle.location = Object.assign({}, location);
|
|
1071
|
-
return vEle;
|
|
1072
|
-
}
|
|
1073
|
-
index = location.endIndex;
|
|
1074
|
-
const textNode = new core$1.VTextNode(i.textContent);
|
|
1075
|
-
textNode.location = location;
|
|
1076
|
-
return textNode;
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
|
-
return (jsxRuntime.jsxs("pre", { ref: props.rootRef, class: {
|
|
1466
|
+
return (jsxRuntime.jsxs("div", { ref: props.rootRef, class: {
|
|
1080
1467
|
'xnote-source-code': true,
|
|
1081
1468
|
'xnote-source-code-line-number': state.lineNumber,
|
|
1082
1469
|
[state.theme || 'github']: true
|
|
1083
|
-
}, lang: state.lang, "data-auto-break": state.autoBreak, "data-theme": state.theme || null, "data-line-number": state.lineNumber, children: [(!readonly()
|
|
1470
|
+
}, "data-lang": state.lang, "data-component": props.component.name, "data-auto-break": state.autoBreak + '', "data-theme": state.theme || null, "data-line-number": state.lineNumber + '', children: [(!readonly() && !output()) && jsxRuntime.jsxs(ComponentToolbar, { visible: isFocus(), children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(Dropdown, { onCheck: changeLang, trigger: 'hover', menu: languageList.map(item => {
|
|
1084
1471
|
return {
|
|
1085
1472
|
label: jsxRuntime.jsx(MenuItem, { checked: state.lang === item.value, children: item.label || 'Plain Text' }),
|
|
1086
1473
|
value: item.value
|
|
@@ -1106,7 +1493,7 @@ function SourceCodeView(props) {
|
|
|
1106
1493
|
}
|
|
1107
1494
|
], children: [jsxRuntime.jsx("div", { class: "xnote-source-code-line-number-bg", style: {
|
|
1108
1495
|
width: Math.max(String(slots.length).length, 2.5) + 'em'
|
|
1109
|
-
} }), jsxRuntime.jsx("
|
|
1496
|
+
} }), jsxRuntime.jsx("pre", { onScroll: updateCaret, class: {
|
|
1110
1497
|
'xnote-source-code-content': true,
|
|
1111
1498
|
'xnote-source-code-content-highlight': blockHighlight
|
|
1112
1499
|
}, style: {
|
|
@@ -1130,20 +1517,44 @@ function SourceCodeView(props) {
|
|
|
1130
1517
|
return core$1.createVNode('div', {
|
|
1131
1518
|
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : '')
|
|
1132
1519
|
}, [
|
|
1133
|
-
core$1.createVNode('
|
|
1520
|
+
core$1.createVNode('span', { class: 'xnote-source-code-line-content' }, children)
|
|
1134
1521
|
]);
|
|
1135
1522
|
}, readonly());
|
|
1136
1523
|
}) }), jsxRuntime.jsx("span", { class: "xnote-source-code-lang", children: lang })] })] }));
|
|
1137
1524
|
};
|
|
1138
1525
|
}
|
|
1526
|
+
function nodesToVNodes(slot, nodes, index) {
|
|
1527
|
+
return nodes.map(i => {
|
|
1528
|
+
const location = {
|
|
1529
|
+
slot,
|
|
1530
|
+
startIndex: index,
|
|
1531
|
+
endIndex: index + i.textContent.length
|
|
1532
|
+
};
|
|
1533
|
+
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
1534
|
+
const childNodes = Array.from(i.childNodes);
|
|
1535
|
+
const vEle = core$1.createVNode('span', {
|
|
1536
|
+
class: i.className
|
|
1537
|
+
}, nodesToVNodes(slot, childNodes, index));
|
|
1538
|
+
index = location.endIndex;
|
|
1539
|
+
vEle.location = Object.assign({}, location);
|
|
1540
|
+
return vEle;
|
|
1541
|
+
}
|
|
1542
|
+
index = location.endIndex;
|
|
1543
|
+
const textNode = new core$1.VTextNode(i.textContent);
|
|
1544
|
+
textNode.location = location;
|
|
1545
|
+
return textNode;
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1139
1548
|
const sourceCodeComponentLoader = {
|
|
1140
|
-
match(element) {
|
|
1141
|
-
return
|
|
1549
|
+
match(element, returnableContentTypes) {
|
|
1550
|
+
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) &&
|
|
1551
|
+
((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
|
|
1552
|
+
element.tagName === 'PRE');
|
|
1142
1553
|
},
|
|
1143
1554
|
read(el, textbus) {
|
|
1144
|
-
const lines = el.querySelectorAll('.xnote-source-code-line');
|
|
1145
1555
|
let slots = [];
|
|
1146
|
-
if (
|
|
1556
|
+
if (el.tagName === 'DIV') {
|
|
1557
|
+
const lines = el.querySelectorAll('.xnote-source-code-line');
|
|
1147
1558
|
slots = Array.from(lines).map(i => {
|
|
1148
1559
|
const code = i.innerText.replace(/[\s\n]+$/, '');
|
|
1149
1560
|
const item = createCodeSlot();
|
|
@@ -1164,9 +1575,10 @@ const sourceCodeComponentLoader = {
|
|
|
1164
1575
|
});
|
|
1165
1576
|
}
|
|
1166
1577
|
return new SourceCodeComponent(textbus, {
|
|
1167
|
-
lang: el.
|
|
1168
|
-
theme: el.
|
|
1169
|
-
lineNumber:
|
|
1578
|
+
lang: el.dataset.lang || '',
|
|
1579
|
+
theme: el.dataset.theme || '',
|
|
1580
|
+
lineNumber: el.dataset.lineNumber === 'true',
|
|
1581
|
+
autoBreak: el.dataset.autoBreak === 'true',
|
|
1170
1582
|
slots
|
|
1171
1583
|
});
|
|
1172
1584
|
},
|
|
@@ -1265,15 +1677,26 @@ function AttrTool(props) {
|
|
|
1265
1677
|
textIndent: 0
|
|
1266
1678
|
});
|
|
1267
1679
|
function updateCheckStates() {
|
|
1268
|
-
|
|
1269
|
-
|
|
1680
|
+
if (!props.slot && !selection.isSelected) {
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1270
1683
|
setCheckStates(draft => {
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1684
|
+
const range = props.slot ? {
|
|
1685
|
+
startSlot: props.slot,
|
|
1686
|
+
endSlot: props.slot,
|
|
1687
|
+
startOffset: 0,
|
|
1688
|
+
endOffset: props.slot.length
|
|
1689
|
+
} : {
|
|
1690
|
+
startSlot: selection.startSlot,
|
|
1691
|
+
startOffset: selection.startOffset,
|
|
1692
|
+
endSlot: selection.endSlot,
|
|
1693
|
+
endOffset: selection.endOffset
|
|
1694
|
+
};
|
|
1695
|
+
const textAlignState = query.queryAttributeByRange(textAlignAttr, range);
|
|
1696
|
+
const textIndentState = query.queryAttributeByRange(textIndentAttr, range);
|
|
1273
1697
|
draft.textAlign = textAlignState.state === core$1.QueryStateType.Enabled ? textAlignState.value : 'left';
|
|
1274
1698
|
draft.textIndent = textIndentState.state === core$1.QueryStateType.Enabled ? textIndentState.value : 0;
|
|
1275
1699
|
});
|
|
1276
|
-
(_b = props.queryAfter) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
1277
1700
|
}
|
|
1278
1701
|
updateCheckStates();
|
|
1279
1702
|
const subscription = refreshService.onRefresh.subscribe(() => {
|
|
@@ -1320,104 +1743,35 @@ function AttrTool(props) {
|
|
|
1320
1743
|
break;
|
|
1321
1744
|
}
|
|
1322
1745
|
}
|
|
1323
|
-
return scopedCss.withScopedCSS(
|
|
1746
|
+
return scopedCss.withScopedCSS(scopedId$c, () => {
|
|
1324
1747
|
const states = checkStates();
|
|
1325
|
-
return (jsxRuntime.jsx(Dropdown, { style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
|
|
1748
|
+
return (jsxRuntime.jsx(Dropdown, { width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
|
|
1326
1749
|
{
|
|
1327
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
|
|
1750
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'L', ctrlKey: true } }), checked: states.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
|
|
1328
1751
|
value: 't-l'
|
|
1329
1752
|
}, {
|
|
1330
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
|
|
1753
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'R', ctrlKey: true } }), checked: states.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
|
|
1331
1754
|
value: 't-r'
|
|
1332
1755
|
}, {
|
|
1333
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
|
|
1756
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'E', ctrlKey: true } }), checked: states.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
|
|
1334
1757
|
value: 't-c'
|
|
1335
1758
|
}, {
|
|
1336
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
|
|
1759
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'J', ctrlKey: true } }), checked: states.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
|
|
1337
1760
|
value: 't-j'
|
|
1338
1761
|
}, {
|
|
1339
1762
|
label: jsxRuntime.jsx(Divider, {}),
|
|
1340
1763
|
value: ''
|
|
1341
1764
|
}, {
|
|
1342
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-increase" }), children: "\u589E\u52A0\u7F29\u8FDB" }),
|
|
1765
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'Tab' } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-increase" }), children: "\u589E\u52A0\u7F29\u8FDB" }),
|
|
1343
1766
|
value: 'i+'
|
|
1344
1767
|
}, {
|
|
1345
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
|
|
1768
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'Tab', shiftKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u51CF\u5C11\u7F29\u8FDB" }),
|
|
1346
1769
|
value: 'i-'
|
|
1347
1770
|
}
|
|
1348
1771
|
], children: props.children || jsxRuntime.jsx(Button, { arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${states.textAlign || 'left'} icon` }) }) }));
|
|
1349
1772
|
});
|
|
1350
1773
|
}
|
|
1351
1774
|
|
|
1352
|
-
const headingAttr = new core$1.Attribute('Heading', {
|
|
1353
|
-
render(node, formatValue) {
|
|
1354
|
-
node.classes.add('xnote-' + formatValue);
|
|
1355
|
-
}
|
|
1356
|
-
});
|
|
1357
|
-
const headingAttrLoader = {
|
|
1358
|
-
match(element) {
|
|
1359
|
-
return /H[1-6]/.test(element.tagName);
|
|
1360
|
-
},
|
|
1361
|
-
read(element) {
|
|
1362
|
-
return {
|
|
1363
|
-
attribute: headingAttr,
|
|
1364
|
-
value: element.tagName.toLowerCase()
|
|
1365
|
-
};
|
|
1366
|
-
}
|
|
1367
|
-
};
|
|
1368
|
-
function registerHeadingShortcut(textbus) {
|
|
1369
|
-
const keyboard = textbus.get(core$1.Keyboard);
|
|
1370
|
-
const commander = textbus.get(core$1.Commander);
|
|
1371
|
-
const selection = textbus.get(core$1.Selection);
|
|
1372
|
-
keyboard.addShortcut({
|
|
1373
|
-
keymap: {
|
|
1374
|
-
key: '123456'.split(''),
|
|
1375
|
-
ctrlKey: true
|
|
1376
|
-
},
|
|
1377
|
-
action(key) {
|
|
1378
|
-
commander.applyAttribute(headingAttr, 'h' + key);
|
|
1379
|
-
}
|
|
1380
|
-
});
|
|
1381
|
-
keyboard.addZenCodingInterceptor({
|
|
1382
|
-
match(content) {
|
|
1383
|
-
return /^#{1,6}$/.test(content);
|
|
1384
|
-
},
|
|
1385
|
-
try(key) {
|
|
1386
|
-
return key === ' ';
|
|
1387
|
-
},
|
|
1388
|
-
action(content) {
|
|
1389
|
-
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
1390
|
-
commonAncestorSlot.cut();
|
|
1391
|
-
commander.applyAttribute(headingAttr, 'h' + content.length);
|
|
1392
|
-
return true;
|
|
1393
|
-
}
|
|
1394
|
-
});
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
function useBlockContent(slot) {
|
|
1398
|
-
const textbus = core$1.useContext();
|
|
1399
|
-
const selection = textbus.get(core$1.Selection);
|
|
1400
|
-
core$1.onBreak(ev => {
|
|
1401
|
-
if (typeof slot === 'function' ? slot(ev.target) : ev.target === slot) {
|
|
1402
|
-
const p = new ParagraphComponent(textbus);
|
|
1403
|
-
ev.target.insert(p);
|
|
1404
|
-
selection.setPosition(p.state.slot, 0);
|
|
1405
|
-
ev.preventDefault();
|
|
1406
|
-
}
|
|
1407
|
-
});
|
|
1408
|
-
core$1.onContentInsert(ev => {
|
|
1409
|
-
if ((typeof slot === 'function' ? slot(ev.target) : ev.target === slot) &&
|
|
1410
|
-
(typeof ev.data.content === 'string' || ev.data.content.type !== core$1.ContentType.BlockComponent)) {
|
|
1411
|
-
const p = new ParagraphComponent(textbus);
|
|
1412
|
-
const childSlot = p.state.slot;
|
|
1413
|
-
childSlot.insert(ev.data.content);
|
|
1414
|
-
ev.target.insert(p);
|
|
1415
|
-
selection.setPosition(childSlot, childSlot.index);
|
|
1416
|
-
ev.preventDefault();
|
|
1417
|
-
}
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
1775
|
const defaultRowHeight = 30;
|
|
1422
1776
|
const defaultColumnWidth = 100;
|
|
1423
1777
|
class TableComponent extends core$1.Component {
|
|
@@ -1440,19 +1794,18 @@ class TableComponent extends core$1.Component {
|
|
|
1440
1794
|
});
|
|
1441
1795
|
}
|
|
1442
1796
|
constructor(textbus, state = {
|
|
1443
|
-
layoutWidth: Array.from({ length:
|
|
1797
|
+
layoutWidth: Array.from({ length: 5 }).fill(100),
|
|
1444
1798
|
rows: Array.from({ length: 3 }).map(() => {
|
|
1445
1799
|
return {
|
|
1446
1800
|
height: defaultRowHeight,
|
|
1447
|
-
cells: Array.from({ length:
|
|
1801
|
+
cells: Array.from({ length: 5 }).map(() => {
|
|
1802
|
+
const p = new ParagraphComponent(textbus);
|
|
1803
|
+
const slot = new core$1.Slot([core$1.ContentType.BlockComponent]);
|
|
1804
|
+
slot.insert(p);
|
|
1448
1805
|
return {
|
|
1449
1806
|
rowspan: 1,
|
|
1450
1807
|
colspan: 1,
|
|
1451
|
-
slot
|
|
1452
|
-
core$1.ContentType.Text,
|
|
1453
|
-
core$1.ContentType.InlineComponent,
|
|
1454
|
-
core$1.ContentType.BlockComponent
|
|
1455
|
-
])
|
|
1808
|
+
slot
|
|
1456
1809
|
};
|
|
1457
1810
|
})
|
|
1458
1811
|
};
|
|
@@ -1464,6 +1817,7 @@ class TableComponent extends core$1.Component {
|
|
|
1464
1817
|
this.tableSelection = core.createSignal(null);
|
|
1465
1818
|
}
|
|
1466
1819
|
setup() {
|
|
1820
|
+
const selection = core$1.useContext(core$1.Selection);
|
|
1467
1821
|
core$1.onFocusIn(() => {
|
|
1468
1822
|
this.focus.next(true);
|
|
1469
1823
|
});
|
|
@@ -1473,12 +1827,42 @@ class TableComponent extends core$1.Component {
|
|
|
1473
1827
|
useBlockContent((slot) => {
|
|
1474
1828
|
return slot.parent === this;
|
|
1475
1829
|
});
|
|
1476
|
-
|
|
1477
|
-
|
|
1830
|
+
const sub = selection.onChange.subscribe(() => {
|
|
1831
|
+
if (selection.commonAncestorComponent !== this || selection.isCollapsed) {
|
|
1832
|
+
this.tableSelection.set(null);
|
|
1833
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
core$1.onDestroy(() => {
|
|
1836
|
+
sub.unsubscribe();
|
|
1837
|
+
});
|
|
1838
|
+
const findPosition = (slot) => {
|
|
1839
|
+
let cell = slot;
|
|
1840
|
+
while ((cell === null || cell === void 0 ? void 0 : cell.parent) && cell.parent !== this) {
|
|
1841
|
+
cell = cell.parentSlot;
|
|
1842
|
+
}
|
|
1843
|
+
if (cell) {
|
|
1844
|
+
const rows = this.state.rows;
|
|
1845
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
1846
|
+
const row = rows[rowIndex].cells;
|
|
1847
|
+
for (let colIndex = 0; colIndex < row.length; colIndex++) {
|
|
1848
|
+
const item = row[colIndex].slot;
|
|
1849
|
+
if (item === cell) {
|
|
1850
|
+
return {
|
|
1851
|
+
rowIndex,
|
|
1852
|
+
colIndex
|
|
1853
|
+
};
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
return null;
|
|
1859
|
+
};
|
|
1860
|
+
const select = (ev, selectPosition) => {
|
|
1861
|
+
this.tableSelection.set(selectPosition);
|
|
1478
1862
|
if (selectPosition) {
|
|
1479
1863
|
const cells = [];
|
|
1480
|
-
this.state.rows.slice(selectPosition.startRow, selectPosition.endRow
|
|
1481
|
-
cells.push(...row.cells.slice(selectPosition.startColumn, selectPosition.endColumn
|
|
1864
|
+
this.state.rows.slice(selectPosition.startRow, selectPosition.endRow).forEach(row => {
|
|
1865
|
+
cells.push(...row.cells.slice(selectPosition.startColumn, selectPosition.endColumn).map(i => i.slot));
|
|
1482
1866
|
});
|
|
1483
1867
|
ev.useRanges(cells.map(i => {
|
|
1484
1868
|
return {
|
|
@@ -1489,33 +1873,64 @@ class TableComponent extends core$1.Component {
|
|
|
1489
1873
|
}));
|
|
1490
1874
|
ev.preventDefault();
|
|
1491
1875
|
}
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
});
|
|
1508
|
-
slot.insert(p);
|
|
1509
|
-
if (slot === selection.anchorSlot) {
|
|
1510
|
-
selection.setAnchor(childSlot, 0);
|
|
1511
|
-
}
|
|
1512
|
-
if (slot === selection.focusSlot) {
|
|
1513
|
-
selection.setFocus(childSlot, 0);
|
|
1876
|
+
};
|
|
1877
|
+
core$1.onGetRanges(ev => {
|
|
1878
|
+
var _a;
|
|
1879
|
+
const startPosition = findPosition(selection.startSlot);
|
|
1880
|
+
const endPosition = findPosition(selection.endSlot);
|
|
1881
|
+
if (startPosition && endPosition) {
|
|
1882
|
+
if (startPosition.rowIndex === endPosition.rowIndex && startPosition.colIndex === endPosition.colIndex) {
|
|
1883
|
+
if (selection.startSlot === selection.endSlot && selection.startOffset === 0 && selection.endOffset === ((_a = selection.startSlot) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1884
|
+
select(ev, {
|
|
1885
|
+
startColumn: startPosition.colIndex,
|
|
1886
|
+
startRow: startPosition.rowIndex,
|
|
1887
|
+
endColumn: endPosition.colIndex + 1,
|
|
1888
|
+
endRow: endPosition.rowIndex + 1
|
|
1889
|
+
});
|
|
1890
|
+
return;
|
|
1514
1891
|
}
|
|
1892
|
+
select(ev, null);
|
|
1893
|
+
return;
|
|
1515
1894
|
}
|
|
1516
|
-
|
|
1895
|
+
const [startColumn, endColumn] = [startPosition.colIndex, endPosition.colIndex].sort((a, b) => a - b);
|
|
1896
|
+
const [startRow, endRow] = [startPosition.rowIndex, endPosition.rowIndex].sort((a, b) => a - b);
|
|
1897
|
+
select(ev, {
|
|
1898
|
+
startColumn,
|
|
1899
|
+
startRow,
|
|
1900
|
+
endColumn: endColumn + 1,
|
|
1901
|
+
endRow: endRow + 1
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
else {
|
|
1905
|
+
select(ev, null);
|
|
1906
|
+
}
|
|
1517
1907
|
});
|
|
1518
1908
|
}
|
|
1909
|
+
// afterContentCheck() {
|
|
1910
|
+
// const selection = this.selection
|
|
1911
|
+
// const rows = this.state.rows
|
|
1912
|
+
// rows.forEach(row => {
|
|
1913
|
+
// row.cells.forEach(cell => {
|
|
1914
|
+
// const slot = cell.slot
|
|
1915
|
+
// if (slot.isEmpty) {
|
|
1916
|
+
// const childSlot = new Slot([
|
|
1917
|
+
// ContentType.Text,
|
|
1918
|
+
// ContentType.InlineComponent
|
|
1919
|
+
// ])
|
|
1920
|
+
// const p = new ParagraphComponent(this.textbus, {
|
|
1921
|
+
// slot: childSlot
|
|
1922
|
+
// })
|
|
1923
|
+
// slot.insert(p)
|
|
1924
|
+
// if (slot === selection.anchorSlot) {
|
|
1925
|
+
// selection.setAnchor(childSlot, 0)
|
|
1926
|
+
// }
|
|
1927
|
+
// if (slot === selection.focusSlot) {
|
|
1928
|
+
// selection.setFocus(childSlot, 0)
|
|
1929
|
+
// }
|
|
1930
|
+
// }
|
|
1931
|
+
// })
|
|
1932
|
+
// })
|
|
1933
|
+
// }
|
|
1519
1934
|
deleteColumn(index) {
|
|
1520
1935
|
this.state.layoutWidth.splice(index, 1);
|
|
1521
1936
|
this.state.rows.forEach(row => {
|
|
@@ -1532,8 +1947,6 @@ class TableComponent extends core$1.Component {
|
|
|
1532
1947
|
this.state.rows.forEach(row => {
|
|
1533
1948
|
const slot = new core$1.Slot([
|
|
1534
1949
|
core$1.ContentType.BlockComponent,
|
|
1535
|
-
core$1.ContentType.InlineComponent,
|
|
1536
|
-
core$1.ContentType.Text
|
|
1537
1950
|
]);
|
|
1538
1951
|
slot.insert(new ParagraphComponent(this.textbus, {
|
|
1539
1952
|
slot: new core$1.Slot([
|
|
@@ -1561,8 +1974,6 @@ class TableComponent extends core$1.Component {
|
|
|
1561
1974
|
cells: this.state.layoutWidth.map(() => {
|
|
1562
1975
|
const slot = new core$1.Slot([
|
|
1563
1976
|
core$1.ContentType.BlockComponent,
|
|
1564
|
-
core$1.ContentType.InlineComponent,
|
|
1565
|
-
core$1.ContentType.Text
|
|
1566
1977
|
]);
|
|
1567
1978
|
slot.insert(new ParagraphComponent(this.textbus, {
|
|
1568
1979
|
slot: new core$1.Slot([
|
|
@@ -1624,7 +2035,7 @@ function registerStrikeThroughShortcut(textbus) {
|
|
|
1624
2035
|
}
|
|
1625
2036
|
const strikeThroughFormatLoader = {
|
|
1626
2037
|
match(element) {
|
|
1627
|
-
return
|
|
2038
|
+
return /^(strike|del|s)$/i.test(element.tagName) || /line-through/.test(element.style.textDecoration);
|
|
1628
2039
|
},
|
|
1629
2040
|
read() {
|
|
1630
2041
|
return {
|
|
@@ -1648,6 +2059,7 @@ class TodolistComponent extends core$1.Component {
|
|
|
1648
2059
|
const selection = core$1.useContext(core$1.Selection);
|
|
1649
2060
|
core$1.onBreak(ev => {
|
|
1650
2061
|
const slot = ev.target.cut(ev.data.index);
|
|
2062
|
+
slot.removeAttribute(headingAttr);
|
|
1651
2063
|
if (ev.target.isEmpty && slot.isEmpty) {
|
|
1652
2064
|
const beforeIndex = this.parent.indexOf(this);
|
|
1653
2065
|
const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
|
|
@@ -1695,21 +2107,32 @@ class TodolistComponent extends core$1.Component {
|
|
|
1695
2107
|
TodolistComponent.type = core$1.ContentType.BlockComponent;
|
|
1696
2108
|
TodolistComponent.componentName = 'TodoListComponent';
|
|
1697
2109
|
TodolistComponent.zenCoding = {
|
|
1698
|
-
match
|
|
2110
|
+
match(content, textbus) {
|
|
2111
|
+
const selection = textbus.get(core$1.Selection);
|
|
2112
|
+
if (selection.commonAncestorComponent instanceof ParagraphComponent) {
|
|
2113
|
+
return /^\[(x|\s)?\]$/.test(content);
|
|
2114
|
+
}
|
|
2115
|
+
return false;
|
|
2116
|
+
},
|
|
1699
2117
|
key: ' ',
|
|
1700
|
-
createState(content) {
|
|
2118
|
+
createState(content, textbus) {
|
|
2119
|
+
const selection = textbus.get(core$1.Selection);
|
|
2120
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
2121
|
+
const slot = new core$1.Slot([
|
|
2122
|
+
core$1.ContentType.InlineComponent,
|
|
2123
|
+
core$1.ContentType.Text
|
|
2124
|
+
]);
|
|
2125
|
+
if (commonAncestorSlot === null || commonAncestorSlot === void 0 ? void 0 : commonAncestorSlot.hasAttribute(textIndentAttr)) {
|
|
2126
|
+
slot.setAttribute(textIndentAttr, commonAncestorSlot.getAttribute(textIndentAttr));
|
|
2127
|
+
}
|
|
1701
2128
|
const isChecked = content.charAt(1) === 'x';
|
|
1702
2129
|
return {
|
|
1703
2130
|
checked: isChecked,
|
|
1704
|
-
slot
|
|
1705
|
-
core$1.ContentType.InlineComponent,
|
|
1706
|
-
core$1.ContentType.Text
|
|
1707
|
-
])
|
|
2131
|
+
slot
|
|
1708
2132
|
};
|
|
1709
2133
|
}
|
|
1710
2134
|
};
|
|
1711
2135
|
function TodolistView(props) {
|
|
1712
|
-
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
1713
2136
|
const component = props.component;
|
|
1714
2137
|
const state = component.state;
|
|
1715
2138
|
function toggle() {
|
|
@@ -1738,11 +2161,7 @@ function TodolistView(props) {
|
|
|
1738
2161
|
marginLeft: indent * 24 + 'px',
|
|
1739
2162
|
justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
|
|
1740
2163
|
textAlign: component.state.slot.getAttribute(textAlignAttr) === 'justify' ? 'justify' : void 0
|
|
1741
|
-
}, children: [jsxRuntime.jsx("div", { class: "xnote-todolist-icon", onClick: toggle, children: jsxRuntime.jsx("span", { "data-checked": checked, class: [checked ? 'xnote-icon-checkbox-checked' : 'xnote-icon-checkbox-unchecked'] }) }),
|
|
1742
|
-
return core$1.createVNode('div', {
|
|
1743
|
-
class: 'xnote-todolist-content'
|
|
1744
|
-
}, children);
|
|
1745
|
-
}, readonly())] }));
|
|
2164
|
+
}, children: [jsxRuntime.jsx("div", { class: "xnote-todolist-icon", onClick: toggle, children: jsxRuntime.jsx("span", { "data-checked": checked, class: [checked ? 'xnote-icon-checkbox-checked' : 'xnote-icon-checkbox-unchecked'] }) }), jsxRuntime.jsx(SlotRender, { slot: slot, tag: 'div', class: 'xnote-todolist-content', renderEnv: readonly() || output() })] }));
|
|
1746
2165
|
};
|
|
1747
2166
|
}
|
|
1748
2167
|
const todolistComponentLoader = {
|
|
@@ -1761,75 +2180,40 @@ const todolistComponentLoader = {
|
|
|
1761
2180
|
}
|
|
1762
2181
|
};
|
|
1763
2182
|
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
}
|
|
1771
|
-
constructor(textbus, state = {
|
|
1772
|
-
slot: new core$1.Slot([
|
|
1773
|
-
core$1.ContentType.Text,
|
|
1774
|
-
core$1.ContentType.InlineComponent,
|
|
1775
|
-
core$1.ContentType.BlockComponent
|
|
1776
|
-
])
|
|
1777
|
-
}) {
|
|
1778
|
-
super(textbus, state);
|
|
1779
|
-
}
|
|
1780
|
-
setup() {
|
|
1781
|
-
useBlockContent(this.state.slot);
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
BlockquoteComponent.type = core$1.ContentType.BlockComponent;
|
|
1785
|
-
BlockquoteComponent.componentName = 'BlockquoteComponent';
|
|
1786
|
-
BlockquoteComponent.zenCoding = {
|
|
1787
|
-
key: ' ',
|
|
1788
|
-
match: /^>$/,
|
|
1789
|
-
createState() {
|
|
1790
|
-
return {
|
|
1791
|
-
slot: new core$1.Slot([
|
|
1792
|
-
core$1.ContentType.Text,
|
|
2183
|
+
function toList(textbus, type) {
|
|
2184
|
+
const commander = textbus.get(core$1.Commander);
|
|
2185
|
+
commander.transform({
|
|
2186
|
+
targetType: ListComponent.type,
|
|
2187
|
+
slotFactory() {
|
|
2188
|
+
return new core$1.Slot([
|
|
1793
2189
|
core$1.ContentType.InlineComponent,
|
|
1794
|
-
core$1.ContentType.
|
|
1795
|
-
])
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
2190
|
+
core$1.ContentType.Text
|
|
2191
|
+
]);
|
|
2192
|
+
},
|
|
2193
|
+
stateFactory(slots) {
|
|
2194
|
+
return slots.map((slot, index) => {
|
|
2195
|
+
return new ListComponent(textbus, {
|
|
2196
|
+
type,
|
|
2197
|
+
reorder: index === 0,
|
|
2198
|
+
slot
|
|
2199
|
+
});
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
});
|
|
2203
|
+
}
|
|
2204
|
+
function registerListShortcut(textbus) {
|
|
2205
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
2206
|
+
keyboard.addShortcut({
|
|
2207
|
+
keymap: {
|
|
2208
|
+
key: ['o', 'u'],
|
|
2209
|
+
ctrlKey: true,
|
|
2210
|
+
shiftKey: true
|
|
2211
|
+
},
|
|
2212
|
+
action(key) {
|
|
2213
|
+
toList(textbus, key === 'o' ? 'OrderedList' : 'UnorderedList');
|
|
2214
|
+
}
|
|
2215
|
+
});
|
|
1808
2216
|
}
|
|
1809
|
-
const blockquoteComponentLoader = {
|
|
1810
|
-
match(element) {
|
|
1811
|
-
return element.tagName === 'BLOCKQUOTE';
|
|
1812
|
-
},
|
|
1813
|
-
read(element, textbus, slotParser) {
|
|
1814
|
-
const delta = slotParser(new core$1.Slot([
|
|
1815
|
-
core$1.ContentType.Text,
|
|
1816
|
-
core$1.ContentType.BlockComponent,
|
|
1817
|
-
core$1.ContentType.InlineComponent
|
|
1818
|
-
]), element).toDelta();
|
|
1819
|
-
const slot = new core$1.Slot([
|
|
1820
|
-
core$1.ContentType.BlockComponent,
|
|
1821
|
-
core$1.ContentType.InlineComponent,
|
|
1822
|
-
core$1.ContentType.Text
|
|
1823
|
-
]);
|
|
1824
|
-
deltaToBlock(delta, textbus).forEach(i => {
|
|
1825
|
-
slot.insert(i);
|
|
1826
|
-
});
|
|
1827
|
-
return new BlockquoteComponent(textbus, {
|
|
1828
|
-
slot
|
|
1829
|
-
});
|
|
1830
|
-
},
|
|
1831
|
-
};
|
|
1832
|
-
|
|
1833
2217
|
class ListComponent extends core$1.Component {
|
|
1834
2218
|
static fromJSON(textbus, json) {
|
|
1835
2219
|
return new ListComponent(textbus, {
|
|
@@ -1851,8 +2235,7 @@ class ListComponent extends core$1.Component {
|
|
|
1851
2235
|
const afterContent = parentSlot.sliceContent(index + 1);
|
|
1852
2236
|
for (const item of afterContent) {
|
|
1853
2237
|
if (item instanceof ListComponent &&
|
|
1854
|
-
item.state.type === 'OrderedList'
|
|
1855
|
-
item.state.slot.getAttribute(textIndentAttr) === this.state.slot.getAttribute(textIndentAttr)) {
|
|
2238
|
+
item.state.type === 'OrderedList') {
|
|
1856
2239
|
if (item.state.reorder) {
|
|
1857
2240
|
break;
|
|
1858
2241
|
}
|
|
@@ -1865,6 +2248,7 @@ class ListComponent extends core$1.Component {
|
|
|
1865
2248
|
});
|
|
1866
2249
|
core$1.onBreak(ev => {
|
|
1867
2250
|
const slot = ev.target.cut(ev.data.index);
|
|
2251
|
+
slot.removeAttribute(headingAttr);
|
|
1868
2252
|
if (ev.target.isEmpty && slot.isEmpty) {
|
|
1869
2253
|
const beforeIndex = this.parent.indexOf(this);
|
|
1870
2254
|
const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
|
|
@@ -1910,21 +2294,52 @@ class ListComponent extends core$1.Component {
|
|
|
1910
2294
|
selection.setPosition(slot, 0);
|
|
1911
2295
|
}
|
|
1912
2296
|
});
|
|
2297
|
+
core$1.useDynamicShortcut({
|
|
2298
|
+
keymap: {
|
|
2299
|
+
key: 'Tab'
|
|
2300
|
+
},
|
|
2301
|
+
action: () => {
|
|
2302
|
+
Promise.resolve().then(() => updateAfterList(this));
|
|
2303
|
+
return false;
|
|
2304
|
+
}
|
|
2305
|
+
});
|
|
2306
|
+
core$1.useDynamicShortcut({
|
|
2307
|
+
keymap: {
|
|
2308
|
+
key: 'Tab',
|
|
2309
|
+
shiftKey: true
|
|
2310
|
+
},
|
|
2311
|
+
action: () => {
|
|
2312
|
+
Promise.resolve().then(() => updateAfterList(this));
|
|
2313
|
+
return false;
|
|
2314
|
+
}
|
|
2315
|
+
});
|
|
1913
2316
|
}
|
|
1914
2317
|
}
|
|
1915
2318
|
ListComponent.componentName = 'ListComponent';
|
|
1916
2319
|
ListComponent.type = core$1.ContentType.BlockComponent;
|
|
1917
2320
|
ListComponent.zenCoding = {
|
|
1918
2321
|
key: ' ',
|
|
1919
|
-
match
|
|
1920
|
-
|
|
2322
|
+
match(content, textbus) {
|
|
2323
|
+
const selection = textbus.get(core$1.Selection);
|
|
2324
|
+
if (selection.commonAncestorComponent instanceof ParagraphComponent) {
|
|
2325
|
+
return /^([1-9]\.|[+*-])$/.test(content);
|
|
2326
|
+
}
|
|
2327
|
+
return false;
|
|
2328
|
+
},
|
|
2329
|
+
createState(content, textbus) {
|
|
2330
|
+
const selection = textbus.get(core$1.Selection);
|
|
2331
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
2332
|
+
const slot = new core$1.Slot([
|
|
2333
|
+
core$1.ContentType.InlineComponent,
|
|
2334
|
+
core$1.ContentType.Text
|
|
2335
|
+
]);
|
|
2336
|
+
if (commonAncestorSlot === null || commonAncestorSlot === void 0 ? void 0 : commonAncestorSlot.hasAttribute(textIndentAttr)) {
|
|
2337
|
+
slot.setAttribute(textIndentAttr, commonAncestorSlot.getAttribute(textIndentAttr));
|
|
2338
|
+
}
|
|
1921
2339
|
return {
|
|
1922
2340
|
type: /[-+*]/.test(content) ? 'UnorderedList' : 'OrderedList',
|
|
1923
2341
|
reorder: true,
|
|
1924
|
-
slot
|
|
1925
|
-
core$1.ContentType.InlineComponent,
|
|
1926
|
-
core$1.ContentType.Text
|
|
1927
|
-
])
|
|
2342
|
+
slot
|
|
1928
2343
|
};
|
|
1929
2344
|
}
|
|
1930
2345
|
};
|
|
@@ -1946,7 +2361,6 @@ function numberToLetter(num) {
|
|
|
1946
2361
|
}).join('');
|
|
1947
2362
|
}
|
|
1948
2363
|
function ListComponentView(props) {
|
|
1949
|
-
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
1950
2364
|
const component = props.component;
|
|
1951
2365
|
function reorder(is) {
|
|
1952
2366
|
component.state.reorder = is;
|
|
@@ -1973,7 +2387,8 @@ function ListComponentView(props) {
|
|
|
1973
2387
|
return () => {
|
|
1974
2388
|
const ListType = component.state.type === 'UnorderedList' ? 'ul' : 'ol';
|
|
1975
2389
|
const ulIcons = ['•', '◦', '▪'];
|
|
1976
|
-
let icon
|
|
2390
|
+
let icon;
|
|
2391
|
+
let listStep = 0;
|
|
1977
2392
|
const indent = component.state.slot.getAttribute(textIndentAttr) || 0;
|
|
1978
2393
|
if (ListType === 'ul') {
|
|
1979
2394
|
icon = ulIcons[indent % 3];
|
|
@@ -1981,7 +2396,6 @@ function ListComponentView(props) {
|
|
|
1981
2396
|
else {
|
|
1982
2397
|
const parentSlot = component.parent;
|
|
1983
2398
|
const index = parentSlot.indexOf(component);
|
|
1984
|
-
let listStep = 0;
|
|
1985
2399
|
if (!component.state.reorder) {
|
|
1986
2400
|
const beforeContent = parentSlot.sliceContent(0, index);
|
|
1987
2401
|
while (beforeContent.length) {
|
|
@@ -2012,7 +2426,7 @@ function ListComponentView(props) {
|
|
|
2012
2426
|
icon = numberToLetter(listStep) + '.';
|
|
2013
2427
|
}
|
|
2014
2428
|
}
|
|
2015
|
-
return (jsxRuntime.jsx(ListType, { ref: props.rootRef, "data-component": component.name, class: "xnote-list", style: {
|
|
2429
|
+
return (jsxRuntime.jsx(ListType, { ref: props.rootRef, "data-component": component.name, "data-reorder": (listStep === 0) + '', class: "xnote-list", style: {
|
|
2016
2430
|
marginLeft: indent * 24 + 'px'
|
|
2017
2431
|
}, children: jsxRuntime.jsxs("li", { style: {
|
|
2018
2432
|
justifyContent: align[component.state.slot.getAttribute(textAlignAttr)],
|
|
@@ -2020,16 +2434,12 @@ function ListComponentView(props) {
|
|
|
2020
2434
|
}, children: [jsxRuntime.jsx("div", { class: "xnote-list-type", children: (component.state.type === 'UnorderedList' || readonly() || output()) ?
|
|
2021
2435
|
jsxRuntime.jsx("span", { class: "xnote-order-btn", children: icon })
|
|
2022
2436
|
:
|
|
2023
|
-
jsxRuntime.jsx(Dropdown, { menu: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsxRuntime.jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsxRuntime.jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }),
|
|
2024
|
-
return core$1.createVNode('div', {
|
|
2025
|
-
class: 'xnote-list-content'
|
|
2026
|
-
}, children);
|
|
2027
|
-
}, readonly())] }) }));
|
|
2437
|
+
jsxRuntime.jsx(Dropdown, { menu: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuItem, { onClick: () => reorder(false), children: "\u7EE7\u7EED\u7F16\u53F7" }), jsxRuntime.jsx(MenuItem, { onClick: () => reorder(true), children: "\u91CD\u65B0\u7F16\u53F7" })] }), children: jsxRuntime.jsx(Button, { style: { color: 'inherit' }, children: icon }) }) }), jsxRuntime.jsx(SlotRender, { slot: component.state.slot, class: 'xnote-list-content', renderEnv: readonly() || output() })] }) }));
|
|
2028
2438
|
};
|
|
2029
2439
|
}
|
|
2030
2440
|
const listComponentLoader = {
|
|
2031
|
-
match(element) {
|
|
2032
|
-
return element.tagName === 'UL' || element.tagName === 'OL';
|
|
2441
|
+
match(element, returnableContentTypes) {
|
|
2442
|
+
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && (element.tagName === 'UL' || element.tagName === 'OL');
|
|
2033
2443
|
},
|
|
2034
2444
|
read(element, textbus, slotParser) {
|
|
2035
2445
|
const type = element.tagName === 'OL' ? 'OrderedList' : 'UnorderedList';
|
|
@@ -2040,7 +2450,7 @@ const listComponentLoader = {
|
|
|
2040
2450
|
]), element.querySelector('.xnote-list-content') || document.createElement('div'));
|
|
2041
2451
|
return new ListComponent(textbus, {
|
|
2042
2452
|
slot,
|
|
2043
|
-
reorder:
|
|
2453
|
+
reorder: element.dataset.reorder !== 'false',
|
|
2044
2454
|
type
|
|
2045
2455
|
});
|
|
2046
2456
|
}
|
|
@@ -2083,125 +2493,58 @@ function useActiveBlock() {
|
|
|
2083
2493
|
sourceCode: false,
|
|
2084
2494
|
highlightBox: false
|
|
2085
2495
|
});
|
|
2086
|
-
function updateCheckStates() {
|
|
2496
|
+
function updateCheckStates(range) {
|
|
2087
2497
|
setCheckStates(draft => {
|
|
2088
|
-
const heading = query.
|
|
2089
|
-
draft.paragraph = query.
|
|
2498
|
+
const heading = query.queryAttributeByRange(headingAttr, range);
|
|
2499
|
+
draft.paragraph = query.queryComponentByRange(ParagraphComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2090
2500
|
draft.h1 = draft.h2 = draft.h3 = draft.h4 = draft.h5 = draft.h6 = false;
|
|
2091
2501
|
if (heading.state === core$1.QueryStateType.Enabled) {
|
|
2092
2502
|
draft[heading.value] = true;
|
|
2093
2503
|
draft.paragraph = false;
|
|
2094
2504
|
}
|
|
2095
|
-
const queryList = query.
|
|
2505
|
+
const queryList = query.queryComponentByRange(ListComponent, range);
|
|
2096
2506
|
draft.unorderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'UnorderedList';
|
|
2097
2507
|
draft.orderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'OrderedList';
|
|
2098
|
-
draft.table = query.
|
|
2099
|
-
draft.todolist = query.
|
|
2100
|
-
draft.blockquote = query.
|
|
2101
|
-
draft.sourceCode = query.
|
|
2508
|
+
draft.table = query.queryComponentByRange(TableComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2509
|
+
draft.todolist = query.queryComponentByRange(TodolistComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2510
|
+
draft.blockquote = query.queryComponentByRange(BlockquoteComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2511
|
+
draft.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === core$1.QueryStateType.Enabled;
|
|
2102
2512
|
});
|
|
2103
2513
|
}
|
|
2104
|
-
updateCheckStates();
|
|
2105
2514
|
const subscription = refreshService.onRefresh.subscribe(() => {
|
|
2106
|
-
|
|
2515
|
+
if (!selection.isSelected) {
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
updateCheckStates({
|
|
2519
|
+
startOffset: selection.startOffset,
|
|
2520
|
+
startSlot: selection.startSlot,
|
|
2521
|
+
endSlot: selection.endSlot,
|
|
2522
|
+
endOffset: selection.endOffset
|
|
2523
|
+
});
|
|
2107
2524
|
});
|
|
2108
2525
|
core.onUnmounted(() => {
|
|
2109
2526
|
subscription.unsubscribe();
|
|
2110
2527
|
});
|
|
2111
2528
|
return function (slot = null) {
|
|
2112
2529
|
if (slot) {
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2530
|
+
updateCheckStates({
|
|
2531
|
+
startOffset: 0,
|
|
2532
|
+
endOffset: slot.length,
|
|
2533
|
+
startSlot: slot,
|
|
2534
|
+
endSlot: slot
|
|
2535
|
+
});
|
|
2117
2536
|
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
type: json.type,
|
|
2126
|
-
slot: textbus.get(core$1.Registry).createSlot(json.slot)
|
|
2127
|
-
});
|
|
2128
|
-
}
|
|
2129
|
-
constructor(textbus, state = {
|
|
2130
|
-
type: '',
|
|
2131
|
-
slot: new core$1.Slot([
|
|
2132
|
-
core$1.ContentType.BlockComponent,
|
|
2133
|
-
core$1.ContentType.InlineComponent,
|
|
2134
|
-
core$1.ContentType.Text
|
|
2135
|
-
])
|
|
2136
|
-
}) {
|
|
2137
|
-
super(textbus, state);
|
|
2138
|
-
}
|
|
2139
|
-
setup() {
|
|
2140
|
-
useBlockContent(this.state.slot);
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
HighlightBoxComponent.defaultTypes = ['❤️', '💡', '📌', '✅', '❎', '👍', '🎉', '🚫', '❗'];
|
|
2144
|
-
HighlightBoxComponent.componentName = 'HighlightBoxComponent';
|
|
2145
|
-
HighlightBoxComponent.type = core$1.ContentType.BlockComponent;
|
|
2146
|
-
function HighlightBoxView(props) {
|
|
2147
|
-
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
2148
|
-
const readonly = useReadonly();
|
|
2149
|
-
const output = useOutput();
|
|
2150
|
-
const emoji = [];
|
|
2151
|
-
for (let i = 0x1F600; i <= 0x1F64F; i++) {
|
|
2152
|
-
emoji.push(i);
|
|
2153
|
-
}
|
|
2154
|
-
const dropdownRef = core.createRef();
|
|
2155
|
-
function setType(type) {
|
|
2156
|
-
var _a;
|
|
2157
|
-
(_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(false);
|
|
2158
|
-
props.component.state.type = type;
|
|
2159
|
-
}
|
|
2160
|
-
return () => {
|
|
2161
|
-
const { state, name } = props.component;
|
|
2162
|
-
if (readonly() || output()) {
|
|
2163
|
-
return (jsxRuntime.jsxs("div", { "data-component": name, ref: props.rootRef, "data-icon": state.type, class: "xnote-highlight-box", children: [jsxRuntime.jsx("div", { class: "xnote-highlight-box-left", children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }), adapter.slotRender(state.slot, children => {
|
|
2164
|
-
return core$1.createVNode('div', {
|
|
2165
|
-
class: 'xnote-highlight-box-content'
|
|
2166
|
-
}, children);
|
|
2167
|
-
}, readonly())] }));
|
|
2537
|
+
else if (selection.isSelected) {
|
|
2538
|
+
updateCheckStates({
|
|
2539
|
+
startOffset: selection.startOffset,
|
|
2540
|
+
startSlot: selection.startSlot,
|
|
2541
|
+
endSlot: selection.endSlot,
|
|
2542
|
+
endOffset: selection.endOffset
|
|
2543
|
+
});
|
|
2168
2544
|
}
|
|
2169
|
-
return (
|
|
2170
|
-
return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
|
|
2171
|
-
}), jsxRuntime.jsx(Divider, {}), emoji.map(i => {
|
|
2172
|
-
const icon = String.fromCodePoint(i);
|
|
2173
|
-
return (jsxRuntime.jsx("button", { onClick: () => setType(icon), type: "button", children: icon }));
|
|
2174
|
-
})] }), children: jsxRuntime.jsx("div", { class: "xnote-highlight-box-icon", children: jsxRuntime.jsx("button", { type: "button", children: state.type || '❤️' }) }) }) }), adapter.slotRender(state.slot, children => {
|
|
2175
|
-
return core$1.createVNode('div', {
|
|
2176
|
-
class: 'xnote-highlight-box-content'
|
|
2177
|
-
}, children);
|
|
2178
|
-
}, readonly())] }));
|
|
2545
|
+
return checkStates();
|
|
2179
2546
|
};
|
|
2180
2547
|
}
|
|
2181
|
-
const highlightBoxComponentLoader = {
|
|
2182
|
-
match(element) {
|
|
2183
|
-
return element.tagName === 'DIV' && element.dataset.component === HighlightBoxComponent.componentName;
|
|
2184
|
-
},
|
|
2185
|
-
read(element, textbus, slotParser) {
|
|
2186
|
-
const delta = slotParser(new core$1.Slot([
|
|
2187
|
-
core$1.ContentType.BlockComponent,
|
|
2188
|
-
core$1.ContentType.InlineComponent,
|
|
2189
|
-
core$1.ContentType.Text
|
|
2190
|
-
]), element.querySelector('.xnote-highlight-box-content')).toDelta();
|
|
2191
|
-
const slot = new core$1.Slot([
|
|
2192
|
-
core$1.ContentType.BlockComponent,
|
|
2193
|
-
core$1.ContentType.InlineComponent,
|
|
2194
|
-
core$1.ContentType.Text
|
|
2195
|
-
]);
|
|
2196
|
-
deltaToBlock(delta, textbus).forEach(i => {
|
|
2197
|
-
slot.insert(i);
|
|
2198
|
-
});
|
|
2199
|
-
return new HighlightBoxComponent(textbus, {
|
|
2200
|
-
type: element.dataset.icon || '',
|
|
2201
|
-
slot
|
|
2202
|
-
});
|
|
2203
|
-
}
|
|
2204
|
-
};
|
|
2205
2548
|
|
|
2206
2549
|
function useBlockTransform() {
|
|
2207
2550
|
const commander = core.inject(core$1.Commander);
|
|
@@ -2223,17 +2566,16 @@ function useBlockTransform() {
|
|
|
2223
2566
|
commander.unApplyAttribute(headingAttr);
|
|
2224
2567
|
commander.transform({
|
|
2225
2568
|
targetType: ParagraphComponent.type,
|
|
2226
|
-
multipleSlot: false,
|
|
2227
2569
|
slotFactory() {
|
|
2228
2570
|
return new core$1.Slot([
|
|
2229
2571
|
core$1.ContentType.InlineComponent,
|
|
2230
2572
|
core$1.ContentType.Text
|
|
2231
2573
|
]);
|
|
2232
2574
|
},
|
|
2233
|
-
stateFactory(
|
|
2234
|
-
return new ParagraphComponent(textbus, {
|
|
2575
|
+
stateFactory(slots) {
|
|
2576
|
+
return slots.map(slot => new ParagraphComponent(textbus, {
|
|
2235
2577
|
slot
|
|
2236
|
-
});
|
|
2578
|
+
}));
|
|
2237
2579
|
}
|
|
2238
2580
|
});
|
|
2239
2581
|
break;
|
|
@@ -2248,99 +2590,50 @@ function useBlockTransform() {
|
|
|
2248
2590
|
}
|
|
2249
2591
|
}
|
|
2250
2592
|
break;
|
|
2251
|
-
case 'todolist':
|
|
2252
|
-
commander.unApplyAttribute(headingAttr);
|
|
2253
|
-
commander.transform({
|
|
2254
|
-
targetType: TodolistComponent.type,
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
core$1.ContentType.
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
case '
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
core$1.ContentType.InlineComponent,
|
|
2279
|
-
core$1.ContentType.Text
|
|
2280
|
-
]);
|
|
2281
|
-
},
|
|
2282
|
-
stateFactory(slot) {
|
|
2283
|
-
return new ListComponent(textbus, {
|
|
2284
|
-
type: value === 'ol' ? 'OrderedList' : 'UnorderedList',
|
|
2285
|
-
reorder: true,
|
|
2286
|
-
slot
|
|
2287
|
-
});
|
|
2288
|
-
}
|
|
2289
|
-
});
|
|
2290
|
-
}
|
|
2291
|
-
break;
|
|
2292
|
-
case 'blockquote':
|
|
2293
|
-
{
|
|
2294
|
-
const state = query.queryComponent(BlockquoteComponent);
|
|
2295
|
-
if (state.state === core$1.QueryStateType.Enabled) {
|
|
2296
|
-
const current = state.value;
|
|
2297
|
-
const parent = current.parent;
|
|
2298
|
-
const index = parent.indexOf(current);
|
|
2299
|
-
parent.retain(index);
|
|
2300
|
-
commander.removeComponent(current);
|
|
2301
|
-
current.__slots__.get(0).sliceContent().forEach(i => {
|
|
2302
|
-
parent.insert(i);
|
|
2303
|
-
});
|
|
2304
|
-
}
|
|
2305
|
-
else {
|
|
2306
|
-
const block = new BlockquoteComponent(textbus);
|
|
2307
|
-
const slot = block.state.slot;
|
|
2308
|
-
if (selection.startSlot === selection.endSlot) {
|
|
2309
|
-
const parentComponent = selection.startSlot.parent;
|
|
2310
|
-
const parentSlot = parentComponent.parent;
|
|
2311
|
-
const position = parentSlot.indexOf(parentComponent);
|
|
2312
|
-
slot.insert(parentComponent);
|
|
2313
|
-
parentSlot.retain(position);
|
|
2314
|
-
parentSlot.insert(block);
|
|
2315
|
-
}
|
|
2316
|
-
else {
|
|
2317
|
-
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
2318
|
-
const scope = selection.getCommonAncestorSlotScope();
|
|
2319
|
-
commonAncestorSlot.cut(scope.startOffset, scope.endOffset).sliceContent().forEach(i => {
|
|
2320
|
-
slot.insert(i);
|
|
2321
|
-
});
|
|
2322
|
-
commonAncestorSlot.retain(scope.startOffset);
|
|
2323
|
-
commonAncestorSlot.insert(block);
|
|
2324
|
-
}
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
break;
|
|
2593
|
+
case 'todolist':
|
|
2594
|
+
commander.unApplyAttribute(headingAttr);
|
|
2595
|
+
commander.transform({
|
|
2596
|
+
targetType: TodolistComponent.type,
|
|
2597
|
+
slotFactory() {
|
|
2598
|
+
return new core$1.Slot([
|
|
2599
|
+
core$1.ContentType.InlineComponent,
|
|
2600
|
+
core$1.ContentType.Text
|
|
2601
|
+
]);
|
|
2602
|
+
},
|
|
2603
|
+
stateFactory(slots) {
|
|
2604
|
+
return slots.map(slot => {
|
|
2605
|
+
return new TodolistComponent(textbus, {
|
|
2606
|
+
checked: false,
|
|
2607
|
+
slot
|
|
2608
|
+
});
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
});
|
|
2612
|
+
break;
|
|
2613
|
+
case 'ol':
|
|
2614
|
+
case 'ul':
|
|
2615
|
+
toList(textbus, value === 'ol' ? 'OrderedList' : 'UnorderedList');
|
|
2616
|
+
break;
|
|
2617
|
+
case 'blockquote':
|
|
2618
|
+
toBlockquote(textbus);
|
|
2619
|
+
break;
|
|
2328
2620
|
case 'sourceCode':
|
|
2329
2621
|
{
|
|
2330
2622
|
const state = query.queryComponent(SourceCodeComponent);
|
|
2331
2623
|
if (state.state === core$1.QueryStateType.Enabled) {
|
|
2332
2624
|
commander.transform({
|
|
2333
2625
|
targetType: ParagraphComponent.type,
|
|
2334
|
-
multipleSlot: false,
|
|
2335
2626
|
slotFactory() {
|
|
2336
2627
|
return new core$1.Slot([
|
|
2337
2628
|
core$1.ContentType.InlineComponent,
|
|
2338
2629
|
core$1.ContentType.Text
|
|
2339
2630
|
]);
|
|
2340
2631
|
},
|
|
2341
|
-
stateFactory(
|
|
2342
|
-
return
|
|
2343
|
-
|
|
2632
|
+
stateFactory(slots) {
|
|
2633
|
+
return slots.map(slot => {
|
|
2634
|
+
return new ParagraphComponent(textbus, {
|
|
2635
|
+
slot
|
|
2636
|
+
});
|
|
2344
2637
|
});
|
|
2345
2638
|
}
|
|
2346
2639
|
});
|
|
@@ -2348,24 +2641,25 @@ function useBlockTransform() {
|
|
|
2348
2641
|
else {
|
|
2349
2642
|
commander.transform({
|
|
2350
2643
|
targetType: SourceCodeComponent.type,
|
|
2351
|
-
multipleSlot: true,
|
|
2352
2644
|
slotFactory() {
|
|
2353
2645
|
return new core$1.Slot([
|
|
2354
2646
|
core$1.ContentType.Text
|
|
2355
2647
|
]);
|
|
2356
2648
|
},
|
|
2357
2649
|
stateFactory(slots) {
|
|
2358
|
-
return new SourceCodeComponent(textbus, {
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
slot
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2650
|
+
return [new SourceCodeComponent(textbus, {
|
|
2651
|
+
lang: '',
|
|
2652
|
+
lineNumber: true,
|
|
2653
|
+
autoBreak: true,
|
|
2654
|
+
slots: slots.map(slot => {
|
|
2655
|
+
slot.cleanFormats();
|
|
2656
|
+
slot.cleanAttributes();
|
|
2657
|
+
return {
|
|
2658
|
+
slot,
|
|
2659
|
+
emphasize: false
|
|
2660
|
+
};
|
|
2661
|
+
})
|
|
2662
|
+
})];
|
|
2369
2663
|
}
|
|
2370
2664
|
});
|
|
2371
2665
|
}
|
|
@@ -2414,7 +2708,7 @@ function useBlockTransform() {
|
|
|
2414
2708
|
function BlockTool() {
|
|
2415
2709
|
const checkStates = useActiveBlock();
|
|
2416
2710
|
const transform = useBlockTransform();
|
|
2417
|
-
return scopedCss.withScopedCSS(
|
|
2711
|
+
return scopedCss.withScopedCSS(scopedId$c, () => {
|
|
2418
2712
|
const states = checkStates();
|
|
2419
2713
|
const types = [
|
|
2420
2714
|
[states.paragraph, 'xnote-icon-pilcrow'],
|
|
@@ -2429,7 +2723,7 @@ function BlockTool() {
|
|
|
2429
2723
|
[states.todolist, 'xnote-icon-checkbox-checked'],
|
|
2430
2724
|
[states.blockquote, 'xnote-icon-quotes-right'],
|
|
2431
2725
|
[states.sourceCode, 'xnote-icon-source-code'],
|
|
2432
|
-
[states.highlightBox, 'xnote-icon-
|
|
2726
|
+
[states.highlightBox, 'xnote-icon-highlight-box'],
|
|
2433
2727
|
];
|
|
2434
2728
|
let currentType = 'xnote-icon-pilcrow';
|
|
2435
2729
|
for (const t of types) {
|
|
@@ -2438,27 +2732,48 @@ function BlockTool() {
|
|
|
2438
2732
|
break;
|
|
2439
2733
|
}
|
|
2440
2734
|
}
|
|
2441
|
-
return (jsxRuntime.jsx(Dropdown, { onCheck: transform, trigger: 'hover', menu: [
|
|
2735
|
+
return (jsxRuntime.jsx(Dropdown, { width: 'auto', onCheck: transform, trigger: 'hover', menu: [
|
|
2442
2736
|
{
|
|
2443
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }),
|
|
2737
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2738
|
+
ctrlKey: true,
|
|
2739
|
+
key: '0'
|
|
2740
|
+
} }), checked: states.paragraph, children: "\u6B63\u6587" }),
|
|
2444
2741
|
value: 'paragraph'
|
|
2445
2742
|
}, {
|
|
2446
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }),
|
|
2743
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2744
|
+
ctrlKey: true,
|
|
2745
|
+
key: '1'
|
|
2746
|
+
} }), checked: states.h1, children: "\u4E00\u7EA7\u6807\u9898" }),
|
|
2447
2747
|
value: 'h1'
|
|
2448
2748
|
}, {
|
|
2449
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }),
|
|
2749
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2750
|
+
ctrlKey: true,
|
|
2751
|
+
key: '2'
|
|
2752
|
+
} }), checked: states.h2, children: "\u4E8C\u7EA7\u6807\u9898" }),
|
|
2450
2753
|
value: 'h2'
|
|
2451
2754
|
}, {
|
|
2452
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }),
|
|
2755
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2756
|
+
ctrlKey: true,
|
|
2757
|
+
key: '3'
|
|
2758
|
+
} }), checked: states.h3, children: "\u4E09\u7EA7\u6807\u9898" }),
|
|
2453
2759
|
value: 'h3'
|
|
2454
2760
|
}, {
|
|
2455
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }),
|
|
2761
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2762
|
+
ctrlKey: true,
|
|
2763
|
+
key: '4'
|
|
2764
|
+
} }), checked: states.h4, children: "\u56DB\u7EA7\u6807\u9898" }),
|
|
2456
2765
|
value: 'h4'
|
|
2457
2766
|
}, {
|
|
2458
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }),
|
|
2767
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2768
|
+
ctrlKey: true,
|
|
2769
|
+
key: '5'
|
|
2770
|
+
} }), checked: states.h5, children: "\u4E94\u7EA7\u6807\u9898" }),
|
|
2459
2771
|
value: 'h5'
|
|
2460
2772
|
}, {
|
|
2461
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }),
|
|
2773
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }), desc: jsxRuntime.jsx(Keymap, { keymap: {
|
|
2774
|
+
ctrlKey: true,
|
|
2775
|
+
key: '6'
|
|
2776
|
+
} }), checked: states.h6, children: "\u516D\u7EA7\u6807\u9898" }),
|
|
2462
2777
|
value: 'h6'
|
|
2463
2778
|
}, {
|
|
2464
2779
|
label: jsxRuntime.jsx(Divider, {}),
|
|
@@ -2467,19 +2782,19 @@ function BlockTool() {
|
|
|
2467
2782
|
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }), checked: states.todolist, children: "\u5F85\u529E\u4E8B\u9879" }),
|
|
2468
2783
|
value: 'todolist'
|
|
2469
2784
|
}, {
|
|
2470
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }), checked: states.orderedList, children: "\u6709\u5E8F\u5217\u8868" }),
|
|
2785
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'O', shiftKey: true, ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }), checked: states.orderedList, children: "\u6709\u5E8F\u5217\u8868" }),
|
|
2471
2786
|
value: 'ol'
|
|
2472
2787
|
}, {
|
|
2473
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-list" }), checked: states.unorderedList, children: "\u65E0\u5E8F\u5217\u8868" }),
|
|
2788
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'U', shiftKey: true, ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-list" }), checked: states.unorderedList, children: "\u65E0\u5E8F\u5217\u8868" }),
|
|
2474
2789
|
value: 'ul'
|
|
2475
2790
|
}, {
|
|
2476
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }), checked: states.blockquote, children: "\u5F15\u7528" }),
|
|
2791
|
+
label: jsxRuntime.jsx(MenuItem, { desc: jsxRuntime.jsx(Keymap, { keymap: { key: '\'', ctrlKey: true } }), icon: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }), checked: states.blockquote, children: "\u5F15\u7528" }),
|
|
2477
2792
|
value: 'blockquote'
|
|
2478
2793
|
}, {
|
|
2479
2794
|
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }), checked: states.sourceCode, children: "\u4EE3\u7801\u5757" }),
|
|
2480
2795
|
value: 'sourceCode'
|
|
2481
2796
|
}, {
|
|
2482
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-
|
|
2797
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-hightlight-box" }), checked: states.highlightBox, children: "\u9AD8\u4EAE\u5757" }),
|
|
2483
2798
|
value: 'highlightBox'
|
|
2484
2799
|
}
|
|
2485
2800
|
], children: jsxRuntime.jsx(Button, { arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: currentType }) }) }));
|
|
@@ -2845,12 +3160,13 @@ function CodeTool() {
|
|
|
2845
3160
|
};
|
|
2846
3161
|
}
|
|
2847
3162
|
|
|
2848
|
-
var
|
|
3163
|
+
var scopedId$b = "vf-accb31";
|
|
2849
3164
|
|
|
2850
3165
|
function ColorTool(props) {
|
|
2851
3166
|
const query = core.inject(core$1.Query);
|
|
2852
3167
|
const refreshService = core.inject(exports.RefreshService);
|
|
2853
3168
|
const commander = core.inject(core$1.Commander);
|
|
3169
|
+
const selection = core.inject(core$1.Selection);
|
|
2854
3170
|
const textColor = core.createSignal('');
|
|
2855
3171
|
const backgroundColor = core.createSignal('');
|
|
2856
3172
|
const [viewModel] = hooks.useProduce({
|
|
@@ -2858,13 +3174,24 @@ function ColorTool(props) {
|
|
|
2858
3174
|
disabled: false,
|
|
2859
3175
|
});
|
|
2860
3176
|
function updateCheckState() {
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
const
|
|
3177
|
+
if (!props.slot && !selection.isSelected) {
|
|
3178
|
+
return;
|
|
3179
|
+
}
|
|
3180
|
+
const range = props.slot ? {
|
|
3181
|
+
startSlot: props.slot,
|
|
3182
|
+
endSlot: props.slot,
|
|
3183
|
+
startOffset: 0,
|
|
3184
|
+
endOffset: props.slot.length
|
|
3185
|
+
} : {
|
|
3186
|
+
startSlot: selection.startSlot,
|
|
3187
|
+
startOffset: selection.startOffset,
|
|
3188
|
+
endSlot: selection.endSlot,
|
|
3189
|
+
endOffset: selection.endOffset
|
|
3190
|
+
};
|
|
3191
|
+
const textState = query.queryFormatByRange(colorFormatter, range);
|
|
3192
|
+
const backgroundState = query.queryFormatByRange(backgroundColorFormatter, range);
|
|
2865
3193
|
textColor.set(textState.state === core$1.QueryStateType.Enabled ? textState.value : '');
|
|
2866
3194
|
backgroundColor.set(backgroundState.state === core$1.QueryStateType.Enabled ? backgroundState.value : '');
|
|
2867
|
-
(_b = props.queryAfter) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
2868
3195
|
}
|
|
2869
3196
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
2870
3197
|
updateCheckState();
|
|
@@ -2874,14 +3201,17 @@ function ColorTool(props) {
|
|
|
2874
3201
|
sub.unsubscribe();
|
|
2875
3202
|
});
|
|
2876
3203
|
const textColors = [
|
|
3204
|
+
'#000',
|
|
2877
3205
|
'#aaa',
|
|
2878
3206
|
'#ff2e2e',
|
|
2879
3207
|
'#ff8d45',
|
|
2880
3208
|
'#ffdf14',
|
|
2881
3209
|
'#5eec75',
|
|
2882
3210
|
'#5dfaff',
|
|
3211
|
+
'#1296db',
|
|
2883
3212
|
'#617fff',
|
|
2884
3213
|
'#c459ff',
|
|
3214
|
+
'#fff',
|
|
2885
3215
|
];
|
|
2886
3216
|
const backgroundColors = [
|
|
2887
3217
|
'#aaa',
|
|
@@ -2893,15 +3223,16 @@ function ColorTool(props) {
|
|
|
2893
3223
|
'#90a0e5',
|
|
2894
3224
|
'#c596e0',
|
|
2895
3225
|
];
|
|
2896
|
-
return scopedCss.withScopedCSS(
|
|
3226
|
+
return scopedCss.withScopedCSS(scopedId$b, () => {
|
|
2897
3227
|
const vm = viewModel();
|
|
2898
|
-
return (jsxRuntime.jsx(Dropdown, { style: props.style, abreast: props.abreast, trigger: 'hover', menu: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "text-colors", children: [jsxRuntime.jsx("div", { class: {
|
|
3228
|
+
return (jsxRuntime.jsx(Dropdown, { style: props.style, width: '180px', abreast: props.abreast, trigger: 'hover', menu: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("div", { class: "color-type", children: "\u6587\u5B57\u989C\u8272" }), jsxRuntime.jsxs("div", { class: "text-colors", children: [jsxRuntime.jsx("div", { class: {
|
|
3229
|
+
'no-background': true,
|
|
2899
3230
|
active: textColor() === ''
|
|
2900
3231
|
}, onClick: () => {
|
|
2901
3232
|
var _a;
|
|
2902
3233
|
(_a = props.applyBefore) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
2903
3234
|
commander.unApplyFormat(colorFormatter);
|
|
2904
|
-
}
|
|
3235
|
+
} }), textColors.map(c => {
|
|
2905
3236
|
return jsxRuntime.jsx("div", { class: {
|
|
2906
3237
|
active: textColor() === c
|
|
2907
3238
|
}, onClick: () => {
|
|
@@ -2961,6 +3292,9 @@ const isSupportFont = (function () {
|
|
|
2961
3292
|
function FontFamilyTool() {
|
|
2962
3293
|
const currentFontFamily = core.createSignal('');
|
|
2963
3294
|
const fontFamilyOptions = [{
|
|
3295
|
+
label: '默认',
|
|
3296
|
+
value: ''
|
|
3297
|
+
}, {
|
|
2964
3298
|
label: '宋体',
|
|
2965
3299
|
value: 'SimSun, STSong'
|
|
2966
3300
|
}, {
|
|
@@ -3002,7 +3336,12 @@ function FontFamilyTool() {
|
|
|
3002
3336
|
}];
|
|
3003
3337
|
const commander = core.inject(core$1.Commander);
|
|
3004
3338
|
function check(v) {
|
|
3005
|
-
|
|
3339
|
+
if (v) {
|
|
3340
|
+
commander.applyFormat(fontFamilyFormatter, v);
|
|
3341
|
+
}
|
|
3342
|
+
else {
|
|
3343
|
+
commander.unApplyFormat(fontFamilyFormatter);
|
|
3344
|
+
}
|
|
3006
3345
|
}
|
|
3007
3346
|
const refreshService = core.inject(exports.RefreshService);
|
|
3008
3347
|
const query = core.inject(core$1.Query);
|
|
@@ -3011,7 +3350,7 @@ function FontFamilyTool() {
|
|
|
3011
3350
|
const result = query.queryFormat(fontFamilyFormatter);
|
|
3012
3351
|
const isHighlight = result.state === core$1.QueryStateType.Enabled;
|
|
3013
3352
|
highlight.set(isHighlight);
|
|
3014
|
-
currentFontFamily.set(isHighlight ? result.value : '
|
|
3353
|
+
currentFontFamily.set(isHighlight ? result.value : '');
|
|
3015
3354
|
});
|
|
3016
3355
|
core.onUnmounted(() => {
|
|
3017
3356
|
subscription.unsubscribe();
|
|
@@ -3019,7 +3358,7 @@ function FontFamilyTool() {
|
|
|
3019
3358
|
return () => {
|
|
3020
3359
|
var _a;
|
|
3021
3360
|
return (jsxRuntime.jsx(Dropdown, { onCheck: check, menu: fontFamilyOptions.map(i => {
|
|
3022
|
-
const disabled = !i.value.split(',').map(i => isSupportFont(i.trim())).some(v => v);
|
|
3361
|
+
const disabled = i.value ? !i.value.split(',').map(i => isSupportFont(i.trim())).some(v => v) : false;
|
|
3023
3362
|
return {
|
|
3024
3363
|
label: jsxRuntime.jsx(MenuItem, { disabled: disabled, checked: currentFontFamily() === i.value, children: i.label }),
|
|
3025
3364
|
disabled,
|
|
@@ -3051,7 +3390,12 @@ function FontSizeTool() {
|
|
|
3051
3390
|
];
|
|
3052
3391
|
const commander = core.inject(core$1.Commander);
|
|
3053
3392
|
function check(v) {
|
|
3054
|
-
|
|
3393
|
+
if (v) {
|
|
3394
|
+
commander.applyFormat(fontSizeFormatter, v);
|
|
3395
|
+
}
|
|
3396
|
+
else {
|
|
3397
|
+
commander.unApplyFormat(fontSizeFormatter);
|
|
3398
|
+
}
|
|
3055
3399
|
}
|
|
3056
3400
|
const refreshService = core.inject(exports.RefreshService);
|
|
3057
3401
|
const query = core.inject(core$1.Query);
|
|
@@ -3091,128 +3435,396 @@ function ItalicTool() {
|
|
|
3091
3435
|
update(draft => {
|
|
3092
3436
|
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
3093
3437
|
});
|
|
3094
|
-
});
|
|
3095
|
-
core.onUnmounted(() => {
|
|
3096
|
-
sub.unsubscribe();
|
|
3097
|
-
});
|
|
3098
|
-
return () => {
|
|
3099
|
-
const vm = viewModel();
|
|
3100
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
|
|
3101
|
-
};
|
|
3102
|
-
}
|
|
3103
|
-
|
|
3104
|
-
var
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3438
|
+
});
|
|
3439
|
+
core.onUnmounted(() => {
|
|
3440
|
+
sub.unsubscribe();
|
|
3441
|
+
});
|
|
3442
|
+
return () => {
|
|
3443
|
+
const vm = viewModel();
|
|
3444
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
|
|
3445
|
+
};
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
var scopedId$a = "vf-e74208";
|
|
3449
|
+
|
|
3450
|
+
exports.EditorService = class EditorService {
|
|
3451
|
+
constructor() {
|
|
3452
|
+
this.hideInlineToolbar = false;
|
|
3453
|
+
this.canShowLeftToolbar = true;
|
|
3454
|
+
this.onLeftToolbarCanVisibleChange = new core$1.Subject();
|
|
3455
|
+
}
|
|
3456
|
+
changeLeftToolbarVisible(b) {
|
|
3457
|
+
this.canShowLeftToolbar = b;
|
|
3458
|
+
this.onLeftToolbarCanVisibleChange.next();
|
|
3459
|
+
}
|
|
3460
|
+
};
|
|
3461
|
+
exports.EditorService = __decorate([
|
|
3462
|
+
core.Injectable({
|
|
3463
|
+
provideIn: 'root'
|
|
3464
|
+
})
|
|
3465
|
+
], exports.EditorService);
|
|
3466
|
+
|
|
3467
|
+
function LinkTool(props) {
|
|
3468
|
+
const selectionBridge = core.inject(platformBrowser.SelectionBridge);
|
|
3469
|
+
const selection = core.inject(core$1.Selection);
|
|
3470
|
+
const commander = core.inject(core$1.Commander);
|
|
3471
|
+
const editorService = core.inject(exports.EditorService);
|
|
3472
|
+
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
3473
|
+
const isShow = core.createSignal(false);
|
|
3474
|
+
const inputRef = core.createRef();
|
|
3475
|
+
function setLink(ev) {
|
|
3476
|
+
ev.preventDefault();
|
|
3477
|
+
const value = inputRef.current.value;
|
|
3478
|
+
if (value) {
|
|
3479
|
+
commander.applyFormat(linkFormatter, {
|
|
3480
|
+
href: value,
|
|
3481
|
+
target: '_blanK'
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
isShow.set(false);
|
|
3485
|
+
}
|
|
3486
|
+
let isClickFromSelf = false;
|
|
3487
|
+
const sub = core$1.fromEvent(document, 'click').subscribe(() => {
|
|
3488
|
+
if (isClickFromSelf) {
|
|
3489
|
+
isClickFromSelf = false;
|
|
3490
|
+
return;
|
|
3491
|
+
}
|
|
3492
|
+
editorService.hideInlineToolbar = false;
|
|
3493
|
+
isShow.set(false);
|
|
3494
|
+
});
|
|
3495
|
+
core.onUnmounted(() => {
|
|
3496
|
+
sub.unsubscribe();
|
|
3497
|
+
});
|
|
3498
|
+
return scopedCss.withScopedCSS(scopedId$a, () => {
|
|
3499
|
+
const containerRect = container.getBoundingClientRect();
|
|
3500
|
+
const rect = isShow() ? selectionBridge.getRect({
|
|
3501
|
+
slot: selection.focusSlot,
|
|
3502
|
+
offset: selection.focusOffset
|
|
3503
|
+
}) : {};
|
|
3504
|
+
return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { onClick: () => {
|
|
3505
|
+
var _a;
|
|
3506
|
+
isShow.set(true);
|
|
3507
|
+
isClickFromSelf = true;
|
|
3508
|
+
(_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
3509
|
+
}, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
|
|
3510
|
+
jsxRuntime.jsx(Popup, { left: rect.left - containerRect.left, top: rect.top + rect.height - containerRect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
|
|
3511
|
+
isClickFromSelf = true;
|
|
3512
|
+
}, class: "input-group", children: [jsxRuntime.jsx("input", { ref: inputRef, placeholder: "\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740", type: "text" }), jsxRuntime.jsx(Button, { type: "submit", children: "\u786E\u5B9A" })] }) })] }));
|
|
3513
|
+
});
|
|
3514
|
+
}
|
|
3515
|
+
|
|
3516
|
+
function StrikeThroughTool() {
|
|
3517
|
+
const query = core.inject(core$1.Query);
|
|
3518
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
3519
|
+
const textbus = core.inject(core$1.Textbus);
|
|
3520
|
+
const [viewModel, update] = hooks.useProduce({
|
|
3521
|
+
highlight: false,
|
|
3522
|
+
disabled: false,
|
|
3523
|
+
});
|
|
3524
|
+
function toggle() {
|
|
3525
|
+
toggleStrikeThrough(textbus);
|
|
3526
|
+
}
|
|
3527
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
3528
|
+
const state = query.queryFormat(strikeThroughFormatter);
|
|
3529
|
+
update(draft => {
|
|
3530
|
+
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
3531
|
+
});
|
|
3532
|
+
});
|
|
3533
|
+
core.onUnmounted(() => {
|
|
3534
|
+
sub.unsubscribe();
|
|
3535
|
+
});
|
|
3536
|
+
return () => {
|
|
3537
|
+
const vm = viewModel();
|
|
3538
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
|
|
3539
|
+
};
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
function UnderlineTool() {
|
|
3543
|
+
const query = core.inject(core$1.Query);
|
|
3544
|
+
const refreshService = core.inject(exports.RefreshService);
|
|
3545
|
+
const textbus = core.inject(core$1.Textbus);
|
|
3546
|
+
const [viewModel, update] = hooks.useProduce({
|
|
3547
|
+
highlight: false,
|
|
3548
|
+
disabled: false,
|
|
3549
|
+
});
|
|
3550
|
+
function toggle() {
|
|
3551
|
+
toggleUnderline(textbus);
|
|
3552
|
+
}
|
|
3553
|
+
const sub = refreshService.onRefresh.subscribe(() => {
|
|
3554
|
+
const state = query.queryFormat(underlineFormatter);
|
|
3555
|
+
update(draft => {
|
|
3556
|
+
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
3557
|
+
});
|
|
3558
|
+
});
|
|
3559
|
+
core.onUnmounted(() => {
|
|
3560
|
+
sub.unsubscribe();
|
|
3561
|
+
});
|
|
3562
|
+
return () => {
|
|
3563
|
+
const vm = viewModel();
|
|
3564
|
+
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-underline" }) });
|
|
3565
|
+
};
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
var scopedId$9 = "vf-cf8e1c";
|
|
3569
|
+
|
|
3570
|
+
class FileUploader {
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
class ImageComponent extends core$1.Component {
|
|
3574
|
+
static fromJSON(textbus, json) {
|
|
3575
|
+
return new ImageComponent(textbus, Object.assign({}, json));
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
ImageComponent.type = core$1.ContentType.InlineComponent;
|
|
3579
|
+
ImageComponent.componentName = 'ImageComponent';
|
|
3580
|
+
function ImageView(props) {
|
|
3581
|
+
const { name, state } = props.component;
|
|
3582
|
+
const imageRef = core.createRef();
|
|
3583
|
+
const readonly = useReadonly();
|
|
3584
|
+
const output = useOutput();
|
|
3585
|
+
return () => {
|
|
3586
|
+
if (readonly() || output()) {
|
|
3587
|
+
return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("img", { alt: "", src: state.src, style: {
|
|
3588
|
+
width: state.width,
|
|
3589
|
+
height: state.height
|
|
3590
|
+
} }) }));
|
|
3591
|
+
}
|
|
3592
|
+
return (jsxRuntime.jsx("div", { class: "xnote-image", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx(DragResize, { source: imageRef, component: props.component, children: jsxRuntime.jsx("img", { alt: "", ref: imageRef, src: state.src, style: {
|
|
3593
|
+
width: state.width,
|
|
3594
|
+
height: state.height
|
|
3595
|
+
} }) }) }));
|
|
3596
|
+
};
|
|
3597
|
+
}
|
|
3598
|
+
const imageComponentLoader = {
|
|
3599
|
+
match(element) {
|
|
3600
|
+
return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
|
|
3601
|
+
},
|
|
3602
|
+
read(element, textbus) {
|
|
3603
|
+
const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
|
|
3604
|
+
return new ImageComponent(textbus, {
|
|
3605
|
+
src: img.src,
|
|
3606
|
+
width: img.style.width || 'auto',
|
|
3607
|
+
height: img.style.height || 'auto'
|
|
3608
|
+
});
|
|
3609
|
+
}
|
|
3610
|
+
};
|
|
3611
|
+
|
|
3612
|
+
class VideoComponent extends core$1.Component {
|
|
3613
|
+
static fromJSON(textbus, json) {
|
|
3614
|
+
return new VideoComponent(textbus, Object.assign({}, json));
|
|
3615
|
+
}
|
|
3616
|
+
setup() {
|
|
3617
|
+
//
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
VideoComponent.type = core$1.ContentType.InlineComponent;
|
|
3621
|
+
VideoComponent.componentName = 'VideoComponent';
|
|
3622
|
+
function VideoView(props) {
|
|
3623
|
+
const { name, state } = props.component;
|
|
3624
|
+
const videoRef = core.createRef();
|
|
3625
|
+
const readonly = useReadonly();
|
|
3626
|
+
const output = useOutput();
|
|
3627
|
+
return () => {
|
|
3628
|
+
if (readonly() || output()) {
|
|
3629
|
+
return (jsxRuntime.jsx("div", { class: "xnote-video", ref: props.rootRef, "data-component": name, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
|
|
3630
|
+
width: state.width,
|
|
3631
|
+
height: state.height
|
|
3632
|
+
} }) }));
|
|
3633
|
+
}
|
|
3634
|
+
return (jsxRuntime.jsx("div", { ref: props.rootRef, class: "xnote-video", "data-component": name, children: jsxRuntime.jsx(DragResize, { source: videoRef, component: props.component, children: jsxRuntime.jsx("video", { ref: videoRef, src: state.src, style: {
|
|
3635
|
+
width: state.width,
|
|
3636
|
+
height: state.height
|
|
3637
|
+
} }) }) }));
|
|
3638
|
+
};
|
|
3639
|
+
}
|
|
3640
|
+
const videoComponentLoader = {
|
|
3641
|
+
match(element) {
|
|
3642
|
+
return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
|
|
3643
|
+
},
|
|
3644
|
+
read(element, textbus) {
|
|
3645
|
+
const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
|
|
3646
|
+
return new VideoComponent(textbus, {
|
|
3647
|
+
src: video.src,
|
|
3648
|
+
width: video.style.width || 'auto',
|
|
3649
|
+
height: video.style.height || 'auto'
|
|
3650
|
+
});
|
|
3651
|
+
}
|
|
3652
|
+
};
|
|
3653
|
+
|
|
3654
|
+
class KatexEditor extends core$1.Textbus {
|
|
3655
|
+
constructor() {
|
|
3656
|
+
const adapter = new adapterViewfly.ViewflyAdapter({
|
|
3657
|
+
[SourceCodeComponent.componentName]: SourceCodeView
|
|
3658
|
+
}, (host, root, injector) => {
|
|
3659
|
+
const appInjector = new core.ReflectiveInjector(injector, [{
|
|
3660
|
+
provide: OutputInjectionToken,
|
|
3661
|
+
useValue: true
|
|
3662
|
+
}]);
|
|
3663
|
+
const app = platformBrowser$1.createApp(root, {
|
|
3664
|
+
context: appInjector
|
|
3665
|
+
}).mount(host);
|
|
3666
|
+
return () => {
|
|
3667
|
+
app.destroy();
|
|
3668
|
+
};
|
|
3669
|
+
});
|
|
3670
|
+
const browserModule = new platformBrowser.BrowserModule({
|
|
3671
|
+
adapter,
|
|
3672
|
+
renderTo: () => {
|
|
3673
|
+
return this.host;
|
|
3674
|
+
}
|
|
3675
|
+
});
|
|
3676
|
+
super({
|
|
3677
|
+
components: [
|
|
3678
|
+
SourceCodeComponent
|
|
3679
|
+
],
|
|
3680
|
+
imports: [browserModule]
|
|
3681
|
+
});
|
|
3682
|
+
this.onValueChange = new core$1.Subject();
|
|
3683
|
+
}
|
|
3684
|
+
mount(host, code) {
|
|
3685
|
+
this.host = host;
|
|
3686
|
+
const model = new SourceCodeComponent(this, {
|
|
3687
|
+
lineNumber: true,
|
|
3688
|
+
autoBreak: true,
|
|
3689
|
+
lang: 'latex',
|
|
3690
|
+
theme: 'github',
|
|
3691
|
+
slots: code.split('\n').map(i => {
|
|
3692
|
+
const slot = new core$1.Slot([core$1.ContentType.Text]);
|
|
3693
|
+
slot.insert(i);
|
|
3694
|
+
return {
|
|
3695
|
+
slot,
|
|
3696
|
+
emphasize: false
|
|
3697
|
+
};
|
|
3698
|
+
})
|
|
3699
|
+
});
|
|
3700
|
+
this.onChange.subscribe(() => {
|
|
3701
|
+
const str = model.state.slots.map(i => {
|
|
3702
|
+
if (i.slot.isEmpty) {
|
|
3703
|
+
return '';
|
|
3704
|
+
}
|
|
3705
|
+
return i.slot.toString();
|
|
3706
|
+
}).join('\n');
|
|
3707
|
+
this.onValueChange.next(str);
|
|
3708
|
+
});
|
|
3709
|
+
return this.render(model);
|
|
3123
3710
|
}
|
|
3124
|
-
let isClickFromSelf = false;
|
|
3125
|
-
const sub = core$1.fromEvent(document, 'click').subscribe(() => {
|
|
3126
|
-
if (isClickFromSelf) {
|
|
3127
|
-
isClickFromSelf = false;
|
|
3128
|
-
return;
|
|
3129
|
-
}
|
|
3130
|
-
isShow.set(false);
|
|
3131
|
-
});
|
|
3132
|
-
core.onUnmounted(() => {
|
|
3133
|
-
sub.unsubscribe();
|
|
3134
|
-
});
|
|
3135
|
-
return scopedCss.withScopedCSS(css$9, () => {
|
|
3136
|
-
const containerRect = container.getBoundingClientRect();
|
|
3137
|
-
const rect = isShow() ? selectionBridge.getRect({
|
|
3138
|
-
slot: selection.focusSlot,
|
|
3139
|
-
offset: selection.focusOffset
|
|
3140
|
-
}) : {};
|
|
3141
|
-
return (jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx(Button, { onClick: () => {
|
|
3142
|
-
isShow.set(true);
|
|
3143
|
-
isClickFromSelf = true;
|
|
3144
|
-
setTimeout(() => { var _a; return (_a = props.hideToolbar) === null || _a === void 0 ? void 0 : _a.call(props); }, 10);
|
|
3145
|
-
}, arrow: true, children: jsxRuntime.jsx("span", { class: "xnote-icon-link" }) }), isShow() &&
|
|
3146
|
-
jsxRuntime.jsx(Popup, { left: rect.left - containerRect.left, top: rect.top + rect.height - containerRect.top, children: jsxRuntime.jsxs("form", { onSubmit: setLink, onClick: () => {
|
|
3147
|
-
isClickFromSelf = true;
|
|
3148
|
-
}, class: "input-group", children: [jsxRuntime.jsx("input", { ref: inputRef, placeholder: "\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740", type: "text" }), jsxRuntime.jsx(Button, { type: "submit", children: "\u786E\u5B9A" })] }) })] }));
|
|
3149
|
-
});
|
|
3150
3711
|
}
|
|
3151
3712
|
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
const textbus = core.inject(core$1.Textbus);
|
|
3156
|
-
const [viewModel, update] = hooks.useProduce({
|
|
3157
|
-
highlight: false,
|
|
3158
|
-
disabled: false,
|
|
3159
|
-
});
|
|
3160
|
-
function toggle() {
|
|
3161
|
-
toggleStrikeThrough(textbus);
|
|
3713
|
+
class KatexComponent extends core$1.Component {
|
|
3714
|
+
static fromJSON(textbus, state) {
|
|
3715
|
+
return new KatexComponent(textbus, state);
|
|
3162
3716
|
}
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3717
|
+
constructor(textbus, state = {
|
|
3718
|
+
text: '% \\f is defined as #1f(#2) using the macro\n' +
|
|
3719
|
+
'\\f\\relax{x} = \\int_{-\\infty}^\\infty\n' +
|
|
3720
|
+
'\\f\\hat\\xi\\,e^{2 \\pi i \\xi x}\n' +
|
|
3721
|
+
'\\,d\\xi'
|
|
3722
|
+
}) {
|
|
3723
|
+
super(textbus, state);
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
KatexComponent.componentName = 'KatexComponent';
|
|
3727
|
+
KatexComponent.type = core$1.ContentType.InlineComponent;
|
|
3728
|
+
function domToVDom(el) {
|
|
3729
|
+
const attrs = {};
|
|
3730
|
+
el.getAttributeNames().forEach(key => {
|
|
3731
|
+
attrs[key] = el.getAttribute(key);
|
|
3168
3732
|
});
|
|
3169
|
-
|
|
3170
|
-
|
|
3733
|
+
attrs.children = Array.from(el.childNodes).map(child => {
|
|
3734
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
3735
|
+
return domToVDom(child);
|
|
3736
|
+
}
|
|
3737
|
+
return child.textContent || '';
|
|
3171
3738
|
});
|
|
3172
|
-
return ()
|
|
3173
|
-
const vm = viewModel();
|
|
3174
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
|
|
3175
|
-
};
|
|
3739
|
+
return core.jsx(el.tagName.toLowerCase(), attrs);
|
|
3176
3740
|
}
|
|
3177
|
-
|
|
3178
|
-
function
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3741
|
+
function KatexComponentView(props) {
|
|
3742
|
+
function toDOM(value) {
|
|
3743
|
+
let htmlString;
|
|
3744
|
+
try {
|
|
3745
|
+
htmlString = Katex.renderToString(value, {
|
|
3746
|
+
displayMode: true,
|
|
3747
|
+
leqno: false,
|
|
3748
|
+
fleqn: false,
|
|
3749
|
+
throwOnError: true,
|
|
3750
|
+
errorColor: '#cc0000',
|
|
3751
|
+
strict: 'warn',
|
|
3752
|
+
output: 'html',
|
|
3753
|
+
trust: false,
|
|
3754
|
+
macros: { '\\f': '#1f(#2)' }
|
|
3755
|
+
});
|
|
3756
|
+
}
|
|
3757
|
+
catch (e) {
|
|
3758
|
+
htmlString = '<span style="color: red">公式错误</span>';
|
|
3759
|
+
}
|
|
3760
|
+
return new DOMParser().parseFromString(htmlString, 'text/html').body.children[0];
|
|
3188
3761
|
}
|
|
3189
|
-
const
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3762
|
+
const selection = core.inject(core$1.Textbus);
|
|
3763
|
+
const editorRef = core.createDynamicRef(node => {
|
|
3764
|
+
const editor = new KatexEditor();
|
|
3765
|
+
editor.mount(node, props.component.state.text).then(() => {
|
|
3766
|
+
editor.focus();
|
|
3193
3767
|
});
|
|
3768
|
+
selection.blur();
|
|
3769
|
+
const subscription = editor.onValueChange.subscribe((value) => {
|
|
3770
|
+
props.component.state.text = value;
|
|
3771
|
+
}).add(core$1.fromEvent(node, 'mousedown').subscribe(ev => ev.stopPropagation()), core$1.fromEvent(document, 'mousedown').subscribe(() => {
|
|
3772
|
+
var _a;
|
|
3773
|
+
(_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(false);
|
|
3774
|
+
}));
|
|
3775
|
+
return () => {
|
|
3776
|
+
subscription.unsubscribe();
|
|
3777
|
+
editor.destroy();
|
|
3778
|
+
};
|
|
3194
3779
|
});
|
|
3195
|
-
core.
|
|
3196
|
-
|
|
3197
|
-
|
|
3780
|
+
const dropdownRef = core.createRef();
|
|
3781
|
+
const output = useOutput();
|
|
3782
|
+
const readonly = useReadonly();
|
|
3198
3783
|
return () => {
|
|
3199
|
-
const
|
|
3200
|
-
return
|
|
3784
|
+
const text = props.component.state.text;
|
|
3785
|
+
return (jsxRuntime.jsx("span", { onClick: () => {
|
|
3786
|
+
var _a;
|
|
3787
|
+
(_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.isShow(true);
|
|
3788
|
+
}, ref: props.rootRef, "data-component": KatexComponent.componentName, "data-katex": encodeURIComponent(text), class: "xnote-katex", children: (output() || readonly()) ?
|
|
3789
|
+
domToVDom(toDOM(text))
|
|
3790
|
+
:
|
|
3791
|
+
jsxRuntime.jsx(Dropdown, { padding: '0', ref: dropdownRef, trigger: 'none', width: '600px', menu: jsxRuntime.jsx("div", { class: "xnote-katex-input", ref: editorRef }), children: domToVDom(toDOM(text)) }) }));
|
|
3201
3792
|
};
|
|
3202
3793
|
}
|
|
3203
|
-
|
|
3204
|
-
|
|
3794
|
+
const katexComponentLoader = {
|
|
3795
|
+
match(element) {
|
|
3796
|
+
return element.dataset.component === KatexComponent.componentName;
|
|
3797
|
+
},
|
|
3798
|
+
read(element, textbus) {
|
|
3799
|
+
const value = element.dataset.katex || '';
|
|
3800
|
+
return new KatexComponent(textbus, {
|
|
3801
|
+
text: decodeURIComponent(value)
|
|
3802
|
+
});
|
|
3803
|
+
}
|
|
3804
|
+
};
|
|
3205
3805
|
|
|
3206
3806
|
function InsertTool(props) {
|
|
3207
3807
|
const commander = core.inject(core$1.Commander);
|
|
3208
3808
|
const selection = core.inject(core$1.Selection);
|
|
3209
3809
|
const textbus = core.inject(core$1.Textbus);
|
|
3810
|
+
const fileUploader = core.inject(FileUploader, null);
|
|
3811
|
+
const dropdownContextService = core.inject(exports.DropdownContextService);
|
|
3210
3812
|
function insert(type) {
|
|
3211
3813
|
var _a;
|
|
3212
3814
|
const component = (_a = props.slot) === null || _a === void 0 ? void 0 : _a.parent;
|
|
3213
3815
|
if (!component) {
|
|
3214
3816
|
return;
|
|
3215
3817
|
}
|
|
3818
|
+
function insertComponent(comp) {
|
|
3819
|
+
if (props.replace) {
|
|
3820
|
+
commander.replaceComponent(component, comp);
|
|
3821
|
+
}
|
|
3822
|
+
else {
|
|
3823
|
+
commander.insertAfter(comp, component);
|
|
3824
|
+
}
|
|
3825
|
+
dropdownContextService.canHide = true;
|
|
3826
|
+
dropdownContextService.hide(false);
|
|
3827
|
+
}
|
|
3216
3828
|
switch (type) {
|
|
3217
3829
|
case 'h1':
|
|
3218
3830
|
case 'h2':
|
|
@@ -3227,12 +3839,12 @@ function InsertTool(props) {
|
|
|
3227
3839
|
core$1.ContentType.Text
|
|
3228
3840
|
]);
|
|
3229
3841
|
if (/h[1-6]/.test(type)) {
|
|
3230
|
-
slot.setAttribute(headingAttr,
|
|
3842
|
+
slot.setAttribute(headingAttr, type);
|
|
3231
3843
|
}
|
|
3232
3844
|
const p = new ParagraphComponent(textbus, {
|
|
3233
3845
|
slot
|
|
3234
3846
|
});
|
|
3235
|
-
|
|
3847
|
+
insertComponent(p);
|
|
3236
3848
|
selection.setPosition(slot, 0);
|
|
3237
3849
|
}
|
|
3238
3850
|
break;
|
|
@@ -3248,7 +3860,7 @@ function InsertTool(props) {
|
|
|
3248
3860
|
reorder: true,
|
|
3249
3861
|
type: type === 'ol' ? 'OrderedList' : 'UnorderedList'
|
|
3250
3862
|
});
|
|
3251
|
-
|
|
3863
|
+
insertComponent(list);
|
|
3252
3864
|
selection.setPosition(slot, 0);
|
|
3253
3865
|
}
|
|
3254
3866
|
break;
|
|
@@ -3265,15 +3877,17 @@ function InsertTool(props) {
|
|
|
3265
3877
|
emphasize: false
|
|
3266
3878
|
}]
|
|
3267
3879
|
});
|
|
3268
|
-
|
|
3880
|
+
insertComponent(comp);
|
|
3269
3881
|
selection.setPosition(slot, 0);
|
|
3270
3882
|
}
|
|
3271
3883
|
break;
|
|
3272
3884
|
case 'table':
|
|
3273
3885
|
{
|
|
3274
3886
|
const table = new TableComponent(textbus);
|
|
3275
|
-
|
|
3276
|
-
|
|
3887
|
+
insertComponent(table);
|
|
3888
|
+
textbus.nextTick(() => {
|
|
3889
|
+
selection.selectFirstPosition(table, true, true);
|
|
3890
|
+
});
|
|
3277
3891
|
}
|
|
3278
3892
|
break;
|
|
3279
3893
|
case 'todolist':
|
|
@@ -3286,31 +3900,56 @@ function InsertTool(props) {
|
|
|
3286
3900
|
slot,
|
|
3287
3901
|
checked: false
|
|
3288
3902
|
});
|
|
3289
|
-
|
|
3903
|
+
insertComponent(comp);
|
|
3290
3904
|
selection.setPosition(slot, 0);
|
|
3291
3905
|
}
|
|
3292
3906
|
break;
|
|
3293
3907
|
case 'image':
|
|
3908
|
+
if (fileUploader) {
|
|
3909
|
+
Promise.resolve().then(() => fileUploader.uploadFile('image')).then(url => {
|
|
3910
|
+
const img = new ImageComponent(textbus, {
|
|
3911
|
+
src: url
|
|
3912
|
+
});
|
|
3913
|
+
commander.insert(img);
|
|
3914
|
+
});
|
|
3915
|
+
}
|
|
3294
3916
|
break;
|
|
3295
3917
|
case 'video':
|
|
3918
|
+
if (fileUploader) {
|
|
3919
|
+
Promise.resolve().then(() => fileUploader.uploadFile('video')).then(url => {
|
|
3920
|
+
const img = new VideoComponent(textbus, {
|
|
3921
|
+
src: url
|
|
3922
|
+
});
|
|
3923
|
+
commander.insert(img);
|
|
3924
|
+
});
|
|
3925
|
+
}
|
|
3296
3926
|
break;
|
|
3297
3927
|
case 'highlightBox':
|
|
3298
3928
|
{
|
|
3299
3929
|
const p = new ParagraphComponent(textbus);
|
|
3300
3930
|
const comp = new HighlightBoxComponent(textbus);
|
|
3301
3931
|
comp.state.slot.insert(p);
|
|
3302
|
-
|
|
3932
|
+
insertComponent(comp);
|
|
3303
3933
|
selection.setPosition(p.state.slot, 0);
|
|
3304
3934
|
}
|
|
3305
3935
|
break;
|
|
3936
|
+
case 'katex':
|
|
3937
|
+
{
|
|
3938
|
+
const p = new ParagraphComponent(textbus);
|
|
3939
|
+
const comp = new KatexComponent(textbus);
|
|
3940
|
+
p.state.slot.insert(comp);
|
|
3941
|
+
insertComponent(p);
|
|
3942
|
+
selection.selectComponent(comp);
|
|
3943
|
+
}
|
|
3944
|
+
break;
|
|
3306
3945
|
}
|
|
3307
3946
|
}
|
|
3308
|
-
return scopedCss.withScopedCSS(
|
|
3309
|
-
return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h5'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h6'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(MenuItem, { onClick: () => insert('table'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-table" }), children: "\u8868\u683C" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('todolist'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }), children: "\u5F85\u529E\u5217\u8868" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('image'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-image" }), children: "\u56FE\u7247" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('video'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-video" }), children: "\u89C6\u9891" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('highlightBox'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-
|
|
3947
|
+
return scopedCss.withScopedCSS(scopedId$9, () => {
|
|
3948
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.hideTitle ? null : jsxRuntime.jsx(MenuHeading, { children: props.replace ? '替换为' : '在下面添加' }), jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h5'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h5" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('h6'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h6" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, onClick: () => insert('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(MenuItem, { onClick: () => insert('table'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-table" }), children: "\u8868\u683C" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('todolist'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }), children: "\u5F85\u529E\u5217\u8868" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('image'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-image" }), children: "\u56FE\u7247" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('video'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-video" }), children: "\u89C6\u9891" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('highlightBox'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-hightlight-box" }), children: "\u9AD8\u4EAE\u5757" }), jsxRuntime.jsx(MenuItem, { onClick: () => insert('katex'), icon: jsxRuntime.jsx("span", { class: "xnote-icon-function" }), children: "\u6570\u5B66\u516C\u5F0F" })] });
|
|
3310
3949
|
});
|
|
3311
3950
|
}
|
|
3312
3951
|
|
|
3313
|
-
var
|
|
3952
|
+
var scopedId$8 = "vf-b05292";
|
|
3314
3953
|
|
|
3315
3954
|
const LeftToolbar = core.withAnnotation({
|
|
3316
3955
|
providers: [exports.RefreshService]
|
|
@@ -3320,6 +3959,7 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3320
3959
|
const selection = core.inject(core$1.Selection);
|
|
3321
3960
|
const rootComponentRef = core.inject(core$1.RootComponentRef);
|
|
3322
3961
|
const refreshService = core.inject(exports.RefreshService);
|
|
3962
|
+
const editorService = core.inject(exports.EditorService);
|
|
3323
3963
|
const checkStates = useActiveBlock();
|
|
3324
3964
|
const toBlock = useBlockTransform();
|
|
3325
3965
|
const activeSlot = core.createSignal(null);
|
|
@@ -3338,18 +3978,29 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3338
3978
|
top: 0,
|
|
3339
3979
|
display: false
|
|
3340
3980
|
});
|
|
3981
|
+
const sub = editorService.onLeftToolbarCanVisibleChange.subscribe(() => {
|
|
3982
|
+
updatePosition(d => {
|
|
3983
|
+
d.display = editorService.canShowLeftToolbar;
|
|
3984
|
+
});
|
|
3985
|
+
});
|
|
3986
|
+
core.onUnmounted(() => {
|
|
3987
|
+
sub.unsubscribe();
|
|
3988
|
+
});
|
|
3989
|
+
let isIgnoreMove = false;
|
|
3341
3990
|
core.onMounted(() => {
|
|
3342
3991
|
const rootComponent = rootComponentRef.component;
|
|
3343
3992
|
const docContentContainer = adapter.getNativeNodeBySlot(rootComponent.state.content);
|
|
3344
3993
|
const sub = core$1.fromEvent(docContentContainer, 'mousemove').pipe(core$1.filter(() => {
|
|
3345
|
-
return
|
|
3994
|
+
return !isIgnoreMove;
|
|
3346
3995
|
}), core$1.map(ev => {
|
|
3996
|
+
var _a;
|
|
3347
3997
|
let currentNode = ev.target;
|
|
3348
3998
|
while (currentNode) {
|
|
3349
3999
|
const slot = adapter.getSlotByNativeNode(currentNode);
|
|
3350
4000
|
if (slot) {
|
|
3351
|
-
if ((slot === null || slot === void 0 ? void 0 : slot.parent)
|
|
3352
|
-
|
|
4001
|
+
if (((_a = slot === null || slot === void 0 ? void 0 : slot.parent) === null || _a === void 0 ? void 0 : _a.type) === core$1.ContentType.InlineComponent) {
|
|
4002
|
+
currentNode = currentNode.parentNode;
|
|
4003
|
+
continue;
|
|
3353
4004
|
}
|
|
3354
4005
|
return slot;
|
|
3355
4006
|
}
|
|
@@ -3364,7 +4015,9 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3364
4015
|
activeSlot.set(slot);
|
|
3365
4016
|
if (slot) {
|
|
3366
4017
|
checkStates(slot);
|
|
3367
|
-
isEmptyBlock.set(slot.parent instanceof ParagraphComponent && slot.isEmpty)
|
|
4018
|
+
isEmptyBlock.set((slot.parent instanceof ParagraphComponent && slot.isEmpty) ||
|
|
4019
|
+
slot.parent instanceof SourceCodeComponent ||
|
|
4020
|
+
slot.parent instanceof TableComponent);
|
|
3368
4021
|
const nativeNode = adapter.getNativeNodeByComponent(slot.parent);
|
|
3369
4022
|
updatePosition(draft => {
|
|
3370
4023
|
const containerRect = docContentContainer.getBoundingClientRect();
|
|
@@ -3417,18 +4070,6 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3417
4070
|
isShow.set(true);
|
|
3418
4071
|
}));
|
|
3419
4072
|
});
|
|
3420
|
-
let snapshot = null;
|
|
3421
|
-
function queryBefore() {
|
|
3422
|
-
const slot = activeSlot();
|
|
3423
|
-
if (slot) {
|
|
3424
|
-
snapshot = selection.createSnapshot();
|
|
3425
|
-
selection.selectSlot(slot);
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
function queryAfter() {
|
|
3429
|
-
snapshot === null || snapshot === void 0 ? void 0 : snapshot.restore();
|
|
3430
|
-
snapshot = null;
|
|
3431
|
-
}
|
|
3432
4073
|
function applyBefore() {
|
|
3433
4074
|
const slot = activeSlot();
|
|
3434
4075
|
if (slot) {
|
|
@@ -3469,11 +4110,15 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3469
4110
|
}
|
|
3470
4111
|
}
|
|
3471
4112
|
const isEmptyBlock = core.createSignal(true);
|
|
3472
|
-
|
|
4113
|
+
function changeIgnoreMove(b) {
|
|
4114
|
+
isIgnoreMove = b;
|
|
4115
|
+
}
|
|
4116
|
+
return scopedCss.withScopedCSS(scopedId$8, () => {
|
|
4117
|
+
var _a;
|
|
3473
4118
|
const position = positionSignal();
|
|
3474
4119
|
const slot = activeSlot();
|
|
3475
4120
|
let activeNode = jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" });
|
|
3476
|
-
const states = checkStates();
|
|
4121
|
+
const states = checkStates(slot);
|
|
3477
4122
|
if (slot) {
|
|
3478
4123
|
const types = [
|
|
3479
4124
|
[states.paragraph, jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" })],
|
|
@@ -3497,15 +4142,20 @@ const LeftToolbar = core.withAnnotation({
|
|
|
3497
4142
|
}
|
|
3498
4143
|
}
|
|
3499
4144
|
}
|
|
4145
|
+
const activeParentComponent = (_a = activeSlot()) === null || _a === void 0 ? void 0 : _a.parent;
|
|
4146
|
+
const needInsert = activeParentComponent instanceof TableComponent || activeParentComponent instanceof SourceCodeComponent;
|
|
3500
4147
|
return (jsxRuntime.jsx("div", { class: "left-toolbar", ref: toolbarRef, children: jsxRuntime.jsx("div", { class: "left-toolbar-btn-wrap", ref: btnRef, style: {
|
|
3501
4148
|
left: position.left + 'px',
|
|
3502
4149
|
top: position.top + 'px',
|
|
3503
|
-
display: position.display && selection.isCollapsed ? 'block' : 'none'
|
|
3504
|
-
}, children: jsxRuntime.jsx(Dropdown, { abreast: true, style: {
|
|
4150
|
+
display: position.display && selection.isCollapsed && editorService.canShowLeftToolbar ? 'block' : 'none'
|
|
4151
|
+
}, children: jsxRuntime.jsx(Dropdown, { toLeft: true, onExpendStateChange: changeIgnoreMove, abreast: true, style: {
|
|
3505
4152
|
position: 'absolute',
|
|
3506
4153
|
right: 0,
|
|
3507
4154
|
top: 0
|
|
3508
|
-
}, menu:
|
|
4155
|
+
}, menu: isEmptyBlock() ?
|
|
4156
|
+
jsxRuntime.jsx(InsertTool, { replace: !needInsert, slot: activeSlot() })
|
|
4157
|
+
:
|
|
4158
|
+
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { class: "btn-group", children: [jsxRuntime.jsx(Button, { ordinary: true, highlight: states.paragraph, onClick: () => transform('paragraph'), children: jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h1, onClick: () => transform('h1'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h1" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h2, onClick: () => transform('h2'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h2" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h3, onClick: () => transform('h3'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h3" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.h4, onClick: () => transform('h4'), children: jsxRuntime.jsx("span", { class: "xnote-icon-heading-h4" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.todolist, onClick: () => transform('todolist'), children: jsxRuntime.jsx("span", { class: "xnote-icon-checkbox-checked" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.orderedList, onClick: () => transform('ol'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list-numbered" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.unorderedList, onClick: () => transform('ul'), children: jsxRuntime.jsx("span", { class: "xnote-icon-list" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.blockquote, onClick: () => transform('blockquote'), children: jsxRuntime.jsx("span", { class: "xnote-icon-quotes-right" }) }), jsxRuntime.jsx(Button, { ordinary: true, highlight: states.sourceCode, onClick: () => transform('sourceCode'), children: jsxRuntime.jsx("span", { class: "xnote-icon-source-code" }) })] }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(AttrTool, { style: { display: 'block' }, abreast: true, slot: slot, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-indent-decrease" }), children: "\u7F29\u8FDB\u548C\u5BF9\u9F50" }) }), jsxRuntime.jsx(ColorTool, { style: { display: 'block' }, abreast: true, applyBefore: applyBefore, children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-color" }), children: "\u989C\u8272" }) }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(MenuItem, { onClick: copy, icon: jsxRuntime.jsx("span", { class: "xnote-icon-copy" }), children: "\u590D\u5236" }), jsxRuntime.jsx(MenuItem, { onClick: remove, icon: jsxRuntime.jsx("span", { class: "xnote-icon-bin" }), children: "\u5220\u9664" }), jsxRuntime.jsx(MenuItem, { onClick: cut, icon: jsxRuntime.jsx("span", { class: "xnote-icon-cut" }), children: "\u526A\u5207" }), jsxRuntime.jsx(Divider, {}), jsxRuntime.jsx(Dropdown, { style: { display: 'block' }, abreast: true, menu: jsxRuntime.jsx(InsertTool, { hideTitle: true, slot: activeSlot() }), children: jsxRuntime.jsx(MenuItem, { arrow: true, icon: jsxRuntime.jsx("span", { class: "xnote-icon-plus" }), children: "\u5728\u4E0B\u9762\u6DFB\u52A0" }) })] }), children: jsxRuntime.jsx("button", { type: "button", class: "left-toolbar-btn", children: isEmptyBlock() ?
|
|
3509
4159
|
jsxRuntime.jsx("span", { children: jsxRuntime.jsx("i", { class: "xnote-icon-plus" }) })
|
|
3510
4160
|
:
|
|
3511
4161
|
jsxRuntime.jsxs("span", { children: [activeNode, jsxRuntime.jsx("i", { style: "font-size: 12px", class: "xnote-icon-more" })] }) }) }) }) }));
|
|
@@ -3529,7 +4179,7 @@ class LeftToolbarPlugin {
|
|
|
3529
4179
|
nativeRenderer: new platformBrowser$1.DomRenderer(),
|
|
3530
4180
|
autoUpdate: true
|
|
3531
4181
|
});
|
|
3532
|
-
const viewDocument = injector.get(platformBrowser.
|
|
4182
|
+
const viewDocument = injector.get(platformBrowser.VIEW_CONTAINER);
|
|
3533
4183
|
const host = document.createElement('div');
|
|
3534
4184
|
viewDocument.appendChild(host);
|
|
3535
4185
|
this.app.mount(host);
|
|
@@ -3540,24 +4190,74 @@ class LeftToolbarPlugin {
|
|
|
3540
4190
|
}
|
|
3541
4191
|
}
|
|
3542
4192
|
|
|
3543
|
-
var
|
|
4193
|
+
var scopedId$7 = "vf-3073ba";
|
|
3544
4194
|
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
4195
|
+
function LinkJump() {
|
|
4196
|
+
const selection = core.inject(core$1.Selection);
|
|
4197
|
+
const query = core.inject(core$1.Query);
|
|
4198
|
+
const bridge = core.inject(platformBrowser.SelectionBridge);
|
|
4199
|
+
const container = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
4200
|
+
const href = core.createSignal('');
|
|
4201
|
+
const ref = core.createRef();
|
|
4202
|
+
const isShow = core.createSignal(false);
|
|
4203
|
+
function onSelectionChange() {
|
|
4204
|
+
if (selection.isCollapsed) {
|
|
4205
|
+
const queryState = query.queryFormat(linkFormatter);
|
|
4206
|
+
if (queryState.state === core$1.QueryStateType.Enabled) {
|
|
4207
|
+
const rect = bridge.getRect({
|
|
4208
|
+
slot: selection.startSlot,
|
|
4209
|
+
offset: selection.startOffset
|
|
4210
|
+
});
|
|
4211
|
+
if (rect) {
|
|
4212
|
+
const offsetRect = container.getBoundingClientRect();
|
|
4213
|
+
Object.assign(ref.current.style, {
|
|
4214
|
+
left: rect.left - offsetRect.left + 'px',
|
|
4215
|
+
top: rect.top - offsetRect.top + 'px'
|
|
4216
|
+
});
|
|
4217
|
+
isShow.set(true);
|
|
4218
|
+
let url = queryState.value.href;
|
|
4219
|
+
if (url.indexOf('://') < 0) {
|
|
4220
|
+
url = 'http://' + url;
|
|
4221
|
+
}
|
|
4222
|
+
href.set(url);
|
|
4223
|
+
return;
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
isShow.set(false);
|
|
3548
4228
|
}
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
4229
|
+
selection.onChange.pipe(core$1.delay()).subscribe(() => {
|
|
4230
|
+
onSelectionChange();
|
|
4231
|
+
});
|
|
4232
|
+
function cleanLink() {
|
|
4233
|
+
isShow.set(false);
|
|
4234
|
+
const commonAncestorSlot = selection.commonAncestorSlot;
|
|
4235
|
+
const index = selection.focusOffset;
|
|
4236
|
+
const ranges = commonAncestorSlot.getFormatRangesByFormatter(linkFormatter, 0, commonAncestorSlot.length);
|
|
4237
|
+
ranges.forEach(range => {
|
|
4238
|
+
if (range.startIndex < index && range.endIndex >= index) {
|
|
4239
|
+
commonAncestorSlot.applyFormat(linkFormatter, {
|
|
4240
|
+
startIndex: range.startIndex,
|
|
4241
|
+
endIndex: range.endIndex,
|
|
4242
|
+
value: null
|
|
4243
|
+
});
|
|
4244
|
+
}
|
|
4245
|
+
});
|
|
4246
|
+
}
|
|
4247
|
+
return platformBrowser$1.createPortal(scopedCss.withScopedCSS(scopedId$7, () => {
|
|
4248
|
+
return (jsxRuntime.jsxs("div", { ref: ref, class: "link-jump-plugin", style: { display: isShow() ? '' : 'none' }, children: [jsxRuntime.jsx("span", { onClick: cleanLink, children: "\u6E05\u9664" }), jsxRuntime.jsx("a", { target: "_blank", href: href(), children: "\u8DF3\u8F6C" })] }));
|
|
4249
|
+
}), container);
|
|
4250
|
+
}
|
|
4251
|
+
|
|
4252
|
+
var scopedId$6 = "vf-fee98b";
|
|
3555
4253
|
|
|
3556
4254
|
const Toolbar = core.withAnnotation({
|
|
3557
4255
|
providers: [exports.RefreshService]
|
|
3558
4256
|
}, function Toolbar() {
|
|
3559
4257
|
const selection = core.inject(core$1.Selection);
|
|
3560
|
-
const viewDocument = core.inject(platformBrowser.
|
|
4258
|
+
const viewDocument = core.inject(platformBrowser.VIEW_CONTAINER);
|
|
4259
|
+
const rootComponentRef = core.inject(core$1.RootComponentRef);
|
|
4260
|
+
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
3561
4261
|
const bridge = core.inject(platformBrowser.SelectionBridge);
|
|
3562
4262
|
const textbus = core.inject(core$1.Textbus);
|
|
3563
4263
|
const editorService = core.inject(exports.EditorService);
|
|
@@ -3579,7 +4279,7 @@ const Toolbar = core.withAnnotation({
|
|
|
3579
4279
|
const toolbarRef = core.createRef();
|
|
3580
4280
|
function getTop() {
|
|
3581
4281
|
const docRect = viewDocument.getBoundingClientRect();
|
|
3582
|
-
const
|
|
4282
|
+
const toolbarHeight = 36;
|
|
3583
4283
|
// const documentHeight = document.documentElement.clientHeight
|
|
3584
4284
|
const selectionFocusRect = bridge.getRect({
|
|
3585
4285
|
slot: selection.focusSlot,
|
|
@@ -3588,14 +4288,12 @@ const Toolbar = core.withAnnotation({
|
|
|
3588
4288
|
if (!selectionFocusRect) {
|
|
3589
4289
|
return null;
|
|
3590
4290
|
}
|
|
3591
|
-
// console.log(selectionFocusRect.top, toolbarRect.height)
|
|
3592
4291
|
const centerLeft = selectionFocusRect.left;
|
|
3593
|
-
const toBottom = selectionFocusRect.top <
|
|
4292
|
+
const toBottom = selectionFocusRect.top < toolbarHeight + 10;
|
|
3594
4293
|
const top = toBottom ?
|
|
3595
4294
|
selectionFocusRect.top + selectionFocusRect.height - docRect.top + 10 :
|
|
3596
|
-
selectionFocusRect.top - docRect.top -
|
|
4295
|
+
selectionFocusRect.top - docRect.top - toolbarHeight - 10;
|
|
3597
4296
|
updateViewPosition(draft => {
|
|
3598
|
-
draft.isHide = false;
|
|
3599
4297
|
draft.transitionDuration = .15;
|
|
3600
4298
|
draft.left = centerLeft - docRect.left;
|
|
3601
4299
|
draft.top = top + 10;
|
|
@@ -3616,13 +4314,15 @@ const Toolbar = core.withAnnotation({
|
|
|
3616
4314
|
sub.unsubscribe();
|
|
3617
4315
|
});
|
|
3618
4316
|
function bindMouseup() {
|
|
3619
|
-
|
|
4317
|
+
const docElement = adapter.getNativeNodeByComponent(rootComponentRef.component);
|
|
4318
|
+
mouseupSubscription = core$1.fromEvent(docElement, 'mouseup').pipe(core$1.filter(ev => {
|
|
3620
4319
|
return !ev.composedPath().includes(toolbarRef.current);
|
|
3621
4320
|
}), core$1.delay(100), core$1.filter(() => {
|
|
3622
4321
|
return !selection.isCollapsed && !(selection.commonAncestorComponent instanceof SourceCodeComponent);
|
|
3623
4322
|
}), core$1.map(getTop), core$1.delay(200)).subscribe((top) => {
|
|
3624
4323
|
if (top !== null) {
|
|
3625
4324
|
updateViewPosition(draft => {
|
|
4325
|
+
draft.isHide = false;
|
|
3626
4326
|
draft.opacity = 1;
|
|
3627
4327
|
draft.top = top;
|
|
3628
4328
|
});
|
|
@@ -3641,16 +4341,16 @@ const Toolbar = core.withAnnotation({
|
|
|
3641
4341
|
});
|
|
3642
4342
|
bindMouseup();
|
|
3643
4343
|
});
|
|
4344
|
+
const instance = core.getCurrentInstance();
|
|
3644
4345
|
function hideToolbar() {
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
});
|
|
4346
|
+
editorService.hideInlineToolbar = true;
|
|
4347
|
+
instance.markAsDirtied();
|
|
3648
4348
|
}
|
|
3649
4349
|
core.onUnmounted(() => {
|
|
3650
4350
|
mousedownSubscription.unsubscribe();
|
|
3651
4351
|
mouseupSubscription.unsubscribe();
|
|
3652
4352
|
});
|
|
3653
|
-
return scopedCss.withScopedCSS(
|
|
4353
|
+
return scopedCss.withScopedCSS(scopedId$6, () => {
|
|
3654
4354
|
const p = viewPosition();
|
|
3655
4355
|
return (jsxRuntime.jsxs("div", { class: "toolbar", ref: toolbarRef, style: {
|
|
3656
4356
|
left: p.left + 'px',
|
|
@@ -3771,53 +4471,226 @@ class Matcher {
|
|
|
3771
4471
|
if (key === 'fontFamily' && typeof styleValue === 'string') {
|
|
3772
4472
|
styleValue = styleValue.replace(/['"]/g, '');
|
|
3773
4473
|
}
|
|
3774
|
-
if (styleValue) {
|
|
3775
|
-
return optionValue.map(v => {
|
|
3776
|
-
if (v instanceof RegExp) {
|
|
3777
|
-
return v.test(styleValue);
|
|
3778
|
-
}
|
|
3779
|
-
return v === styleValue;
|
|
3780
|
-
}).includes(true);
|
|
4474
|
+
if (styleValue) {
|
|
4475
|
+
return optionValue.map(v => {
|
|
4476
|
+
if (v instanceof RegExp) {
|
|
4477
|
+
return v.test(styleValue);
|
|
4478
|
+
}
|
|
4479
|
+
return v === styleValue;
|
|
4480
|
+
}).includes(true);
|
|
4481
|
+
}
|
|
4482
|
+
return false;
|
|
4483
|
+
}).includes(false);
|
|
4484
|
+
};
|
|
4485
|
+
}
|
|
4486
|
+
}
|
|
4487
|
+
|
|
4488
|
+
class Organization {
|
|
4489
|
+
}
|
|
4490
|
+
function registerAtShortcut(textbus) {
|
|
4491
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
4492
|
+
const selection = textbus.get(core$1.Selection);
|
|
4493
|
+
const commander = textbus.get(core$1.Commander);
|
|
4494
|
+
keyboard.addShortcut({
|
|
4495
|
+
keymap: {
|
|
4496
|
+
key: '@',
|
|
4497
|
+
shiftKey: true
|
|
4498
|
+
},
|
|
4499
|
+
action() {
|
|
4500
|
+
const { commonAncestorComponent } = selection;
|
|
4501
|
+
if (commonAncestorComponent instanceof SourceCodeComponent) {
|
|
4502
|
+
return false;
|
|
4503
|
+
}
|
|
4504
|
+
const at = new AtComponent(textbus);
|
|
4505
|
+
commander.insert(at);
|
|
4506
|
+
selection.setPosition(at.state.slot, 0);
|
|
4507
|
+
}
|
|
4508
|
+
});
|
|
4509
|
+
}
|
|
4510
|
+
class AtComponent extends core$1.Component {
|
|
4511
|
+
static fromJSON(textbus, { slot: slotState, userInfo }) {
|
|
4512
|
+
const registry = textbus.get(core$1.Registry);
|
|
4513
|
+
if (slotState) {
|
|
4514
|
+
const slot = registry.createSlot(slotState);
|
|
4515
|
+
return new AtComponent({
|
|
4516
|
+
slot
|
|
4517
|
+
});
|
|
4518
|
+
}
|
|
4519
|
+
return new AtComponent(textbus, {
|
|
4520
|
+
userInfo,
|
|
4521
|
+
});
|
|
4522
|
+
}
|
|
4523
|
+
constructor(textbus, state = {
|
|
4524
|
+
slot: new core$1.Slot([core$1.ContentType.Text])
|
|
4525
|
+
}) {
|
|
4526
|
+
if (!state.userInfo && !state.slot) {
|
|
4527
|
+
state.slot = new core$1.Slot([core$1.ContentType.Text]);
|
|
4528
|
+
}
|
|
4529
|
+
super(textbus, state);
|
|
4530
|
+
this.focus = new core$1.Subject();
|
|
4531
|
+
this.members = core.createSignal([]);
|
|
4532
|
+
this.selectedIndex = core.createSignal(0);
|
|
4533
|
+
}
|
|
4534
|
+
setup() {
|
|
4535
|
+
let isFocus = false;
|
|
4536
|
+
core$1.onFocus(() => {
|
|
4537
|
+
isFocus = true;
|
|
4538
|
+
this.focus.next(true);
|
|
4539
|
+
onChange.next();
|
|
4540
|
+
});
|
|
4541
|
+
core$1.onBlur(() => {
|
|
4542
|
+
isFocus = false;
|
|
4543
|
+
this.focus.next(false);
|
|
4544
|
+
setTimeout(() => {
|
|
4545
|
+
if (this.parent && !this.state.userInfo) {
|
|
4546
|
+
const slot = this.state.slot;
|
|
4547
|
+
let text = '@';
|
|
4548
|
+
if (slot) {
|
|
4549
|
+
text += slot.isEmpty ? '' : slot.toString();
|
|
4550
|
+
}
|
|
4551
|
+
const snapshot = selection.createSnapshot();
|
|
4552
|
+
selection.selectComponent(this);
|
|
4553
|
+
commander.insert(text);
|
|
4554
|
+
snapshot.restore(true);
|
|
4555
|
+
}
|
|
4556
|
+
});
|
|
4557
|
+
});
|
|
4558
|
+
const organization = core$1.useContext(Organization);
|
|
4559
|
+
const selection = core$1.useContext(core$1.Selection);
|
|
4560
|
+
const commander = core$1.useContext(core$1.Commander);
|
|
4561
|
+
const onChange = new core$1.Subject();
|
|
4562
|
+
core$1.onContentInserted((ev) => {
|
|
4563
|
+
const key = this.state.slot.toString();
|
|
4564
|
+
if (key.length > 10) {
|
|
4565
|
+
selection.selectComponent(this);
|
|
4566
|
+
commander.insert(key);
|
|
4567
|
+
ev.preventDefault();
|
|
4568
|
+
return;
|
|
4569
|
+
}
|
|
4570
|
+
onChange.next();
|
|
4571
|
+
});
|
|
4572
|
+
core$1.onContentDeleted(() => {
|
|
4573
|
+
onChange.next();
|
|
4574
|
+
});
|
|
4575
|
+
core$1.onBreak((ev) => {
|
|
4576
|
+
const member = this.members()[this.selectedIndex()];
|
|
4577
|
+
if (member) {
|
|
4578
|
+
this.state.userInfo = Object.assign({}, member);
|
|
4579
|
+
}
|
|
4580
|
+
selection.selectComponentEnd(this);
|
|
4581
|
+
ev.preventDefault();
|
|
4582
|
+
});
|
|
4583
|
+
core$1.useDynamicShortcut({
|
|
4584
|
+
keymap: {
|
|
4585
|
+
key: ['ArrowDown', 'ArrowUp']
|
|
4586
|
+
},
|
|
4587
|
+
action: (key) => {
|
|
4588
|
+
let index = this.selectedIndex();
|
|
4589
|
+
if (key === 'ArrowUp') {
|
|
4590
|
+
if (index > 0) {
|
|
4591
|
+
index--;
|
|
4592
|
+
this.selectedIndex.set(index);
|
|
4593
|
+
}
|
|
4594
|
+
return;
|
|
4595
|
+
}
|
|
4596
|
+
if (index < this.members().length - 1) {
|
|
4597
|
+
index++;
|
|
4598
|
+
this.selectedIndex.set(index);
|
|
3781
4599
|
}
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
4600
|
+
}
|
|
4601
|
+
});
|
|
4602
|
+
const subs = onChange.pipe(core$1.switchMap(() => {
|
|
4603
|
+
const key = this.state.slot.toString();
|
|
4604
|
+
return core$1.fromPromise(organization.getMembers(key));
|
|
4605
|
+
})).subscribe((members) => {
|
|
4606
|
+
this.members.set(members);
|
|
4607
|
+
this.selectedIndex.set(0);
|
|
4608
|
+
if (isFocus) {
|
|
4609
|
+
this.focus.next(true);
|
|
4610
|
+
}
|
|
4611
|
+
});
|
|
4612
|
+
core$1.onDestroy(() => {
|
|
4613
|
+
subs.unsubscribe();
|
|
4614
|
+
});
|
|
3785
4615
|
}
|
|
3786
4616
|
}
|
|
4617
|
+
AtComponent.componentName = 'AtComponent';
|
|
4618
|
+
AtComponent.type = core$1.ContentType.InlineComponent;
|
|
3787
4619
|
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
4620
|
+
function AtComponentView(props) {
|
|
4621
|
+
const selection = core.inject(core$1.Selection);
|
|
4622
|
+
const dropdownRef = core.createRef();
|
|
4623
|
+
const subscription = props.component.focus.subscribe((b) => {
|
|
4624
|
+
if (dropdownRef.current && props.component.members().length) {
|
|
4625
|
+
dropdownRef.current.isShow(b);
|
|
4626
|
+
}
|
|
4627
|
+
});
|
|
4628
|
+
core.onUnmounted(() => {
|
|
4629
|
+
subscription.unsubscribe();
|
|
4630
|
+
});
|
|
3798
4631
|
const readonly = useReadonly();
|
|
3799
4632
|
const output = useOutput();
|
|
4633
|
+
const membersRef = core.createRef();
|
|
4634
|
+
core.onUpdated(() => {
|
|
4635
|
+
if (output() || readonly()) {
|
|
4636
|
+
return;
|
|
4637
|
+
}
|
|
4638
|
+
const container = membersRef.current;
|
|
4639
|
+
if (container) {
|
|
4640
|
+
const focusItem = container.children[props.component.selectedIndex()];
|
|
4641
|
+
if (focusItem) {
|
|
4642
|
+
const itemRect = focusItem.getBoundingClientRect();
|
|
4643
|
+
const dropdownMenu = container.parentNode.parentNode;
|
|
4644
|
+
const containerRect = dropdownMenu.getBoundingClientRect();
|
|
4645
|
+
if (itemRect.top - 5 < containerRect.top) {
|
|
4646
|
+
dropdownMenu.scrollTop += itemRect.top - 5 - containerRect.top;
|
|
4647
|
+
}
|
|
4648
|
+
else if (itemRect.bottom + 5 > containerRect.bottom) {
|
|
4649
|
+
dropdownMenu.scrollTop += itemRect.bottom + 5 - containerRect.bottom;
|
|
4650
|
+
}
|
|
4651
|
+
}
|
|
4652
|
+
}
|
|
4653
|
+
});
|
|
3800
4654
|
return () => {
|
|
4655
|
+
const { slot, userInfo } = props.component.state;
|
|
4656
|
+
const selectedIndex = props.component.selectedIndex();
|
|
4657
|
+
if (userInfo) {
|
|
4658
|
+
return (jsxRuntime.jsxs("div", { class: "xnote-at xnote-at-complete", "data-info": encodeURIComponent(JSON.stringify(userInfo)), ref: props.rootRef, "data-component": props.component.name, children: [jsxRuntime.jsx("span", { children: "@" }), userInfo.name] }));
|
|
4659
|
+
}
|
|
3801
4660
|
if (readonly() || output()) {
|
|
3802
|
-
return (jsxRuntime.
|
|
3803
|
-
width: state.width,
|
|
3804
|
-
height: state.height
|
|
3805
|
-
} }) }));
|
|
4661
|
+
return (jsxRuntime.jsxs("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: [jsxRuntime.jsx("span", { children: "@" }), slot && jsxRuntime.jsx(SlotRender, { slot: slot, class: 'xnote-at-input', tag: "span" })] }));
|
|
3806
4662
|
}
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
4663
|
+
const members = props.component.members();
|
|
4664
|
+
return (jsxRuntime.jsx("div", { class: "xnote-at", ref: props.rootRef, "data-component": props.component.name, children: jsxRuntime.jsxs(Dropdown, { trigger: 'none', ref: dropdownRef, menu: jsxRuntime.jsx("div", { class: "xnote-at-menu", ref: membersRef, children: members.map((member, index) => {
|
|
4665
|
+
let hsl = color.any2Hsl(member.color);
|
|
4666
|
+
if (hsl === 'unknown') {
|
|
4667
|
+
hsl = color.any2Hsl('#000');
|
|
4668
|
+
}
|
|
4669
|
+
const rgb = color.hsl2Rgb(hsl);
|
|
4670
|
+
const yiq = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
|
|
4671
|
+
const color$1 = yiq >= 128 ? '#000' : '#fff';
|
|
4672
|
+
return (jsxRuntime.jsxs("div", { onClick: () => {
|
|
4673
|
+
props.component.state.userInfo = member;
|
|
4674
|
+
selection.selectComponentEnd(props.component);
|
|
4675
|
+
}, class: ['xnote-at-member', { selected: index === selectedIndex }], children: [jsxRuntime.jsx("div", { class: "xnote-at-member-avatar", children: member.avatar ? jsxRuntime.jsx("img", { src: member.avatar, alt: member.name }) :
|
|
4676
|
+
jsxRuntime.jsx("span", { class: "xnote-at-member-avatar-bg", style: { background: member.color, color: color$1 }, children: member.name }) }), jsxRuntime.jsxs("div", { class: "xnote-at-member-info", children: [jsxRuntime.jsx("div", { class: "xnote-at-member-name", children: member.name }), jsxRuntime.jsx("div", { class: "xnote-at-member-desc", children: member.groupName })] })] }, member.id));
|
|
4677
|
+
}) }), children: [jsxRuntime.jsx("span", { children: "@" }), slot && jsxRuntime.jsx(SlotRender, { slot: slot, tag: 'span', class: 'xnote-at-input' })] }) }));
|
|
3811
4678
|
};
|
|
3812
4679
|
}
|
|
3813
|
-
const
|
|
4680
|
+
const atComponentLoader = {
|
|
3814
4681
|
match(element) {
|
|
3815
|
-
return element.
|
|
4682
|
+
return element.dataset.component === AtComponent.componentName;
|
|
3816
4683
|
},
|
|
3817
|
-
read(element, textbus) {
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
4684
|
+
read(element, textbus, slotParser) {
|
|
4685
|
+
const data = element.dataset.info;
|
|
4686
|
+
if (data) {
|
|
4687
|
+
return new AtComponent(textbus, {
|
|
4688
|
+
userInfo: JSON.parse(decodeURIComponent(data))
|
|
4689
|
+
});
|
|
4690
|
+
}
|
|
4691
|
+
const slot = slotParser(new core$1.Slot([core$1.ContentType.Text]), element.querySelector('.xnote-at-input') || document.createElement('div'));
|
|
4692
|
+
return new AtComponent(textbus, {
|
|
4693
|
+
slot
|
|
3821
4694
|
});
|
|
3822
4695
|
}
|
|
3823
4696
|
};
|
|
@@ -3828,30 +4701,13 @@ class RootComponent extends core$1.Component {
|
|
|
3828
4701
|
this.onCompositionStart = new core$1.Subject();
|
|
3829
4702
|
}
|
|
3830
4703
|
static fromJSON(textbus, json) {
|
|
3831
|
-
const heading = textbus.get(core$1.Registry).createSlot(json.heading);
|
|
3832
4704
|
const content = textbus.get(core$1.Registry).createSlot(json.content);
|
|
3833
4705
|
return new RootComponent(textbus, {
|
|
3834
|
-
heading,
|
|
3835
4706
|
content
|
|
3836
4707
|
});
|
|
3837
4708
|
}
|
|
3838
4709
|
setup() {
|
|
3839
|
-
|
|
3840
|
-
const selection = textbus.get(core$1.Selection);
|
|
3841
|
-
core$1.onBreak(ev => {
|
|
3842
|
-
if (ev.target === this.state.heading) {
|
|
3843
|
-
const afterContent = ev.target.cut(ev.data.index);
|
|
3844
|
-
const p = new ParagraphComponent(textbus, {
|
|
3845
|
-
slot: afterContent
|
|
3846
|
-
});
|
|
3847
|
-
const body = this.state.content;
|
|
3848
|
-
body.retain(0);
|
|
3849
|
-
body.insert(p);
|
|
3850
|
-
selection.setPosition(afterContent, 0);
|
|
3851
|
-
ev.preventDefault();
|
|
3852
|
-
}
|
|
3853
|
-
});
|
|
3854
|
-
useBlockContent(this.state.content);
|
|
4710
|
+
useBlockContent((slot) => slot === this.state.content);
|
|
3855
4711
|
core$1.onCompositionStart(ev => {
|
|
3856
4712
|
this.onCompositionStart.next(ev);
|
|
3857
4713
|
});
|
|
@@ -3871,16 +4727,10 @@ class RootComponent extends core$1.Component {
|
|
|
3871
4727
|
RootComponent.componentName = 'RootComponent';
|
|
3872
4728
|
RootComponent.type = core$1.ContentType.BlockComponent;
|
|
3873
4729
|
function RootView(props) {
|
|
3874
|
-
const
|
|
3875
|
-
const { heading, content } = props.component.state;
|
|
4730
|
+
const { content } = props.component.state;
|
|
3876
4731
|
const ref = core.createDynamicRef(node => {
|
|
3877
|
-
const sub = props.component.onCompositionStart.subscribe(
|
|
3878
|
-
|
|
3879
|
-
node.children[0].dataset.placeholder = '';
|
|
3880
|
-
}
|
|
3881
|
-
else {
|
|
3882
|
-
node.children[1].dataset.placeholder = '';
|
|
3883
|
-
}
|
|
4732
|
+
const sub = props.component.onCompositionStart.subscribe(() => {
|
|
4733
|
+
node.children[0].dataset.placeholder = '';
|
|
3884
4734
|
});
|
|
3885
4735
|
return () => {
|
|
3886
4736
|
sub.unsubscribe();
|
|
@@ -3890,19 +4740,10 @@ function RootView(props) {
|
|
|
3890
4740
|
props.component.afterCheck();
|
|
3891
4741
|
});
|
|
3892
4742
|
const readonly = useReadonly();
|
|
4743
|
+
const output = useOutput();
|
|
3893
4744
|
return () => {
|
|
3894
4745
|
const { rootRef } = props;
|
|
3895
|
-
return (jsxRuntime.
|
|
3896
|
-
return (core$1.createVNode('div', {
|
|
3897
|
-
class: 'xnote-title',
|
|
3898
|
-
'data-placeholder': heading.isEmpty ? '请输入标题' : ''
|
|
3899
|
-
}, children));
|
|
3900
|
-
}, readonly()), adapter.slotRender(content, children => {
|
|
3901
|
-
return (core$1.createVNode('div', {
|
|
3902
|
-
class: 'xnote-content',
|
|
3903
|
-
'data-placeholder': content.isEmpty ? '请输入内容' : ''
|
|
3904
|
-
}, children));
|
|
3905
|
-
}, readonly())] }));
|
|
4746
|
+
return (jsxRuntime.jsx("div", { class: "xnote-root", dir: 'auto', ref: [rootRef, ref], "data-component": props.component.name, children: jsxRuntime.jsx(SlotRender, { slot: content, tag: 'div', class: "xnote-content", "data-placeholder": content.isEmpty ? '请输入内容' : '', renderEnv: readonly() || output() }) }));
|
|
3906
4747
|
};
|
|
3907
4748
|
}
|
|
3908
4749
|
const rootComponentLoader = {
|
|
@@ -3916,9 +4757,7 @@ const rootComponentLoader = {
|
|
|
3916
4757
|
core$1.ContentType.Text
|
|
3917
4758
|
]), element).toDelta();
|
|
3918
4759
|
const slot = new core$1.Slot([
|
|
3919
|
-
core$1.ContentType.BlockComponent
|
|
3920
|
-
core$1.ContentType.InlineComponent,
|
|
3921
|
-
core$1.ContentType.Text
|
|
4760
|
+
core$1.ContentType.BlockComponent
|
|
3922
4761
|
]);
|
|
3923
4762
|
deltaToBlock(delta, textbus).forEach(i => {
|
|
3924
4763
|
slot.insert(i);
|
|
@@ -3927,7 +4766,7 @@ const rootComponentLoader = {
|
|
|
3927
4766
|
}
|
|
3928
4767
|
};
|
|
3929
4768
|
|
|
3930
|
-
var
|
|
4769
|
+
var scopedId$5 = "vf-681de2";
|
|
3931
4770
|
|
|
3932
4771
|
let TableService = class TableService {
|
|
3933
4772
|
constructor() {
|
|
@@ -3945,6 +4784,7 @@ TableService = __decorate([
|
|
|
3945
4784
|
function ResizeColumn(props) {
|
|
3946
4785
|
const dragLineRef = core.createRef();
|
|
3947
4786
|
let activeCol = null;
|
|
4787
|
+
const editorService = core.inject(exports.EditorService);
|
|
3948
4788
|
core.onMounted(() => {
|
|
3949
4789
|
const { tableRef } = props;
|
|
3950
4790
|
let isDrag = false;
|
|
@@ -3977,6 +4817,7 @@ function ResizeColumn(props) {
|
|
|
3977
4817
|
}
|
|
3978
4818
|
})).add(core$1.fromEvent(dragLineRef.current, 'mousedown').subscribe(downEvent => {
|
|
3979
4819
|
isDrag = true;
|
|
4820
|
+
editorService.changeLeftToolbarVisible(false);
|
|
3980
4821
|
props.onActiveStateChange(true);
|
|
3981
4822
|
const x = downEvent.clientX;
|
|
3982
4823
|
const layoutWidth = props.component.state.layoutWidth;
|
|
@@ -3984,16 +4825,20 @@ function ResizeColumn(props) {
|
|
|
3984
4825
|
const initLeft = layoutWidth.slice(0, activeCol).reduce((a, b) => a + b, 0);
|
|
3985
4826
|
const minWidth = 30;
|
|
3986
4827
|
const minLeft = initLeft - initWidth + minWidth;
|
|
4828
|
+
const layoutWidthArr = layoutWidth.slice();
|
|
3987
4829
|
const moveEvent = core$1.fromEvent(document, 'mousemove').subscribe(moveEvent => {
|
|
3988
4830
|
const distanceX = moveEvent.clientX - x;
|
|
3989
4831
|
dragLineRef.current.style.left = Math.max(initLeft + distanceX, minLeft) + 'px';
|
|
3990
|
-
|
|
4832
|
+
layoutWidthArr[activeCol - 1] = Math.max(initWidth + distanceX, minWidth);
|
|
4833
|
+
props.layoutWidth.set(layoutWidthArr.slice());
|
|
3991
4834
|
}).add(core$1.fromEvent(document, 'mouseup').subscribe(upEvent => {
|
|
3992
4835
|
isDrag = false;
|
|
4836
|
+
editorService.changeLeftToolbarVisible(true);
|
|
3993
4837
|
props.onActiveStateChange(false);
|
|
3994
4838
|
moveEvent.unsubscribe();
|
|
3995
4839
|
const distanceX = upEvent.clientX - x;
|
|
3996
4840
|
props.component.state.layoutWidth[activeCol - 1] = Math.max(initWidth + distanceX, minWidth);
|
|
4841
|
+
props.layoutWidth.set(props.component.state.layoutWidth);
|
|
3997
4842
|
}));
|
|
3998
4843
|
}));
|
|
3999
4844
|
return () => {
|
|
@@ -4014,12 +4859,12 @@ function ResizeColumn(props) {
|
|
|
4014
4859
|
});
|
|
4015
4860
|
return () => sub.unsubscribe();
|
|
4016
4861
|
});
|
|
4017
|
-
return scopedCss.withScopedCSS(
|
|
4862
|
+
return scopedCss.withScopedCSS(scopedId$5, () => {
|
|
4018
4863
|
return jsxRuntime.jsx("div", { ref: dragLineRef, class: ['drag-line'] });
|
|
4019
4864
|
});
|
|
4020
4865
|
}
|
|
4021
4866
|
|
|
4022
|
-
var
|
|
4867
|
+
var scopedId$4 = "vf-39cb2c";
|
|
4023
4868
|
|
|
4024
4869
|
function TopBar(props) {
|
|
4025
4870
|
const editorService = core.inject(exports.EditorService);
|
|
@@ -4087,14 +4932,14 @@ function TopBar(props) {
|
|
|
4087
4932
|
s.unsubscribe();
|
|
4088
4933
|
});
|
|
4089
4934
|
const deleteIndex = core.createSignal(null);
|
|
4090
|
-
return scopedCss.withScopedCSS(
|
|
4935
|
+
return scopedCss.withScopedCSS(scopedId$4, () => {
|
|
4091
4936
|
const { state, tableSelection } = props.component;
|
|
4092
4937
|
const position = tableSelection();
|
|
4093
4938
|
return (jsxRuntime.jsx("div", { class: ['top-bar', {
|
|
4094
4939
|
active: props.isFocus()
|
|
4095
4940
|
}], children: jsxRuntime.jsxs("div", { class: "toolbar-wrapper", children: [jsxRuntime.jsx("div", { class: "insert-bar", children: jsxRuntime.jsx("table", { style: {
|
|
4096
4941
|
transform: `translateX(${-leftDistance()}px)`
|
|
4097
|
-
}, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children:
|
|
4942
|
+
}, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: props.layoutWidth().map((i, index) => {
|
|
4098
4943
|
return (jsxRuntime.jsx("td", { style: { width: i + 'px', minWidth: i + 'px' }, children: jsxRuntime.jsxs("div", { class: "tool-container", children: [index === 0 && (jsxRuntime.jsx("span", { onMouseenter: () => {
|
|
4099
4944
|
tableService.onInsertColumnBefore.next(0);
|
|
4100
4945
|
}, onMouseleave: () => {
|
|
@@ -4120,7 +4965,7 @@ function TopBar(props) {
|
|
|
4120
4965
|
}, children: jsxRuntime.jsx("span", { class: "xnote-icon-bin" }) }) }) })] }) }));
|
|
4121
4966
|
}) }) }) }) }), jsxRuntime.jsx("div", { class: ['action-bar', { active: props.isFocus() }], children: jsxRuntime.jsx("table", { style: {
|
|
4122
4967
|
transform: `translateX(${-leftDistance()}px)`
|
|
4123
|
-
}, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children:
|
|
4968
|
+
}, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: props.layoutWidth().map((i, index) => {
|
|
4124
4969
|
return jsxRuntime.jsx("td", { onClick: ev => {
|
|
4125
4970
|
mouseDownFromToolbar = true;
|
|
4126
4971
|
if (!ev.shiftKey) {
|
|
@@ -4140,7 +4985,7 @@ function TopBar(props) {
|
|
|
4140
4985
|
});
|
|
4141
4986
|
}
|
|
4142
4987
|
|
|
4143
|
-
var
|
|
4988
|
+
var scopedId$3 = "vf-6059df";
|
|
4144
4989
|
|
|
4145
4990
|
function Scroll(props) {
|
|
4146
4991
|
const scrollRef = core.createRef();
|
|
@@ -4154,7 +4999,7 @@ function Scroll(props) {
|
|
|
4154
4999
|
const el = scrollRef.current;
|
|
4155
5000
|
function update() {
|
|
4156
5001
|
if (props.isFocus()) {
|
|
4157
|
-
input.caret.refresh(
|
|
5002
|
+
input.caret.refresh();
|
|
4158
5003
|
}
|
|
4159
5004
|
updateShowShadow(draft => {
|
|
4160
5005
|
draft.leftEnd = el.scrollLeft === 0;
|
|
@@ -4172,19 +5017,21 @@ function Scroll(props) {
|
|
|
4172
5017
|
draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
|
|
4173
5018
|
});
|
|
4174
5019
|
});
|
|
4175
|
-
return scopedCss.withScopedCSS(
|
|
4176
|
-
return jsxRuntime.jsx("div", { ref: [scrollRef
|
|
5020
|
+
return scopedCss.withScopedCSS(scopedId$3, () => {
|
|
5021
|
+
return jsxRuntime.jsx("div", { ref: [scrollRef], class: ['scroll-container', {
|
|
4177
5022
|
'left-end': showShadow().leftEnd,
|
|
4178
5023
|
'right-end': showShadow().rightEnd,
|
|
4179
5024
|
'active': props.isFocus(),
|
|
4180
5025
|
// 'hide-selection': isSelectColumn()
|
|
4181
5026
|
}], onScroll: ev => {
|
|
4182
|
-
|
|
5027
|
+
setTimeout(() => {
|
|
5028
|
+
tableService.onScroll.next(ev.target.scrollLeft);
|
|
5029
|
+
}, 10);
|
|
4183
5030
|
}, children: props.children });
|
|
4184
5031
|
});
|
|
4185
5032
|
}
|
|
4186
5033
|
|
|
4187
|
-
var
|
|
5034
|
+
var scopedId$2 = "vf-aaece0";
|
|
4188
5035
|
|
|
4189
5036
|
function LeftBar(props) {
|
|
4190
5037
|
const editorService = core.inject(exports.EditorService);
|
|
@@ -4258,7 +5105,7 @@ function LeftBar(props) {
|
|
|
4258
5105
|
textbus.focus();
|
|
4259
5106
|
});
|
|
4260
5107
|
}
|
|
4261
|
-
return scopedCss.withScopedCSS(
|
|
5108
|
+
return scopedCss.withScopedCSS(scopedId$2, () => {
|
|
4262
5109
|
const { state, tableSelection } = props.component;
|
|
4263
5110
|
const position = tableSelection();
|
|
4264
5111
|
return (jsxRuntime.jsxs("div", { class: ['left-bar', { active: props.isFocus() }], children: [jsxRuntime.jsx("div", { class: "insert-bar", children: jsxRuntime.jsx("table", { ref: insertBarRef, children: jsxRuntime.jsx("tbody", { children: state.rows.map((_, index) => {
|
|
@@ -4306,7 +5153,7 @@ function LeftBar(props) {
|
|
|
4306
5153
|
});
|
|
4307
5154
|
}
|
|
4308
5155
|
|
|
4309
|
-
var
|
|
5156
|
+
var scopedId$1 = "vf-d4c4a9";
|
|
4310
5157
|
|
|
4311
5158
|
function sum(numbers) {
|
|
4312
5159
|
return numbers.reduce((a, b) => a + b, 0);
|
|
@@ -4339,7 +5186,7 @@ function ResizeRow(props) {
|
|
|
4339
5186
|
});
|
|
4340
5187
|
return () => sub.unsubscribe();
|
|
4341
5188
|
});
|
|
4342
|
-
return scopedCss.withScopedCSS(
|
|
5189
|
+
return scopedCss.withScopedCSS(scopedId$1, () => {
|
|
4343
5190
|
return jsxRuntime.jsx("div", { ref: dragLineRef, style: {
|
|
4344
5191
|
display: styles().visible ? 'block' : 'none',
|
|
4345
5192
|
top: styles().top + 'px',
|
|
@@ -4348,7 +5195,7 @@ function ResizeRow(props) {
|
|
|
4348
5195
|
});
|
|
4349
5196
|
}
|
|
4350
5197
|
|
|
4351
|
-
var
|
|
5198
|
+
var scopedId = "vf-4a5ad1";
|
|
4352
5199
|
|
|
4353
5200
|
function SelectionMask(props) {
|
|
4354
5201
|
const [styles, updateStyles] = hooks.useProduce({
|
|
@@ -4401,7 +5248,7 @@ function SelectionMask(props) {
|
|
|
4401
5248
|
core.onUnmounted(() => {
|
|
4402
5249
|
s.unsubscribe();
|
|
4403
5250
|
});
|
|
4404
|
-
return scopedCss.withScopedCSS(
|
|
5251
|
+
return scopedCss.withScopedCSS(scopedId, () => {
|
|
4405
5252
|
const style = styles();
|
|
4406
5253
|
return (jsxRuntime.jsx("div", { class: "mask", style: {
|
|
4407
5254
|
display: style.visible ? 'block' : 'none',
|
|
@@ -4415,81 +5262,25 @@ function SelectionMask(props) {
|
|
|
4415
5262
|
});
|
|
4416
5263
|
}
|
|
4417
5264
|
|
|
5265
|
+
// import { SlotRender } from '../SlotRender'
|
|
4418
5266
|
const TableComponentView = core.withAnnotation({
|
|
4419
5267
|
providers: [TableService]
|
|
4420
5268
|
}, function TableComponentView(props) {
|
|
4421
5269
|
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
5270
|
+
const editorService = core.inject(exports.EditorService);
|
|
4422
5271
|
const isFocus = core.createSignal(false);
|
|
5272
|
+
const layoutWidth = core.createSignal(props.component.state.layoutWidth);
|
|
4423
5273
|
const subscription = props.component.focus.subscribe(b => {
|
|
4424
5274
|
isFocus.set(b);
|
|
5275
|
+
if (!b) {
|
|
5276
|
+
editorService.hideInlineToolbar = false;
|
|
5277
|
+
}
|
|
4425
5278
|
});
|
|
4426
5279
|
core.onUnmounted(() => {
|
|
4427
5280
|
subscription.unsubscribe();
|
|
4428
5281
|
});
|
|
4429
5282
|
const tableRef = core.createRef();
|
|
4430
|
-
const scrollRef = core.createRef();
|
|
4431
5283
|
const isResizeColumn = core.createSignal(false);
|
|
4432
|
-
const selection = core.inject(core$1.Selection);
|
|
4433
|
-
const findPosition = (slot) => {
|
|
4434
|
-
let cell = slot;
|
|
4435
|
-
while ((cell === null || cell === void 0 ? void 0 : cell.parent) && cell.parent !== props.component) {
|
|
4436
|
-
cell = cell.parentSlot;
|
|
4437
|
-
}
|
|
4438
|
-
if (cell) {
|
|
4439
|
-
const rows = props.component.state.rows;
|
|
4440
|
-
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
4441
|
-
const row = rows[rowIndex].cells;
|
|
4442
|
-
for (let colIndex = 0; colIndex < row.length; colIndex++) {
|
|
4443
|
-
const item = row[colIndex].slot;
|
|
4444
|
-
if (item === cell) {
|
|
4445
|
-
return {
|
|
4446
|
-
rowIndex,
|
|
4447
|
-
colIndex
|
|
4448
|
-
};
|
|
4449
|
-
}
|
|
4450
|
-
}
|
|
4451
|
-
}
|
|
4452
|
-
}
|
|
4453
|
-
return null;
|
|
4454
|
-
};
|
|
4455
|
-
core.onMounted(() => {
|
|
4456
|
-
const sub = selection.onChange.subscribe(() => {
|
|
4457
|
-
var _a;
|
|
4458
|
-
if (selection.commonAncestorComponent !== props.component || selection.isCollapsed) {
|
|
4459
|
-
props.component.tableSelection.set(null);
|
|
4460
|
-
return;
|
|
4461
|
-
}
|
|
4462
|
-
const startPosition = findPosition(selection.startSlot);
|
|
4463
|
-
const endPosition = findPosition(selection.endSlot);
|
|
4464
|
-
if (startPosition && endPosition) {
|
|
4465
|
-
if (startPosition.rowIndex === endPosition.rowIndex && startPosition.colIndex === endPosition.colIndex) {
|
|
4466
|
-
if (selection.startSlot === selection.endSlot && selection.startOffset === 0 && selection.endOffset === ((_a = selection.startSlot) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
4467
|
-
props.component.tableSelection.set({
|
|
4468
|
-
startColumn: startPosition.colIndex,
|
|
4469
|
-
startRow: startPosition.rowIndex,
|
|
4470
|
-
endColumn: endPosition.colIndex + 1,
|
|
4471
|
-
endRow: endPosition.rowIndex + 1
|
|
4472
|
-
});
|
|
4473
|
-
return;
|
|
4474
|
-
}
|
|
4475
|
-
props.component.tableSelection.set(null);
|
|
4476
|
-
return;
|
|
4477
|
-
}
|
|
4478
|
-
const [startColumn, endColumn] = [startPosition.colIndex, endPosition.colIndex].sort((a, b) => a - b);
|
|
4479
|
-
const [startRow, endRow] = [startPosition.rowIndex, endPosition.rowIndex].sort((a, b) => a - b);
|
|
4480
|
-
props.component.tableSelection.set({
|
|
4481
|
-
startColumn,
|
|
4482
|
-
startRow,
|
|
4483
|
-
endColumn: endColumn + 1,
|
|
4484
|
-
endRow: endRow + 1
|
|
4485
|
-
});
|
|
4486
|
-
}
|
|
4487
|
-
else {
|
|
4488
|
-
props.component.tableSelection.set(null);
|
|
4489
|
-
}
|
|
4490
|
-
});
|
|
4491
|
-
return () => sub.unsubscribe();
|
|
4492
|
-
});
|
|
4493
5284
|
const rowMapping = new WeakMap();
|
|
4494
5285
|
const readonly = useReadonly();
|
|
4495
5286
|
const output = useOutput();
|
|
@@ -4502,45 +5293,42 @@ const TableComponentView = core.withAnnotation({
|
|
|
4502
5293
|
}
|
|
4503
5294
|
rowMapping.set(row, Math.random());
|
|
4504
5295
|
});
|
|
4505
|
-
Promise.resolve().then(() => {
|
|
4506
|
-
props.component.afterContentCheck();
|
|
4507
|
-
});
|
|
4508
5296
|
if (readonly() || output()) {
|
|
4509
|
-
return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, ref: props.rootRef, children: jsxRuntime.jsx("div", { class: "xnote-table-container", children: jsxRuntime.jsxs("table", { class: [
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
}
|
|
4526
|
-
return (jsxRuntime.
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
5297
|
+
return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, children: jsxRuntime.jsx("div", { class: "xnote-table-inner", ref: props.rootRef, children: jsxRuntime.jsx("div", { class: "xnote-table-container", children: jsxRuntime.jsxs("table", { class: [
|
|
5298
|
+
'xnote-table-content',
|
|
5299
|
+
{
|
|
5300
|
+
'hide-selection': props.component.tableSelection()
|
|
5301
|
+
}
|
|
5302
|
+
], children: [jsxRuntime.jsx("colgroup", { children: layoutWidth().map(w => {
|
|
5303
|
+
return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
|
|
5304
|
+
}) }), jsxRuntime.jsx("tbody", { children: rows.map((row) => {
|
|
5305
|
+
return (jsxRuntime.jsx("tr", { children: row.cells.map(cell => {
|
|
5306
|
+
return adapter.slotRender(cell.slot, children => {
|
|
5307
|
+
return core$1.createVNode('td', {
|
|
5308
|
+
key: cell.slot.id
|
|
5309
|
+
}, children);
|
|
5310
|
+
}, readonly() || output());
|
|
5311
|
+
}) }, rowMapping.get(row)));
|
|
5312
|
+
}) })] }) }) }) }));
|
|
5313
|
+
}
|
|
5314
|
+
return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": state.layoutWidth, children: jsxRuntime.jsxs("div", { class: "xnote-table-inner", ref: props.rootRef, children: [jsxRuntime.jsx(TopBar, { isFocus: isFocus, layoutWidth: layoutWidth, component: props.component }), jsxRuntime.jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsxRuntime.jsx(Scroll, { isFocus: isFocus, children: jsxRuntime.jsxs("div", { class: "xnote-table-container", children: [jsxRuntime.jsxs("table", { ref: tableRef, class: [
|
|
5315
|
+
'xnote-table-content',
|
|
5316
|
+
{
|
|
5317
|
+
'hide-selection': props.component.tableSelection()
|
|
5318
|
+
}
|
|
5319
|
+
], children: [jsxRuntime.jsx("colgroup", { children: layoutWidth().map(w => {
|
|
5320
|
+
return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
|
|
5321
|
+
}) }), jsxRuntime.jsx("tbody", { children: rows.map((row) => {
|
|
5322
|
+
return (jsxRuntime.jsx("tr", { children: row.cells.map(cell => {
|
|
5323
|
+
return adapter.slotRender(cell.slot, children => {
|
|
5324
|
+
return core$1.createVNode('td', {
|
|
5325
|
+
key: cell.slot.id
|
|
5326
|
+
}, children);
|
|
5327
|
+
}, readonly() || output());
|
|
5328
|
+
}) }, rowMapping.get(row)));
|
|
5329
|
+
}) })] }), jsxRuntime.jsx(ResizeColumn, { tableRef: tableRef, component: props.component, layoutWidth: layoutWidth, onActiveStateChange: isActive => {
|
|
5330
|
+
isResizeColumn.set(isActive);
|
|
5331
|
+
} }), jsxRuntime.jsx(SelectionMask, { tableRef: tableRef, component: props.component })] }) }), jsxRuntime.jsx(ResizeRow, { component: props.component, tableRef: tableRef })] }) }));
|
|
4544
5332
|
};
|
|
4545
5333
|
});
|
|
4546
5334
|
const tableComponentLoader = {
|
|
@@ -4561,8 +5349,6 @@ const tableComponentLoader = {
|
|
|
4561
5349
|
Array.from(row.cells).forEach(cell => {
|
|
4562
5350
|
const slot = new core$1.Slot([
|
|
4563
5351
|
core$1.ContentType.BlockComponent,
|
|
4564
|
-
core$1.ContentType.InlineComponent,
|
|
4565
|
-
core$1.ContentType.Text
|
|
4566
5352
|
]);
|
|
4567
5353
|
arr.push({
|
|
4568
5354
|
slot,
|
|
@@ -4590,8 +5376,6 @@ const tableComponentLoader = {
|
|
|
4590
5376
|
Array.from(row.cells).forEach(cell => {
|
|
4591
5377
|
const slot = new core$1.Slot([
|
|
4592
5378
|
core$1.ContentType.BlockComponent,
|
|
4593
|
-
core$1.ContentType.InlineComponent,
|
|
4594
|
-
core$1.ContentType.Text
|
|
4595
5379
|
]);
|
|
4596
5380
|
arr.push({
|
|
4597
5381
|
slot,
|
|
@@ -4678,8 +5462,6 @@ function autoComplete(table) {
|
|
|
4678
5462
|
rowspan: 1,
|
|
4679
5463
|
colspan: 1,
|
|
4680
5464
|
slot: new core$1.Slot([
|
|
4681
|
-
core$1.ContentType.Text,
|
|
4682
|
-
core$1.ContentType.InlineComponent,
|
|
4683
5465
|
core$1.ContentType.BlockComponent
|
|
4684
5466
|
])
|
|
4685
5467
|
};
|
|
@@ -4699,48 +5481,90 @@ function autoComplete(table) {
|
|
|
4699
5481
|
});
|
|
4700
5482
|
}
|
|
4701
5483
|
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
5484
|
+
function findFocusCell(table, slot) {
|
|
5485
|
+
var _a;
|
|
5486
|
+
while (slot) {
|
|
5487
|
+
if (table.__slots__.includes(slot)) {
|
|
5488
|
+
return slot;
|
|
5489
|
+
}
|
|
5490
|
+
slot = (_a = slot.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
|
4708
5491
|
}
|
|
5492
|
+
return null;
|
|
4709
5493
|
}
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
5494
|
+
let TableSelectionAwarenessDelegate = class TableSelectionAwarenessDelegate extends platformBrowser.CollaborateSelectionAwarenessDelegate {
|
|
5495
|
+
constructor(domAdapter, selection) {
|
|
5496
|
+
super();
|
|
5497
|
+
this.domAdapter = domAdapter;
|
|
5498
|
+
this.selection = selection;
|
|
5499
|
+
}
|
|
5500
|
+
getRects(abstractSelection) {
|
|
5501
|
+
const { focusSlot, anchorSlot } = abstractSelection;
|
|
5502
|
+
const focusPaths = this.selection.getPathsBySlot(focusSlot);
|
|
5503
|
+
const anchorPaths = this.selection.getPathsBySlot(anchorSlot);
|
|
5504
|
+
const focusIsStart = core$1.Selection.compareSelectionPaths(focusPaths, anchorPaths);
|
|
5505
|
+
let startSlot;
|
|
5506
|
+
let endSlot;
|
|
5507
|
+
if (focusIsStart) {
|
|
5508
|
+
startSlot = focusSlot;
|
|
5509
|
+
endSlot = anchorSlot;
|
|
4723
5510
|
}
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
5511
|
+
else {
|
|
5512
|
+
startSlot = anchorSlot;
|
|
5513
|
+
endSlot = focusSlot;
|
|
5514
|
+
}
|
|
5515
|
+
const commonAncestorComponent = core$1.Selection.getCommonAncestorComponent(startSlot, endSlot);
|
|
5516
|
+
if (!(commonAncestorComponent instanceof TableComponent)) {
|
|
5517
|
+
return false;
|
|
5518
|
+
}
|
|
5519
|
+
const range = getSelectedRanges(commonAncestorComponent, findFocusCell(commonAncestorComponent, startSlot), findFocusCell(commonAncestorComponent, endSlot));
|
|
5520
|
+
const rows = commonAncestorComponent.state.rows;
|
|
5521
|
+
const startFocusSlot = rows[range.startRow].cells[range.startColumn].slot;
|
|
5522
|
+
const endFocusSlot = rows[range.endRow].cells[range.endColumn].slot;
|
|
5523
|
+
const renderer = this.domAdapter;
|
|
5524
|
+
const startRect = renderer.getNativeNodeBySlot(startFocusSlot).getBoundingClientRect();
|
|
5525
|
+
const endRect = renderer.getNativeNodeBySlot(endFocusSlot).getBoundingClientRect();
|
|
5526
|
+
return [{
|
|
5527
|
+
left: startRect.left,
|
|
5528
|
+
top: startRect.top,
|
|
5529
|
+
width: endRect.left + endRect.width - startRect.left,
|
|
5530
|
+
height: endRect.top + endRect.height - startRect.top
|
|
5531
|
+
}];
|
|
5532
|
+
}
|
|
5533
|
+
};
|
|
5534
|
+
TableSelectionAwarenessDelegate = __decorate([
|
|
5535
|
+
core.Injectable(),
|
|
5536
|
+
__metadata("design:paramtypes", [platformBrowser.DomAdapter,
|
|
5537
|
+
core$1.Selection])
|
|
5538
|
+
], TableSelectionAwarenessDelegate);
|
|
5539
|
+
function getSelectedRanges(component, startSlot, endSlot) {
|
|
5540
|
+
const p1 = finedPosition(component, startSlot);
|
|
5541
|
+
const p2 = finedPosition(component, endSlot);
|
|
5542
|
+
return {
|
|
5543
|
+
startRow: Math.min(p1.rowIndex, p2.rowIndex),
|
|
5544
|
+
endRow: Math.max(p1.rowIndex, p2.rowIndex),
|
|
5545
|
+
startColumn: Math.min(p1.columnIndex, p2.columnIndex),
|
|
5546
|
+
endColumn: Math.max(p1.columnIndex, p2.columnIndex)
|
|
4728
5547
|
};
|
|
4729
5548
|
}
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
5549
|
+
function finedPosition(component, slot) {
|
|
5550
|
+
const rows = component.state.rows;
|
|
5551
|
+
for (let i = 0; i < rows.length; i++) {
|
|
5552
|
+
const row = rows[i];
|
|
5553
|
+
for (let j = 0; j < row.cells.length; j++) {
|
|
5554
|
+
const cell = row.cells[j].slot;
|
|
5555
|
+
if (cell === slot) {
|
|
5556
|
+
return {
|
|
5557
|
+
rowIndex: i,
|
|
5558
|
+
columnIndex: j
|
|
5559
|
+
};
|
|
5560
|
+
}
|
|
5561
|
+
}
|
|
4739
5562
|
}
|
|
4740
|
-
|
|
5563
|
+
return null;
|
|
5564
|
+
}
|
|
4741
5565
|
|
|
4742
|
-
|
|
4743
|
-
|
|
5566
|
+
class Editor extends core$1.Textbus {
|
|
5567
|
+
constructor(editorConfig = {}) {
|
|
4744
5568
|
const adapter = new adapterViewfly.ViewflyAdapter({
|
|
4745
5569
|
[ParagraphComponent.componentName]: ParagraphView,
|
|
4746
5570
|
[RootComponent.componentName]: RootView,
|
|
@@ -4751,19 +5575,59 @@ function createXNote(host_1) {
|
|
|
4751
5575
|
[HighlightBoxComponent.componentName]: HighlightBoxView,
|
|
4752
5576
|
[ListComponent.componentName]: ListComponentView,
|
|
4753
5577
|
[ImageComponent.componentName]: ImageView,
|
|
4754
|
-
[VideoComponent.componentName]: VideoView
|
|
5578
|
+
[VideoComponent.componentName]: VideoView,
|
|
5579
|
+
[AtComponent.componentName]: AtComponentView,
|
|
5580
|
+
[KatexComponent.componentName]: KatexComponentView,
|
|
4755
5581
|
}, (host, root, injector) => {
|
|
4756
5582
|
const appInjector = new core.ReflectiveInjector(injector, [{
|
|
4757
5583
|
provide: OutputInjectionToken,
|
|
4758
5584
|
useValue: false
|
|
4759
5585
|
}]);
|
|
4760
|
-
const app = platformBrowser$1.createApp(root, {
|
|
5586
|
+
const app = platformBrowser$1.createApp(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [root, jsxRuntime.jsx(LinkJump, {})] }), {
|
|
4761
5587
|
context: appInjector
|
|
4762
5588
|
}).mount(host);
|
|
4763
5589
|
return () => {
|
|
4764
5590
|
app.destroy();
|
|
4765
5591
|
};
|
|
4766
5592
|
});
|
|
5593
|
+
const browserModule = new platformBrowser.BrowserModule(Object.assign({ renderTo: () => {
|
|
5594
|
+
return this.host;
|
|
5595
|
+
}, useContentEditable: platformBrowser.isMobileBrowser(), adapter, componentLoaders: [
|
|
5596
|
+
atComponentLoader,
|
|
5597
|
+
sourceCodeComponentLoader,
|
|
5598
|
+
listComponentLoader,
|
|
5599
|
+
tableComponentLoader,
|
|
5600
|
+
imageComponentLoader,
|
|
5601
|
+
highlightBoxComponentLoader,
|
|
5602
|
+
blockquoteComponentLoader,
|
|
5603
|
+
videoComponentLoader,
|
|
5604
|
+
todolistComponentLoader,
|
|
5605
|
+
katexComponentLoader,
|
|
5606
|
+
paragraphComponentLoader,
|
|
5607
|
+
], formatLoaders: [
|
|
5608
|
+
backgroundColorFormatLoader,
|
|
5609
|
+
boldFormatLoader,
|
|
5610
|
+
codeFormatLoader,
|
|
5611
|
+
colorFormatLoader,
|
|
5612
|
+
fontFamilyFormatLoader,
|
|
5613
|
+
fontSizeFormatLoader,
|
|
5614
|
+
italicFormatLoader,
|
|
5615
|
+
linkFormatLoader,
|
|
5616
|
+
strikeThroughFormatLoader,
|
|
5617
|
+
underlineFormatLoader
|
|
5618
|
+
], attributeLoaders: [
|
|
5619
|
+
headingAttrLoader,
|
|
5620
|
+
textAlignAttrLoader,
|
|
5621
|
+
textIndentAttrLoader
|
|
5622
|
+
] }, editorConfig.viewOptions));
|
|
5623
|
+
const modules = [browserModule];
|
|
5624
|
+
if (editorConfig.collaborateConfig) {
|
|
5625
|
+
modules.push(new collaborate.CollaborateModule(editorConfig.collaborateConfig));
|
|
5626
|
+
browserModule.providers.push({
|
|
5627
|
+
provide: platformBrowser.CollaborateSelectionAwarenessDelegate,
|
|
5628
|
+
useClass: TableSelectionAwarenessDelegate
|
|
5629
|
+
});
|
|
5630
|
+
}
|
|
4767
5631
|
const vDomAdapter = new adapterViewfly.ViewflyVDomAdapter({
|
|
4768
5632
|
[ParagraphComponent.componentName]: ParagraphView,
|
|
4769
5633
|
[RootComponent.componentName]: RootView,
|
|
@@ -4774,14 +5638,16 @@ function createXNote(host_1) {
|
|
|
4774
5638
|
[HighlightBoxComponent.componentName]: HighlightBoxView,
|
|
4775
5639
|
[ListComponent.componentName]: ListComponentView,
|
|
4776
5640
|
[ImageComponent.componentName]: ImageView,
|
|
4777
|
-
[VideoComponent.componentName]: VideoView
|
|
5641
|
+
[VideoComponent.componentName]: VideoView,
|
|
5642
|
+
[AtComponent.componentName]: AtComponentView,
|
|
5643
|
+
[KatexComponent.componentName]: KatexComponentView
|
|
4778
5644
|
}, (host, root, injector) => {
|
|
4779
5645
|
const appInjector = new core.ReflectiveInjector(injector, [{
|
|
4780
5646
|
provide: OutputInjectionToken,
|
|
4781
5647
|
useValue: true
|
|
4782
5648
|
}, {
|
|
4783
5649
|
provide: platformBrowser.DomAdapter,
|
|
4784
|
-
useFactory() {
|
|
5650
|
+
useFactory: () => {
|
|
4785
5651
|
return vDomAdapter;
|
|
4786
5652
|
}
|
|
4787
5653
|
}]);
|
|
@@ -4793,50 +5659,7 @@ function createXNote(host_1) {
|
|
|
4793
5659
|
app.destroy();
|
|
4794
5660
|
};
|
|
4795
5661
|
});
|
|
4796
|
-
|
|
4797
|
-
renderTo() {
|
|
4798
|
-
return host;
|
|
4799
|
-
},
|
|
4800
|
-
adapter,
|
|
4801
|
-
componentLoaders: [
|
|
4802
|
-
highlightBoxComponentLoader,
|
|
4803
|
-
blockquoteComponentLoader,
|
|
4804
|
-
paragraphComponentLoader,
|
|
4805
|
-
sourceCodeComponentLoader,
|
|
4806
|
-
todolistComponentLoader,
|
|
4807
|
-
tableComponentLoader,
|
|
4808
|
-
listComponentLoader,
|
|
4809
|
-
imageComponentLoader,
|
|
4810
|
-
videoComponentLoader
|
|
4811
|
-
],
|
|
4812
|
-
formatLoaders: [
|
|
4813
|
-
backgroundColorFormatLoader,
|
|
4814
|
-
boldFormatLoader,
|
|
4815
|
-
codeFormatLoader,
|
|
4816
|
-
colorFormatLoader,
|
|
4817
|
-
fontFamilyFormatLoader,
|
|
4818
|
-
fontSizeFormatLoader,
|
|
4819
|
-
italicFormatLoader,
|
|
4820
|
-
linkFormatLoader,
|
|
4821
|
-
strikeThroughFormatLoader,
|
|
4822
|
-
underlineFormatLoader
|
|
4823
|
-
],
|
|
4824
|
-
attributeLoaders: [
|
|
4825
|
-
headingAttrLoader,
|
|
4826
|
-
textAlignAttrLoader,
|
|
4827
|
-
textIndentAttrLoader
|
|
4828
|
-
]
|
|
4829
|
-
});
|
|
4830
|
-
const modules = [browserModule];
|
|
4831
|
-
if (config.collaborateConfig) {
|
|
4832
|
-
modules.push(new collaborate.CollaborateModule(config.collaborateConfig));
|
|
4833
|
-
}
|
|
4834
|
-
const textbus = new core$1.Textbus({
|
|
4835
|
-
additionalAdapters: [vDomAdapter],
|
|
4836
|
-
zenCoding: true,
|
|
4837
|
-
readonly: config.readonly,
|
|
4838
|
-
imports: modules,
|
|
4839
|
-
components: [
|
|
5662
|
+
super(Object.assign({ zenCoding: true, additionalAdapters: [vDomAdapter], imports: modules, components: [
|
|
4840
5663
|
ImageComponent,
|
|
4841
5664
|
ParagraphComponent,
|
|
4842
5665
|
RootComponent,
|
|
@@ -4846,9 +5669,10 @@ function createXNote(host_1) {
|
|
|
4846
5669
|
TableComponent,
|
|
4847
5670
|
HighlightBoxComponent,
|
|
4848
5671
|
ListComponent,
|
|
4849
|
-
VideoComponent
|
|
4850
|
-
|
|
4851
|
-
|
|
5672
|
+
VideoComponent,
|
|
5673
|
+
AtComponent,
|
|
5674
|
+
KatexComponent
|
|
5675
|
+
], formatters: [
|
|
4852
5676
|
backgroundColorFormatter,
|
|
4853
5677
|
boldFormatter,
|
|
4854
5678
|
codeFormatter,
|
|
@@ -4859,18 +5683,14 @@ function createXNote(host_1) {
|
|
|
4859
5683
|
linkFormatter,
|
|
4860
5684
|
strikeThroughFormatter,
|
|
4861
5685
|
underlineFormatter
|
|
4862
|
-
],
|
|
4863
|
-
attributes: [
|
|
5686
|
+
], attributes: [
|
|
4864
5687
|
headingAttr,
|
|
4865
5688
|
textAlignAttr,
|
|
4866
5689
|
textIndentAttr
|
|
4867
|
-
],
|
|
4868
|
-
providers: [],
|
|
4869
|
-
plugins: [
|
|
5690
|
+
], plugins: [
|
|
4870
5691
|
new LeftToolbarPlugin(),
|
|
4871
5692
|
new ToolbarPlugin(),
|
|
4872
|
-
],
|
|
4873
|
-
onAfterStartup(textbus) {
|
|
5693
|
+
], onAfterStartup(textbus) {
|
|
4874
5694
|
registerBoldShortcut(textbus);
|
|
4875
5695
|
registerCodeShortcut(textbus);
|
|
4876
5696
|
registerItalicShortcut(textbus);
|
|
@@ -4879,34 +5699,52 @@ function createXNote(host_1) {
|
|
|
4879
5699
|
registerHeadingShortcut(textbus);
|
|
4880
5700
|
registerTextAlignShortcut(textbus);
|
|
4881
5701
|
registerTextIndentShortcut(textbus);
|
|
4882
|
-
|
|
4883
|
-
|
|
5702
|
+
registerAtShortcut(textbus);
|
|
5703
|
+
registerListShortcut(textbus);
|
|
5704
|
+
registerBlockquoteShortcut(textbus);
|
|
5705
|
+
} }, editorConfig));
|
|
5706
|
+
this.editorConfig = editorConfig;
|
|
5707
|
+
this.translator = new platformBrowser$1.OutputTranslator();
|
|
5708
|
+
this.vDomAdapter = vDomAdapter;
|
|
5709
|
+
}
|
|
5710
|
+
mount(host) {
|
|
5711
|
+
this.host = host;
|
|
4884
5712
|
let rootComp;
|
|
5713
|
+
const config = this.editorConfig;
|
|
4885
5714
|
if (config.content) {
|
|
4886
|
-
const parser =
|
|
5715
|
+
const parser = this.get(platformBrowser.Parser);
|
|
4887
5716
|
const doc = parser.parseDoc(config.content, rootComponentLoader);
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
5717
|
+
if (doc instanceof core$1.Component) {
|
|
5718
|
+
rootComp = doc;
|
|
5719
|
+
}
|
|
5720
|
+
else {
|
|
5721
|
+
const content = new core$1.Slot([
|
|
5722
|
+
core$1.ContentType.BlockComponent
|
|
5723
|
+
]);
|
|
5724
|
+
if (doc instanceof core$1.Slot) {
|
|
5725
|
+
deltaToBlock(doc.toDelta(), this).forEach(i => {
|
|
5726
|
+
content.insert(i);
|
|
5727
|
+
});
|
|
5728
|
+
}
|
|
5729
|
+
rootComp = new RootComponent(this, {
|
|
5730
|
+
content
|
|
5731
|
+
});
|
|
5732
|
+
}
|
|
4892
5733
|
}
|
|
4893
5734
|
else {
|
|
4894
|
-
rootComp = new RootComponent(
|
|
4895
|
-
|
|
4896
|
-
content: new core$1.Slot([core$1.ContentType.Text, core$1.ContentType.InlineComponent, core$1.ContentType.BlockComponent])
|
|
5735
|
+
rootComp = new RootComponent(this, {
|
|
5736
|
+
content: new core$1.Slot([core$1.ContentType.BlockComponent])
|
|
4897
5737
|
});
|
|
4898
5738
|
}
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
return translator.transform(vDomAdapter.host);
|
|
4905
|
-
}
|
|
4906
|
-
};
|
|
4907
|
-
});
|
|
5739
|
+
return this.render(rootComp);
|
|
5740
|
+
}
|
|
5741
|
+
getHTML() {
|
|
5742
|
+
return this.translator.transform(this.vDomAdapter.host);
|
|
5743
|
+
}
|
|
4908
5744
|
}
|
|
4909
5745
|
|
|
5746
|
+
exports.AtComponent = AtComponent;
|
|
5747
|
+
exports.AtComponentView = AtComponentView;
|
|
4910
5748
|
exports.AttrTool = AttrTool;
|
|
4911
5749
|
exports.BlockTool = BlockTool;
|
|
4912
5750
|
exports.BlockquoteComponent = BlockquoteComponent;
|
|
@@ -4920,6 +5758,8 @@ exports.Divider = Divider;
|
|
|
4920
5758
|
exports.DragResize = DragResize;
|
|
4921
5759
|
exports.Dropdown = Dropdown;
|
|
4922
5760
|
exports.DropdownMenuPortal = DropdownMenuPortal;
|
|
5761
|
+
exports.Editor = Editor;
|
|
5762
|
+
exports.FileUploader = FileUploader;
|
|
4923
5763
|
exports.FontFamilyTool = FontFamilyTool;
|
|
4924
5764
|
exports.FontSizeTool = FontSizeTool;
|
|
4925
5765
|
exports.HighlightBoxComponent = HighlightBoxComponent;
|
|
@@ -4928,13 +5768,19 @@ exports.ImageComponent = ImageComponent;
|
|
|
4928
5768
|
exports.ImageView = ImageView;
|
|
4929
5769
|
exports.InsertTool = InsertTool;
|
|
4930
5770
|
exports.ItalicTool = ItalicTool;
|
|
5771
|
+
exports.KatexComponent = KatexComponent;
|
|
5772
|
+
exports.KatexComponentView = KatexComponentView;
|
|
5773
|
+
exports.Keymap = Keymap;
|
|
4931
5774
|
exports.LeftToolbar = LeftToolbar;
|
|
4932
5775
|
exports.LeftToolbarPlugin = LeftToolbarPlugin;
|
|
5776
|
+
exports.LinkJump = LinkJump;
|
|
4933
5777
|
exports.LinkTool = LinkTool;
|
|
4934
5778
|
exports.ListComponent = ListComponent;
|
|
4935
5779
|
exports.ListComponentView = ListComponentView;
|
|
4936
5780
|
exports.Matcher = Matcher;
|
|
5781
|
+
exports.MenuHeading = MenuHeading;
|
|
4937
5782
|
exports.MenuItem = MenuItem;
|
|
5783
|
+
exports.Organization = Organization;
|
|
4938
5784
|
exports.OutputInjectionToken = OutputInjectionToken;
|
|
4939
5785
|
exports.ParagraphComponent = ParagraphComponent;
|
|
4940
5786
|
exports.ParagraphView = ParagraphView;
|
|
@@ -4954,6 +5800,7 @@ exports.ToolbarPlugin = ToolbarPlugin;
|
|
|
4954
5800
|
exports.UnderlineTool = UnderlineTool;
|
|
4955
5801
|
exports.VideoComponent = VideoComponent;
|
|
4956
5802
|
exports.VideoView = VideoView;
|
|
5803
|
+
exports.atComponentLoader = atComponentLoader;
|
|
4957
5804
|
exports.autoComplete = autoComplete;
|
|
4958
5805
|
exports.backgroundColorFormatLoader = backgroundColorFormatLoader;
|
|
4959
5806
|
exports.backgroundColorFormatter = backgroundColorFormatter;
|
|
@@ -4964,7 +5811,6 @@ exports.codeFormatLoader = codeFormatLoader;
|
|
|
4964
5811
|
exports.codeFormatter = codeFormatter;
|
|
4965
5812
|
exports.colorFormatLoader = colorFormatLoader;
|
|
4966
5813
|
exports.colorFormatter = colorFormatter;
|
|
4967
|
-
exports.createXNote = createXNote;
|
|
4968
5814
|
exports.deltaToBlock = deltaToBlock;
|
|
4969
5815
|
exports.fontFamilyFormatLoader = fontFamilyFormatLoader;
|
|
4970
5816
|
exports.fontFamilyFormatter = fontFamilyFormatter;
|
|
@@ -4977,15 +5823,19 @@ exports.imageComponentLoader = imageComponentLoader;
|
|
|
4977
5823
|
exports.isSupportFont = isSupportFont;
|
|
4978
5824
|
exports.italicFormatLoader = italicFormatLoader;
|
|
4979
5825
|
exports.italicFormatter = italicFormatter;
|
|
5826
|
+
exports.katexComponentLoader = katexComponentLoader;
|
|
4980
5827
|
exports.languageList = languageList;
|
|
4981
5828
|
exports.linkFormatLoader = linkFormatLoader;
|
|
4982
5829
|
exports.linkFormatter = linkFormatter;
|
|
4983
5830
|
exports.listComponentLoader = listComponentLoader;
|
|
4984
5831
|
exports.paragraphComponentLoader = paragraphComponentLoader;
|
|
5832
|
+
exports.registerAtShortcut = registerAtShortcut;
|
|
5833
|
+
exports.registerBlockquoteShortcut = registerBlockquoteShortcut;
|
|
4985
5834
|
exports.registerBoldShortcut = registerBoldShortcut;
|
|
4986
5835
|
exports.registerCodeShortcut = registerCodeShortcut;
|
|
4987
5836
|
exports.registerHeadingShortcut = registerHeadingShortcut;
|
|
4988
5837
|
exports.registerItalicShortcut = registerItalicShortcut;
|
|
5838
|
+
exports.registerListShortcut = registerListShortcut;
|
|
4989
5839
|
exports.registerStrikeThroughShortcut = registerStrikeThroughShortcut;
|
|
4990
5840
|
exports.registerTextAlignShortcut = registerTextAlignShortcut;
|
|
4991
5841
|
exports.registerTextIndentShortcut = registerTextIndentShortcut;
|
|
@@ -5000,6 +5850,8 @@ exports.textAlignAttr = textAlignAttr;
|
|
|
5000
5850
|
exports.textAlignAttrLoader = textAlignAttrLoader;
|
|
5001
5851
|
exports.textIndentAttr = textIndentAttr;
|
|
5002
5852
|
exports.textIndentAttrLoader = textIndentAttrLoader;
|
|
5853
|
+
exports.toBlockquote = toBlockquote;
|
|
5854
|
+
exports.toList = toList;
|
|
5003
5855
|
exports.todolistComponentLoader = todolistComponentLoader;
|
|
5004
5856
|
exports.toggleBold = toggleBold;
|
|
5005
5857
|
exports.toggleCode = toggleCode;
|