@jvs-milkdown/crepe 1.2.28 → 1.2.30
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/lib/cjs/builder.js +2 -1
- package/lib/cjs/builder.js.map +1 -1
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js +84 -62
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +1121 -988
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/builder.js +2 -1
- package/lib/esm/builder.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +84 -62
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +1143 -1010
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/image-block.css +5 -1
- package/lib/theme/common/reset.css +1 -1
- package/lib/theme/common/table.css +5 -0
- package/lib/theme/common/toolbar.css +23 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/component.d.ts +2 -2
- package/lib/types/feature/fixed-toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/index.d.ts +2 -0
- package/lib/types/feature/fixed-toolbar/index.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/outline-panel.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/view-menu-state.d.ts +3 -0
- package/lib/types/feature/fixed-toolbar/view-menu-state.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts +2 -2
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/feature/code-mirror/index.ts +51 -46
- package/src/feature/fixed-toolbar/component.tsx +203 -110
- package/src/feature/fixed-toolbar/index.ts +30 -8
- package/src/feature/fixed-toolbar/outline-panel.tsx +1 -2
- package/src/feature/fixed-toolbar/view-menu-state.ts +2 -0
- package/src/feature/toolbar/component.tsx +57 -44
- package/src/feature/toolbar/index.ts +9 -13
- package/src/theme/common/image-block.css +6 -1
- package/src/theme/common/reset.css +1 -1
- package/src/theme/common/table.css +5 -0
- package/src/theme/common/toolbar.css +30 -0
|
@@ -377,6 +377,29 @@ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
|
|
|
377
377
|
return CrepeFeature2;
|
|
378
378
|
})(CrepeFeature || {});
|
|
379
379
|
|
|
380
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
381
|
+
let _popupCount = 0;
|
|
382
|
+
function getIsAnyPopupOpen() {
|
|
383
|
+
return _popupCount > 0;
|
|
384
|
+
}
|
|
385
|
+
function addPopupChangeListener(fn) {
|
|
386
|
+
listeners.add(fn);
|
|
387
|
+
return () => listeners.delete(fn);
|
|
388
|
+
}
|
|
389
|
+
function incrementPopupCount() {
|
|
390
|
+
const wasZero = _popupCount === 0;
|
|
391
|
+
_popupCount++;
|
|
392
|
+
if (wasZero) {
|
|
393
|
+
listeners.forEach((fn) => fn());
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function decrementPopupCount() {
|
|
397
|
+
_popupCount = Math.max(0, _popupCount - 1);
|
|
398
|
+
if (_popupCount === 0) {
|
|
399
|
+
listeners.forEach((fn) => fn());
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
380
403
|
const remarkTextColorPlugin = $remark(
|
|
381
404
|
"remarkTextColor",
|
|
382
405
|
() => function() {
|
|
@@ -1034,29 +1057,6 @@ const formatPainterIcon = `
|
|
|
1034
1057
|
</svg>
|
|
1035
1058
|
`;
|
|
1036
1059
|
|
|
1037
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
1038
|
-
let _popupCount = 0;
|
|
1039
|
-
function getIsAnyPopupOpen() {
|
|
1040
|
-
return _popupCount > 0;
|
|
1041
|
-
}
|
|
1042
|
-
function addPopupChangeListener(fn) {
|
|
1043
|
-
listeners.add(fn);
|
|
1044
|
-
return () => listeners.delete(fn);
|
|
1045
|
-
}
|
|
1046
|
-
function incrementPopupCount() {
|
|
1047
|
-
const wasZero = _popupCount === 0;
|
|
1048
|
-
_popupCount++;
|
|
1049
|
-
if (wasZero) {
|
|
1050
|
-
listeners.forEach((fn) => fn());
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
function decrementPopupCount() {
|
|
1054
|
-
_popupCount = Math.max(0, _popupCount - 1);
|
|
1055
|
-
if (_popupCount === 0) {
|
|
1056
|
-
listeners.forEach((fn) => fn());
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
1060
|
function keepAlive(..._args) {
|
|
1061
1061
|
}
|
|
1062
1062
|
|
|
@@ -4163,7 +4163,7 @@ const Toolbar = defineComponent({
|
|
|
4163
4163
|
ctx: { type: Object, required: true },
|
|
4164
4164
|
hide: { type: Function, required: true },
|
|
4165
4165
|
show: { type: Object, required: true },
|
|
4166
|
-
|
|
4166
|
+
state: { type: Object, required: true },
|
|
4167
4167
|
config: { type: Object, required: false },
|
|
4168
4168
|
isFixed: { type: Boolean, required: false }
|
|
4169
4169
|
},
|
|
@@ -4765,17 +4765,17 @@ const Toolbar = defineComponent({
|
|
|
4765
4765
|
if (ctx) fn(ctx);
|
|
4766
4766
|
};
|
|
4767
4767
|
function checkActive(checker) {
|
|
4768
|
-
var _a;
|
|
4769
|
-
keepAlive(props.
|
|
4770
|
-
const status = (
|
|
4768
|
+
var _a, _b;
|
|
4769
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4770
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(editorCtx)) == null ? void 0 : _b.status;
|
|
4771
4771
|
if (status !== EditorStatus.Created) return false;
|
|
4772
4772
|
return checker(ctx);
|
|
4773
4773
|
}
|
|
4774
4774
|
const blockGroups = computed(() => getGroups$1("", void 0, ctx));
|
|
4775
4775
|
const activeBlockItem = computed(() => {
|
|
4776
|
-
var _a;
|
|
4777
|
-
keepAlive(props.
|
|
4778
|
-
const status = (
|
|
4776
|
+
var _a, _b;
|
|
4777
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4778
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(editorCtx)) == null ? void 0 : _b.status;
|
|
4779
4779
|
if (status !== EditorStatus.Created) return null;
|
|
4780
4780
|
const view = ctx.get(editorViewCtx);
|
|
4781
4781
|
const { $from } = view.state.selection;
|
|
@@ -4813,9 +4813,9 @@ const Toolbar = defineComponent({
|
|
|
4813
4813
|
return targetIcon;
|
|
4814
4814
|
});
|
|
4815
4815
|
const currentAlignIndent = computed(() => {
|
|
4816
|
-
var _a;
|
|
4817
|
-
keepAlive(props.
|
|
4818
|
-
const status = (
|
|
4816
|
+
var _a, _b;
|
|
4817
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4818
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(editorCtx)) == null ? void 0 : _b.status;
|
|
4819
4819
|
if (status !== EditorStatus.Created) return { align: "left", indent: 0 };
|
|
4820
4820
|
const view = ctx.get(editorViewCtx);
|
|
4821
4821
|
let align = "left";
|
|
@@ -4885,13 +4885,15 @@ const Toolbar = defineComponent({
|
|
|
4885
4885
|
}
|
|
4886
4886
|
};
|
|
4887
4887
|
const canMerge = computed(() => {
|
|
4888
|
-
|
|
4888
|
+
var _a;
|
|
4889
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4889
4890
|
const view = ctx == null ? void 0 : ctx.get(editorViewCtx);
|
|
4890
4891
|
if (!view) return false;
|
|
4891
4892
|
return mergeCells(view.state);
|
|
4892
4893
|
});
|
|
4893
4894
|
const canSplit = computed(() => {
|
|
4894
|
-
|
|
4895
|
+
var _a;
|
|
4896
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4895
4897
|
const view = ctx == null ? void 0 : ctx.get(editorViewCtx);
|
|
4896
4898
|
if (!view) return false;
|
|
4897
4899
|
return splitCell(view.state);
|
|
@@ -4951,16 +4953,16 @@ const Toolbar = defineComponent({
|
|
|
4951
4953
|
showAlignMenu.value = false;
|
|
4952
4954
|
};
|
|
4953
4955
|
const currentColorState = computed(() => {
|
|
4954
|
-
var _a;
|
|
4955
|
-
keepAlive(props.
|
|
4956
|
-
const status = (
|
|
4956
|
+
var _a, _b;
|
|
4957
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
4958
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(editorCtx)) == null ? void 0 : _b.status;
|
|
4957
4959
|
if (status !== EditorStatus.Created)
|
|
4958
4960
|
return { textColor: null, bgColor: null };
|
|
4959
4961
|
const view = ctx.get(editorViewCtx);
|
|
4960
4962
|
const { state } = view;
|
|
4961
4963
|
const schema = ctx.get(schemaCtx);
|
|
4962
|
-
const tcHasMark = schema.marks[
|
|
4963
|
-
const bcHasMark = schema.marks[
|
|
4964
|
+
const tcHasMark = schema.marks["textColor"];
|
|
4965
|
+
const bcHasMark = schema.marks["bgColor"];
|
|
4964
4966
|
if (!tcHasMark || !bcHasMark) return { textColor: null, bgColor: null };
|
|
4965
4967
|
const tcType = textColorSchema.type(ctx);
|
|
4966
4968
|
const bcType = bgColorSchema.type(ctx);
|
|
@@ -5007,8 +5009,8 @@ const Toolbar = defineComponent({
|
|
|
5007
5009
|
const { tr } = state;
|
|
5008
5010
|
const { from, to, empty } = state.selection;
|
|
5009
5011
|
const schema = ctx.get(schemaCtx);
|
|
5010
|
-
const tcHasMark = schema.marks[
|
|
5011
|
-
const bcHasMark = schema.marks[
|
|
5012
|
+
const tcHasMark = schema.marks["textColor"];
|
|
5013
|
+
const bcHasMark = schema.marks["bgColor"];
|
|
5012
5014
|
if (!tcHasMark || !bcHasMark) return;
|
|
5013
5015
|
const textColorType = textColorSchema.type(ctx);
|
|
5014
5016
|
const bgColorType = bgColorSchema.type(ctx);
|
|
@@ -5024,29 +5026,37 @@ const Toolbar = defineComponent({
|
|
|
5024
5026
|
showColorMenu.value = false;
|
|
5025
5027
|
};
|
|
5026
5028
|
const currentFontState = computed(() => {
|
|
5027
|
-
var _a;
|
|
5028
|
-
keepAlive(props.
|
|
5029
|
-
const status = (
|
|
5029
|
+
var _a, _b;
|
|
5030
|
+
keepAlive(props.state, (_a = props.state) == null ? void 0 : _a.value);
|
|
5031
|
+
const status = (_b = ctx == null ? void 0 : ctx.get(editorCtx)) == null ? void 0 : _b.status;
|
|
5030
5032
|
if (status !== EditorStatus.Created)
|
|
5031
5033
|
return { fontFamily: null, fontSize: null };
|
|
5032
5034
|
const view = ctx.get(editorViewCtx);
|
|
5033
5035
|
const { state } = view;
|
|
5034
5036
|
const schema = ctx.get(schemaCtx);
|
|
5035
|
-
const ffHasMark = schema.marks[
|
|
5036
|
-
const fsHasMark = schema.marks[
|
|
5037
|
-
if (!ffHasMark || !fsHasMark)
|
|
5037
|
+
const ffHasMark = schema.marks["fontFamily"];
|
|
5038
|
+
const fsHasMark = schema.marks["fontSize"];
|
|
5039
|
+
if (!ffHasMark || !fsHasMark) {
|
|
5040
|
+
return { fontFamily: null, fontSize: null };
|
|
5041
|
+
}
|
|
5038
5042
|
const ffType = fontFamilySchema.type(ctx);
|
|
5039
5043
|
const fsType = fontSizeSchema.type(ctx);
|
|
5040
5044
|
const { $cursor, ranges } = state.selection;
|
|
5045
|
+
let result = {
|
|
5046
|
+
fontFamily: null,
|
|
5047
|
+
fontSize: null
|
|
5048
|
+
};
|
|
5041
5049
|
if ($cursor) {
|
|
5042
5050
|
let fontFamily = null;
|
|
5043
5051
|
let fontSize = null;
|
|
5044
5052
|
const marks = state.storedMarks || $cursor.marks();
|
|
5045
5053
|
for (const mark of marks) {
|
|
5046
|
-
if (mark.type === ffType)
|
|
5047
|
-
|
|
5054
|
+
if (mark.type === ffType)
|
|
5055
|
+
fontFamily = mark.attrs.fontFamily || null;
|
|
5056
|
+
if (mark.type === fsType)
|
|
5057
|
+
fontSize = mark.attrs.fontSize || null;
|
|
5048
5058
|
}
|
|
5049
|
-
|
|
5059
|
+
result = { fontFamily, fontSize };
|
|
5050
5060
|
} else {
|
|
5051
5061
|
const fontFamilies = /* @__PURE__ */ new Set();
|
|
5052
5062
|
const fontSizes = /* @__PURE__ */ new Set();
|
|
@@ -5056,15 +5066,20 @@ const Toolbar = defineComponent({
|
|
|
5056
5066
|
if (node.isText) {
|
|
5057
5067
|
const ffMark = ffType.isInSet(node.marks);
|
|
5058
5068
|
const fsMark = fsType.isInSet(node.marks);
|
|
5059
|
-
fontFamilies.add(
|
|
5060
|
-
|
|
5069
|
+
fontFamilies.add(
|
|
5070
|
+
ffMark ? ffMark.attrs.fontFamily : null
|
|
5071
|
+
);
|
|
5072
|
+
fontSizes.add(
|
|
5073
|
+
fsMark ? fsMark.attrs.fontSize : null
|
|
5074
|
+
);
|
|
5061
5075
|
}
|
|
5062
5076
|
});
|
|
5063
5077
|
}
|
|
5064
5078
|
const fontFamily = fontFamilies.size === 1 ? Array.from(fontFamilies)[0] : "mixed";
|
|
5065
5079
|
const fontSize = fontSizes.size === 1 ? Array.from(fontSizes)[0] : "mixed";
|
|
5066
|
-
|
|
5080
|
+
result = { fontFamily, fontSize };
|
|
5067
5081
|
}
|
|
5082
|
+
return result;
|
|
5068
5083
|
});
|
|
5069
5084
|
const setFontFamily = (fontFamily) => {
|
|
5070
5085
|
const commands = ctx.get(commandsCtx);
|
|
@@ -5295,7 +5310,11 @@ const Toolbar = defineComponent({
|
|
|
5295
5310
|
color: "#363B4C"
|
|
5296
5311
|
}
|
|
5297
5312
|
},
|
|
5298
|
-
|
|
5313
|
+
(() => {
|
|
5314
|
+
const fontState = currentFontState.value;
|
|
5315
|
+
const fontFamily = fontState == null ? void 0 : fontState.fontFamily;
|
|
5316
|
+
return fontFamily && fontFamily !== "mixed" ? fontFamily.split(",")[0].replace(/['"]/g, "") || (ctx ? i18n(ctx, "customMenu.fontDefault") : "\u9ED8\u8BA4") : ctx ? i18n(ctx, "customMenu.fontDefault") : "\u9ED8\u8BA4";
|
|
5317
|
+
})()
|
|
5299
5318
|
),
|
|
5300
5319
|
/* @__PURE__ */ h(
|
|
5301
5320
|
"span",
|
|
@@ -5325,7 +5344,10 @@ const Toolbar = defineComponent({
|
|
|
5325
5344
|
flexShrink: 0
|
|
5326
5345
|
}
|
|
5327
5346
|
},
|
|
5328
|
-
/* @__PURE__ */ h("span", { style: { fontSize: "13px", color: "#363B4C" } },
|
|
5347
|
+
/* @__PURE__ */ h("span", { style: { fontSize: "13px", color: "#363B4C" } }, (() => {
|
|
5348
|
+
const fs = currentFontState.value.fontSize;
|
|
5349
|
+
return fs && fs !== "mixed" ? fs : "16px";
|
|
5350
|
+
})()),
|
|
5329
5351
|
/* @__PURE__ */ h(
|
|
5330
5352
|
"span",
|
|
5331
5353
|
{
|
|
@@ -6429,21 +6451,21 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
6429
6451
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6430
6452
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
6431
6453
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
6432
|
-
var _tooltipProvider, _content, _app,
|
|
6454
|
+
var _tooltipProvider, _content, _app, _state, _show, _mousePressed, _removePopupListener, _onDocumentMouseUp;
|
|
6433
6455
|
const toolbarTooltip = tooltipFactory("CREPE_TOOLBAR");
|
|
6434
6456
|
class ToolbarView {
|
|
6435
6457
|
constructor(ctx, view, config) {
|
|
6436
6458
|
__privateAdd(this, _tooltipProvider);
|
|
6437
6459
|
__privateAdd(this, _content);
|
|
6438
6460
|
__privateAdd(this, _app);
|
|
6439
|
-
__privateAdd(this,
|
|
6461
|
+
__privateAdd(this, _state);
|
|
6440
6462
|
__privateAdd(this, _show, ref(false));
|
|
6441
6463
|
__privateAdd(this, _mousePressed, false);
|
|
6442
6464
|
__privateAdd(this, _removePopupListener);
|
|
6443
6465
|
__privateAdd(this, _onDocumentMouseUp);
|
|
6444
6466
|
this.update = (view, prevState) => {
|
|
6445
6467
|
__privateGet(this, _tooltipProvider).update(view, prevState);
|
|
6446
|
-
__privateGet(this,
|
|
6468
|
+
__privateGet(this, _state).value = view.state;
|
|
6447
6469
|
};
|
|
6448
6470
|
this.destroy = () => {
|
|
6449
6471
|
var _a;
|
|
@@ -6460,12 +6482,12 @@ class ToolbarView {
|
|
|
6460
6482
|
};
|
|
6461
6483
|
const content = document.createElement("div");
|
|
6462
6484
|
content.className = "milkdown-toolbar";
|
|
6463
|
-
__privateSet(this,
|
|
6485
|
+
__privateSet(this, _state, shallowRef(view.state));
|
|
6464
6486
|
const app = createApp(Toolbar, {
|
|
6465
6487
|
ctx,
|
|
6466
6488
|
hide: this.hide,
|
|
6467
6489
|
config,
|
|
6468
|
-
|
|
6490
|
+
state: __privateGet(this, _state),
|
|
6469
6491
|
show: __privateGet(this, _show)
|
|
6470
6492
|
});
|
|
6471
6493
|
app.mount(content);
|
|
@@ -6529,7 +6551,7 @@ class ToolbarView {
|
|
|
6529
6551
|
_tooltipProvider = new WeakMap();
|
|
6530
6552
|
_content = new WeakMap();
|
|
6531
6553
|
_app = new WeakMap();
|
|
6532
|
-
|
|
6554
|
+
_state = new WeakMap();
|
|
6533
6555
|
_show = new WeakMap();
|
|
6534
6556
|
_mousePressed = new WeakMap();
|
|
6535
6557
|
_removePopupListener = new WeakMap();
|