@textbus/xnote 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/index.esm.js +176 -166
- package/bundles/index.js +175 -165
- package/package.json +1 -1
package/bundles/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from '@viewfly/core/jsx-runtime';
|
|
2
2
|
import { withScopedCSS } from '@viewfly/scoped-css';
|
|
3
3
|
import { Injectable, InjectFlags, Injector, inject, createSignal, onUnmounted, getCurrentInstance, createRef, withAnnotation, onUpdated, onMounted, InjectionToken, ReflectiveInjector, createDynamicRef, jsx as jsx$1, viewfly, Fragment as Fragment$1, watch } from '@viewfly/core';
|
|
4
|
-
import { Subject, fromEvent, Selection, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, merge, createVNode, Slot, Component, Registry, Query, QueryStateType, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDestroy, onGetRanges,
|
|
4
|
+
import { Subject, fromEvent, Selection, Subscription, Attribute, Keyboard, Commander, Controller, useContext, onBreak, onContentInsert, ContentType, merge, createVNode, Slot, Component, Registry, Query, QueryStateType, Formatter, BehaviorSubject, onSlotApplyFormat, onSlotSetAttribute, onPaste, onFocus, onBlur, useDynamicShortcut, VTextNode, onFocusIn, onFocusOut, onDestroy, onGetRanges, onParentSlotUpdated, Textbus, RootComponentRef, filter, map, distinctUntilChanged, sampleTime, debounceTime, throttleTime, delay, onContentInserted, onContentDeleted, switchMap, fromPromise, onCompositionStart } from '@textbus/core';
|
|
5
5
|
import { normalizeHex, hex2Hsl, hex2Rgb, hex2Hsv, hsl2Hex, hsl2Hsv, hsl2Rgb, rgb2Hsl, rgb2Hex, rgb2Hsv, hsv2Hex, hsv2Hsl, hsv2Rgb, any2Hsl, parseCss } from '@tanbo/color';
|
|
6
6
|
import { VIEW_CONTAINER, isMac, DomAdapter, Input, SelectionBridge, BrowserModule, VIEW_DOCUMENT, CollaborateSelectionAwarenessDelegate, isMobileBrowser, CollaborateCursor, Parser } from '@textbus/platform-browser';
|
|
7
7
|
import { createPortal, createApp, DomRenderer, HTMLRenderer, OutputTranslator } from '@viewfly/platform-browser';
|
|
@@ -1277,6 +1277,166 @@ const highlightBoxComponentLoader = {
|
|
|
1277
1277
|
}
|
|
1278
1278
|
};
|
|
1279
1279
|
|
|
1280
|
+
const fontSizeFormatter = new Formatter('fontSize', {
|
|
1281
|
+
render(children, formatValue) {
|
|
1282
|
+
return {
|
|
1283
|
+
fallbackTagName: 'span',
|
|
1284
|
+
attach(host) {
|
|
1285
|
+
host.styles.set('fontSize', formatValue);
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
const fontSizeFormatLoader = {
|
|
1291
|
+
match(element) {
|
|
1292
|
+
return !!element.style.fontSize;
|
|
1293
|
+
},
|
|
1294
|
+
read(element) {
|
|
1295
|
+
return {
|
|
1296
|
+
formatter: fontSizeFormatter,
|
|
1297
|
+
value: element.style.fontSize
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
const boldFormatter = new Formatter('bold', {
|
|
1303
|
+
render(children) {
|
|
1304
|
+
return createVNode('strong', null, children);
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
function toggleBold(textbus) {
|
|
1308
|
+
const controller = textbus.get(Controller);
|
|
1309
|
+
if (controller.readonly) {
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
const query = textbus.get(Query);
|
|
1313
|
+
const commander = textbus.get(Commander);
|
|
1314
|
+
const state = query.queryFormat(boldFormatter);
|
|
1315
|
+
if (state.state === QueryStateType.Normal) {
|
|
1316
|
+
commander.applyFormat(boldFormatter, true);
|
|
1317
|
+
}
|
|
1318
|
+
else {
|
|
1319
|
+
commander.unApplyFormat(boldFormatter);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
function registerBoldShortcut(textbus) {
|
|
1323
|
+
const keyboard = textbus.get(Keyboard);
|
|
1324
|
+
keyboard.addShortcut({
|
|
1325
|
+
keymap: {
|
|
1326
|
+
modKey: true,
|
|
1327
|
+
key: 'b'
|
|
1328
|
+
},
|
|
1329
|
+
action: () => {
|
|
1330
|
+
toggleBold(textbus);
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
const boldFormatLoader = {
|
|
1335
|
+
match(element) {
|
|
1336
|
+
return element.tagName === 'STRONG' || element.tagName === 'B' || /bold|[5-9]00/.test(element.style.fontWeight);
|
|
1337
|
+
},
|
|
1338
|
+
read() {
|
|
1339
|
+
return {
|
|
1340
|
+
formatter: boldFormatter,
|
|
1341
|
+
value: true
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
const colorFormatter = new Formatter('color', {
|
|
1347
|
+
render(children, formatValue) {
|
|
1348
|
+
return {
|
|
1349
|
+
fallbackTagName: 'span',
|
|
1350
|
+
attach(host) {
|
|
1351
|
+
host.styles.set('color', formatValue);
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
const colorFormatLoader = {
|
|
1357
|
+
match(element) {
|
|
1358
|
+
return !!element.style.color;
|
|
1359
|
+
},
|
|
1360
|
+
read(element) {
|
|
1361
|
+
return {
|
|
1362
|
+
formatter: colorFormatter,
|
|
1363
|
+
value: element.style.color
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
function createTimelineItem(textbus, theme) {
|
|
1369
|
+
const slot = new Slot([
|
|
1370
|
+
ContentType.BlockComponent,
|
|
1371
|
+
]);
|
|
1372
|
+
const title = new ParagraphComponent(textbus);
|
|
1373
|
+
title.state.slot.insert('时间主题', [
|
|
1374
|
+
[fontSizeFormatter, '18px'],
|
|
1375
|
+
[boldFormatter, true]
|
|
1376
|
+
]);
|
|
1377
|
+
title.state.slot.insert(' 2020-02-02', [
|
|
1378
|
+
[fontSizeFormatter, '15px'],
|
|
1379
|
+
[colorFormatter, '#777']
|
|
1380
|
+
]);
|
|
1381
|
+
const desc = new ParagraphComponent(textbus);
|
|
1382
|
+
desc.state.slot.insert('描述信息...');
|
|
1383
|
+
slot.insert(title);
|
|
1384
|
+
slot.insert(desc);
|
|
1385
|
+
return { theme, slot };
|
|
1386
|
+
}
|
|
1387
|
+
class TimelineComponent extends Component {
|
|
1388
|
+
static fromJSON(textbus, json) {
|
|
1389
|
+
const registry = textbus.get(Registry);
|
|
1390
|
+
return new TimelineComponent(textbus, {
|
|
1391
|
+
items: json.items.map(i => {
|
|
1392
|
+
return {
|
|
1393
|
+
theme: i.theme,
|
|
1394
|
+
slot: registry.createSlot(i.slot)
|
|
1395
|
+
};
|
|
1396
|
+
})
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
getSlots() {
|
|
1400
|
+
return this.state.items.map(i => i.slot);
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
TimelineComponent.componentName = 'TimelineComponent';
|
|
1404
|
+
TimelineComponent.type = ContentType.BlockComponent;
|
|
1405
|
+
|
|
1406
|
+
function createStepItem(textbus) {
|
|
1407
|
+
const slot = new Slot([
|
|
1408
|
+
ContentType.BlockComponent
|
|
1409
|
+
]);
|
|
1410
|
+
const title = new ParagraphComponent(textbus);
|
|
1411
|
+
title.state.slot.insert('标题', [
|
|
1412
|
+
[fontSizeFormatter, '18px'],
|
|
1413
|
+
[boldFormatter, true]
|
|
1414
|
+
]);
|
|
1415
|
+
const content = new ParagraphComponent(textbus);
|
|
1416
|
+
content.state.slot.insert('描述信息...');
|
|
1417
|
+
slot.insert(title);
|
|
1418
|
+
slot.insert(content);
|
|
1419
|
+
return { slot };
|
|
1420
|
+
}
|
|
1421
|
+
class StepComponent extends Component {
|
|
1422
|
+
static fromJSON(textbus, json) {
|
|
1423
|
+
const registry = textbus.get(Registry);
|
|
1424
|
+
return new StepComponent(textbus, {
|
|
1425
|
+
step: json.step,
|
|
1426
|
+
items: json.items.map(i => {
|
|
1427
|
+
return {
|
|
1428
|
+
slot: registry.createSlot(i.slot)
|
|
1429
|
+
};
|
|
1430
|
+
})
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
getSlots() {
|
|
1434
|
+
return this.state.items.map(i => i.slot);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
StepComponent.componentName = 'StepComponent';
|
|
1438
|
+
StepComponent.type = ContentType.BlockComponent;
|
|
1439
|
+
|
|
1280
1440
|
class ParagraphComponent extends Component {
|
|
1281
1441
|
static fromJSON(textbus, json) {
|
|
1282
1442
|
const slot = textbus.get(Registry).createSlot(json.slot);
|
|
@@ -1307,7 +1467,9 @@ class ParagraphComponent extends Component {
|
|
|
1307
1467
|
slot: afterSlot
|
|
1308
1468
|
});
|
|
1309
1469
|
if (isEmpty && (this.parentComponent instanceof BlockquoteComponent ||
|
|
1310
|
-
this.parentComponent instanceof HighlightBoxComponent
|
|
1470
|
+
this.parentComponent instanceof HighlightBoxComponent ||
|
|
1471
|
+
this.parentComponent instanceof TimelineComponent ||
|
|
1472
|
+
this.parentComponent instanceof StepComponent)) {
|
|
1311
1473
|
commander.insertAfter(nextParagraph, this.parentComponent);
|
|
1312
1474
|
commander.removeComponent(this);
|
|
1313
1475
|
}
|
|
@@ -3493,7 +3655,7 @@ const backgroundColorFormatter = new Formatter('backgroundColor', {
|
|
|
3493
3655
|
});
|
|
3494
3656
|
const backgroundColorFormatLoader = {
|
|
3495
3657
|
match(element) {
|
|
3496
|
-
return element.tagName !== 'TD' && !!element.style.backgroundColor;
|
|
3658
|
+
return element.tagName !== 'TD' && element.tagName !== 'TH' && !!element.style.backgroundColor;
|
|
3497
3659
|
},
|
|
3498
3660
|
read(element) {
|
|
3499
3661
|
return {
|
|
@@ -3503,50 +3665,6 @@ const backgroundColorFormatLoader = {
|
|
|
3503
3665
|
}
|
|
3504
3666
|
};
|
|
3505
3667
|
|
|
3506
|
-
const boldFormatter = new Formatter('bold', {
|
|
3507
|
-
render(children) {
|
|
3508
|
-
return createVNode('strong', null, children);
|
|
3509
|
-
}
|
|
3510
|
-
});
|
|
3511
|
-
function toggleBold(textbus) {
|
|
3512
|
-
const controller = textbus.get(Controller);
|
|
3513
|
-
if (controller.readonly) {
|
|
3514
|
-
return;
|
|
3515
|
-
}
|
|
3516
|
-
const query = textbus.get(Query);
|
|
3517
|
-
const commander = textbus.get(Commander);
|
|
3518
|
-
const state = query.queryFormat(boldFormatter);
|
|
3519
|
-
if (state.state === QueryStateType.Normal) {
|
|
3520
|
-
commander.applyFormat(boldFormatter, true);
|
|
3521
|
-
}
|
|
3522
|
-
else {
|
|
3523
|
-
commander.unApplyFormat(boldFormatter);
|
|
3524
|
-
}
|
|
3525
|
-
}
|
|
3526
|
-
function registerBoldShortcut(textbus) {
|
|
3527
|
-
const keyboard = textbus.get(Keyboard);
|
|
3528
|
-
keyboard.addShortcut({
|
|
3529
|
-
keymap: {
|
|
3530
|
-
modKey: true,
|
|
3531
|
-
key: 'b'
|
|
3532
|
-
},
|
|
3533
|
-
action: () => {
|
|
3534
|
-
toggleBold(textbus);
|
|
3535
|
-
}
|
|
3536
|
-
});
|
|
3537
|
-
}
|
|
3538
|
-
const boldFormatLoader = {
|
|
3539
|
-
match(element) {
|
|
3540
|
-
return element.tagName === 'STRONG' || element.tagName === 'B' || /bold|[5-9]00/.test(element.style.fontWeight);
|
|
3541
|
-
},
|
|
3542
|
-
read() {
|
|
3543
|
-
return {
|
|
3544
|
-
formatter: boldFormatter,
|
|
3545
|
-
value: true
|
|
3546
|
-
};
|
|
3547
|
-
}
|
|
3548
|
-
};
|
|
3549
|
-
|
|
3550
3668
|
const codeFormatter = new Formatter('code', {
|
|
3551
3669
|
inheritable: false,
|
|
3552
3670
|
render(children) {
|
|
@@ -3594,28 +3712,6 @@ const codeFormatLoader = {
|
|
|
3594
3712
|
}
|
|
3595
3713
|
};
|
|
3596
3714
|
|
|
3597
|
-
const colorFormatter = new Formatter('color', {
|
|
3598
|
-
render(children, formatValue) {
|
|
3599
|
-
return {
|
|
3600
|
-
fallbackTagName: 'span',
|
|
3601
|
-
attach(host) {
|
|
3602
|
-
host.styles.set('color', formatValue);
|
|
3603
|
-
}
|
|
3604
|
-
};
|
|
3605
|
-
}
|
|
3606
|
-
});
|
|
3607
|
-
const colorFormatLoader = {
|
|
3608
|
-
match(element) {
|
|
3609
|
-
return !!element.style.color;
|
|
3610
|
-
},
|
|
3611
|
-
read(element) {
|
|
3612
|
-
return {
|
|
3613
|
-
formatter: colorFormatter,
|
|
3614
|
-
value: element.style.color
|
|
3615
|
-
};
|
|
3616
|
-
}
|
|
3617
|
-
};
|
|
3618
|
-
|
|
3619
3715
|
const fontFamilyFormatter = new Formatter('fontFamily', {
|
|
3620
3716
|
render(children, formatValue) {
|
|
3621
3717
|
return {
|
|
@@ -3638,28 +3734,6 @@ const fontFamilyFormatLoader = {
|
|
|
3638
3734
|
}
|
|
3639
3735
|
};
|
|
3640
3736
|
|
|
3641
|
-
const fontSizeFormatter = new Formatter('fontSize', {
|
|
3642
|
-
render(children, formatValue) {
|
|
3643
|
-
return {
|
|
3644
|
-
fallbackTagName: 'span',
|
|
3645
|
-
attach(host) {
|
|
3646
|
-
host.styles.set('fontSize', formatValue);
|
|
3647
|
-
}
|
|
3648
|
-
};
|
|
3649
|
-
}
|
|
3650
|
-
});
|
|
3651
|
-
const fontSizeFormatLoader = {
|
|
3652
|
-
match(element) {
|
|
3653
|
-
return !!element.style.fontSize;
|
|
3654
|
-
},
|
|
3655
|
-
read(element) {
|
|
3656
|
-
return {
|
|
3657
|
-
formatter: fontSizeFormatter,
|
|
3658
|
-
value: element.style.fontSize
|
|
3659
|
-
};
|
|
3660
|
-
}
|
|
3661
|
-
};
|
|
3662
|
-
|
|
3663
3737
|
const italicFormatter = new Formatter('italic', {
|
|
3664
3738
|
render(children) {
|
|
3665
3739
|
return createVNode('em', null, children);
|
|
@@ -4319,14 +4393,14 @@ const cellBackgroundAttr = new Attribute('cellBackground', {
|
|
|
4319
4393
|
}
|
|
4320
4394
|
hsl.s *= 0.7;
|
|
4321
4395
|
const newRgba = hsl2Rgb(hsl);
|
|
4322
|
-
node.styles.set('borderColor', `rgba(${newRgba.r}, ${newRgba.g}, ${newRgba.b}, ${rgba.a})`);
|
|
4396
|
+
node.styles.set('borderColor', `rgba(${newRgba.r}, ${newRgba.g}, ${newRgba.b}, ${rgba.a || 1})`);
|
|
4323
4397
|
}
|
|
4324
4398
|
node.styles.set('backgroundColor', formatValue);
|
|
4325
4399
|
}
|
|
4326
4400
|
});
|
|
4327
4401
|
const cellBackgroundAttrLoader = {
|
|
4328
4402
|
match(element) {
|
|
4329
|
-
return element
|
|
4403
|
+
return (element.tagName === 'TD' || element.tagName === 'TH') && !!element.style.backgroundColor;
|
|
4330
4404
|
},
|
|
4331
4405
|
read(element) {
|
|
4332
4406
|
return {
|
|
@@ -4690,78 +4764,6 @@ const katexComponentLoader = {
|
|
|
4690
4764
|
}
|
|
4691
4765
|
};
|
|
4692
4766
|
|
|
4693
|
-
function createTimelineItem(textbus, theme) {
|
|
4694
|
-
const slot = new Slot([
|
|
4695
|
-
ContentType.BlockComponent,
|
|
4696
|
-
]);
|
|
4697
|
-
const title = new ParagraphComponent(textbus);
|
|
4698
|
-
title.state.slot.insert('时间主题', [
|
|
4699
|
-
[fontSizeFormatter, '18px'],
|
|
4700
|
-
[boldFormatter, true]
|
|
4701
|
-
]);
|
|
4702
|
-
title.state.slot.insert(' 2020-02-02', [
|
|
4703
|
-
[fontSizeFormatter, '15px'],
|
|
4704
|
-
[colorFormatter, '#777']
|
|
4705
|
-
]);
|
|
4706
|
-
const desc = new ParagraphComponent(textbus);
|
|
4707
|
-
desc.state.slot.insert('描述信息...');
|
|
4708
|
-
slot.insert(title);
|
|
4709
|
-
slot.insert(desc);
|
|
4710
|
-
return { theme, slot };
|
|
4711
|
-
}
|
|
4712
|
-
class TimelineComponent extends Component {
|
|
4713
|
-
static fromJSON(textbus, json) {
|
|
4714
|
-
const registry = textbus.get(Registry);
|
|
4715
|
-
return new TimelineComponent(textbus, {
|
|
4716
|
-
items: json.items.map(i => {
|
|
4717
|
-
return {
|
|
4718
|
-
theme: i.theme,
|
|
4719
|
-
slot: registry.createSlot(i.slot)
|
|
4720
|
-
};
|
|
4721
|
-
})
|
|
4722
|
-
});
|
|
4723
|
-
}
|
|
4724
|
-
getSlots() {
|
|
4725
|
-
return this.state.items.map(i => i.slot);
|
|
4726
|
-
}
|
|
4727
|
-
}
|
|
4728
|
-
TimelineComponent.componentName = 'TimelineComponent';
|
|
4729
|
-
TimelineComponent.type = ContentType.BlockComponent;
|
|
4730
|
-
|
|
4731
|
-
function createStepItem(textbus) {
|
|
4732
|
-
const slot = new Slot([
|
|
4733
|
-
ContentType.BlockComponent
|
|
4734
|
-
]);
|
|
4735
|
-
const title = new ParagraphComponent(textbus);
|
|
4736
|
-
title.state.slot.insert('标题', [
|
|
4737
|
-
[fontSizeFormatter, '18px'],
|
|
4738
|
-
[boldFormatter, true]
|
|
4739
|
-
]);
|
|
4740
|
-
const content = new ParagraphComponent(textbus);
|
|
4741
|
-
content.state.slot.insert('描述信息...');
|
|
4742
|
-
slot.insert(title);
|
|
4743
|
-
slot.insert(content);
|
|
4744
|
-
return { slot };
|
|
4745
|
-
}
|
|
4746
|
-
class StepComponent extends Component {
|
|
4747
|
-
static fromJSON(textbus, json) {
|
|
4748
|
-
const registry = textbus.get(Registry);
|
|
4749
|
-
return new StepComponent(textbus, {
|
|
4750
|
-
step: json.step,
|
|
4751
|
-
items: json.items.map(i => {
|
|
4752
|
-
return {
|
|
4753
|
-
slot: registry.createSlot(i.slot)
|
|
4754
|
-
};
|
|
4755
|
-
})
|
|
4756
|
-
});
|
|
4757
|
-
}
|
|
4758
|
-
getSlots() {
|
|
4759
|
-
return this.state.items.map(i => i.slot);
|
|
4760
|
-
}
|
|
4761
|
-
}
|
|
4762
|
-
StepComponent.componentName = 'StepComponent';
|
|
4763
|
-
StepComponent.type = ContentType.BlockComponent;
|
|
4764
|
-
|
|
4765
4767
|
function InsertTool(props) {
|
|
4766
4768
|
const commander = inject(Commander);
|
|
4767
4769
|
const selection = inject(Selection);
|
|
@@ -6422,7 +6424,9 @@ const TableComponentView = withAnnotation({
|
|
|
6422
6424
|
], children: [jsx("colgroup", { children: state.columnsConfig.map(w => {
|
|
6423
6425
|
return jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
|
|
6424
6426
|
}) }), jsx("tbody", { children: normalizedData.map((row) => {
|
|
6425
|
-
return (jsx("tr", { children: row.cells.
|
|
6427
|
+
return (jsx("tr", { children: row.cells.filter(i => {
|
|
6428
|
+
return i.visible;
|
|
6429
|
+
}).map(cell => {
|
|
6426
6430
|
return adapter.slotRender(cell.raw.slot, children => {
|
|
6427
6431
|
return createVNode('td', {
|
|
6428
6432
|
key: cell.raw.id,
|
|
@@ -6489,6 +6493,9 @@ const tableComponentLoader = {
|
|
|
6489
6493
|
ContentType.Text
|
|
6490
6494
|
]), cell).toDelta();
|
|
6491
6495
|
const results = deltaToBlock(delta, textbus);
|
|
6496
|
+
delta.attributes.forEach((value, key) => {
|
|
6497
|
+
slot.setAttribute(key, value);
|
|
6498
|
+
});
|
|
6492
6499
|
results.forEach(i => {
|
|
6493
6500
|
slot.insert(i);
|
|
6494
6501
|
});
|
|
@@ -6517,6 +6524,9 @@ const tableComponentLoader = {
|
|
|
6517
6524
|
ContentType.Text
|
|
6518
6525
|
]), cell).toDelta();
|
|
6519
6526
|
const results = deltaToBlock(delta, textbus);
|
|
6527
|
+
delta.attributes.forEach((value, key) => {
|
|
6528
|
+
slot.setAttribute(key, value);
|
|
6529
|
+
});
|
|
6520
6530
|
results.forEach(i => {
|
|
6521
6531
|
slot.insert(i);
|
|
6522
6532
|
});
|
package/bundles/index.js
CHANGED
|
@@ -1279,6 +1279,166 @@ const highlightBoxComponentLoader = {
|
|
|
1279
1279
|
}
|
|
1280
1280
|
};
|
|
1281
1281
|
|
|
1282
|
+
const fontSizeFormatter = new core$1.Formatter('fontSize', {
|
|
1283
|
+
render(children, formatValue) {
|
|
1284
|
+
return {
|
|
1285
|
+
fallbackTagName: 'span',
|
|
1286
|
+
attach(host) {
|
|
1287
|
+
host.styles.set('fontSize', formatValue);
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
const fontSizeFormatLoader = {
|
|
1293
|
+
match(element) {
|
|
1294
|
+
return !!element.style.fontSize;
|
|
1295
|
+
},
|
|
1296
|
+
read(element) {
|
|
1297
|
+
return {
|
|
1298
|
+
formatter: fontSizeFormatter,
|
|
1299
|
+
value: element.style.fontSize
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
const boldFormatter = new core$1.Formatter('bold', {
|
|
1305
|
+
render(children) {
|
|
1306
|
+
return core$1.createVNode('strong', null, children);
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
function toggleBold(textbus) {
|
|
1310
|
+
const controller = textbus.get(core$1.Controller);
|
|
1311
|
+
if (controller.readonly) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
const query = textbus.get(core$1.Query);
|
|
1315
|
+
const commander = textbus.get(core$1.Commander);
|
|
1316
|
+
const state = query.queryFormat(boldFormatter);
|
|
1317
|
+
if (state.state === core$1.QueryStateType.Normal) {
|
|
1318
|
+
commander.applyFormat(boldFormatter, true);
|
|
1319
|
+
}
|
|
1320
|
+
else {
|
|
1321
|
+
commander.unApplyFormat(boldFormatter);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
function registerBoldShortcut(textbus) {
|
|
1325
|
+
const keyboard = textbus.get(core$1.Keyboard);
|
|
1326
|
+
keyboard.addShortcut({
|
|
1327
|
+
keymap: {
|
|
1328
|
+
modKey: true,
|
|
1329
|
+
key: 'b'
|
|
1330
|
+
},
|
|
1331
|
+
action: () => {
|
|
1332
|
+
toggleBold(textbus);
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
const boldFormatLoader = {
|
|
1337
|
+
match(element) {
|
|
1338
|
+
return element.tagName === 'STRONG' || element.tagName === 'B' || /bold|[5-9]00/.test(element.style.fontWeight);
|
|
1339
|
+
},
|
|
1340
|
+
read() {
|
|
1341
|
+
return {
|
|
1342
|
+
formatter: boldFormatter,
|
|
1343
|
+
value: true
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
|
|
1348
|
+
const colorFormatter = new core$1.Formatter('color', {
|
|
1349
|
+
render(children, formatValue) {
|
|
1350
|
+
return {
|
|
1351
|
+
fallbackTagName: 'span',
|
|
1352
|
+
attach(host) {
|
|
1353
|
+
host.styles.set('color', formatValue);
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
const colorFormatLoader = {
|
|
1359
|
+
match(element) {
|
|
1360
|
+
return !!element.style.color;
|
|
1361
|
+
},
|
|
1362
|
+
read(element) {
|
|
1363
|
+
return {
|
|
1364
|
+
formatter: colorFormatter,
|
|
1365
|
+
value: element.style.color
|
|
1366
|
+
};
|
|
1367
|
+
}
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
function createTimelineItem(textbus, theme) {
|
|
1371
|
+
const slot = new core$1.Slot([
|
|
1372
|
+
core$1.ContentType.BlockComponent,
|
|
1373
|
+
]);
|
|
1374
|
+
const title = new ParagraphComponent(textbus);
|
|
1375
|
+
title.state.slot.insert('时间主题', [
|
|
1376
|
+
[fontSizeFormatter, '18px'],
|
|
1377
|
+
[boldFormatter, true]
|
|
1378
|
+
]);
|
|
1379
|
+
title.state.slot.insert(' 2020-02-02', [
|
|
1380
|
+
[fontSizeFormatter, '15px'],
|
|
1381
|
+
[colorFormatter, '#777']
|
|
1382
|
+
]);
|
|
1383
|
+
const desc = new ParagraphComponent(textbus);
|
|
1384
|
+
desc.state.slot.insert('描述信息...');
|
|
1385
|
+
slot.insert(title);
|
|
1386
|
+
slot.insert(desc);
|
|
1387
|
+
return { theme, slot };
|
|
1388
|
+
}
|
|
1389
|
+
class TimelineComponent extends core$1.Component {
|
|
1390
|
+
static fromJSON(textbus, json) {
|
|
1391
|
+
const registry = textbus.get(core$1.Registry);
|
|
1392
|
+
return new TimelineComponent(textbus, {
|
|
1393
|
+
items: json.items.map(i => {
|
|
1394
|
+
return {
|
|
1395
|
+
theme: i.theme,
|
|
1396
|
+
slot: registry.createSlot(i.slot)
|
|
1397
|
+
};
|
|
1398
|
+
})
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
getSlots() {
|
|
1402
|
+
return this.state.items.map(i => i.slot);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
TimelineComponent.componentName = 'TimelineComponent';
|
|
1406
|
+
TimelineComponent.type = core$1.ContentType.BlockComponent;
|
|
1407
|
+
|
|
1408
|
+
function createStepItem(textbus) {
|
|
1409
|
+
const slot = new core$1.Slot([
|
|
1410
|
+
core$1.ContentType.BlockComponent
|
|
1411
|
+
]);
|
|
1412
|
+
const title = new ParagraphComponent(textbus);
|
|
1413
|
+
title.state.slot.insert('标题', [
|
|
1414
|
+
[fontSizeFormatter, '18px'],
|
|
1415
|
+
[boldFormatter, true]
|
|
1416
|
+
]);
|
|
1417
|
+
const content = new ParagraphComponent(textbus);
|
|
1418
|
+
content.state.slot.insert('描述信息...');
|
|
1419
|
+
slot.insert(title);
|
|
1420
|
+
slot.insert(content);
|
|
1421
|
+
return { slot };
|
|
1422
|
+
}
|
|
1423
|
+
class StepComponent extends core$1.Component {
|
|
1424
|
+
static fromJSON(textbus, json) {
|
|
1425
|
+
const registry = textbus.get(core$1.Registry);
|
|
1426
|
+
return new StepComponent(textbus, {
|
|
1427
|
+
step: json.step,
|
|
1428
|
+
items: json.items.map(i => {
|
|
1429
|
+
return {
|
|
1430
|
+
slot: registry.createSlot(i.slot)
|
|
1431
|
+
};
|
|
1432
|
+
})
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
getSlots() {
|
|
1436
|
+
return this.state.items.map(i => i.slot);
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
StepComponent.componentName = 'StepComponent';
|
|
1440
|
+
StepComponent.type = core$1.ContentType.BlockComponent;
|
|
1441
|
+
|
|
1282
1442
|
class ParagraphComponent extends core$1.Component {
|
|
1283
1443
|
static fromJSON(textbus, json) {
|
|
1284
1444
|
const slot = textbus.get(core$1.Registry).createSlot(json.slot);
|
|
@@ -1309,7 +1469,9 @@ class ParagraphComponent extends core$1.Component {
|
|
|
1309
1469
|
slot: afterSlot
|
|
1310
1470
|
});
|
|
1311
1471
|
if (isEmpty && (this.parentComponent instanceof BlockquoteComponent ||
|
|
1312
|
-
this.parentComponent instanceof HighlightBoxComponent
|
|
1472
|
+
this.parentComponent instanceof HighlightBoxComponent ||
|
|
1473
|
+
this.parentComponent instanceof TimelineComponent ||
|
|
1474
|
+
this.parentComponent instanceof StepComponent)) {
|
|
1313
1475
|
commander.insertAfter(nextParagraph, this.parentComponent);
|
|
1314
1476
|
commander.removeComponent(this);
|
|
1315
1477
|
}
|
|
@@ -3495,7 +3657,7 @@ const backgroundColorFormatter = new core$1.Formatter('backgroundColor', {
|
|
|
3495
3657
|
});
|
|
3496
3658
|
const backgroundColorFormatLoader = {
|
|
3497
3659
|
match(element) {
|
|
3498
|
-
return element.tagName !== 'TD' && !!element.style.backgroundColor;
|
|
3660
|
+
return element.tagName !== 'TD' && element.tagName !== 'TH' && !!element.style.backgroundColor;
|
|
3499
3661
|
},
|
|
3500
3662
|
read(element) {
|
|
3501
3663
|
return {
|
|
@@ -3505,50 +3667,6 @@ const backgroundColorFormatLoader = {
|
|
|
3505
3667
|
}
|
|
3506
3668
|
};
|
|
3507
3669
|
|
|
3508
|
-
const boldFormatter = new core$1.Formatter('bold', {
|
|
3509
|
-
render(children) {
|
|
3510
|
-
return core$1.createVNode('strong', null, children);
|
|
3511
|
-
}
|
|
3512
|
-
});
|
|
3513
|
-
function toggleBold(textbus) {
|
|
3514
|
-
const controller = textbus.get(core$1.Controller);
|
|
3515
|
-
if (controller.readonly) {
|
|
3516
|
-
return;
|
|
3517
|
-
}
|
|
3518
|
-
const query = textbus.get(core$1.Query);
|
|
3519
|
-
const commander = textbus.get(core$1.Commander);
|
|
3520
|
-
const state = query.queryFormat(boldFormatter);
|
|
3521
|
-
if (state.state === core$1.QueryStateType.Normal) {
|
|
3522
|
-
commander.applyFormat(boldFormatter, true);
|
|
3523
|
-
}
|
|
3524
|
-
else {
|
|
3525
|
-
commander.unApplyFormat(boldFormatter);
|
|
3526
|
-
}
|
|
3527
|
-
}
|
|
3528
|
-
function registerBoldShortcut(textbus) {
|
|
3529
|
-
const keyboard = textbus.get(core$1.Keyboard);
|
|
3530
|
-
keyboard.addShortcut({
|
|
3531
|
-
keymap: {
|
|
3532
|
-
modKey: true,
|
|
3533
|
-
key: 'b'
|
|
3534
|
-
},
|
|
3535
|
-
action: () => {
|
|
3536
|
-
toggleBold(textbus);
|
|
3537
|
-
}
|
|
3538
|
-
});
|
|
3539
|
-
}
|
|
3540
|
-
const boldFormatLoader = {
|
|
3541
|
-
match(element) {
|
|
3542
|
-
return element.tagName === 'STRONG' || element.tagName === 'B' || /bold|[5-9]00/.test(element.style.fontWeight);
|
|
3543
|
-
},
|
|
3544
|
-
read() {
|
|
3545
|
-
return {
|
|
3546
|
-
formatter: boldFormatter,
|
|
3547
|
-
value: true
|
|
3548
|
-
};
|
|
3549
|
-
}
|
|
3550
|
-
};
|
|
3551
|
-
|
|
3552
3670
|
const codeFormatter = new core$1.Formatter('code', {
|
|
3553
3671
|
inheritable: false,
|
|
3554
3672
|
render(children) {
|
|
@@ -3596,28 +3714,6 @@ const codeFormatLoader = {
|
|
|
3596
3714
|
}
|
|
3597
3715
|
};
|
|
3598
3716
|
|
|
3599
|
-
const colorFormatter = new core$1.Formatter('color', {
|
|
3600
|
-
render(children, formatValue) {
|
|
3601
|
-
return {
|
|
3602
|
-
fallbackTagName: 'span',
|
|
3603
|
-
attach(host) {
|
|
3604
|
-
host.styles.set('color', formatValue);
|
|
3605
|
-
}
|
|
3606
|
-
};
|
|
3607
|
-
}
|
|
3608
|
-
});
|
|
3609
|
-
const colorFormatLoader = {
|
|
3610
|
-
match(element) {
|
|
3611
|
-
return !!element.style.color;
|
|
3612
|
-
},
|
|
3613
|
-
read(element) {
|
|
3614
|
-
return {
|
|
3615
|
-
formatter: colorFormatter,
|
|
3616
|
-
value: element.style.color
|
|
3617
|
-
};
|
|
3618
|
-
}
|
|
3619
|
-
};
|
|
3620
|
-
|
|
3621
3717
|
const fontFamilyFormatter = new core$1.Formatter('fontFamily', {
|
|
3622
3718
|
render(children, formatValue) {
|
|
3623
3719
|
return {
|
|
@@ -3640,28 +3736,6 @@ const fontFamilyFormatLoader = {
|
|
|
3640
3736
|
}
|
|
3641
3737
|
};
|
|
3642
3738
|
|
|
3643
|
-
const fontSizeFormatter = new core$1.Formatter('fontSize', {
|
|
3644
|
-
render(children, formatValue) {
|
|
3645
|
-
return {
|
|
3646
|
-
fallbackTagName: 'span',
|
|
3647
|
-
attach(host) {
|
|
3648
|
-
host.styles.set('fontSize', formatValue);
|
|
3649
|
-
}
|
|
3650
|
-
};
|
|
3651
|
-
}
|
|
3652
|
-
});
|
|
3653
|
-
const fontSizeFormatLoader = {
|
|
3654
|
-
match(element) {
|
|
3655
|
-
return !!element.style.fontSize;
|
|
3656
|
-
},
|
|
3657
|
-
read(element) {
|
|
3658
|
-
return {
|
|
3659
|
-
formatter: fontSizeFormatter,
|
|
3660
|
-
value: element.style.fontSize
|
|
3661
|
-
};
|
|
3662
|
-
}
|
|
3663
|
-
};
|
|
3664
|
-
|
|
3665
3739
|
const italicFormatter = new core$1.Formatter('italic', {
|
|
3666
3740
|
render(children) {
|
|
3667
3741
|
return core$1.createVNode('em', null, children);
|
|
@@ -4321,14 +4395,14 @@ const cellBackgroundAttr = new core$1.Attribute('cellBackground', {
|
|
|
4321
4395
|
}
|
|
4322
4396
|
hsl.s *= 0.7;
|
|
4323
4397
|
const newRgba = color.hsl2Rgb(hsl);
|
|
4324
|
-
node.styles.set('borderColor', `rgba(${newRgba.r}, ${newRgba.g}, ${newRgba.b}, ${rgba.a})`);
|
|
4398
|
+
node.styles.set('borderColor', `rgba(${newRgba.r}, ${newRgba.g}, ${newRgba.b}, ${rgba.a || 1})`);
|
|
4325
4399
|
}
|
|
4326
4400
|
node.styles.set('backgroundColor', formatValue);
|
|
4327
4401
|
}
|
|
4328
4402
|
});
|
|
4329
4403
|
const cellBackgroundAttrLoader = {
|
|
4330
4404
|
match(element) {
|
|
4331
|
-
return element
|
|
4405
|
+
return (element.tagName === 'TD' || element.tagName === 'TH') && !!element.style.backgroundColor;
|
|
4332
4406
|
},
|
|
4333
4407
|
read(element) {
|
|
4334
4408
|
return {
|
|
@@ -4692,78 +4766,6 @@ const katexComponentLoader = {
|
|
|
4692
4766
|
}
|
|
4693
4767
|
};
|
|
4694
4768
|
|
|
4695
|
-
function createTimelineItem(textbus, theme) {
|
|
4696
|
-
const slot = new core$1.Slot([
|
|
4697
|
-
core$1.ContentType.BlockComponent,
|
|
4698
|
-
]);
|
|
4699
|
-
const title = new ParagraphComponent(textbus);
|
|
4700
|
-
title.state.slot.insert('时间主题', [
|
|
4701
|
-
[fontSizeFormatter, '18px'],
|
|
4702
|
-
[boldFormatter, true]
|
|
4703
|
-
]);
|
|
4704
|
-
title.state.slot.insert(' 2020-02-02', [
|
|
4705
|
-
[fontSizeFormatter, '15px'],
|
|
4706
|
-
[colorFormatter, '#777']
|
|
4707
|
-
]);
|
|
4708
|
-
const desc = new ParagraphComponent(textbus);
|
|
4709
|
-
desc.state.slot.insert('描述信息...');
|
|
4710
|
-
slot.insert(title);
|
|
4711
|
-
slot.insert(desc);
|
|
4712
|
-
return { theme, slot };
|
|
4713
|
-
}
|
|
4714
|
-
class TimelineComponent extends core$1.Component {
|
|
4715
|
-
static fromJSON(textbus, json) {
|
|
4716
|
-
const registry = textbus.get(core$1.Registry);
|
|
4717
|
-
return new TimelineComponent(textbus, {
|
|
4718
|
-
items: json.items.map(i => {
|
|
4719
|
-
return {
|
|
4720
|
-
theme: i.theme,
|
|
4721
|
-
slot: registry.createSlot(i.slot)
|
|
4722
|
-
};
|
|
4723
|
-
})
|
|
4724
|
-
});
|
|
4725
|
-
}
|
|
4726
|
-
getSlots() {
|
|
4727
|
-
return this.state.items.map(i => i.slot);
|
|
4728
|
-
}
|
|
4729
|
-
}
|
|
4730
|
-
TimelineComponent.componentName = 'TimelineComponent';
|
|
4731
|
-
TimelineComponent.type = core$1.ContentType.BlockComponent;
|
|
4732
|
-
|
|
4733
|
-
function createStepItem(textbus) {
|
|
4734
|
-
const slot = new core$1.Slot([
|
|
4735
|
-
core$1.ContentType.BlockComponent
|
|
4736
|
-
]);
|
|
4737
|
-
const title = new ParagraphComponent(textbus);
|
|
4738
|
-
title.state.slot.insert('标题', [
|
|
4739
|
-
[fontSizeFormatter, '18px'],
|
|
4740
|
-
[boldFormatter, true]
|
|
4741
|
-
]);
|
|
4742
|
-
const content = new ParagraphComponent(textbus);
|
|
4743
|
-
content.state.slot.insert('描述信息...');
|
|
4744
|
-
slot.insert(title);
|
|
4745
|
-
slot.insert(content);
|
|
4746
|
-
return { slot };
|
|
4747
|
-
}
|
|
4748
|
-
class StepComponent extends core$1.Component {
|
|
4749
|
-
static fromJSON(textbus, json) {
|
|
4750
|
-
const registry = textbus.get(core$1.Registry);
|
|
4751
|
-
return new StepComponent(textbus, {
|
|
4752
|
-
step: json.step,
|
|
4753
|
-
items: json.items.map(i => {
|
|
4754
|
-
return {
|
|
4755
|
-
slot: registry.createSlot(i.slot)
|
|
4756
|
-
};
|
|
4757
|
-
})
|
|
4758
|
-
});
|
|
4759
|
-
}
|
|
4760
|
-
getSlots() {
|
|
4761
|
-
return this.state.items.map(i => i.slot);
|
|
4762
|
-
}
|
|
4763
|
-
}
|
|
4764
|
-
StepComponent.componentName = 'StepComponent';
|
|
4765
|
-
StepComponent.type = core$1.ContentType.BlockComponent;
|
|
4766
|
-
|
|
4767
4769
|
function InsertTool(props) {
|
|
4768
4770
|
const commander = core.inject(core$1.Commander);
|
|
4769
4771
|
const selection = core.inject(core$1.Selection);
|
|
@@ -6424,7 +6426,9 @@ const TableComponentView = core.withAnnotation({
|
|
|
6424
6426
|
], children: [jsxRuntime.jsx("colgroup", { children: state.columnsConfig.map(w => {
|
|
6425
6427
|
return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
|
|
6426
6428
|
}) }), jsxRuntime.jsx("tbody", { children: normalizedData.map((row) => {
|
|
6427
|
-
return (jsxRuntime.jsx("tr", { children: row.cells.
|
|
6429
|
+
return (jsxRuntime.jsx("tr", { children: row.cells.filter(i => {
|
|
6430
|
+
return i.visible;
|
|
6431
|
+
}).map(cell => {
|
|
6428
6432
|
return adapter.slotRender(cell.raw.slot, children => {
|
|
6429
6433
|
return core$1.createVNode('td', {
|
|
6430
6434
|
key: cell.raw.id,
|
|
@@ -6491,6 +6495,9 @@ const tableComponentLoader = {
|
|
|
6491
6495
|
core$1.ContentType.Text
|
|
6492
6496
|
]), cell).toDelta();
|
|
6493
6497
|
const results = deltaToBlock(delta, textbus);
|
|
6498
|
+
delta.attributes.forEach((value, key) => {
|
|
6499
|
+
slot.setAttribute(key, value);
|
|
6500
|
+
});
|
|
6494
6501
|
results.forEach(i => {
|
|
6495
6502
|
slot.insert(i);
|
|
6496
6503
|
});
|
|
@@ -6519,6 +6526,9 @@ const tableComponentLoader = {
|
|
|
6519
6526
|
core$1.ContentType.Text
|
|
6520
6527
|
]), cell).toDelta();
|
|
6521
6528
|
const results = deltaToBlock(delta, textbus);
|
|
6529
|
+
delta.attributes.forEach((value, key) => {
|
|
6530
|
+
slot.setAttribute(key, value);
|
|
6531
|
+
});
|
|
6522
6532
|
results.forEach(i => {
|
|
6523
6533
|
slot.insert(i);
|
|
6524
6534
|
});
|
package/package.json
CHANGED