@textbus/xnote 0.3.4 → 0.3.6
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 +309 -390
- package/bundles/index.js +307 -388
- package/bundles/plugins/tools/_common/tool.service.d.ts +0 -2
- package/bundles/textbus/components/at/at.component.d.ts +1 -1
- package/bundles/textbus/components/blockqoute/blockquote.component.d.ts +1 -1
- package/bundles/textbus/components/highlight-box/highlight-box.component.d.ts +1 -1
- package/bundles/textbus/components/katex/katex.component.d.ts +1 -1
- package/bundles/textbus/components/paragraph/paragraph.component.d.ts +2 -2
- package/bundles/textbus/components/root/root.component.d.ts +1 -1
- package/bundles/textbus/components/step/step.component.d.ts +1 -1
- package/bundles/textbus/components/table/table.component.d.ts +1 -1
- package/bundles/textbus/components/timeline/timeline.component.d.ts +1 -1
- package/bundles/textbus/components/video/video.component.d.ts +1 -1
- package/index.tsx +7 -7
- package/package.json +9 -10
package/bundles/index.js
CHANGED
|
@@ -7,7 +7,6 @@ var core$1 = require('@textbus/core');
|
|
|
7
7
|
var color = require('@tanbo/color');
|
|
8
8
|
var platformBrowser = require('@textbus/platform-browser');
|
|
9
9
|
var platformBrowser$1 = require('@viewfly/platform-browser');
|
|
10
|
-
var hooks = require('@viewfly/hooks');
|
|
11
10
|
var highlightjs = require('highlight.js');
|
|
12
11
|
var uuid = require('uuid');
|
|
13
12
|
var Katex = require('katex');
|
|
@@ -1166,7 +1165,7 @@ function useBlockContent(slot) {
|
|
|
1166
1165
|
const selection = textbus.get(core$1.Selection);
|
|
1167
1166
|
core$1.onBreak(ev => {
|
|
1168
1167
|
if (typeof slot === 'function' ? slot(ev.target) : ev.target === slot) {
|
|
1169
|
-
const p = new ParagraphComponent(
|
|
1168
|
+
const p = new ParagraphComponent();
|
|
1170
1169
|
ev.target.insert(p);
|
|
1171
1170
|
selection.setPosition(p.state.slot, 0);
|
|
1172
1171
|
ev.preventDefault();
|
|
@@ -1175,7 +1174,7 @@ function useBlockContent(slot) {
|
|
|
1175
1174
|
core$1.onContentInsert(ev => {
|
|
1176
1175
|
if ((typeof slot === 'function' ? slot(ev.target) : ev.target === slot) &&
|
|
1177
1176
|
(typeof ev.data.content === 'string' || ev.data.content.type !== core$1.ContentType.BlockComponent)) {
|
|
1178
|
-
const p = new ParagraphComponent(
|
|
1177
|
+
const p = new ParagraphComponent();
|
|
1179
1178
|
const childSlot = p.state.slot;
|
|
1180
1179
|
childSlot.insert(ev.data.content);
|
|
1181
1180
|
ev.target.insert(p);
|
|
@@ -1197,10 +1196,12 @@ function SlotRender(props) {
|
|
|
1197
1196
|
});
|
|
1198
1197
|
}
|
|
1199
1198
|
let sub = listen(slot);
|
|
1200
|
-
core.
|
|
1201
|
-
|
|
1199
|
+
core.watch(() => {
|
|
1200
|
+
return props.slot;
|
|
1201
|
+
}, (currentSlot, oldSlot) => {
|
|
1202
|
+
if (oldSlot !== currentSlot) {
|
|
1202
1203
|
sub.unsubscribe();
|
|
1203
|
-
sub = listen(
|
|
1204
|
+
sub = listen(currentSlot);
|
|
1204
1205
|
}
|
|
1205
1206
|
});
|
|
1206
1207
|
core.onUnmounted(() => {
|
|
@@ -1217,16 +1218,16 @@ function SlotRender(props) {
|
|
|
1217
1218
|
class BlockquoteComponent extends core$1.Component {
|
|
1218
1219
|
static fromJSON(textbus, json) {
|
|
1219
1220
|
const slot = textbus.get(core$1.Registry).createSlot(json.slot);
|
|
1220
|
-
return new BlockquoteComponent(
|
|
1221
|
+
return new BlockquoteComponent({
|
|
1221
1222
|
slot
|
|
1222
1223
|
});
|
|
1223
1224
|
}
|
|
1224
|
-
constructor(
|
|
1225
|
+
constructor(state = {
|
|
1225
1226
|
slot: new core$1.Slot([
|
|
1226
1227
|
core$1.ContentType.BlockComponent
|
|
1227
1228
|
])
|
|
1228
1229
|
}) {
|
|
1229
|
-
super(
|
|
1230
|
+
super(state);
|
|
1230
1231
|
}
|
|
1231
1232
|
getSlots() {
|
|
1232
1233
|
return [this.state.slot];
|
|
@@ -1291,7 +1292,7 @@ function toBlockquote(textbus) {
|
|
|
1291
1292
|
});
|
|
1292
1293
|
}
|
|
1293
1294
|
else {
|
|
1294
|
-
const block = new BlockquoteComponent(
|
|
1295
|
+
const block = new BlockquoteComponent();
|
|
1295
1296
|
const slot = block.state.slot;
|
|
1296
1297
|
if (selection.startSlot === selection.endSlot) {
|
|
1297
1298
|
const parentComponent = selection.startSlot.parent;
|
|
@@ -1336,7 +1337,7 @@ const blockquoteComponentLoader = {
|
|
|
1336
1337
|
match(element, returnableContentTypes) {
|
|
1337
1338
|
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) && element.tagName === 'BLOCKQUOTE';
|
|
1338
1339
|
},
|
|
1339
|
-
read(element,
|
|
1340
|
+
read(element, _, slotParser) {
|
|
1340
1341
|
const delta = slotParser(new core$1.Slot([
|
|
1341
1342
|
core$1.ContentType.BlockComponent,
|
|
1342
1343
|
core$1.ContentType.InlineComponent,
|
|
@@ -1345,10 +1346,10 @@ const blockquoteComponentLoader = {
|
|
|
1345
1346
|
const slot = new core$1.Slot([
|
|
1346
1347
|
core$1.ContentType.BlockComponent,
|
|
1347
1348
|
]);
|
|
1348
|
-
deltaToBlock(delta
|
|
1349
|
+
deltaToBlock(delta).forEach(i => {
|
|
1349
1350
|
slot.insert(i);
|
|
1350
1351
|
});
|
|
1351
|
-
return new BlockquoteComponent(
|
|
1352
|
+
return new BlockquoteComponent({
|
|
1352
1353
|
slot
|
|
1353
1354
|
});
|
|
1354
1355
|
},
|
|
@@ -1356,18 +1357,18 @@ const blockquoteComponentLoader = {
|
|
|
1356
1357
|
|
|
1357
1358
|
class HighlightBoxComponent extends core$1.Component {
|
|
1358
1359
|
static fromJSON(textbus, json) {
|
|
1359
|
-
return new HighlightBoxComponent(
|
|
1360
|
+
return new HighlightBoxComponent({
|
|
1360
1361
|
type: json.type,
|
|
1361
1362
|
slot: textbus.get(core$1.Registry).createSlot(json.slot)
|
|
1362
1363
|
});
|
|
1363
1364
|
}
|
|
1364
|
-
constructor(
|
|
1365
|
+
constructor(state = {
|
|
1365
1366
|
type: '',
|
|
1366
1367
|
slot: new core$1.Slot([
|
|
1367
1368
|
core$1.ContentType.BlockComponent,
|
|
1368
1369
|
])
|
|
1369
1370
|
}) {
|
|
1370
|
-
super(
|
|
1371
|
+
super(state);
|
|
1371
1372
|
}
|
|
1372
1373
|
getSlots() {
|
|
1373
1374
|
return [this.state.slot];
|
|
@@ -1433,10 +1434,10 @@ const highlightBoxComponentLoader = {
|
|
|
1433
1434
|
const slot = new core$1.Slot([
|
|
1434
1435
|
core$1.ContentType.BlockComponent,
|
|
1435
1436
|
]);
|
|
1436
|
-
deltaToBlock(delta
|
|
1437
|
+
deltaToBlock(delta).forEach(i => {
|
|
1437
1438
|
slot.insert(i);
|
|
1438
1439
|
});
|
|
1439
|
-
return new HighlightBoxComponent(
|
|
1440
|
+
return new HighlightBoxComponent({
|
|
1440
1441
|
type: element.dataset.icon || '',
|
|
1441
1442
|
slot
|
|
1442
1443
|
});
|
|
@@ -1531,11 +1532,11 @@ const colorFormatLoader = {
|
|
|
1531
1532
|
}
|
|
1532
1533
|
};
|
|
1533
1534
|
|
|
1534
|
-
function createTimelineItem(
|
|
1535
|
+
function createTimelineItem(theme) {
|
|
1535
1536
|
const slot = new core$1.Slot([
|
|
1536
1537
|
core$1.ContentType.BlockComponent,
|
|
1537
1538
|
]);
|
|
1538
|
-
const title = new ParagraphComponent(
|
|
1539
|
+
const title = new ParagraphComponent();
|
|
1539
1540
|
title.state.slot.insert('时间主题', [
|
|
1540
1541
|
[fontSizeFormatter, '18px'],
|
|
1541
1542
|
[boldFormatter, true]
|
|
@@ -1544,7 +1545,7 @@ function createTimelineItem(textbus, theme) {
|
|
|
1544
1545
|
[fontSizeFormatter, '15px'],
|
|
1545
1546
|
[colorFormatter, '#777']
|
|
1546
1547
|
]);
|
|
1547
|
-
const desc = new ParagraphComponent(
|
|
1548
|
+
const desc = new ParagraphComponent();
|
|
1548
1549
|
desc.state.slot.insert('描述信息...');
|
|
1549
1550
|
slot.insert(title);
|
|
1550
1551
|
slot.insert(desc);
|
|
@@ -1553,7 +1554,7 @@ function createTimelineItem(textbus, theme) {
|
|
|
1553
1554
|
class TimelineComponent extends core$1.Component {
|
|
1554
1555
|
static fromJSON(textbus, json) {
|
|
1555
1556
|
const registry = textbus.get(core$1.Registry);
|
|
1556
|
-
return new TimelineComponent(
|
|
1557
|
+
return new TimelineComponent({
|
|
1557
1558
|
items: json.items.map(i => {
|
|
1558
1559
|
return {
|
|
1559
1560
|
theme: i.theme,
|
|
@@ -1587,16 +1588,16 @@ Object.defineProperty(TimelineComponent, "type", {
|
|
|
1587
1588
|
value: core$1.ContentType.BlockComponent
|
|
1588
1589
|
});
|
|
1589
1590
|
|
|
1590
|
-
function createStepItem(
|
|
1591
|
+
function createStepItem() {
|
|
1591
1592
|
const slot = new core$1.Slot([
|
|
1592
1593
|
core$1.ContentType.BlockComponent
|
|
1593
1594
|
]);
|
|
1594
|
-
const title = new ParagraphComponent(
|
|
1595
|
+
const title = new ParagraphComponent();
|
|
1595
1596
|
title.state.slot.insert('标题', [
|
|
1596
1597
|
[fontSizeFormatter, '18px'],
|
|
1597
1598
|
[boldFormatter, true]
|
|
1598
1599
|
]);
|
|
1599
|
-
const content = new ParagraphComponent(
|
|
1600
|
+
const content = new ParagraphComponent();
|
|
1600
1601
|
content.state.slot.insert('描述信息...');
|
|
1601
1602
|
slot.insert(title);
|
|
1602
1603
|
slot.insert(content);
|
|
@@ -1605,7 +1606,7 @@ function createStepItem(textbus) {
|
|
|
1605
1606
|
class StepComponent extends core$1.Component {
|
|
1606
1607
|
static fromJSON(textbus, json) {
|
|
1607
1608
|
const registry = textbus.get(core$1.Registry);
|
|
1608
|
-
return new StepComponent(
|
|
1609
|
+
return new StepComponent({
|
|
1609
1610
|
step: json.step,
|
|
1610
1611
|
items: json.items.map(i => {
|
|
1611
1612
|
return {
|
|
@@ -1645,17 +1646,17 @@ Object.defineProperty(StepComponent, "type", {
|
|
|
1645
1646
|
class ParagraphComponent extends core$1.Component {
|
|
1646
1647
|
static fromJSON(textbus, json) {
|
|
1647
1648
|
const slot = textbus.get(core$1.Registry).createSlot(json.slot);
|
|
1648
|
-
return new ParagraphComponent(
|
|
1649
|
+
return new ParagraphComponent({
|
|
1649
1650
|
slot
|
|
1650
1651
|
});
|
|
1651
1652
|
}
|
|
1652
|
-
constructor(
|
|
1653
|
+
constructor(state = {
|
|
1653
1654
|
slot: new core$1.Slot([
|
|
1654
1655
|
core$1.ContentType.InlineComponent,
|
|
1655
1656
|
core$1.ContentType.Text
|
|
1656
1657
|
])
|
|
1657
1658
|
}) {
|
|
1658
|
-
super(
|
|
1659
|
+
super(state);
|
|
1659
1660
|
}
|
|
1660
1661
|
getSlots() {
|
|
1661
1662
|
return [this.state.slot];
|
|
@@ -1668,7 +1669,7 @@ class ParagraphComponent extends core$1.Component {
|
|
|
1668
1669
|
const isEmpty = this.state.slot.isEmpty;
|
|
1669
1670
|
const afterSlot = ev.target.cut(ev.data.index);
|
|
1670
1671
|
afterSlot.removeAttribute(headingAttr);
|
|
1671
|
-
const nextParagraph = new ParagraphComponent(
|
|
1672
|
+
const nextParagraph = new ParagraphComponent({
|
|
1672
1673
|
slot: afterSlot
|
|
1673
1674
|
});
|
|
1674
1675
|
if (isEmpty && (this.parentComponent instanceof BlockquoteComponent ||
|
|
@@ -1711,7 +1712,7 @@ const paragraphComponentLoader = {
|
|
|
1711
1712
|
return returnableContentTypes.includes(core$1.ContentType.BlockComponent) &&
|
|
1712
1713
|
(element.dataset.component === ParagraphComponent.componentName || /^P|H[1-6]$/.test(element.tagName));
|
|
1713
1714
|
},
|
|
1714
|
-
read(element,
|
|
1715
|
+
read(element, _, slotParser) {
|
|
1715
1716
|
let content;
|
|
1716
1717
|
if (/^P|H[1-6]$/.test(element.tagName)) {
|
|
1717
1718
|
content = element;
|
|
@@ -1729,7 +1730,7 @@ const paragraphComponentLoader = {
|
|
|
1729
1730
|
core$1.ContentType.InlineComponent,
|
|
1730
1731
|
core$1.ContentType.BlockComponent
|
|
1731
1732
|
]), content).toDelta();
|
|
1732
|
-
const results = deltaToBlock(delta
|
|
1733
|
+
const results = deltaToBlock(delta);
|
|
1733
1734
|
if (results.length === 1) {
|
|
1734
1735
|
return results[0];
|
|
1735
1736
|
}
|
|
@@ -1742,7 +1743,7 @@ const paragraphComponentLoader = {
|
|
|
1742
1743
|
return containerSlot;
|
|
1743
1744
|
}
|
|
1744
1745
|
};
|
|
1745
|
-
function deltaToBlock(delta
|
|
1746
|
+
function deltaToBlock(delta) {
|
|
1746
1747
|
const results = [];
|
|
1747
1748
|
let slot = null;
|
|
1748
1749
|
for (const item of delta) {
|
|
@@ -1755,7 +1756,7 @@ function deltaToBlock(delta, textbus) {
|
|
|
1755
1756
|
delta.attributes.forEach((value, key) => {
|
|
1756
1757
|
slot.setAttribute(key, value);
|
|
1757
1758
|
});
|
|
1758
|
-
results.push(new ParagraphComponent(
|
|
1759
|
+
results.push(new ParagraphComponent({
|
|
1759
1760
|
slot
|
|
1760
1761
|
}));
|
|
1761
1762
|
}
|
|
@@ -1920,7 +1921,7 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
1920
1921
|
}
|
|
1921
1922
|
static fromJSON(textbus, json) {
|
|
1922
1923
|
const registry = textbus.get(core$1.Registry);
|
|
1923
|
-
return new SourceCodeComponent(
|
|
1924
|
+
return new SourceCodeComponent({
|
|
1924
1925
|
slots: json.slots.map(item => {
|
|
1925
1926
|
return {
|
|
1926
1927
|
slot: registry.createSlot(item.slot),
|
|
@@ -1950,7 +1951,7 @@ class SourceCodeComponent extends core$1.Component {
|
|
|
1950
1951
|
core$1.ContentType.InlineComponent,
|
|
1951
1952
|
core$1.ContentType.Text
|
|
1952
1953
|
]);
|
|
1953
|
-
const paragraph = new ParagraphComponent(
|
|
1954
|
+
const paragraph = new ParagraphComponent({
|
|
1954
1955
|
slot
|
|
1955
1956
|
});
|
|
1956
1957
|
const index = parentSlot.indexOf(parentComponent);
|
|
@@ -2288,7 +2289,8 @@ function SourceCodeView(props) {
|
|
|
2288
2289
|
}
|
|
2289
2290
|
}
|
|
2290
2291
|
return core$1.createVNode('div', {
|
|
2291
|
-
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : '')
|
|
2292
|
+
class: 'xnote-source-code-line' + (item.emphasize ? ' xnote-source-code-line-emphasize' : ''),
|
|
2293
|
+
key: item.slot.id
|
|
2292
2294
|
}, [
|
|
2293
2295
|
core$1.createVNode('span', { class: 'xnote-source-code-line-content' }, children)
|
|
2294
2296
|
]);
|
|
@@ -2324,7 +2326,7 @@ const sourceCodeComponentLoader = {
|
|
|
2324
2326
|
((element.tagName === 'DIV' && element.dataset.component === SourceCodeComponent.componentName) ||
|
|
2325
2327
|
element.tagName === 'PRE');
|
|
2326
2328
|
},
|
|
2327
|
-
read(el
|
|
2329
|
+
read(el) {
|
|
2328
2330
|
let slots = [];
|
|
2329
2331
|
if (el.tagName === 'DIV') {
|
|
2330
2332
|
const lines = el.querySelectorAll('.xnote-source-code-line');
|
|
@@ -2347,7 +2349,7 @@ const sourceCodeComponentLoader = {
|
|
|
2347
2349
|
return item;
|
|
2348
2350
|
});
|
|
2349
2351
|
}
|
|
2350
|
-
return new SourceCodeComponent(
|
|
2352
|
+
return new SourceCodeComponent({
|
|
2351
2353
|
lang: el.dataset.lang || '',
|
|
2352
2354
|
theme: el.dataset.theme || '',
|
|
2353
2355
|
lineNumber: el.dataset.lineNumber === 'true',
|
|
@@ -2442,7 +2444,7 @@ function registerTextIndentShortcut(textbus) {
|
|
|
2442
2444
|
|
|
2443
2445
|
class ImageComponent extends core$1.Component {
|
|
2444
2446
|
static fromJSON(textbus, json) {
|
|
2445
|
-
return new ImageComponent(
|
|
2447
|
+
return new ImageComponent(Object.assign({}, json));
|
|
2446
2448
|
}
|
|
2447
2449
|
getSlots() {
|
|
2448
2450
|
return [];
|
|
@@ -2482,9 +2484,9 @@ const imageComponentLoader = {
|
|
|
2482
2484
|
match(element) {
|
|
2483
2485
|
return element.tagName === 'IMG' || element.dataset.component === ImageComponent.componentName;
|
|
2484
2486
|
},
|
|
2485
|
-
read(element
|
|
2487
|
+
read(element) {
|
|
2486
2488
|
const img = element instanceof HTMLImageElement ? element : (element.querySelector('img') || document.createElement('img'));
|
|
2487
|
-
return new ImageComponent(
|
|
2489
|
+
return new ImageComponent({
|
|
2488
2490
|
src: img.src,
|
|
2489
2491
|
width: img.style.width || 'auto',
|
|
2490
2492
|
height: img.style.height || 'auto'
|
|
@@ -2493,8 +2495,8 @@ const imageComponentLoader = {
|
|
|
2493
2495
|
};
|
|
2494
2496
|
|
|
2495
2497
|
class VideoComponent extends core$1.Component {
|
|
2496
|
-
static fromJSON(
|
|
2497
|
-
return new VideoComponent(
|
|
2498
|
+
static fromJSON(_, json) {
|
|
2499
|
+
return new VideoComponent(Object.assign({}, json));
|
|
2498
2500
|
}
|
|
2499
2501
|
getSlots() {
|
|
2500
2502
|
return [];
|
|
@@ -2534,9 +2536,9 @@ const videoComponentLoader = {
|
|
|
2534
2536
|
match(element) {
|
|
2535
2537
|
return element.tagName === 'VIDEO' || element.dataset.component === VideoComponent.componentName;
|
|
2536
2538
|
},
|
|
2537
|
-
read(element
|
|
2539
|
+
read(element) {
|
|
2538
2540
|
const video = element instanceof HTMLVideoElement ? element : (element.querySelector('video') || document.createElement('video'));
|
|
2539
|
-
return new VideoComponent(
|
|
2541
|
+
return new VideoComponent({
|
|
2540
2542
|
src: video.src,
|
|
2541
2543
|
width: video.style.width || 'auto',
|
|
2542
2544
|
height: video.style.height || 'auto'
|
|
@@ -2546,18 +2548,6 @@ const videoComponentLoader = {
|
|
|
2546
2548
|
|
|
2547
2549
|
let ToolService = class ToolService {
|
|
2548
2550
|
constructor(selection, controller) {
|
|
2549
|
-
Object.defineProperty(this, "selection", {
|
|
2550
|
-
enumerable: true,
|
|
2551
|
-
configurable: true,
|
|
2552
|
-
writable: true,
|
|
2553
|
-
value: selection
|
|
2554
|
-
});
|
|
2555
|
-
Object.defineProperty(this, "controller", {
|
|
2556
|
-
enumerable: true,
|
|
2557
|
-
configurable: true,
|
|
2558
|
-
writable: true,
|
|
2559
|
-
value: controller
|
|
2560
|
-
});
|
|
2561
2551
|
Object.defineProperty(this, "state", {
|
|
2562
2552
|
enumerable: true,
|
|
2563
2553
|
configurable: true,
|
|
@@ -2570,12 +2560,11 @@ let ToolService = class ToolService {
|
|
|
2570
2560
|
writable: true,
|
|
2571
2561
|
value: void 0
|
|
2572
2562
|
});
|
|
2573
|
-
|
|
2563
|
+
this.state = core.createSignal({
|
|
2574
2564
|
inSourceCode: false,
|
|
2575
2565
|
readonly: controller.readonly,
|
|
2576
2566
|
selectEmbed: false,
|
|
2577
2567
|
});
|
|
2578
|
-
this.state = state;
|
|
2579
2568
|
this.sub = core$1.merge(selection.onChange, controller.onReadonlyStateChange).subscribe(() => {
|
|
2580
2569
|
const { startSlot, endSlot, startOffset, endOffset } = selection;
|
|
2581
2570
|
let is = false;
|
|
@@ -2585,10 +2574,10 @@ let ToolService = class ToolService {
|
|
|
2585
2574
|
is = true;
|
|
2586
2575
|
}
|
|
2587
2576
|
}
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2577
|
+
this.state.set({
|
|
2578
|
+
selectEmbed: is,
|
|
2579
|
+
readonly: controller.readonly,
|
|
2580
|
+
inSourceCode: selection.commonAncestorComponent instanceof SourceCodeComponent
|
|
2592
2581
|
});
|
|
2593
2582
|
});
|
|
2594
2583
|
}
|
|
@@ -2612,7 +2601,7 @@ function AttrTool(props) {
|
|
|
2612
2601
|
const selection = core.inject(core$1.Selection);
|
|
2613
2602
|
const query = core.inject(core$1.Query);
|
|
2614
2603
|
const refreshService = core.inject(exports.RefreshService);
|
|
2615
|
-
const
|
|
2604
|
+
const checkStates = core.reactive({
|
|
2616
2605
|
textAlign: 'left',
|
|
2617
2606
|
textIndent: 0
|
|
2618
2607
|
});
|
|
@@ -2620,23 +2609,21 @@ function AttrTool(props) {
|
|
|
2620
2609
|
if (!props.slot && !selection.isSelected) {
|
|
2621
2610
|
return;
|
|
2622
2611
|
}
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
draft.textIndent = textIndentState.state === core$1.QueryStateType.Enabled ? textIndentState.value : 0;
|
|
2639
|
-
});
|
|
2612
|
+
const range = props.slot ? {
|
|
2613
|
+
startSlot: props.slot,
|
|
2614
|
+
endSlot: props.slot,
|
|
2615
|
+
startOffset: 0,
|
|
2616
|
+
endOffset: props.slot.length
|
|
2617
|
+
} : {
|
|
2618
|
+
startSlot: selection.startSlot,
|
|
2619
|
+
startOffset: selection.startOffset,
|
|
2620
|
+
endSlot: selection.endSlot,
|
|
2621
|
+
endOffset: selection.endOffset
|
|
2622
|
+
};
|
|
2623
|
+
const textAlignState = query.queryAttributeByRange(textAlignAttr, range);
|
|
2624
|
+
const textIndentState = query.queryAttributeByRange(textIndentAttr, range);
|
|
2625
|
+
checkStates.textAlign = textAlignState.state === core$1.QueryStateType.Enabled ? textAlignState.value : 'left';
|
|
2626
|
+
checkStates.textIndent = textIndentState.state === core$1.QueryStateType.Enabled ? textIndentState.value : 0;
|
|
2640
2627
|
}
|
|
2641
2628
|
updateCheckStates();
|
|
2642
2629
|
const subscription = refreshService.onRefresh.subscribe(() => {
|
|
@@ -2685,20 +2672,19 @@ function AttrTool(props) {
|
|
|
2685
2672
|
}
|
|
2686
2673
|
const commonState = useCommonState();
|
|
2687
2674
|
return scopedCss.withScopedCSS(scopedId$e, () => {
|
|
2688
|
-
const states = checkStates();
|
|
2689
2675
|
const b = commonState().inSourceCode || commonState().readonly;
|
|
2690
2676
|
return (jsxRuntime.jsx(Dropdown, { disabled: b, width: 'auto', style: props.style, abreast: props.abreast, onCheck: updateAttr, trigger: 'hover', menu: [
|
|
2691
2677
|
{
|
|
2692
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'L', modKey: true } }), checked:
|
|
2678
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-left" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'L', modKey: true } }), checked: checkStates.textAlign === 'left', children: "\u5DE6\u5BF9\u9F50" }),
|
|
2693
2679
|
value: 't-l'
|
|
2694
2680
|
}, {
|
|
2695
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'R', modKey: true } }), checked:
|
|
2681
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-right" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'R', modKey: true } }), checked: checkStates.textAlign === 'right', children: "\u53F3\u5BF9\u9F50" }),
|
|
2696
2682
|
value: 't-r'
|
|
2697
2683
|
}, {
|
|
2698
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'E', modKey: true } }), checked:
|
|
2684
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-center" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'E', modKey: true } }), checked: checkStates.textAlign === 'center', children: "\u5C45\u4E2D\u5BF9\u9F50" }),
|
|
2699
2685
|
value: 't-c'
|
|
2700
2686
|
}, {
|
|
2701
|
-
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'J', modKey: true } }), checked:
|
|
2687
|
+
label: jsxRuntime.jsx(MenuItem, { icon: jsxRuntime.jsx("span", { class: "xnote-icon-paragraph-justify" }), desc: jsxRuntime.jsx(Keymap, { keymap: { key: 'J', modKey: true } }), checked: checkStates.textAlign === 'justify', children: "\u5206\u6563\u5BF9\u9F50" }),
|
|
2702
2688
|
value: 't-j'
|
|
2703
2689
|
}, {
|
|
2704
2690
|
label: jsxRuntime.jsx(Divider, {}),
|
|
@@ -2710,7 +2696,7 @@ function AttrTool(props) {
|
|
|
2710
2696
|
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" }),
|
|
2711
2697
|
value: 'i-'
|
|
2712
2698
|
}
|
|
2713
|
-
], children: props.children || jsxRuntime.jsx(Button, { disabled: b, arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${
|
|
2699
|
+
], children: props.children || jsxRuntime.jsx(Button, { disabled: b, arrow: true, highlight: false, children: jsxRuntime.jsx("span", { class: `xnote-icon-paragraph-${checkStates.textAlign || 'left'} icon` }) }) }));
|
|
2714
2700
|
});
|
|
2715
2701
|
}
|
|
2716
2702
|
|
|
@@ -2825,7 +2811,7 @@ const defaultColumnWidth = 100;
|
|
|
2825
2811
|
class TableComponent extends core$1.Component {
|
|
2826
2812
|
static fromJSON(textbus, json) {
|
|
2827
2813
|
const registry = textbus.get(core$1.Registry);
|
|
2828
|
-
return new TableComponent(
|
|
2814
|
+
return new TableComponent({
|
|
2829
2815
|
columnsConfig: json.columnsConfig || [],
|
|
2830
2816
|
mergeConfig: json.mergeConfig || [],
|
|
2831
2817
|
rows: json.rows.map(row => {
|
|
@@ -2841,14 +2827,14 @@ class TableComponent extends core$1.Component {
|
|
|
2841
2827
|
})
|
|
2842
2828
|
});
|
|
2843
2829
|
}
|
|
2844
|
-
constructor(
|
|
2830
|
+
constructor(state = {
|
|
2845
2831
|
columnsConfig: Array.from({ length: 5 }).fill(defaultColumnWidth),
|
|
2846
2832
|
mergeConfig: {},
|
|
2847
2833
|
rows: Array.from({ length: 3 }).map(() => {
|
|
2848
2834
|
return {
|
|
2849
2835
|
height: defaultRowHeight,
|
|
2850
2836
|
cells: Array.from({ length: 5 }).map(() => {
|
|
2851
|
-
const p = new ParagraphComponent(
|
|
2837
|
+
const p = new ParagraphComponent();
|
|
2852
2838
|
const slot = new core$1.Slot([core$1.ContentType.BlockComponent]);
|
|
2853
2839
|
slot.insert(p);
|
|
2854
2840
|
return {
|
|
@@ -2859,18 +2845,18 @@ class TableComponent extends core$1.Component {
|
|
|
2859
2845
|
};
|
|
2860
2846
|
})
|
|
2861
2847
|
}) {
|
|
2862
|
-
super(
|
|
2848
|
+
super(state);
|
|
2863
2849
|
Object.defineProperty(this, "selection", {
|
|
2864
2850
|
enumerable: true,
|
|
2865
2851
|
configurable: true,
|
|
2866
2852
|
writable: true,
|
|
2867
|
-
value:
|
|
2853
|
+
value: void 0
|
|
2868
2854
|
});
|
|
2869
2855
|
Object.defineProperty(this, "commander", {
|
|
2870
2856
|
enumerable: true,
|
|
2871
2857
|
configurable: true,
|
|
2872
2858
|
writable: true,
|
|
2873
|
-
value:
|
|
2859
|
+
value: void 0
|
|
2874
2860
|
});
|
|
2875
2861
|
Object.defineProperty(this, "focus", {
|
|
2876
2862
|
enumerable: true,
|
|
@@ -3135,6 +3121,8 @@ class TableComponent extends core$1.Component {
|
|
|
3135
3121
|
}
|
|
3136
3122
|
setup() {
|
|
3137
3123
|
const selection = core$1.useContext(core$1.Selection);
|
|
3124
|
+
this.selection = selection;
|
|
3125
|
+
this.commander = core$1.useContext(core$1.Commander);
|
|
3138
3126
|
core$1.onFocusIn(() => {
|
|
3139
3127
|
this.focus.next(true);
|
|
3140
3128
|
});
|
|
@@ -3152,7 +3140,7 @@ class TableComponent extends core$1.Component {
|
|
|
3152
3140
|
this.tableSelection.set(null);
|
|
3153
3141
|
}
|
|
3154
3142
|
});
|
|
3155
|
-
core$1.
|
|
3143
|
+
core$1.onDetach(() => {
|
|
3156
3144
|
sub.unsubscribe();
|
|
3157
3145
|
});
|
|
3158
3146
|
core$1.onGetRanges(ev => {
|
|
@@ -3262,7 +3250,7 @@ class TableComponent extends core$1.Component {
|
|
|
3262
3250
|
const slot = new core$1.Slot([
|
|
3263
3251
|
core$1.ContentType.BlockComponent,
|
|
3264
3252
|
]);
|
|
3265
|
-
slot.insert(new ParagraphComponent(
|
|
3253
|
+
slot.insert(new ParagraphComponent({
|
|
3266
3254
|
slot: new core$1.Slot([
|
|
3267
3255
|
core$1.ContentType.InlineComponent,
|
|
3268
3256
|
core$1.ContentType.Text
|
|
@@ -3287,7 +3275,7 @@ class TableComponent extends core$1.Component {
|
|
|
3287
3275
|
const slot = new core$1.Slot([
|
|
3288
3276
|
core$1.ContentType.BlockComponent,
|
|
3289
3277
|
]);
|
|
3290
|
-
slot.insert(new ParagraphComponent(
|
|
3278
|
+
slot.insert(new ParagraphComponent({
|
|
3291
3279
|
slot: new core$1.Slot([
|
|
3292
3280
|
core$1.ContentType.InlineComponent,
|
|
3293
3281
|
core$1.ContentType.Text
|
|
@@ -3368,7 +3356,7 @@ const strikeThroughFormatLoader = {
|
|
|
3368
3356
|
class TodolistComponent extends core$1.Component {
|
|
3369
3357
|
static fromJSON(textbus, json) {
|
|
3370
3358
|
const slot = textbus.get(core$1.Registry).createSlot(json.slot);
|
|
3371
|
-
return new TodolistComponent(
|
|
3359
|
+
return new TodolistComponent({
|
|
3372
3360
|
slot,
|
|
3373
3361
|
checked: json.checked
|
|
3374
3362
|
});
|
|
@@ -3377,7 +3365,6 @@ class TodolistComponent extends core$1.Component {
|
|
|
3377
3365
|
return [this.state.slot];
|
|
3378
3366
|
}
|
|
3379
3367
|
setup() {
|
|
3380
|
-
const textbus = core$1.useContext();
|
|
3381
3368
|
const commander = core$1.useContext(core$1.Commander);
|
|
3382
3369
|
const selection = core$1.useContext(core$1.Selection);
|
|
3383
3370
|
core$1.onBreak(ev => {
|
|
@@ -3387,7 +3374,7 @@ class TodolistComponent extends core$1.Component {
|
|
|
3387
3374
|
const beforeIndex = this.parent.indexOf(this);
|
|
3388
3375
|
const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
|
|
3389
3376
|
if (beforeComponent instanceof TodolistComponent) {
|
|
3390
|
-
const nextComponent = new ParagraphComponent(
|
|
3377
|
+
const nextComponent = new ParagraphComponent({
|
|
3391
3378
|
slot: new core$1.Slot([
|
|
3392
3379
|
core$1.ContentType.Text,
|
|
3393
3380
|
core$1.ContentType.InlineComponent
|
|
@@ -3401,7 +3388,7 @@ class TodolistComponent extends core$1.Component {
|
|
|
3401
3388
|
return;
|
|
3402
3389
|
}
|
|
3403
3390
|
}
|
|
3404
|
-
const nextParagraph = new TodolistComponent(
|
|
3391
|
+
const nextParagraph = new TodolistComponent({
|
|
3405
3392
|
checked: this.state.checked,
|
|
3406
3393
|
slot
|
|
3407
3394
|
});
|
|
@@ -3418,7 +3405,7 @@ class TodolistComponent extends core$1.Component {
|
|
|
3418
3405
|
return false;
|
|
3419
3406
|
}
|
|
3420
3407
|
const slot = selection.commonAncestorSlot.cut();
|
|
3421
|
-
const paragraph = new ParagraphComponent(
|
|
3408
|
+
const paragraph = new ParagraphComponent({
|
|
3422
3409
|
slot
|
|
3423
3410
|
});
|
|
3424
3411
|
commander.replaceComponent(this, paragraph);
|
|
@@ -3506,12 +3493,12 @@ const todolistComponentLoader = {
|
|
|
3506
3493
|
match(element) {
|
|
3507
3494
|
return element.dataset.component === TodolistComponent.componentName;
|
|
3508
3495
|
},
|
|
3509
|
-
read(element,
|
|
3496
|
+
read(element, _, slotParser) {
|
|
3510
3497
|
const slot = slotParser(new core$1.Slot([
|
|
3511
3498
|
core$1.ContentType.Text,
|
|
3512
3499
|
core$1.ContentType.InlineComponent
|
|
3513
3500
|
]), element.children[1]);
|
|
3514
|
-
return new TodolistComponent(
|
|
3501
|
+
return new TodolistComponent({
|
|
3515
3502
|
checked: element.children[0].hasAttribute('checked'),
|
|
3516
3503
|
slot
|
|
3517
3504
|
});
|
|
@@ -3530,7 +3517,7 @@ function toList(textbus, type) {
|
|
|
3530
3517
|
},
|
|
3531
3518
|
stateFactory(slots) {
|
|
3532
3519
|
return slots.map((slot, index) => {
|
|
3533
|
-
return new ListComponent(
|
|
3520
|
+
return new ListComponent({
|
|
3534
3521
|
type,
|
|
3535
3522
|
reorder: index === 0,
|
|
3536
3523
|
slot
|
|
@@ -3554,7 +3541,7 @@ function registerListShortcut(textbus) {
|
|
|
3554
3541
|
}
|
|
3555
3542
|
class ListComponent extends core$1.Component {
|
|
3556
3543
|
static fromJSON(textbus, json) {
|
|
3557
|
-
return new ListComponent(
|
|
3544
|
+
return new ListComponent({
|
|
3558
3545
|
type: json.type,
|
|
3559
3546
|
reorder: json.reorder,
|
|
3560
3547
|
slot: textbus.get(core$1.Registry).createSlot(json.slot)
|
|
@@ -3564,7 +3551,6 @@ class ListComponent extends core$1.Component {
|
|
|
3564
3551
|
return [this.state.slot];
|
|
3565
3552
|
}
|
|
3566
3553
|
setup() {
|
|
3567
|
-
const textbus = core$1.useContext();
|
|
3568
3554
|
const commander = core$1.useContext(core$1.Commander);
|
|
3569
3555
|
const selection = core$1.useContext(core$1.Selection);
|
|
3570
3556
|
const updateAfterList = (ref) => {
|
|
@@ -3594,7 +3580,7 @@ class ListComponent extends core$1.Component {
|
|
|
3594
3580
|
const beforeIndex = this.parent.indexOf(this);
|
|
3595
3581
|
const beforeComponent = this.parent.getContentAtIndex(beforeIndex - 1);
|
|
3596
3582
|
if (beforeComponent instanceof ListComponent) {
|
|
3597
|
-
const nextComponent = new ParagraphComponent(
|
|
3583
|
+
const nextComponent = new ParagraphComponent({
|
|
3598
3584
|
slot: new core$1.Slot([
|
|
3599
3585
|
core$1.ContentType.Text,
|
|
3600
3586
|
core$1.ContentType.InlineComponent
|
|
@@ -3609,7 +3595,7 @@ class ListComponent extends core$1.Component {
|
|
|
3609
3595
|
return;
|
|
3610
3596
|
}
|
|
3611
3597
|
}
|
|
3612
|
-
const nextList = new ListComponent(
|
|
3598
|
+
const nextList = new ListComponent({
|
|
3613
3599
|
slot,
|
|
3614
3600
|
reorder: false,
|
|
3615
3601
|
type: this.state.type
|
|
@@ -3628,7 +3614,7 @@ class ListComponent extends core$1.Component {
|
|
|
3628
3614
|
return false;
|
|
3629
3615
|
}
|
|
3630
3616
|
const slot = selection.commonAncestorSlot.cut();
|
|
3631
|
-
const paragraph = new ParagraphComponent(
|
|
3617
|
+
const paragraph = new ParagraphComponent({
|
|
3632
3618
|
slot
|
|
3633
3619
|
});
|
|
3634
3620
|
commander.replaceComponent(this, paragraph);
|
|
@@ -3804,7 +3790,7 @@ const listComponentLoader = {
|
|
|
3804
3790
|
core$1.ContentType.InlineComponent,
|
|
3805
3791
|
core$1.ContentType.Text
|
|
3806
3792
|
]), element.querySelector('.xnote-list-content') || document.createElement('div'));
|
|
3807
|
-
return new ListComponent(
|
|
3793
|
+
return new ListComponent({
|
|
3808
3794
|
slot,
|
|
3809
3795
|
reorder: element.dataset.reorder !== 'false',
|
|
3810
3796
|
type
|
|
@@ -3818,7 +3804,7 @@ const listComponentLoader = {
|
|
|
3818
3804
|
core$1.ContentType.InlineComponent,
|
|
3819
3805
|
core$1.ContentType.Text
|
|
3820
3806
|
]), i);
|
|
3821
|
-
const component = new ListComponent(
|
|
3807
|
+
const component = new ListComponent({
|
|
3822
3808
|
slot,
|
|
3823
3809
|
reorder: index === 0,
|
|
3824
3810
|
type
|
|
@@ -3833,7 +3819,7 @@ function useActiveBlock() {
|
|
|
3833
3819
|
const query = core.inject(core$1.Query);
|
|
3834
3820
|
const selection = core.inject(core$1.Selection);
|
|
3835
3821
|
const refreshService = core.inject(exports.RefreshService);
|
|
3836
|
-
const
|
|
3822
|
+
const checkStates = core.reactive({
|
|
3837
3823
|
paragraph: false,
|
|
3838
3824
|
h1: false,
|
|
3839
3825
|
h2: false,
|
|
@@ -3850,22 +3836,20 @@ function useActiveBlock() {
|
|
|
3850
3836
|
highlightBox: false
|
|
3851
3837
|
});
|
|
3852
3838
|
function updateCheckStates(range) {
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
draft.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === core$1.QueryStateType.Enabled;
|
|
3868
|
-
});
|
|
3839
|
+
const heading = query.queryAttributeByRange(headingAttr, range);
|
|
3840
|
+
checkStates.paragraph = query.queryComponentByRange(ParagraphComponent, range).state === core$1.QueryStateType.Enabled;
|
|
3841
|
+
checkStates.h1 = checkStates.h2 = checkStates.h3 = checkStates.h4 = checkStates.h5 = checkStates.h6 = false;
|
|
3842
|
+
if (heading.state === core$1.QueryStateType.Enabled) {
|
|
3843
|
+
checkStates[heading.value] = true;
|
|
3844
|
+
checkStates.paragraph = false;
|
|
3845
|
+
}
|
|
3846
|
+
const queryList = query.queryComponentByRange(ListComponent, range);
|
|
3847
|
+
checkStates.unorderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'UnorderedList';
|
|
3848
|
+
checkStates.orderedList = queryList.state === core$1.QueryStateType.Enabled && queryList.value.state.type === 'OrderedList';
|
|
3849
|
+
checkStates.table = query.queryComponentByRange(TableComponent, range).state === core$1.QueryStateType.Enabled;
|
|
3850
|
+
checkStates.todolist = query.queryComponentByRange(TodolistComponent, range).state === core$1.QueryStateType.Enabled;
|
|
3851
|
+
checkStates.blockquote = query.queryComponentByRange(BlockquoteComponent, range).state === core$1.QueryStateType.Enabled;
|
|
3852
|
+
checkStates.sourceCode = query.queryComponentByRange(SourceCodeComponent, range).state === core$1.QueryStateType.Enabled;
|
|
3869
3853
|
}
|
|
3870
3854
|
const subscription = refreshService.onRefresh.subscribe(() => {
|
|
3871
3855
|
if (!selection.isSelected) {
|
|
@@ -3898,7 +3882,7 @@ function useActiveBlock() {
|
|
|
3898
3882
|
endOffset: selection.endOffset
|
|
3899
3883
|
});
|
|
3900
3884
|
}
|
|
3901
|
-
return checkStates
|
|
3885
|
+
return checkStates;
|
|
3902
3886
|
};
|
|
3903
3887
|
}
|
|
3904
3888
|
|
|
@@ -3929,7 +3913,7 @@ function useBlockTransform() {
|
|
|
3929
3913
|
]);
|
|
3930
3914
|
},
|
|
3931
3915
|
stateFactory(slots) {
|
|
3932
|
-
return slots.map(slot => new ParagraphComponent(
|
|
3916
|
+
return slots.map(slot => new ParagraphComponent({
|
|
3933
3917
|
slot
|
|
3934
3918
|
}));
|
|
3935
3919
|
}
|
|
@@ -3937,7 +3921,7 @@ function useBlockTransform() {
|
|
|
3937
3921
|
break;
|
|
3938
3922
|
case 'table':
|
|
3939
3923
|
{
|
|
3940
|
-
const table = new TableComponent(
|
|
3924
|
+
const table = new TableComponent();
|
|
3941
3925
|
if (((_a = selection.commonAncestorSlot) === null || _a === void 0 ? void 0 : _a.isEmpty) && ((_b = selection.commonAncestorComponent) === null || _b === void 0 ? void 0 : _b.name) === ParagraphComponent.componentName) {
|
|
3942
3926
|
commander.replaceComponent(selection.commonAncestorComponent, table);
|
|
3943
3927
|
}
|
|
@@ -3958,7 +3942,7 @@ function useBlockTransform() {
|
|
|
3958
3942
|
},
|
|
3959
3943
|
stateFactory(slots) {
|
|
3960
3944
|
return slots.map(slot => {
|
|
3961
|
-
return new TodolistComponent(
|
|
3945
|
+
return new TodolistComponent({
|
|
3962
3946
|
checked: false,
|
|
3963
3947
|
slot
|
|
3964
3948
|
});
|
|
@@ -3987,7 +3971,7 @@ function useBlockTransform() {
|
|
|
3987
3971
|
},
|
|
3988
3972
|
stateFactory(slots) {
|
|
3989
3973
|
return slots.map(slot => {
|
|
3990
|
-
return new ParagraphComponent(
|
|
3974
|
+
return new ParagraphComponent({
|
|
3991
3975
|
slot
|
|
3992
3976
|
});
|
|
3993
3977
|
});
|
|
@@ -4003,7 +3987,7 @@ function useBlockTransform() {
|
|
|
4003
3987
|
]);
|
|
4004
3988
|
},
|
|
4005
3989
|
stateFactory(slots) {
|
|
4006
|
-
return [new SourceCodeComponent(
|
|
3990
|
+
return [new SourceCodeComponent({
|
|
4007
3991
|
lang: '',
|
|
4008
3992
|
lineNumber: true,
|
|
4009
3993
|
autoBreak: true,
|
|
@@ -4035,7 +4019,7 @@ function useBlockTransform() {
|
|
|
4035
4019
|
});
|
|
4036
4020
|
}
|
|
4037
4021
|
else {
|
|
4038
|
-
const block = new HighlightBoxComponent(
|
|
4022
|
+
const block = new HighlightBoxComponent();
|
|
4039
4023
|
const slot = block.state.slot;
|
|
4040
4024
|
if (selection.startSlot === selection.endSlot) {
|
|
4041
4025
|
const parentComponent = selection.startSlot.parent;
|
|
@@ -4417,7 +4401,7 @@ function BoldTool() {
|
|
|
4417
4401
|
const textbus = core.inject(core$1.Textbus);
|
|
4418
4402
|
const refreshService = core.inject(exports.RefreshService);
|
|
4419
4403
|
const commonState = useCommonState();
|
|
4420
|
-
const
|
|
4404
|
+
const viewModel = core.reactive({
|
|
4421
4405
|
highlight: false,
|
|
4422
4406
|
});
|
|
4423
4407
|
function toggle() {
|
|
@@ -4425,16 +4409,13 @@ function BoldTool() {
|
|
|
4425
4409
|
}
|
|
4426
4410
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
4427
4411
|
const state = query.queryFormat(boldFormatter);
|
|
4428
|
-
|
|
4429
|
-
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
4430
|
-
});
|
|
4412
|
+
viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
4431
4413
|
});
|
|
4432
4414
|
core.onUnmounted(() => {
|
|
4433
4415
|
sub.unsubscribe();
|
|
4434
4416
|
});
|
|
4435
4417
|
return () => {
|
|
4436
|
-
|
|
4437
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-bold" }) });
|
|
4418
|
+
return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-bold" }) });
|
|
4438
4419
|
};
|
|
4439
4420
|
}
|
|
4440
4421
|
|
|
@@ -4456,7 +4437,7 @@ function CodeTool() {
|
|
|
4456
4437
|
const refreshService = core.inject(exports.RefreshService);
|
|
4457
4438
|
const textbus = core.inject(core$1.Textbus);
|
|
4458
4439
|
const commonState = useCommonState();
|
|
4459
|
-
const
|
|
4440
|
+
const viewModel = core.reactive({
|
|
4460
4441
|
highlight: false,
|
|
4461
4442
|
});
|
|
4462
4443
|
function toggle() {
|
|
@@ -4464,16 +4445,13 @@ function CodeTool() {
|
|
|
4464
4445
|
}
|
|
4465
4446
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
4466
4447
|
const state = query.queryFormat(codeFormatter);
|
|
4467
|
-
|
|
4468
|
-
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
4469
|
-
});
|
|
4448
|
+
viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
4470
4449
|
});
|
|
4471
4450
|
core.onUnmounted(() => {
|
|
4472
4451
|
sub.unsubscribe();
|
|
4473
4452
|
});
|
|
4474
4453
|
return () => {
|
|
4475
|
-
|
|
4476
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-code" }) });
|
|
4454
|
+
return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-code" }) });
|
|
4477
4455
|
};
|
|
4478
4456
|
}
|
|
4479
4457
|
|
|
@@ -4692,7 +4670,7 @@ class KatexEditor extends core$1.Textbus {
|
|
|
4692
4670
|
}
|
|
4693
4671
|
mount(host, code) {
|
|
4694
4672
|
this.host = host;
|
|
4695
|
-
const model = new SourceCodeComponent(
|
|
4673
|
+
const model = new SourceCodeComponent({
|
|
4696
4674
|
lineNumber: true,
|
|
4697
4675
|
autoBreak: true,
|
|
4698
4676
|
lang: 'latex',
|
|
@@ -4721,15 +4699,15 @@ class KatexEditor extends core$1.Textbus {
|
|
|
4721
4699
|
|
|
4722
4700
|
class KatexComponent extends core$1.Component {
|
|
4723
4701
|
static fromJSON(textbus, state) {
|
|
4724
|
-
return new KatexComponent(
|
|
4702
|
+
return new KatexComponent(state);
|
|
4725
4703
|
}
|
|
4726
|
-
constructor(
|
|
4704
|
+
constructor(state = {
|
|
4727
4705
|
text: '% \\f is defined as #1f(#2) using the macro\n' +
|
|
4728
4706
|
'\\f\\relax{x} = \\int_{-\\infty}^\\infty\n' +
|
|
4729
4707
|
'\\f\\hat\\xi\\,e^{2 \\pi i \\xi x}\n' +
|
|
4730
4708
|
'\\,d\\xi'
|
|
4731
4709
|
}) {
|
|
4732
|
-
super(
|
|
4710
|
+
super(state);
|
|
4733
4711
|
}
|
|
4734
4712
|
getSlots() {
|
|
4735
4713
|
return [];
|
|
@@ -4817,9 +4795,9 @@ const katexComponentLoader = {
|
|
|
4817
4795
|
match(element) {
|
|
4818
4796
|
return element.dataset.component === KatexComponent.componentName;
|
|
4819
4797
|
},
|
|
4820
|
-
read(element
|
|
4798
|
+
read(element) {
|
|
4821
4799
|
const value = element.dataset.katex || '';
|
|
4822
|
-
return new KatexComponent(
|
|
4800
|
+
return new KatexComponent({
|
|
4823
4801
|
text: decodeURIComponent(value)
|
|
4824
4802
|
});
|
|
4825
4803
|
}
|
|
@@ -4863,7 +4841,7 @@ function InsertMenu(props) {
|
|
|
4863
4841
|
if (/h[1-6]/.test(type)) {
|
|
4864
4842
|
slot.setAttribute(headingAttr, type);
|
|
4865
4843
|
}
|
|
4866
|
-
const p = new ParagraphComponent(
|
|
4844
|
+
const p = new ParagraphComponent({
|
|
4867
4845
|
slot
|
|
4868
4846
|
});
|
|
4869
4847
|
insertComponent(p);
|
|
@@ -4877,7 +4855,7 @@ function InsertMenu(props) {
|
|
|
4877
4855
|
core$1.ContentType.InlineComponent,
|
|
4878
4856
|
core$1.ContentType.Text
|
|
4879
4857
|
]);
|
|
4880
|
-
const list = new ListComponent(
|
|
4858
|
+
const list = new ListComponent({
|
|
4881
4859
|
slot,
|
|
4882
4860
|
reorder: true,
|
|
4883
4861
|
type: type === 'ol' ? 'OrderedList' : 'UnorderedList'
|
|
@@ -4891,7 +4869,7 @@ function InsertMenu(props) {
|
|
|
4891
4869
|
const slot = new core$1.Slot([
|
|
4892
4870
|
core$1.ContentType.Text
|
|
4893
4871
|
]);
|
|
4894
|
-
const comp = new SourceCodeComponent(
|
|
4872
|
+
const comp = new SourceCodeComponent({
|
|
4895
4873
|
lang: '',
|
|
4896
4874
|
lineNumber: true,
|
|
4897
4875
|
slots: [{
|
|
@@ -4905,7 +4883,7 @@ function InsertMenu(props) {
|
|
|
4905
4883
|
break;
|
|
4906
4884
|
case 'table':
|
|
4907
4885
|
{
|
|
4908
|
-
const table = new TableComponent(
|
|
4886
|
+
const table = new TableComponent();
|
|
4909
4887
|
insertComponent(table);
|
|
4910
4888
|
textbus.nextTick(() => {
|
|
4911
4889
|
selection.selectFirstPosition(table, true, true);
|
|
@@ -4918,7 +4896,7 @@ function InsertMenu(props) {
|
|
|
4918
4896
|
core$1.ContentType.Text,
|
|
4919
4897
|
core$1.ContentType.InlineComponent
|
|
4920
4898
|
]);
|
|
4921
|
-
const comp = new TodolistComponent(
|
|
4899
|
+
const comp = new TodolistComponent({
|
|
4922
4900
|
slot,
|
|
4923
4901
|
checked: false
|
|
4924
4902
|
});
|
|
@@ -4929,7 +4907,7 @@ function InsertMenu(props) {
|
|
|
4929
4907
|
case 'image':
|
|
4930
4908
|
if (fileUploader) {
|
|
4931
4909
|
Promise.resolve().then(() => fileUploader.uploadFile('image')).then(url => {
|
|
4932
|
-
const img = new ImageComponent(
|
|
4910
|
+
const img = new ImageComponent({
|
|
4933
4911
|
src: url
|
|
4934
4912
|
});
|
|
4935
4913
|
commander.insert(img);
|
|
@@ -4939,7 +4917,7 @@ function InsertMenu(props) {
|
|
|
4939
4917
|
case 'video':
|
|
4940
4918
|
if (fileUploader) {
|
|
4941
4919
|
Promise.resolve().then(() => fileUploader.uploadFile('video')).then(url => {
|
|
4942
|
-
const img = new VideoComponent(
|
|
4920
|
+
const img = new VideoComponent({
|
|
4943
4921
|
src: url
|
|
4944
4922
|
});
|
|
4945
4923
|
commander.insert(img);
|
|
@@ -4948,8 +4926,8 @@ function InsertMenu(props) {
|
|
|
4948
4926
|
break;
|
|
4949
4927
|
case 'highlightBox':
|
|
4950
4928
|
{
|
|
4951
|
-
const p = new ParagraphComponent(
|
|
4952
|
-
const comp = new HighlightBoxComponent(
|
|
4929
|
+
const p = new ParagraphComponent();
|
|
4930
|
+
const comp = new HighlightBoxComponent();
|
|
4953
4931
|
comp.state.slot.insert(p);
|
|
4954
4932
|
insertComponent(comp);
|
|
4955
4933
|
selection.setPosition(p.state.slot, 0);
|
|
@@ -4957,8 +4935,8 @@ function InsertMenu(props) {
|
|
|
4957
4935
|
break;
|
|
4958
4936
|
case 'katex':
|
|
4959
4937
|
{
|
|
4960
|
-
const p = new ParagraphComponent(
|
|
4961
|
-
const comp = new KatexComponent(
|
|
4938
|
+
const p = new ParagraphComponent();
|
|
4939
|
+
const comp = new KatexComponent();
|
|
4962
4940
|
p.state.slot.insert(comp);
|
|
4963
4941
|
insertComponent(p);
|
|
4964
4942
|
selection.selectComponent(comp);
|
|
@@ -4966,17 +4944,17 @@ function InsertMenu(props) {
|
|
|
4966
4944
|
break;
|
|
4967
4945
|
case 'step':
|
|
4968
4946
|
{
|
|
4969
|
-
const step = new StepComponent(
|
|
4947
|
+
const step = new StepComponent({
|
|
4970
4948
|
step: 0,
|
|
4971
|
-
items: [createStepItem(
|
|
4949
|
+
items: [createStepItem()]
|
|
4972
4950
|
});
|
|
4973
4951
|
insertComponent(step);
|
|
4974
4952
|
selection.selectFirstPosition(step, false, true);
|
|
4975
4953
|
}
|
|
4976
4954
|
break;
|
|
4977
4955
|
case 'timeline': {
|
|
4978
|
-
const timeline = new TimelineComponent(
|
|
4979
|
-
items: [createTimelineItem(
|
|
4956
|
+
const timeline = new TimelineComponent({
|
|
4957
|
+
items: [createTimelineItem('#296eff')]
|
|
4980
4958
|
});
|
|
4981
4959
|
insertComponent(timeline);
|
|
4982
4960
|
selection.selectFirstPosition(timeline, false, true);
|
|
@@ -5009,7 +4987,7 @@ function ItalicTool() {
|
|
|
5009
4987
|
const query = core.inject(core$1.Query);
|
|
5010
4988
|
const refreshService = core.inject(exports.RefreshService);
|
|
5011
4989
|
const textbus = core.inject(core$1.Textbus);
|
|
5012
|
-
const
|
|
4990
|
+
const viewModel = core.reactive({
|
|
5013
4991
|
highlight: false,
|
|
5014
4992
|
});
|
|
5015
4993
|
function toggle() {
|
|
@@ -5017,17 +4995,14 @@ function ItalicTool() {
|
|
|
5017
4995
|
}
|
|
5018
4996
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
5019
4997
|
const state = query.queryFormat(italicFormatter);
|
|
5020
|
-
|
|
5021
|
-
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
5022
|
-
});
|
|
4998
|
+
viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
5023
4999
|
});
|
|
5024
5000
|
core.onUnmounted(() => {
|
|
5025
5001
|
sub.unsubscribe();
|
|
5026
5002
|
});
|
|
5027
5003
|
const commonState = useCommonState();
|
|
5028
5004
|
return () => {
|
|
5029
|
-
|
|
5030
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
|
|
5005
|
+
return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-italic" }) });
|
|
5031
5006
|
};
|
|
5032
5007
|
}
|
|
5033
5008
|
|
|
@@ -5136,7 +5111,7 @@ function StrikeThroughTool() {
|
|
|
5136
5111
|
const query = core.inject(core$1.Query);
|
|
5137
5112
|
const refreshService = core.inject(exports.RefreshService);
|
|
5138
5113
|
const textbus = core.inject(core$1.Textbus);
|
|
5139
|
-
const
|
|
5114
|
+
const viewModel = core.reactive({
|
|
5140
5115
|
highlight: false,
|
|
5141
5116
|
});
|
|
5142
5117
|
function toggle() {
|
|
@@ -5144,17 +5119,14 @@ function StrikeThroughTool() {
|
|
|
5144
5119
|
}
|
|
5145
5120
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
5146
5121
|
const state = query.queryFormat(strikeThroughFormatter);
|
|
5147
|
-
|
|
5148
|
-
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
5149
|
-
});
|
|
5122
|
+
viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
5150
5123
|
});
|
|
5151
5124
|
core.onUnmounted(() => {
|
|
5152
5125
|
sub.unsubscribe();
|
|
5153
5126
|
});
|
|
5154
5127
|
const commonState = useCommonState();
|
|
5155
5128
|
return () => {
|
|
5156
|
-
|
|
5157
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
|
|
5129
|
+
return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-strikethrough" }) });
|
|
5158
5130
|
};
|
|
5159
5131
|
}
|
|
5160
5132
|
|
|
@@ -5162,13 +5134,11 @@ function SubscriptTool() {
|
|
|
5162
5134
|
const query = core.inject(core$1.Query);
|
|
5163
5135
|
const selection = core.inject(core$1.Selection);
|
|
5164
5136
|
const commander = core.inject(core$1.Commander);
|
|
5165
|
-
const
|
|
5137
|
+
const state = core.reactive({
|
|
5166
5138
|
highlight: false
|
|
5167
5139
|
});
|
|
5168
5140
|
const sub = selection.onChange.subscribe(() => {
|
|
5169
|
-
|
|
5170
|
-
draft.highlight = getState();
|
|
5171
|
-
});
|
|
5141
|
+
state.highlight = getState();
|
|
5172
5142
|
});
|
|
5173
5143
|
function getState() {
|
|
5174
5144
|
const s = query.queryFormat(subscriptFormatter);
|
|
@@ -5189,7 +5159,7 @@ function SubscriptTool() {
|
|
|
5189
5159
|
}
|
|
5190
5160
|
const commonState = useCommonState();
|
|
5191
5161
|
return () => {
|
|
5192
|
-
return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state
|
|
5162
|
+
return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state.highlight, onClick: apply, children: jsxRuntime.jsx("span", { class: "xnote-icon-subscript" }) }));
|
|
5193
5163
|
};
|
|
5194
5164
|
}
|
|
5195
5165
|
|
|
@@ -5197,13 +5167,11 @@ function SuperscriptTool() {
|
|
|
5197
5167
|
const query = core.inject(core$1.Query);
|
|
5198
5168
|
const selection = core.inject(core$1.Selection);
|
|
5199
5169
|
const commander = core.inject(core$1.Commander);
|
|
5200
|
-
const
|
|
5170
|
+
const state = core.reactive({
|
|
5201
5171
|
highlight: false
|
|
5202
5172
|
});
|
|
5203
5173
|
const sub = selection.onChange.subscribe(() => {
|
|
5204
|
-
|
|
5205
|
-
draft.highlight = getState();
|
|
5206
|
-
});
|
|
5174
|
+
state.highlight = getState();
|
|
5207
5175
|
});
|
|
5208
5176
|
function getState() {
|
|
5209
5177
|
const s = query.queryFormat(superscriptFormatter);
|
|
@@ -5224,7 +5192,7 @@ function SuperscriptTool() {
|
|
|
5224
5192
|
}
|
|
5225
5193
|
const commonState = useCommonState();
|
|
5226
5194
|
return () => {
|
|
5227
|
-
return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state
|
|
5195
|
+
return (jsxRuntime.jsx(Button, { disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, highlight: state.highlight, onClick: apply, children: jsxRuntime.jsx("span", { class: "xnote-icon-superscript" }) }));
|
|
5228
5196
|
};
|
|
5229
5197
|
}
|
|
5230
5198
|
|
|
@@ -5326,7 +5294,7 @@ function UnderlineTool() {
|
|
|
5326
5294
|
const query = core.inject(core$1.Query);
|
|
5327
5295
|
const refreshService = core.inject(exports.RefreshService);
|
|
5328
5296
|
const textbus = core.inject(core$1.Textbus);
|
|
5329
|
-
const
|
|
5297
|
+
const viewModel = core.reactive({
|
|
5330
5298
|
highlight: false,
|
|
5331
5299
|
});
|
|
5332
5300
|
function toggle() {
|
|
@@ -5334,17 +5302,14 @@ function UnderlineTool() {
|
|
|
5334
5302
|
}
|
|
5335
5303
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
5336
5304
|
const state = query.queryFormat(underlineFormatter);
|
|
5337
|
-
|
|
5338
|
-
draft.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
5339
|
-
});
|
|
5305
|
+
viewModel.highlight = state.state === core$1.QueryStateType.Enabled;
|
|
5340
5306
|
});
|
|
5341
5307
|
core.onUnmounted(() => {
|
|
5342
5308
|
sub.unsubscribe();
|
|
5343
5309
|
});
|
|
5344
5310
|
const commonState = useCommonState();
|
|
5345
5311
|
return () => {
|
|
5346
|
-
|
|
5347
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-underline" }) });
|
|
5312
|
+
return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: commonState().inSourceCode || commonState().readonly || commonState().selectEmbed, onClick: toggle, children: jsxRuntime.jsx("span", { class: "xnote-icon-underline" }) });
|
|
5348
5313
|
};
|
|
5349
5314
|
}
|
|
5350
5315
|
|
|
@@ -5536,7 +5501,7 @@ const cellBackgroundAttrLoader = {
|
|
|
5536
5501
|
function CellBackgroundTool() {
|
|
5537
5502
|
const refreshService = core.inject(exports.RefreshService);
|
|
5538
5503
|
const selection = core.inject(core$1.Selection);
|
|
5539
|
-
const
|
|
5504
|
+
const viewModel = core.reactive({
|
|
5540
5505
|
disabled: false,
|
|
5541
5506
|
});
|
|
5542
5507
|
function setColor(picker) {
|
|
@@ -5577,9 +5542,7 @@ function CellBackgroundTool() {
|
|
|
5577
5542
|
}
|
|
5578
5543
|
}
|
|
5579
5544
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
5580
|
-
|
|
5581
|
-
draft.disabled = !isInTable(selection);
|
|
5582
|
-
});
|
|
5545
|
+
viewModel.disabled = !isInTable(selection);
|
|
5583
5546
|
});
|
|
5584
5547
|
core.onUnmounted(() => {
|
|
5585
5548
|
sub.unsubscribe();
|
|
@@ -5595,8 +5558,7 @@ function CellBackgroundTool() {
|
|
|
5595
5558
|
'#c596e0',
|
|
5596
5559
|
];
|
|
5597
5560
|
return () => {
|
|
5598
|
-
const
|
|
5599
|
-
const d = vm.disabled || commonState().readonly || commonState().inSourceCode;
|
|
5561
|
+
const d = viewModel.disabled || commonState().readonly || commonState().inSourceCode;
|
|
5600
5562
|
return (jsxRuntime.jsx(Dropdown, { width: '177px', disabled: d, menu: jsxRuntime.jsx(ColorPicker, { recentColors: defaultColors, onSelected: setColor }), trigger: 'hover', children: jsxRuntime.jsx(Button, { disabled: d, arrow: true, children: jsxRuntime.jsx("span", { class: "xnote-icon-palette" }) }) }));
|
|
5601
5563
|
};
|
|
5602
5564
|
}
|
|
@@ -5604,7 +5566,7 @@ function CellBackgroundTool() {
|
|
|
5604
5566
|
function MergeCellsTool() {
|
|
5605
5567
|
const refreshService = core.inject(exports.RefreshService);
|
|
5606
5568
|
const selection = core.inject(core$1.Selection);
|
|
5607
|
-
const
|
|
5569
|
+
const viewModel = core.reactive({
|
|
5608
5570
|
highlight: false,
|
|
5609
5571
|
disabled: false,
|
|
5610
5572
|
});
|
|
@@ -5615,33 +5577,30 @@ function MergeCellsTool() {
|
|
|
5615
5577
|
}
|
|
5616
5578
|
}
|
|
5617
5579
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
return;
|
|
5626
|
-
}
|
|
5580
|
+
const is = isInTable(selection);
|
|
5581
|
+
if (is) {
|
|
5582
|
+
const p1 = getTableSlotBySlot(selection.startSlot);
|
|
5583
|
+
const p2 = getTableSlotBySlot(selection.endSlot);
|
|
5584
|
+
if (p1 && p2) {
|
|
5585
|
+
viewModel.disabled = p1 === p2;
|
|
5586
|
+
return;
|
|
5627
5587
|
}
|
|
5628
|
-
|
|
5629
|
-
|
|
5588
|
+
}
|
|
5589
|
+
viewModel.disabled = true;
|
|
5630
5590
|
});
|
|
5631
5591
|
core.onUnmounted(() => {
|
|
5632
5592
|
sub.unsubscribe();
|
|
5633
5593
|
});
|
|
5634
5594
|
const commonState = useCommonState();
|
|
5635
5595
|
return () => {
|
|
5636
|
-
|
|
5637
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: merge, children: jsxRuntime.jsx("span", { class: "xnote-icon-merge-cells" }) });
|
|
5596
|
+
return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: viewModel.disabled || commonState().readonly || commonState().inSourceCode, onClick: merge, children: jsxRuntime.jsx("span", { class: "xnote-icon-merge-cells" }) });
|
|
5638
5597
|
};
|
|
5639
5598
|
}
|
|
5640
5599
|
|
|
5641
5600
|
function SplitCellsTool() {
|
|
5642
5601
|
const refreshService = core.inject(exports.RefreshService);
|
|
5643
5602
|
const selection = core.inject(core$1.Selection);
|
|
5644
|
-
const
|
|
5603
|
+
const viewModel = core.reactive({
|
|
5645
5604
|
highlight: false,
|
|
5646
5605
|
disabled: false,
|
|
5647
5606
|
});
|
|
@@ -5666,47 +5625,44 @@ function SplitCellsTool() {
|
|
|
5666
5625
|
}
|
|
5667
5626
|
const sub = refreshService.onRefresh.subscribe(() => {
|
|
5668
5627
|
const commonAncestorComponent = selection.commonAncestorComponent;
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
for (const
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
return;
|
|
5678
|
-
}
|
|
5628
|
+
if (commonAncestorComponent instanceof TableComponent) {
|
|
5629
|
+
const slots = commonAncestorComponent.getSelectedNormalizedSlots();
|
|
5630
|
+
if (slots) {
|
|
5631
|
+
for (const item of slots) {
|
|
5632
|
+
for (const cell of item.cells) {
|
|
5633
|
+
if (cell.visible && cell.colspan > 1 || cell.colspan > 1) {
|
|
5634
|
+
viewModel.disabled = false;
|
|
5635
|
+
return;
|
|
5679
5636
|
}
|
|
5680
5637
|
}
|
|
5681
5638
|
}
|
|
5682
5639
|
}
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5640
|
+
}
|
|
5641
|
+
else {
|
|
5642
|
+
let parentSlot = selection.commonAncestorSlot;
|
|
5643
|
+
while (parentSlot) {
|
|
5644
|
+
if (parentSlot.parent instanceof TableComponent) {
|
|
5645
|
+
const slots = parentSlot.parent.getNormalizedData();
|
|
5646
|
+
for (const item of slots) {
|
|
5647
|
+
for (const cell of item.cells) {
|
|
5648
|
+
if (cell.raw.slot === parentSlot) {
|
|
5649
|
+
viewModel.disabled = !(cell.colspan > 1 || cell.colspan > 1);
|
|
5650
|
+
return;
|
|
5694
5651
|
}
|
|
5695
5652
|
}
|
|
5696
5653
|
}
|
|
5697
|
-
parentSlot = parentSlot.parentSlot;
|
|
5698
5654
|
}
|
|
5655
|
+
parentSlot = parentSlot.parentSlot;
|
|
5699
5656
|
}
|
|
5700
|
-
|
|
5701
|
-
|
|
5657
|
+
}
|
|
5658
|
+
viewModel.disabled = true;
|
|
5702
5659
|
});
|
|
5703
5660
|
core.onUnmounted(() => {
|
|
5704
5661
|
sub.unsubscribe();
|
|
5705
5662
|
});
|
|
5706
5663
|
const commonState = useCommonState();
|
|
5707
5664
|
return () => {
|
|
5708
|
-
|
|
5709
|
-
return jsxRuntime.jsx(Button, { highlight: vm.highlight, disabled: vm.disabled || commonState().readonly || commonState().inSourceCode, onClick: split, children: jsxRuntime.jsx("span", { class: "xnote-icon-split-cells" }) });
|
|
5665
|
+
return jsxRuntime.jsx(Button, { highlight: viewModel.highlight, disabled: viewModel.disabled || commonState().readonly || commonState().inSourceCode, onClick: split, children: jsxRuntime.jsx("span", { class: "xnote-icon-split-cells" }) });
|
|
5710
5666
|
};
|
|
5711
5667
|
}
|
|
5712
5668
|
|
|
@@ -5742,15 +5698,13 @@ const LeftToolbar = core.withAnnotation({
|
|
|
5742
5698
|
refreshService.onRefresh.next();
|
|
5743
5699
|
}
|
|
5744
5700
|
}
|
|
5745
|
-
const
|
|
5701
|
+
const positionSignal = core.reactive({
|
|
5746
5702
|
left: 0,
|
|
5747
5703
|
top: 0,
|
|
5748
5704
|
display: false
|
|
5749
5705
|
});
|
|
5750
5706
|
const sub = editorService.onLeftToolbarCanVisibleChange.subscribe(() => {
|
|
5751
|
-
|
|
5752
|
-
d.display = editorService.canShowLeftToolbar;
|
|
5753
|
-
});
|
|
5707
|
+
positionSignal.display = editorService.canShowLeftToolbar;
|
|
5754
5708
|
});
|
|
5755
5709
|
core.onUnmounted(() => {
|
|
5756
5710
|
sub.unsubscribe();
|
|
@@ -5788,18 +5742,14 @@ const LeftToolbar = core.withAnnotation({
|
|
|
5788
5742
|
slot.parent instanceof SourceCodeComponent ||
|
|
5789
5743
|
slot.parent instanceof TableComponent);
|
|
5790
5744
|
const nativeNode = adapter.getNativeNodeByComponent(slot.parent);
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
draft.top = currentRect.top - containerRect.top + docContentContainer.offsetTop;
|
|
5797
|
-
});
|
|
5745
|
+
const containerRect = docContentContainer.getBoundingClientRect();
|
|
5746
|
+
const currentRect = nativeNode.getBoundingClientRect();
|
|
5747
|
+
positionSignal.display = true;
|
|
5748
|
+
positionSignal.left = currentRect.left - containerRect.left;
|
|
5749
|
+
positionSignal.top = currentRect.top - containerRect.top + docContentContainer.offsetTop;
|
|
5798
5750
|
}
|
|
5799
5751
|
else {
|
|
5800
|
-
|
|
5801
|
-
draft.display = false;
|
|
5802
|
-
});
|
|
5752
|
+
positionSignal.display = false;
|
|
5803
5753
|
isEmptyBlock.set(false);
|
|
5804
5754
|
}
|
|
5805
5755
|
});
|
|
@@ -5878,7 +5828,6 @@ const LeftToolbar = core.withAnnotation({
|
|
|
5878
5828
|
}
|
|
5879
5829
|
return scopedCss.withScopedCSS(scopedId$a, () => {
|
|
5880
5830
|
var _a;
|
|
5881
|
-
const position = positionSignal();
|
|
5882
5831
|
const slot = activeSlot();
|
|
5883
5832
|
let activeNode = jsxRuntime.jsx("span", { class: "xnote-icon-pilcrow" });
|
|
5884
5833
|
const states = checkStates(slot);
|
|
@@ -5908,9 +5857,9 @@ const LeftToolbar = core.withAnnotation({
|
|
|
5908
5857
|
const activeParentComponent = (_a = activeSlot()) === null || _a === void 0 ? void 0 : _a.parent;
|
|
5909
5858
|
const needInsert = activeParentComponent instanceof TableComponent || activeParentComponent instanceof SourceCodeComponent;
|
|
5910
5859
|
return (jsxRuntime.jsx("div", { class: "left-toolbar", ref: toolbarRef, children: jsxRuntime.jsx("div", { class: "left-toolbar-btn-wrap", ref: btnRef, style: {
|
|
5911
|
-
left:
|
|
5912
|
-
top:
|
|
5913
|
-
display:
|
|
5860
|
+
left: positionSignal.left + 'px',
|
|
5861
|
+
top: positionSignal.top + 'px',
|
|
5862
|
+
display: positionSignal.display && editorService.canShowLeftToolbar ? 'block' : 'none'
|
|
5914
5863
|
}, children: jsxRuntime.jsx(Dropdown, { toLeft: true, onExpendStateChange: changeIgnoreMove, abreast: true, style: {
|
|
5915
5864
|
position: 'absolute',
|
|
5916
5865
|
right: 0,
|
|
@@ -6038,14 +5987,14 @@ const InlineToolbar = core.withAnnotation({
|
|
|
6038
5987
|
const subscription = core$1.merge(textbus.onChange, selection.onChange).pipe(core$1.debounceTime(20), core$1.tap(() => {
|
|
6039
5988
|
refreshService.onRefresh.next();
|
|
6040
5989
|
}), core$1.delay(200)).subscribe(() => {
|
|
6041
|
-
if (viewPosition
|
|
5990
|
+
if (viewPosition.isHide) {
|
|
6042
5991
|
editorService.changeLeftToolbarVisible(true);
|
|
6043
5992
|
}
|
|
6044
5993
|
});
|
|
6045
5994
|
core.onUnmounted(() => {
|
|
6046
5995
|
subscription.unsubscribe();
|
|
6047
5996
|
});
|
|
6048
|
-
const
|
|
5997
|
+
const viewPosition = core.reactive({
|
|
6049
5998
|
left: 0,
|
|
6050
5999
|
top: 0,
|
|
6051
6000
|
isHide: true,
|
|
@@ -6123,21 +6072,17 @@ const InlineToolbar = core.withAnnotation({
|
|
|
6123
6072
|
const top = toBottom ?
|
|
6124
6073
|
selectionFocusRect.top + selectionFocusRect.height - docRect.top + 10 :
|
|
6125
6074
|
selectionFocusRect.top - docRect.top - toolbarHeight - 10;
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
draft.top = top + 10;
|
|
6131
|
-
});
|
|
6075
|
+
viewPosition.transitionDuration = .15;
|
|
6076
|
+
viewPosition.left = centerLeft - docRect.left;
|
|
6077
|
+
// draft.left = Math.max(centerLeft - docRect.left, toolbarRect.width / 2 + 10 - docRect.left)
|
|
6078
|
+
viewPosition.top = top + 10;
|
|
6132
6079
|
return top;
|
|
6133
6080
|
}
|
|
6134
6081
|
const sub = textbus.onChange.pipe(core$1.debounceTime(100)).subscribe(() => {
|
|
6135
|
-
if (!viewPosition
|
|
6082
|
+
if (!viewPosition.isHide) {
|
|
6136
6083
|
const top = getTop();
|
|
6137
6084
|
if (top !== null && !selection.isCollapsed) {
|
|
6138
|
-
|
|
6139
|
-
draft.top = top;
|
|
6140
|
-
});
|
|
6085
|
+
viewPosition.top = top;
|
|
6141
6086
|
return;
|
|
6142
6087
|
}
|
|
6143
6088
|
}
|
|
@@ -6160,11 +6105,9 @@ const InlineToolbar = core.withAnnotation({
|
|
|
6160
6105
|
return !selection.isCollapsed && !(selection.commonAncestorComponent instanceof SourceCodeComponent);
|
|
6161
6106
|
}), core$1.map(getTop), core$1.delay(200)).subscribe((top) => {
|
|
6162
6107
|
if (top !== null) {
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
draft.top = top;
|
|
6167
|
-
});
|
|
6108
|
+
viewPosition.isHide = false;
|
|
6109
|
+
viewPosition.opacity = 1;
|
|
6110
|
+
viewPosition.top = top;
|
|
6168
6111
|
editorService.changeLeftToolbarVisible(false);
|
|
6169
6112
|
}
|
|
6170
6113
|
else {
|
|
@@ -6177,11 +6120,9 @@ const InlineToolbar = core.withAnnotation({
|
|
|
6177
6120
|
return;
|
|
6178
6121
|
}
|
|
6179
6122
|
mouseupSubscription.unsubscribe();
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
draft.transitionDuration = 0;
|
|
6184
|
-
});
|
|
6123
|
+
viewPosition.opacity = 0;
|
|
6124
|
+
viewPosition.isHide = true;
|
|
6125
|
+
viewPosition.transitionDuration = 0;
|
|
6185
6126
|
bindMouseup();
|
|
6186
6127
|
});
|
|
6187
6128
|
const instance = core.getCurrentInstance();
|
|
@@ -6194,14 +6135,13 @@ const InlineToolbar = core.withAnnotation({
|
|
|
6194
6135
|
mouseupSubscription.unsubscribe();
|
|
6195
6136
|
});
|
|
6196
6137
|
return scopedCss.withScopedCSS(scopedId$8, () => {
|
|
6197
|
-
const p = viewPosition();
|
|
6198
6138
|
return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme], ref: toolbarRef, style: {
|
|
6199
|
-
left:
|
|
6200
|
-
top:
|
|
6201
|
-
pointerEvents:
|
|
6202
|
-
opacity:
|
|
6139
|
+
left: viewPosition.left + 'px',
|
|
6140
|
+
top: viewPosition.top + 'px',
|
|
6141
|
+
pointerEvents: viewPosition.isHide ? 'none' : 'initial',
|
|
6142
|
+
opacity: viewPosition.opacity,
|
|
6203
6143
|
display: editorService.hideInlineToolbar ? 'none' : '',
|
|
6204
|
-
transitionDuration:
|
|
6144
|
+
transitionDuration: viewPosition.transitionDuration + 's'
|
|
6205
6145
|
}, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, { hideToolbar: hideToolbar }) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextColorTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextBackgroundColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
|
|
6206
6146
|
});
|
|
6207
6147
|
});
|
|
@@ -6289,10 +6229,11 @@ class StaticToolbarPlugin {
|
|
|
6289
6229
|
const container = document.createElement('div');
|
|
6290
6230
|
container.style.position = 'relative';
|
|
6291
6231
|
container.style.borderRadius = 'inherit';
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6232
|
+
const Context = core.createContext([{
|
|
6233
|
+
provide: DropdownMenuContainer,
|
|
6234
|
+
useValue: container
|
|
6235
|
+
}]);
|
|
6236
|
+
this.app = platformBrowser$1.createApp(jsxRuntime.jsx(Context, { children: jsxRuntime.jsx(StaticToolbar, { theme: this.options.theme }) }), {
|
|
6296
6237
|
context: injector
|
|
6297
6238
|
});
|
|
6298
6239
|
this.options.host.appendChild(container);
|
|
@@ -6324,39 +6265,30 @@ const SuspensionToolbar = core.withAnnotation({
|
|
|
6324
6265
|
core.onUnmounted(() => {
|
|
6325
6266
|
subscription.unsubscribe();
|
|
6326
6267
|
});
|
|
6327
|
-
const
|
|
6268
|
+
const styles = core.reactive({
|
|
6328
6269
|
top: 0,
|
|
6329
6270
|
opacity: 1,
|
|
6330
6271
|
});
|
|
6331
6272
|
subscription.add(core$1.fromEvent(document, 'scroll').pipe(core$1.tap(() => {
|
|
6332
|
-
|
|
6333
|
-
draft.opacity = 0;
|
|
6334
|
-
});
|
|
6273
|
+
styles.opacity = 0;
|
|
6335
6274
|
}), core$1.debounceTime(100), core$1.tap(() => {
|
|
6336
6275
|
const rect = viewDocument.getBoundingClientRect();
|
|
6337
6276
|
if (rect.top < 10) {
|
|
6338
|
-
|
|
6339
|
-
draft.top = Math.min(-rect.top + 10, rect.height - 100);
|
|
6340
|
-
});
|
|
6277
|
+
styles.top = Math.min(-rect.top + 10, rect.height - 100);
|
|
6341
6278
|
}
|
|
6342
6279
|
else {
|
|
6343
|
-
|
|
6344
|
-
draft.top = 0;
|
|
6345
|
-
});
|
|
6280
|
+
styles.top = 0;
|
|
6346
6281
|
}
|
|
6347
6282
|
}), core$1.delay(100)).subscribe(() => {
|
|
6348
|
-
|
|
6349
|
-
draft.opacity = 1;
|
|
6350
|
-
});
|
|
6283
|
+
styles.opacity = 1;
|
|
6351
6284
|
}));
|
|
6352
6285
|
return scopedCss.withScopedCSS(scopedId$6, () => {
|
|
6353
|
-
const s = styles();
|
|
6354
6286
|
return (jsxRuntime.jsxs("div", { class: ['toolbar', props.theme, {
|
|
6355
|
-
suspension:
|
|
6287
|
+
suspension: styles.top === 0 ? '' : 'suspension'
|
|
6356
6288
|
}], style: {
|
|
6357
|
-
top:
|
|
6358
|
-
opacity:
|
|
6359
|
-
pointerEvents:
|
|
6289
|
+
top: styles.top + 'px',
|
|
6290
|
+
opacity: styles.opacity,
|
|
6291
|
+
pointerEvents: styles.opacity === 0 ? 'none' : 'initial',
|
|
6360
6292
|
}, children: [jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UndoTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(RedoTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(InsertTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BlockTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(AttrTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(BoldTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(ItalicTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(StrikeThroughTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(UnderlineTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontSizeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(FontFamilyTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(LinkTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CodeTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextColorTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(TextBackgroundColorTool, {}) }), jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SubscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SuperscriptTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CleanFormatsTool, {}) }), query.queryComponent(TableComponent).state === core$1.QueryStateType.Enabled && jsxRuntime.jsxs(core.Fragment, { children: [jsxRuntime.jsx(SplitLine, {}), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(MergeCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(SplitCellsTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellBackgroundTool, {}) }), jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(CellAlignTool, {}) })] }, "table")] }));
|
|
6361
6293
|
});
|
|
6362
6294
|
});
|
|
@@ -6539,7 +6471,7 @@ function registerAtShortcut(textbus) {
|
|
|
6539
6471
|
if (commonAncestorComponent instanceof SourceCodeComponent) {
|
|
6540
6472
|
return false;
|
|
6541
6473
|
}
|
|
6542
|
-
const at = new AtComponent(
|
|
6474
|
+
const at = new AtComponent();
|
|
6543
6475
|
commander.insert(at);
|
|
6544
6476
|
selection.setPosition(at.state.slot, 0);
|
|
6545
6477
|
}
|
|
@@ -6550,21 +6482,21 @@ class AtComponent extends core$1.Component {
|
|
|
6550
6482
|
const registry = textbus.get(core$1.Registry);
|
|
6551
6483
|
if (slotState) {
|
|
6552
6484
|
const slot = registry.createSlot(slotState);
|
|
6553
|
-
return new AtComponent(
|
|
6485
|
+
return new AtComponent({
|
|
6554
6486
|
slot
|
|
6555
6487
|
});
|
|
6556
6488
|
}
|
|
6557
|
-
return new AtComponent(
|
|
6489
|
+
return new AtComponent({
|
|
6558
6490
|
userInfo,
|
|
6559
6491
|
});
|
|
6560
6492
|
}
|
|
6561
|
-
constructor(
|
|
6493
|
+
constructor(state = {
|
|
6562
6494
|
slot: new core$1.Slot([core$1.ContentType.Text])
|
|
6563
6495
|
}) {
|
|
6564
6496
|
if (!state.userInfo && !state.slot) {
|
|
6565
6497
|
state.slot = new core$1.Slot([core$1.ContentType.Text]);
|
|
6566
6498
|
}
|
|
6567
|
-
super(
|
|
6499
|
+
super(state);
|
|
6568
6500
|
Object.defineProperty(this, "focus", {
|
|
6569
6501
|
enumerable: true,
|
|
6570
6502
|
configurable: true,
|
|
@@ -6587,13 +6519,13 @@ class AtComponent extends core$1.Component {
|
|
|
6587
6519
|
enumerable: true,
|
|
6588
6520
|
configurable: true,
|
|
6589
6521
|
writable: true,
|
|
6590
|
-
value:
|
|
6522
|
+
value: void 0
|
|
6591
6523
|
});
|
|
6592
6524
|
Object.defineProperty(this, "organization", {
|
|
6593
6525
|
enumerable: true,
|
|
6594
6526
|
configurable: true,
|
|
6595
6527
|
writable: true,
|
|
6596
|
-
value:
|
|
6528
|
+
value: void 0
|
|
6597
6529
|
});
|
|
6598
6530
|
}
|
|
6599
6531
|
getSlots() {
|
|
@@ -6606,6 +6538,8 @@ class AtComponent extends core$1.Component {
|
|
|
6606
6538
|
return [];
|
|
6607
6539
|
}
|
|
6608
6540
|
setup() {
|
|
6541
|
+
this.selection = core$1.useContext(core$1.Selection);
|
|
6542
|
+
this.organization = core$1.useContext(Organization);
|
|
6609
6543
|
let isFocus = false;
|
|
6610
6544
|
core$1.onFocus(() => {
|
|
6611
6545
|
isFocus = true;
|
|
@@ -6680,7 +6614,7 @@ class AtComponent extends core$1.Component {
|
|
|
6680
6614
|
this.focus.next(true);
|
|
6681
6615
|
}
|
|
6682
6616
|
});
|
|
6683
|
-
core$1.
|
|
6617
|
+
core$1.onDetach(() => {
|
|
6684
6618
|
subs.unsubscribe();
|
|
6685
6619
|
});
|
|
6686
6620
|
}
|
|
@@ -6770,12 +6704,12 @@ const atComponentLoader = {
|
|
|
6770
6704
|
read(element, textbus, slotParser) {
|
|
6771
6705
|
const data = element.dataset.info;
|
|
6772
6706
|
if (data) {
|
|
6773
|
-
return new AtComponent(
|
|
6707
|
+
return new AtComponent({
|
|
6774
6708
|
userInfo: JSON.parse(decodeURIComponent(data))
|
|
6775
6709
|
});
|
|
6776
6710
|
}
|
|
6777
6711
|
const slot = slotParser(new core$1.Slot([core$1.ContentType.Text]), element.querySelector('.xnote-at-input') || document.createElement('div'));
|
|
6778
|
-
return new AtComponent(
|
|
6712
|
+
return new AtComponent({
|
|
6779
6713
|
slot
|
|
6780
6714
|
});
|
|
6781
6715
|
}
|
|
@@ -6793,7 +6727,7 @@ class RootComponent extends core$1.Component {
|
|
|
6793
6727
|
}
|
|
6794
6728
|
static fromJSON(textbus, json) {
|
|
6795
6729
|
const content = textbus.get(core$1.Registry).createSlot(json.content);
|
|
6796
|
-
return new RootComponent(
|
|
6730
|
+
return new RootComponent({
|
|
6797
6731
|
content
|
|
6798
6732
|
});
|
|
6799
6733
|
}
|
|
@@ -6822,7 +6756,7 @@ class RootComponent extends core$1.Component {
|
|
|
6822
6756
|
}
|
|
6823
6757
|
const selection = this.textbus.get(core$1.Selection);
|
|
6824
6758
|
content.retain(content.length);
|
|
6825
|
-
const newParagraph = new ParagraphComponent(
|
|
6759
|
+
const newParagraph = new ParagraphComponent();
|
|
6826
6760
|
content.insert(newParagraph);
|
|
6827
6761
|
selection.setPosition(newParagraph.state.slot, 0);
|
|
6828
6762
|
}
|
|
@@ -6871,7 +6805,7 @@ const rootComponentLoader = {
|
|
|
6871
6805
|
match() {
|
|
6872
6806
|
return true;
|
|
6873
6807
|
},
|
|
6874
|
-
read(element,
|
|
6808
|
+
read(element, _, slotParser) {
|
|
6875
6809
|
const delta = slotParser(new core$1.Slot([
|
|
6876
6810
|
core$1.ContentType.BlockComponent,
|
|
6877
6811
|
core$1.ContentType.InlineComponent,
|
|
@@ -6880,7 +6814,7 @@ const rootComponentLoader = {
|
|
|
6880
6814
|
const slot = new core$1.Slot([
|
|
6881
6815
|
core$1.ContentType.BlockComponent
|
|
6882
6816
|
]);
|
|
6883
|
-
deltaToBlock(delta
|
|
6817
|
+
deltaToBlock(delta).forEach(i => {
|
|
6884
6818
|
slot.insert(i);
|
|
6885
6819
|
});
|
|
6886
6820
|
return slot;
|
|
@@ -7126,7 +7060,7 @@ function Scroll(props) {
|
|
|
7126
7060
|
const scrollRef = core.createRef();
|
|
7127
7061
|
const input = core.inject(platformBrowser.Input);
|
|
7128
7062
|
const tableService = core.inject(TableService);
|
|
7129
|
-
const
|
|
7063
|
+
const showShadow = core.reactive({
|
|
7130
7064
|
leftEnd: false,
|
|
7131
7065
|
rightEnd: false
|
|
7132
7066
|
});
|
|
@@ -7136,10 +7070,8 @@ function Scroll(props) {
|
|
|
7136
7070
|
if (props.isFocus()) {
|
|
7137
7071
|
input.caret.refresh();
|
|
7138
7072
|
}
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
|
|
7142
|
-
});
|
|
7073
|
+
showShadow.leftEnd = el.scrollLeft === 0;
|
|
7074
|
+
showShadow.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
|
|
7143
7075
|
}
|
|
7144
7076
|
update();
|
|
7145
7077
|
const s = core$1.fromEvent(el, 'scroll').subscribe(update);
|
|
@@ -7147,15 +7079,13 @@ function Scroll(props) {
|
|
|
7147
7079
|
});
|
|
7148
7080
|
core.onUpdated(() => {
|
|
7149
7081
|
const el = scrollRef.current;
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
draft.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
|
|
7153
|
-
});
|
|
7082
|
+
showShadow.leftEnd = el.scrollLeft === 0;
|
|
7083
|
+
showShadow.rightEnd = el.scrollLeft === el.scrollWidth - el.offsetWidth;
|
|
7154
7084
|
});
|
|
7155
7085
|
return scopedCss.withScopedCSS(scopedId$3, () => {
|
|
7156
7086
|
return jsxRuntime.jsx("div", { ref: [scrollRef], class: ['scroll-container', {
|
|
7157
|
-
'left-end': showShadow
|
|
7158
|
-
'right-end': showShadow
|
|
7087
|
+
'left-end': showShadow.leftEnd,
|
|
7088
|
+
'right-end': showShadow.rightEnd,
|
|
7159
7089
|
'active': props.isFocus(),
|
|
7160
7090
|
// 'hide-selection': isSelectColumn()
|
|
7161
7091
|
}], onScroll: ev => {
|
|
@@ -7298,34 +7228,30 @@ var scopedId$1 = "vf-d4c4a9";
|
|
|
7298
7228
|
function ResizeRow(props) {
|
|
7299
7229
|
const dragLineRef = core.createRef();
|
|
7300
7230
|
const tableService = core.inject(TableService);
|
|
7301
|
-
const
|
|
7231
|
+
const styles = core.reactive({
|
|
7302
7232
|
visible: false,
|
|
7303
7233
|
top: 0
|
|
7304
7234
|
});
|
|
7305
7235
|
core.onMounted(() => {
|
|
7306
7236
|
const sub = tableService.onInsertRowBefore.subscribe(i => {
|
|
7307
7237
|
if (i === null) {
|
|
7308
|
-
|
|
7309
|
-
draft.visible = false;
|
|
7310
|
-
});
|
|
7238
|
+
styles.visible = false;
|
|
7311
7239
|
return;
|
|
7312
7240
|
}
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
draft.top = row.offsetTop + row.offsetHeight;
|
|
7321
|
-
});
|
|
7241
|
+
styles.visible = true;
|
|
7242
|
+
if (i === -1) {
|
|
7243
|
+
styles.top = 0;
|
|
7244
|
+
return;
|
|
7245
|
+
}
|
|
7246
|
+
const row = props.tableRef.current.rows.item(i);
|
|
7247
|
+
styles.top = row.offsetTop + row.offsetHeight;
|
|
7322
7248
|
});
|
|
7323
7249
|
return () => sub.unsubscribe();
|
|
7324
7250
|
});
|
|
7325
7251
|
return scopedCss.withScopedCSS(scopedId$1, () => {
|
|
7326
7252
|
return jsxRuntime.jsx("div", { ref: dragLineRef, style: {
|
|
7327
|
-
display: styles
|
|
7328
|
-
top: styles
|
|
7253
|
+
display: styles.visible ? 'block' : 'none',
|
|
7254
|
+
top: styles.top + 'px',
|
|
7329
7255
|
width: sum(props.component.state.columnsConfig) + 'px'
|
|
7330
7256
|
}, class: 'drag-line' });
|
|
7331
7257
|
});
|
|
@@ -7334,7 +7260,7 @@ function ResizeRow(props) {
|
|
|
7334
7260
|
var scopedId = "vf-4a5ad1";
|
|
7335
7261
|
|
|
7336
7262
|
function SelectionMask(props) {
|
|
7337
|
-
const
|
|
7263
|
+
const styles = core.reactive({
|
|
7338
7264
|
visible: false,
|
|
7339
7265
|
left: 0,
|
|
7340
7266
|
top: 0,
|
|
@@ -7348,6 +7274,7 @@ function SelectionMask(props) {
|
|
|
7348
7274
|
});
|
|
7349
7275
|
core.watch(props.component.tableSelection, update);
|
|
7350
7276
|
function update() {
|
|
7277
|
+
var _a;
|
|
7351
7278
|
const selection = props.component.tableSelection();
|
|
7352
7279
|
const state = props.component.state;
|
|
7353
7280
|
if (isShowMask(props.component)) {
|
|
@@ -7364,21 +7291,16 @@ function SelectionMask(props) {
|
|
|
7364
7291
|
heightCompensation += 0.5;
|
|
7365
7292
|
}
|
|
7366
7293
|
const trs = Array.from(props.tableRef.current.rows);
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
draft.width = sum(state.columnsConfig.slice(selection.startColumn, selection.endColumn)) - 1 + 'px';
|
|
7375
|
-
draft.height = trs[selection.endRow - 1].offsetTop + height + heightCompensation - draft.top + 'px';
|
|
7376
|
-
});
|
|
7294
|
+
const height = trs[selection.endRow - 1].offsetHeight ||
|
|
7295
|
+
((_a = trs[selection.endRow - 1].children[0]) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
|
|
7296
|
+
styles.visible = true;
|
|
7297
|
+
styles.left = sum(state.columnsConfig.slice(0, selection.startColumn));
|
|
7298
|
+
styles.top = trs[selection.startRow].offsetTop + topCompensation;
|
|
7299
|
+
styles.width = sum(state.columnsConfig.slice(selection.startColumn, selection.endColumn)) - 1 + 'px';
|
|
7300
|
+
styles.height = trs[selection.endRow - 1].offsetTop + height + heightCompensation - styles.top + 'px';
|
|
7377
7301
|
}
|
|
7378
7302
|
else {
|
|
7379
|
-
|
|
7380
|
-
draft.visible = false;
|
|
7381
|
-
});
|
|
7303
|
+
styles.visible = false;
|
|
7382
7304
|
}
|
|
7383
7305
|
}
|
|
7384
7306
|
const s = props.component.changeMarker.onChange.pipe(core$1.debounceTime(30)).subscribe(() => {
|
|
@@ -7388,15 +7310,14 @@ function SelectionMask(props) {
|
|
|
7388
7310
|
s.unsubscribe();
|
|
7389
7311
|
});
|
|
7390
7312
|
return scopedCss.withScopedCSS(scopedId, () => {
|
|
7391
|
-
const style = styles();
|
|
7392
7313
|
return (jsxRuntime.jsx("div", { class: "mask", style: {
|
|
7393
|
-
display:
|
|
7394
|
-
left:
|
|
7395
|
-
top:
|
|
7396
|
-
right:
|
|
7397
|
-
width:
|
|
7398
|
-
height:
|
|
7399
|
-
bottom:
|
|
7314
|
+
display: styles.visible ? 'block' : 'none',
|
|
7315
|
+
left: styles.left + 'px',
|
|
7316
|
+
top: styles.top + 'px',
|
|
7317
|
+
right: styles.right + 'px',
|
|
7318
|
+
width: styles.width,
|
|
7319
|
+
height: styles.height,
|
|
7320
|
+
bottom: styles.bottom + 'px'
|
|
7400
7321
|
} }));
|
|
7401
7322
|
});
|
|
7402
7323
|
}
|
|
@@ -7611,7 +7532,7 @@ const tableComponentLoader = {
|
|
|
7611
7532
|
core$1.ContentType.InlineComponent,
|
|
7612
7533
|
core$1.ContentType.Text
|
|
7613
7534
|
]), cell).toDelta();
|
|
7614
|
-
const results = deltaToBlock(delta
|
|
7535
|
+
const results = deltaToBlock(delta);
|
|
7615
7536
|
delta.attributes.forEach((value, key) => {
|
|
7616
7537
|
slot.setAttribute(key, value);
|
|
7617
7538
|
});
|
|
@@ -7642,7 +7563,7 @@ const tableComponentLoader = {
|
|
|
7642
7563
|
core$1.ContentType.InlineComponent,
|
|
7643
7564
|
core$1.ContentType.Text
|
|
7644
7565
|
]), cell).toDelta();
|
|
7645
|
-
const results = deltaToBlock(delta
|
|
7566
|
+
const results = deltaToBlock(delta);
|
|
7646
7567
|
delta.attributes.forEach((value, key) => {
|
|
7647
7568
|
slot.setAttribute(key, value);
|
|
7648
7569
|
});
|
|
@@ -7669,7 +7590,7 @@ const tableComponentLoader = {
|
|
|
7669
7590
|
layoutWidth[i] = layoutWidth[i] || 100;
|
|
7670
7591
|
}
|
|
7671
7592
|
layoutWidth.length = length;
|
|
7672
|
-
return new TableComponent(
|
|
7593
|
+
return new TableComponent({
|
|
7673
7594
|
columnsConfig: layoutWidth,
|
|
7674
7595
|
mergeConfig: cells.mergedConfig,
|
|
7675
7596
|
rows: cells.table.map(i => {
|
|
@@ -7758,7 +7679,6 @@ TableSelectionAwarenessDelegate = __decorate([
|
|
|
7758
7679
|
|
|
7759
7680
|
function TimelineComponentView(props) {
|
|
7760
7681
|
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
7761
|
-
const textbus = core.inject(core$1.Textbus);
|
|
7762
7682
|
const isOutput = useOutput();
|
|
7763
7683
|
const isReadonly = useReadonly();
|
|
7764
7684
|
return () => {
|
|
@@ -7771,7 +7691,7 @@ function TimelineComponentView(props) {
|
|
|
7771
7691
|
backgroundColor: item.theme,
|
|
7772
7692
|
} }), !isOutput() && !isReadonly() && jsxRuntime.jsxs("div", { class: "xnote-timeline-tools", children: [jsxRuntime.jsx(Button, { class: "xnote-timeline-add xnote-icon-plus", onClick: () => {
|
|
7773
7693
|
const index = component.state.items.indexOf(item) + 1;
|
|
7774
|
-
component.state.items.splice(index, 0, createTimelineItem(
|
|
7694
|
+
component.state.items.splice(index, 0, createTimelineItem(item.theme));
|
|
7775
7695
|
} }), jsxRuntime.jsx(Button, { class: "xnote-timeline-add xnote-icon-bin", onClick: () => {
|
|
7776
7696
|
const index = component.state.items.indexOf(item);
|
|
7777
7697
|
component.state.items.splice(index, 1);
|
|
@@ -7787,8 +7707,8 @@ const timelineComponentLoader = {
|
|
|
7787
7707
|
match(element) {
|
|
7788
7708
|
return element.className === 'xnote-timeline';
|
|
7789
7709
|
},
|
|
7790
|
-
read(element,
|
|
7791
|
-
return new TimelineComponent(
|
|
7710
|
+
read(element, _, slotParser) {
|
|
7711
|
+
return new TimelineComponent({
|
|
7792
7712
|
items: Array.from(element.children).map(child => {
|
|
7793
7713
|
const slot = new core$1.Slot([
|
|
7794
7714
|
core$1.ContentType.BlockComponent
|
|
@@ -7804,7 +7724,6 @@ const timelineComponentLoader = {
|
|
|
7804
7724
|
|
|
7805
7725
|
function StepComponentView(props) {
|
|
7806
7726
|
const adapter = core.inject(platformBrowser.DomAdapter);
|
|
7807
|
-
const textbus = core.inject(core$1.Textbus);
|
|
7808
7727
|
const isOutput = useOutput();
|
|
7809
7728
|
const isReadonly = useReadonly();
|
|
7810
7729
|
return () => {
|
|
@@ -7830,7 +7749,7 @@ function StepComponentView(props) {
|
|
|
7830
7749
|
}
|
|
7831
7750
|
}, children: index + 1 })] }), !isOutput() && !isReadonly() && jsxRuntime.jsxs("div", { class: "xnote-step-tools", children: [jsxRuntime.jsx(Button, { class: "xnote-step-add xnote-icon-plus", onClick: () => {
|
|
7832
7751
|
const index = component.state.items.indexOf(item) + 1;
|
|
7833
|
-
component.state.items.splice(index, 0, createStepItem(
|
|
7752
|
+
component.state.items.splice(index, 0, createStepItem());
|
|
7834
7753
|
} }), jsxRuntime.jsx(Button, { class: "xnote-step-add xnote-icon-bin", onClick: () => {
|
|
7835
7754
|
const index = component.state.items.indexOf(item);
|
|
7836
7755
|
component.state.items.splice(index, 1);
|
|
@@ -7846,8 +7765,8 @@ const stepComponentLoader = {
|
|
|
7846
7765
|
match(element) {
|
|
7847
7766
|
return element.dataset.component === StepComponent.componentName;
|
|
7848
7767
|
},
|
|
7849
|
-
read(element,
|
|
7850
|
-
return new StepComponent(
|
|
7768
|
+
read(element, _, slotParser) {
|
|
7769
|
+
return new StepComponent({
|
|
7851
7770
|
step: Number(element.dataset.step) || 0,
|
|
7852
7771
|
items: Array.from(element.children).map(child => {
|
|
7853
7772
|
const slot = new core$1.Slot([
|
|
@@ -8129,7 +8048,7 @@ class Editor extends core$1.Textbus {
|
|
|
8129
8048
|
rootComp = this.createModel(config.content);
|
|
8130
8049
|
}
|
|
8131
8050
|
else {
|
|
8132
|
-
rootComp = new RootComponent(
|
|
8051
|
+
rootComp = new RootComponent({
|
|
8133
8052
|
content: new core$1.Slot([core$1.ContentType.BlockComponent])
|
|
8134
8053
|
});
|
|
8135
8054
|
}
|
|
@@ -8165,11 +8084,11 @@ class Editor extends core$1.Textbus {
|
|
|
8165
8084
|
core$1.ContentType.BlockComponent
|
|
8166
8085
|
]);
|
|
8167
8086
|
if (doc instanceof core$1.Slot) {
|
|
8168
|
-
deltaToBlock(doc.toDelta()
|
|
8087
|
+
deltaToBlock(doc.toDelta()).forEach(i => {
|
|
8169
8088
|
content.insert(i);
|
|
8170
8089
|
});
|
|
8171
8090
|
}
|
|
8172
|
-
return new RootComponent(
|
|
8091
|
+
return new RootComponent({
|
|
8173
8092
|
content
|
|
8174
8093
|
});
|
|
8175
8094
|
}
|