rme 0.2.0 → 0.2.2
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/dist/index.d.ts +42 -6
- package/dist/index.mjs +1271 -330
- package/dist/index.mjs.map +4 -4
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -4355,11 +4355,17 @@ var require_object2 = __commonJS({
|
|
|
4355
4355
|
import { createTheme } from "@drl990114/codemirror-themes";
|
|
4356
4356
|
|
|
4357
4357
|
// src/editor/codemirror/codemirror.ts
|
|
4358
|
-
import {
|
|
4358
|
+
import {
|
|
4359
|
+
ensureSyntaxTree
|
|
4360
|
+
} from "@codemirror/language";
|
|
4361
|
+
import { languages } from "@codemirror/language-data";
|
|
4362
|
+
import { EditorState as CodeMirrorEditorState, Compartment } from "@codemirror/state";
|
|
4359
4363
|
import { EditorView as CodeMirrorEditorView, keymap } from "@codemirror/view";
|
|
4360
4364
|
import { assertGet, isPromise, replaceNodeAtPosition } from "@remirror/core";
|
|
4361
4365
|
import { exitCode } from "@remirror/pm/commands";
|
|
4366
|
+
import { redo, undo } from "@remirror/pm/history";
|
|
4362
4367
|
import { Selection, TextSelection } from "@remirror/pm/state";
|
|
4368
|
+
import { nanoid } from "nanoid";
|
|
4363
4369
|
|
|
4364
4370
|
// src/editor/theme/codemirror/dark.ts
|
|
4365
4371
|
import { tags as t } from "@lezer/highlight";
|
|
@@ -4536,6 +4542,7 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
4536
4542
|
background-color: ${(props) => props.theme.bgColor};
|
|
4537
4543
|
color: ${(props) => props.theme.primaryFontColor};
|
|
4538
4544
|
word-wrap: break-word;
|
|
4545
|
+
white-space: pre-wrap;
|
|
4539
4546
|
padding: 0 20px;
|
|
4540
4547
|
padding-bottom: 1em;
|
|
4541
4548
|
box-sizing: border-box;
|
|
@@ -4547,7 +4554,7 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
4547
4554
|
|
|
4548
4555
|
& a {
|
|
4549
4556
|
background-color: transparent;
|
|
4550
|
-
color:
|
|
4557
|
+
color: ${(props) => props.theme.linkColor || props.theme.accentColor};
|
|
4551
4558
|
text-decoration: none;
|
|
4552
4559
|
}
|
|
4553
4560
|
|
|
@@ -4590,11 +4597,16 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
4590
4597
|
max-width: 100%;
|
|
4591
4598
|
box-sizing: content-box;
|
|
4592
4599
|
background-color: ${(props) => props.theme.imgBgColor};
|
|
4600
|
+
vertical-align: bottom;
|
|
4593
4601
|
}
|
|
4594
4602
|
|
|
4595
4603
|
& hr {
|
|
4596
|
-
|
|
4597
|
-
|
|
4604
|
+
box-sizing: content-box;
|
|
4605
|
+
height: 0;
|
|
4606
|
+
margin: 1.5em 0;
|
|
4607
|
+
border: 0;
|
|
4608
|
+
border-top: 1px solid ${(props) => props.theme.hrBorderColor};
|
|
4609
|
+
background: ${(props) => props.theme.hrBgColor};
|
|
4598
4610
|
}
|
|
4599
4611
|
|
|
4600
4612
|
& kbd {
|
|
@@ -4658,18 +4670,6 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
4658
4670
|
margin: 1em 40px;
|
|
4659
4671
|
}
|
|
4660
4672
|
|
|
4661
|
-
& hr {
|
|
4662
|
-
box-sizing: content-box;
|
|
4663
|
-
overflow: hidden;
|
|
4664
|
-
background: transparent;
|
|
4665
|
-
border-bottom: 1px solid #21262d;
|
|
4666
|
-
height: 0.25em;
|
|
4667
|
-
padding: 0;
|
|
4668
|
-
margin: 24px 0;
|
|
4669
|
-
background-color: #30363d;
|
|
4670
|
-
border: 0;
|
|
4671
|
-
}
|
|
4672
|
-
|
|
4673
4673
|
& input {
|
|
4674
4674
|
font: inherit;
|
|
4675
4675
|
margin: 0;
|
|
@@ -4699,7 +4699,7 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
4699
4699
|
border-spacing: 0;
|
|
4700
4700
|
border-collapse: collapse;
|
|
4701
4701
|
display: block;
|
|
4702
|
-
width:
|
|
4702
|
+
width: 100%;
|
|
4703
4703
|
max-width: 100%;
|
|
4704
4704
|
overflow: auto;
|
|
4705
4705
|
margin: 1em 0;
|
|
@@ -4765,7 +4765,7 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
4765
4765
|
& [role='button']:focus,
|
|
4766
4766
|
& input[type='radio']:focus,
|
|
4767
4767
|
& input[type='checkbox']:focus {
|
|
4768
|
-
outline: 2px solid
|
|
4768
|
+
outline: 2px solid ${(props) => props.theme.accentColor};
|
|
4769
4769
|
outline-offset: -2px;
|
|
4770
4770
|
box-shadow: none;
|
|
4771
4771
|
}
|
|
@@ -4803,48 +4803,48 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
4803
4803
|
& h6 {
|
|
4804
4804
|
position: relative;
|
|
4805
4805
|
margin: 0;
|
|
4806
|
-
line-height: 1;
|
|
4806
|
+
line-height: 1.25;
|
|
4807
4807
|
}
|
|
4808
4808
|
|
|
4809
4809
|
& h1 {
|
|
4810
4810
|
font-weight: 600;
|
|
4811
|
-
margin:
|
|
4812
|
-
font-size: 1.
|
|
4811
|
+
margin: 0.6em 0 1.2em 0;
|
|
4812
|
+
font-size: 1.875em;
|
|
4813
4813
|
}
|
|
4814
4814
|
|
|
4815
4815
|
& h2 {
|
|
4816
4816
|
font-weight: 600;
|
|
4817
|
-
margin:
|
|
4817
|
+
margin: 0.55em 0 1.1em 0;
|
|
4818
4818
|
font-size: 1.75em;
|
|
4819
4819
|
}
|
|
4820
4820
|
|
|
4821
4821
|
& h3 {
|
|
4822
4822
|
font-weight: 600;
|
|
4823
|
-
margin:
|
|
4823
|
+
margin: 0.5em 0 1em 0;
|
|
4824
4824
|
font-size: 1.6em;
|
|
4825
4825
|
}
|
|
4826
4826
|
|
|
4827
4827
|
& h4 {
|
|
4828
4828
|
font-weight: 600;
|
|
4829
|
-
margin:
|
|
4829
|
+
margin: 0.45em 0 0.9em 0;
|
|
4830
4830
|
font-size: 1.46em;
|
|
4831
4831
|
}
|
|
4832
4832
|
|
|
4833
4833
|
& h5 {
|
|
4834
4834
|
font-weight: 600;
|
|
4835
|
-
margin:
|
|
4835
|
+
margin: 0.4em 0 0.8em 0;
|
|
4836
4836
|
font-size: 1.3em;
|
|
4837
4837
|
}
|
|
4838
4838
|
|
|
4839
4839
|
& h6 {
|
|
4840
4840
|
font-weight: 600;
|
|
4841
|
-
margin:
|
|
4841
|
+
margin: 0.4em 0 0.8em 0;
|
|
4842
4842
|
font-size: 1.2em;
|
|
4843
4843
|
}
|
|
4844
4844
|
|
|
4845
4845
|
& p {
|
|
4846
4846
|
margin-top: 0;
|
|
4847
|
-
margin-bottom:
|
|
4847
|
+
margin-bottom: 0.5em;
|
|
4848
4848
|
}
|
|
4849
4849
|
|
|
4850
4850
|
& blockquote {
|
|
@@ -4858,7 +4858,7 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
4858
4858
|
& ol {
|
|
4859
4859
|
margin-top: 0;
|
|
4860
4860
|
margin-bottom: 0;
|
|
4861
|
-
padding-left:
|
|
4861
|
+
padding-left: 1.5em;
|
|
4862
4862
|
}
|
|
4863
4863
|
|
|
4864
4864
|
& ol ol,
|
|
@@ -5199,19 +5199,22 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
5199
5199
|
display: inline-block;
|
|
5200
5200
|
}
|
|
5201
5201
|
|
|
5202
|
-
.inline-
|
|
5202
|
+
.inline-input {
|
|
5203
5203
|
position: relative;
|
|
5204
5204
|
}
|
|
5205
5205
|
|
|
5206
|
-
.inline-
|
|
5206
|
+
.inline-input-src {
|
|
5207
5207
|
display: inline;
|
|
5208
5208
|
padding: 0.2em 0.4em;
|
|
5209
5209
|
margin: 0;
|
|
5210
5210
|
background-color: ${(props) => props.theme.codeBgColor};
|
|
5211
5211
|
border-radius: 6px;
|
|
5212
|
+
br {
|
|
5213
|
+
display: none;
|
|
5214
|
+
}
|
|
5212
5215
|
}
|
|
5213
5216
|
|
|
5214
|
-
.inline-
|
|
5217
|
+
.inline-input-preview {
|
|
5215
5218
|
position: absolute;
|
|
5216
5219
|
top: calc(100% + 0.5em);
|
|
5217
5220
|
left: 50%;
|
|
@@ -5225,11 +5228,47 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
5225
5228
|
z-index: 1;
|
|
5226
5229
|
}
|
|
5227
5230
|
|
|
5228
|
-
.inline-
|
|
5229
|
-
display: inline-block;
|
|
5231
|
+
.inline-input-render {
|
|
5230
5232
|
line-height: normal;
|
|
5231
5233
|
}
|
|
5232
5234
|
|
|
5235
|
+
.math-block-nodeview {
|
|
5236
|
+
position: relative;
|
|
5237
|
+
margin: 0;
|
|
5238
|
+
|
|
5239
|
+
br {
|
|
5240
|
+
display: none;
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5243
|
+
|
|
5244
|
+
.math-block-render {
|
|
5245
|
+
display: flex;
|
|
5246
|
+
justify-content: center;
|
|
5247
|
+
align-items: center;
|
|
5248
|
+
padding: 1em 0;
|
|
5249
|
+
border-radius: 0.2em;
|
|
5250
|
+
|
|
5251
|
+
&:hover {
|
|
5252
|
+
border: 1px solid ${(props) => props.theme.borderColor};
|
|
5253
|
+
}
|
|
5254
|
+
}
|
|
5255
|
+
|
|
5256
|
+
.math-block-preview {
|
|
5257
|
+
position: absolute;
|
|
5258
|
+
top: calc(100% + 0.5em);
|
|
5259
|
+
left: 50%;
|
|
5260
|
+
transform: translateX(-50%);
|
|
5261
|
+
display: flex;
|
|
5262
|
+
justify-content: center;
|
|
5263
|
+
align-items: center;
|
|
5264
|
+
padding: 1em 0;
|
|
5265
|
+
width: 100%;
|
|
5266
|
+
border: 1px solid ${(props) => props.theme.borderColor};
|
|
5267
|
+
border-radius: 0.2em;
|
|
5268
|
+
background-color: ${(props) => props.theme.bgColor};
|
|
5269
|
+
z-index: 1;
|
|
5270
|
+
}
|
|
5271
|
+
|
|
5233
5272
|
.html-node {
|
|
5234
5273
|
position: relative;
|
|
5235
5274
|
min-height: 40px;
|
|
@@ -5258,7 +5297,6 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
5258
5297
|
outline: none;
|
|
5259
5298
|
}
|
|
5260
5299
|
|
|
5261
|
-
|
|
5262
5300
|
& .ProseMirror-focused {
|
|
5263
5301
|
outline: none;
|
|
5264
5302
|
}
|
|
@@ -5293,6 +5331,20 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
5293
5331
|
}
|
|
5294
5332
|
}
|
|
5295
5333
|
|
|
5334
|
+
.cm-copy-btn {
|
|
5335
|
+
position: absolute;
|
|
5336
|
+
top: 6px;
|
|
5337
|
+
right: 6px;
|
|
5338
|
+
padding: 4px 8px;
|
|
5339
|
+
transition: all 0.3s;
|
|
5340
|
+
font-size: small;
|
|
5341
|
+
border-radius: ${(props) => props.theme.smallBorderRadius};
|
|
5342
|
+
cursor: pointer;
|
|
5343
|
+
z-index: 1000;
|
|
5344
|
+
color: ${(props) => props.theme.labelFontColor};
|
|
5345
|
+
background: ${(props) => props.theme.hoverColor};
|
|
5346
|
+
}
|
|
5347
|
+
|
|
5296
5348
|
.cm-editor {
|
|
5297
5349
|
height: auto;
|
|
5298
5350
|
padding: 12px 0;
|
|
@@ -5388,7 +5440,6 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
5388
5440
|
|
|
5389
5441
|
& .html-image-node-view-wrapper {
|
|
5390
5442
|
display: inline-block;
|
|
5391
|
-
line-height: 0;
|
|
5392
5443
|
|
|
5393
5444
|
&:hover {
|
|
5394
5445
|
outline: 2px solid #58a6ff;
|
|
@@ -5401,7 +5452,7 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
5401
5452
|
}
|
|
5402
5453
|
|
|
5403
5454
|
& .ProseMirror-selectednode {
|
|
5404
|
-
outline: 2px solid
|
|
5455
|
+
outline: 2px solid ${(props) => props.theme.accentColor};
|
|
5405
5456
|
}
|
|
5406
5457
|
|
|
5407
5458
|
& .ProseMirror th.selectedCell,
|
|
@@ -5727,12 +5778,6 @@ var lightTheme = {
|
|
|
5727
5778
|
};
|
|
5728
5779
|
|
|
5729
5780
|
// src/editor/codemirror/codemirror.ts
|
|
5730
|
-
import {
|
|
5731
|
-
ensureSyntaxTree
|
|
5732
|
-
} from "@codemirror/language";
|
|
5733
|
-
import { languages } from "@codemirror/language-data";
|
|
5734
|
-
import { nanoid } from "nanoid";
|
|
5735
|
-
import { redo, undo } from "@remirror/pm/history";
|
|
5736
5781
|
var cmInstanceMap = /* @__PURE__ */ new Map();
|
|
5737
5782
|
var themeRef = { current: createTheme(lightTheme.codemirrorTheme) };
|
|
5738
5783
|
var changeTheme = (theme) => {
|
|
@@ -5770,6 +5815,8 @@ var MfCodemirrorView = class {
|
|
|
5770
5815
|
this.id = nanoid();
|
|
5771
5816
|
this.content = "";
|
|
5772
5817
|
this.updating = false;
|
|
5818
|
+
this.copyButton = null;
|
|
5819
|
+
this.copyButtonContainer = null;
|
|
5773
5820
|
this.view = view;
|
|
5774
5821
|
this.getPos = getPos;
|
|
5775
5822
|
this.node = node;
|
|
@@ -5803,6 +5850,9 @@ var MfCodemirrorView = class {
|
|
|
5803
5850
|
});
|
|
5804
5851
|
cmInstanceMap.set(this.id, this);
|
|
5805
5852
|
this.updateLanguage();
|
|
5853
|
+
if (this.options.copyButton?.enabled !== false) {
|
|
5854
|
+
this.createCopyButton();
|
|
5855
|
+
}
|
|
5806
5856
|
}
|
|
5807
5857
|
update(node) {
|
|
5808
5858
|
if (node.type !== this.node.type) {
|
|
@@ -6001,6 +6051,95 @@ var MfCodemirrorView = class {
|
|
|
6001
6051
|
return true;
|
|
6002
6052
|
};
|
|
6003
6053
|
}
|
|
6054
|
+
/**
|
|
6055
|
+
* Creates the copy button and adds it to the CodeMirror editor
|
|
6056
|
+
*/
|
|
6057
|
+
createCopyButton() {
|
|
6058
|
+
if (!this.cm.dom || !this.options) return;
|
|
6059
|
+
this.copyButton = document.createElement("div");
|
|
6060
|
+
this.copyButton.className = "cm-copy-btn";
|
|
6061
|
+
this.copyButton.innerHTML = `<i class="ri-file-copy-line"></i>`;
|
|
6062
|
+
const tooltip = "Copy code";
|
|
6063
|
+
this.copyButton.title = tooltip;
|
|
6064
|
+
this.setupCopyButtonEvents();
|
|
6065
|
+
this.cm.dom.appendChild(this.copyButton);
|
|
6066
|
+
this.copyButton.style.pointerEvents = "auto";
|
|
6067
|
+
}
|
|
6068
|
+
/**
|
|
6069
|
+
* Sets up event listeners for the copy button
|
|
6070
|
+
*/
|
|
6071
|
+
setupCopyButtonEvents() {
|
|
6072
|
+
if (!this.copyButton) return;
|
|
6073
|
+
this.copyButton.addEventListener("mouseenter", () => {
|
|
6074
|
+
if (!this.copyButton) return;
|
|
6075
|
+
this.copyButton.style.transform = "translateY(-1px)";
|
|
6076
|
+
});
|
|
6077
|
+
this.copyButton.addEventListener("mousedown", (e) => {
|
|
6078
|
+
e.preventDefault();
|
|
6079
|
+
e.stopPropagation();
|
|
6080
|
+
});
|
|
6081
|
+
this.copyButton.addEventListener("mouseleave", () => {
|
|
6082
|
+
if (!this.copyButton) return;
|
|
6083
|
+
this.copyButton.style.transform = "translateY(0)";
|
|
6084
|
+
});
|
|
6085
|
+
this.copyButton.addEventListener("click", this.handleCopy.bind(this), {
|
|
6086
|
+
capture: true
|
|
6087
|
+
});
|
|
6088
|
+
}
|
|
6089
|
+
/**
|
|
6090
|
+
* Handles the copy button click event
|
|
6091
|
+
*/
|
|
6092
|
+
async handleCopy(e) {
|
|
6093
|
+
e.stopPropagation();
|
|
6094
|
+
e.preventDefault();
|
|
6095
|
+
if (!this.options) return;
|
|
6096
|
+
const code = this.node.textContent;
|
|
6097
|
+
if (this.options.copyButton?.customCopyFunction) {
|
|
6098
|
+
try {
|
|
6099
|
+
const result = this.options.copyButton.customCopyFunction(code);
|
|
6100
|
+
if (result instanceof Promise) {
|
|
6101
|
+
const success = await result;
|
|
6102
|
+
if (success) {
|
|
6103
|
+
this.showCopySuccess();
|
|
6104
|
+
}
|
|
6105
|
+
} else {
|
|
6106
|
+
if (result) {
|
|
6107
|
+
this.showCopySuccess();
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6110
|
+
return;
|
|
6111
|
+
} catch (error) {
|
|
6112
|
+
console.error("Custom copy function failed:", error);
|
|
6113
|
+
}
|
|
6114
|
+
}
|
|
6115
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
6116
|
+
try {
|
|
6117
|
+
await navigator.clipboard.writeText(code);
|
|
6118
|
+
this.showCopySuccess();
|
|
6119
|
+
} catch (error) {
|
|
6120
|
+
console.error("Clipboard API failed:", error);
|
|
6121
|
+
}
|
|
6122
|
+
} else {
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6125
|
+
/**
|
|
6126
|
+
* Shows copy success feedback
|
|
6127
|
+
*/
|
|
6128
|
+
showCopySuccess() {
|
|
6129
|
+
if (!this.copyButton || !this.options) return;
|
|
6130
|
+
const originalTitle = this.copyButton.title;
|
|
6131
|
+
const successTooltip = "Copied!";
|
|
6132
|
+
this.copyButton.innerHTML = `<i class="ri-check-line"></i>`;
|
|
6133
|
+
this.copyButton.title = successTooltip;
|
|
6134
|
+
this.copyButton.style.color = "green";
|
|
6135
|
+
setTimeout(() => {
|
|
6136
|
+
if (this.copyButton) {
|
|
6137
|
+
this.copyButton.innerHTML = `<i class="ri-file-copy-line"></i>`;
|
|
6138
|
+
this.copyButton.title = originalTitle;
|
|
6139
|
+
this.copyButton.style.color = "inherit";
|
|
6140
|
+
}
|
|
6141
|
+
}, 1500);
|
|
6142
|
+
}
|
|
6004
6143
|
};
|
|
6005
6144
|
var getLanguageMap = () => {
|
|
6006
6145
|
const languageMap = {};
|
|
@@ -6072,6 +6211,23 @@ import { ProsemirrorDevTools } from "@remirror/dev";
|
|
|
6072
6211
|
import { createReactManager } from "@remirror/react";
|
|
6073
6212
|
import { DocExtension } from "remirror/extensions";
|
|
6074
6213
|
|
|
6214
|
+
// src/editor/extensions/CodeMirror/codemirror-extension.ts
|
|
6215
|
+
import { languages as languages3 } from "@codemirror/language-data";
|
|
6216
|
+
import {
|
|
6217
|
+
command as command4,
|
|
6218
|
+
extension as extension16,
|
|
6219
|
+
findParentNodeOfType as findParentNodeOfType5,
|
|
6220
|
+
isElementDomNode as isElementDomNode4,
|
|
6221
|
+
isEqual,
|
|
6222
|
+
isTextSelection as isTextSelection3,
|
|
6223
|
+
keyBinding,
|
|
6224
|
+
NodeExtension as NodeExtension10,
|
|
6225
|
+
nodeInputRule as nodeInputRule9,
|
|
6226
|
+
setBlockType as setBlockType3
|
|
6227
|
+
} from "@remirror/core";
|
|
6228
|
+
import { TextSelection as TextSelection11 } from "@remirror/pm/state";
|
|
6229
|
+
import { Decoration as Decoration8, DecorationSet as DecorationSet5 } from "@remirror/pm/view";
|
|
6230
|
+
|
|
6075
6231
|
// src/editor/transform/parser.ts
|
|
6076
6232
|
import { Mark } from "@remirror/pm/model";
|
|
6077
6233
|
import MarkdownIt from "markdown-it";
|
|
@@ -6098,6 +6254,9 @@ var rule = (state) => {
|
|
|
6098
6254
|
if (match) {
|
|
6099
6255
|
const checked = match[1] === "x";
|
|
6100
6256
|
inlineToken.content = inlineToken.content.slice(match[0].length);
|
|
6257
|
+
inlineToken.children?.forEach((child) => {
|
|
6258
|
+
child.content = inlineToken.content;
|
|
6259
|
+
});
|
|
6101
6260
|
const checkboxToken = new Token("list_checkbox", "input", 0);
|
|
6102
6261
|
checkboxToken.attrPush(["type", "checkbox"]);
|
|
6103
6262
|
if (checked) {
|
|
@@ -6158,7 +6317,7 @@ function buildHtmlStringFromAst(ast) {
|
|
|
6158
6317
|
import Token2 from "markdown-it/lib/token.mjs";
|
|
6159
6318
|
import voidElements from "void-elements";
|
|
6160
6319
|
var needSplitInlineHtmlTokenTags = ["img", "iframe", "br"];
|
|
6161
|
-
var excludeHtmlInlineNodes = ["html_inline_node", "html_image", "iframe_inline", "html_br"];
|
|
6320
|
+
var excludeHtmlInlineNodes = ["html_inline_node", "html_image", "iframe_inline", "html_br", "math_inline"];
|
|
6162
6321
|
var typeMap = {
|
|
6163
6322
|
img: "html_image",
|
|
6164
6323
|
iframe: "iframe_inline",
|
|
@@ -6187,6 +6346,7 @@ function getMergeArr(phrasingContents) {
|
|
|
6187
6346
|
}
|
|
6188
6347
|
}
|
|
6189
6348
|
} else {
|
|
6349
|
+
;
|
|
6190
6350
|
phrasingContent.complete = true;
|
|
6191
6351
|
}
|
|
6192
6352
|
}
|
|
@@ -6273,8 +6433,13 @@ var rule2 = (state) => {
|
|
|
6273
6433
|
if (childs.length > 0) {
|
|
6274
6434
|
const newToken = new Token2("inline", "", 0);
|
|
6275
6435
|
newToken.children = [...childs];
|
|
6436
|
+
newToken.content = childs.map((child2) => {
|
|
6437
|
+
if (child2.type === "softbreak") {
|
|
6438
|
+
return "\n";
|
|
6439
|
+
}
|
|
6440
|
+
return child2.content;
|
|
6441
|
+
}).join("");
|
|
6276
6442
|
newTokens.push(newToken);
|
|
6277
|
-
newToken.content = childs.map((child2) => child2.content).join("");
|
|
6278
6443
|
childs = [];
|
|
6279
6444
|
}
|
|
6280
6445
|
newTokens.push(child);
|
|
@@ -6314,9 +6479,116 @@ function MarkdownItHtmlInline(md) {
|
|
|
6314
6479
|
}
|
|
6315
6480
|
var markdown_it_html_inline_default = MarkdownItHtmlInline;
|
|
6316
6481
|
|
|
6317
|
-
// src/editor/transform/markdown-it-
|
|
6482
|
+
// src/editor/transform/markdown-it-math.ts
|
|
6318
6483
|
import Token3 from "markdown-it/lib/token.mjs";
|
|
6319
6484
|
var rule3 = (state) => {
|
|
6485
|
+
let edited = false;
|
|
6486
|
+
const tokens = state.tokens;
|
|
6487
|
+
let tokensLength = tokens.length;
|
|
6488
|
+
console.log("tokens", tokens);
|
|
6489
|
+
for (let i = 0; i <= tokensLength - 1; i++) {
|
|
6490
|
+
const curToken = tokens[i];
|
|
6491
|
+
if (curToken.type === "math_block") {
|
|
6492
|
+
const originalContent = curToken.content || "";
|
|
6493
|
+
const mathToken = new Token3("math_block", "", 0);
|
|
6494
|
+
mathToken.attrs = { tex: curToken.attrs?.[0]?.[1] || "" };
|
|
6495
|
+
console.log("mathTOken", mathToken);
|
|
6496
|
+
mathToken.content = originalContent;
|
|
6497
|
+
mathToken.block = true;
|
|
6498
|
+
mathToken.map = curToken.map;
|
|
6499
|
+
tokens[i] = mathToken;
|
|
6500
|
+
edited = true;
|
|
6501
|
+
}
|
|
6502
|
+
let newTokens = [];
|
|
6503
|
+
if (curToken.type === "inline" && curToken.children && curToken.children.some((t18) => t18.type === "math_inline")) {
|
|
6504
|
+
const inlineTokens = curToken.children;
|
|
6505
|
+
inlineTokens.forEach((t18) => {
|
|
6506
|
+
if (t18.type === "math_inline") {
|
|
6507
|
+
const tex = t18.attrs?.tex || "";
|
|
6508
|
+
const originalContent = t18.content || "";
|
|
6509
|
+
const mathToken = new Token3("math_inline", "", 0);
|
|
6510
|
+
mathToken.attrs = { tex };
|
|
6511
|
+
mathToken.content = originalContent;
|
|
6512
|
+
newTokens.push(mathToken);
|
|
6513
|
+
edited = true;
|
|
6514
|
+
} else {
|
|
6515
|
+
newTokens.push(t18);
|
|
6516
|
+
}
|
|
6517
|
+
});
|
|
6518
|
+
tokens.splice(i, 1, ...newTokens);
|
|
6519
|
+
tokensLength += newTokens.length - 1;
|
|
6520
|
+
continue;
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
return edited;
|
|
6524
|
+
};
|
|
6525
|
+
function MarkdownItMath(md) {
|
|
6526
|
+
md.inline.ruler.after("escape", "math_inline", (state, silent) => {
|
|
6527
|
+
const pos = state.pos;
|
|
6528
|
+
const ch = state.src.charCodeAt(pos);
|
|
6529
|
+
if (ch !== 36) return false;
|
|
6530
|
+
if (state.src.charCodeAt(pos + 1) === 36) return false;
|
|
6531
|
+
let start = pos + 1;
|
|
6532
|
+
let end = start;
|
|
6533
|
+
while ((end = state.src.indexOf("$", end)) !== -1) {
|
|
6534
|
+
let backslashes = 0;
|
|
6535
|
+
let i = end - 1;
|
|
6536
|
+
while (i >= 0 && state.src[i] === "\\") {
|
|
6537
|
+
backslashes++;
|
|
6538
|
+
i--;
|
|
6539
|
+
}
|
|
6540
|
+
if (backslashes % 2 === 0) break;
|
|
6541
|
+
end++;
|
|
6542
|
+
}
|
|
6543
|
+
if (end === -1) return false;
|
|
6544
|
+
if (!silent) {
|
|
6545
|
+
const token = state.push("math_inline", "", 0);
|
|
6546
|
+
const tex = state.src.slice(start, end);
|
|
6547
|
+
const originalContent = state.src.slice(pos, end + 1);
|
|
6548
|
+
token.attrs = { tex };
|
|
6549
|
+
token.content = originalContent;
|
|
6550
|
+
}
|
|
6551
|
+
state.pos = end + 1;
|
|
6552
|
+
return true;
|
|
6553
|
+
});
|
|
6554
|
+
md.block.ruler.after("fence", "math_block", (state, startLine, endLine, silent) => {
|
|
6555
|
+
let pos = state.bMarks[startLine] + state.tShift[startLine];
|
|
6556
|
+
const max3 = state.eMarks[startLine];
|
|
6557
|
+
if (pos + 2 > max3) return false;
|
|
6558
|
+
if (state.src.charCodeAt(pos) !== 36 || state.src.charCodeAt(pos + 1) !== 36) return false;
|
|
6559
|
+
pos += 2;
|
|
6560
|
+
if (silent) return true;
|
|
6561
|
+
let nextLine = startLine;
|
|
6562
|
+
let found2 = false;
|
|
6563
|
+
let content = "";
|
|
6564
|
+
for (; ; ) {
|
|
6565
|
+
nextLine++;
|
|
6566
|
+
if (nextLine >= endLine) break;
|
|
6567
|
+
let lineStart = state.bMarks[nextLine] + state.tShift[nextLine];
|
|
6568
|
+
const lineEnd = state.eMarks[nextLine];
|
|
6569
|
+
if (state.src.charCodeAt(lineStart) === 36 && state.src.charCodeAt(lineStart + 1) === 36) {
|
|
6570
|
+
found2 = true;
|
|
6571
|
+
pos = lineStart + 2;
|
|
6572
|
+
break;
|
|
6573
|
+
}
|
|
6574
|
+
}
|
|
6575
|
+
if (!found2) return false;
|
|
6576
|
+
content = state.getLines(startLine + 1, nextLine, state.tShift[startLine + 1], true);
|
|
6577
|
+
const originalContent = state.getLines(startLine, nextLine + 1, state.tShift[startLine], true);
|
|
6578
|
+
const token = state.push("math_block", "div", 0);
|
|
6579
|
+
token.block = true;
|
|
6580
|
+
token.content = originalContent;
|
|
6581
|
+
token.attrs = [["tex", content]];
|
|
6582
|
+
token.map = [startLine, nextLine + 1];
|
|
6583
|
+
state.line = nextLine + 1;
|
|
6584
|
+
return true;
|
|
6585
|
+
}, { alt: ["paragraph", "reference", "blockquote", "list"] });
|
|
6586
|
+
md.core.ruler.push("markdown-it-math", rule3);
|
|
6587
|
+
}
|
|
6588
|
+
|
|
6589
|
+
// src/editor/transform/markdown-it-mermaid.ts
|
|
6590
|
+
import Token4 from "markdown-it/lib/token.mjs";
|
|
6591
|
+
var rule4 = (state) => {
|
|
6320
6592
|
let edited = false;
|
|
6321
6593
|
const tokens = state.tokens;
|
|
6322
6594
|
const tokensLength = tokens.length;
|
|
@@ -6324,7 +6596,7 @@ var rule3 = (state) => {
|
|
|
6324
6596
|
const curToken = tokens[i];
|
|
6325
6597
|
if (curToken.type === "fence" && curToken.info === "mermaid") {
|
|
6326
6598
|
const code = curToken.content;
|
|
6327
|
-
const mermaidToken = new
|
|
6599
|
+
const mermaidToken = new Token4("mermaid_node", "", 0);
|
|
6328
6600
|
mermaidToken.content = code;
|
|
6329
6601
|
tokens[i] = mermaidToken;
|
|
6330
6602
|
}
|
|
@@ -6332,7 +6604,7 @@ var rule3 = (state) => {
|
|
|
6332
6604
|
return edited;
|
|
6333
6605
|
};
|
|
6334
6606
|
function MarkdownItMermaid(md) {
|
|
6335
|
-
md.core.ruler.push("markdown-it-mermaid",
|
|
6607
|
+
md.core.ruler.push("markdown-it-mermaid", rule4);
|
|
6336
6608
|
}
|
|
6337
6609
|
var markdown_it_mermaid_default = MarkdownItMermaid;
|
|
6338
6610
|
|
|
@@ -6390,7 +6662,11 @@ var MarkdownParseState = class {
|
|
|
6390
6662
|
const handler = this.tokenHandlers[tok.type];
|
|
6391
6663
|
if (!handler) return;
|
|
6392
6664
|
if (!handler) throw new UnknowMarkdownItTokenError(tok.type, Object.keys(this.tokenHandlers));
|
|
6393
|
-
|
|
6665
|
+
if (tok.type === "inline" && tok.children && tok.children.length > 0) {
|
|
6666
|
+
this.parseTokens(tok.children);
|
|
6667
|
+
} else {
|
|
6668
|
+
handler(this, tok);
|
|
6669
|
+
}
|
|
6394
6670
|
}
|
|
6395
6671
|
}
|
|
6396
6672
|
// Add a node at the current position.
|
|
@@ -6508,7 +6784,7 @@ function buildTokenHandlers(schema, parserRules) {
|
|
|
6508
6784
|
var MarkdownParser = class {
|
|
6509
6785
|
constructor(schema, parserRules) {
|
|
6510
6786
|
this.schema = schema;
|
|
6511
|
-
this.tokenizer = MarkdownIt("commonmark", { html: true }).disable(["emphasis", "autolink", "backticks", "entity", "reference", "image", "link"]).enable(["table"]).use(markdown_it_html_inline_default).use(markdown_it_list_checkbox_default).use(markdown_it_mermaid_default);
|
|
6787
|
+
this.tokenizer = MarkdownIt("commonmark", { html: true }).disable(["emphasis", "autolink", "backticks", "entity", "reference", "image", "link"]).enable(["table"]).use(markdown_it_html_inline_default).use(markdown_it_list_checkbox_default).use(markdown_it_mermaid_default).use(MarkdownItMath);
|
|
6512
6788
|
this.tokenHandlers = buildTokenHandlers(schema, parserRules);
|
|
6513
6789
|
}
|
|
6514
6790
|
parse(text) {
|
|
@@ -8095,16 +8371,36 @@ HtmlBrExtension = __decorateClass([
|
|
|
8095
8371
|
})
|
|
8096
8372
|
], HtmlBrExtension);
|
|
8097
8373
|
|
|
8374
|
+
// src/editor/extensions/HtmlNode/html-block-extension.ts
|
|
8375
|
+
import { NodeExtension as NodeExtension3, extension as extension4, isElementDomNode, nodeInputRule as nodeInputRule2 } from "@remirror/core";
|
|
8376
|
+
import { TextSelection as TextSelection4 } from "@remirror/pm/state";
|
|
8377
|
+
import block_names from "markdown-it/lib/common/html_blocks.mjs";
|
|
8378
|
+
|
|
8098
8379
|
// src/editor/utils/common.ts
|
|
8099
8380
|
var arrayExclude = (arr, excludeArr) => {
|
|
8100
8381
|
return arr.filter((item) => !excludeArr.includes(item));
|
|
8101
8382
|
};
|
|
8102
8383
|
|
|
8103
|
-
// src/editor/extensions/
|
|
8104
|
-
import {
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8384
|
+
// src/editor/extensions/CodeMirror/codemirror-utils.ts
|
|
8385
|
+
import { Selection as Selection2 } from "@remirror/pm/state";
|
|
8386
|
+
function arrowHandler(dir) {
|
|
8387
|
+
return ({ dispatch, view, tr }) => {
|
|
8388
|
+
if (!view) {
|
|
8389
|
+
return false;
|
|
8390
|
+
}
|
|
8391
|
+
if (!(tr.selection.empty && view.endOfTextblock(dir))) {
|
|
8392
|
+
return false;
|
|
8393
|
+
}
|
|
8394
|
+
const side = dir === "left" || dir === "up" ? -1 : 1;
|
|
8395
|
+
const $head = tr.selection.$head;
|
|
8396
|
+
const nextPos = Selection2.near(tr.doc.resolve(side > 0 ? $head.after() : $head.before()), side);
|
|
8397
|
+
if (nextPos.$head && (nextPos.$head.parent.type.name === "codeMirror" || nextPos.$head.parent.type.name === "html_block" || nextPos.$head.parent.type.name === "mermaid_node" || nextPos.$head.parent.type.name === "math_block")) {
|
|
8398
|
+
dispatch?.(tr.setSelection(nextPos));
|
|
8399
|
+
return true;
|
|
8400
|
+
}
|
|
8401
|
+
return false;
|
|
8402
|
+
};
|
|
8403
|
+
}
|
|
8108
8404
|
|
|
8109
8405
|
// node_modules/@lezer/common/dist/index.js
|
|
8110
8406
|
var DefaultBufferLength = 1024;
|
|
@@ -14447,11 +14743,12 @@ var autoCloseTags2 = /* @__PURE__ */ EditorView5.inputHandler.of((view, from, to
|
|
|
14447
14743
|
});
|
|
14448
14744
|
|
|
14449
14745
|
// src/editor/extensions/HtmlNode/html-block-view.ts
|
|
14746
|
+
import { Compartment as Compartment2 } from "@codemirror/state";
|
|
14450
14747
|
function removeNewlines(str) {
|
|
14451
14748
|
return str.replace(/\n+|\t/g, "");
|
|
14452
14749
|
}
|
|
14453
14750
|
var HtmlNodeView = class {
|
|
14454
|
-
constructor(node, view, getPos) {
|
|
14751
|
+
constructor(node, view, getPos, options) {
|
|
14455
14752
|
this._htmlSrcElt = null;
|
|
14456
14753
|
this.destroying = false;
|
|
14457
14754
|
this.ignoreMutation = () => true;
|
|
@@ -14465,6 +14762,7 @@ var HtmlNodeView = class {
|
|
|
14465
14762
|
this._outerView = view;
|
|
14466
14763
|
this._getPos = getPos;
|
|
14467
14764
|
this.schema = node.type.schema;
|
|
14765
|
+
this.options = options;
|
|
14468
14766
|
this.dom = document.createElement("div");
|
|
14469
14767
|
this.dom.classList.add("html-node");
|
|
14470
14768
|
this._htmlRenderElt = document.createElement("p");
|
|
@@ -14539,7 +14837,6 @@ var HtmlNodeView = class {
|
|
|
14539
14837
|
} catch (err) {
|
|
14540
14838
|
}
|
|
14541
14839
|
}
|
|
14542
|
-
// == Inner Editor ================================== /
|
|
14543
14840
|
setSelection(anchor, head) {
|
|
14544
14841
|
if (!this._innerView) {
|
|
14545
14842
|
this.openEditor();
|
|
@@ -14563,6 +14860,10 @@ var HtmlNodeView = class {
|
|
|
14563
14860
|
useProsemirrorHistoryKey: true,
|
|
14564
14861
|
codemirrorEditorViewConfig: {
|
|
14565
14862
|
parent: this._htmlSrcElt
|
|
14863
|
+
},
|
|
14864
|
+
copyButton: {
|
|
14865
|
+
enabled: true,
|
|
14866
|
+
customCopyFunction: this.options?.customCopyFunction
|
|
14566
14867
|
}
|
|
14567
14868
|
}
|
|
14568
14869
|
});
|
|
@@ -14614,31 +14915,6 @@ var HtmlNodeView = class {
|
|
|
14614
14915
|
}
|
|
14615
14916
|
};
|
|
14616
14917
|
|
|
14617
|
-
// src/editor/extensions/HtmlNode/html-block-extension.ts
|
|
14618
|
-
import { TextSelection as TextSelection4 } from "@remirror/pm/state";
|
|
14619
|
-
import block_names from "markdown-it/lib/common/html_blocks.mjs";
|
|
14620
|
-
|
|
14621
|
-
// src/editor/extensions/CodeMirror/codemirror-utils.ts
|
|
14622
|
-
import { Selection as Selection2 } from "@remirror/pm/state";
|
|
14623
|
-
function arrowHandler(dir) {
|
|
14624
|
-
return ({ dispatch, view, tr }) => {
|
|
14625
|
-
if (!view) {
|
|
14626
|
-
return false;
|
|
14627
|
-
}
|
|
14628
|
-
if (!(tr.selection.empty && view.endOfTextblock(dir))) {
|
|
14629
|
-
return false;
|
|
14630
|
-
}
|
|
14631
|
-
const side = dir === "left" || dir === "up" ? -1 : 1;
|
|
14632
|
-
const $head = tr.selection.$head;
|
|
14633
|
-
const nextPos = Selection2.near(tr.doc.resolve(side > 0 ? $head.after() : $head.before()), side);
|
|
14634
|
-
if (nextPos.$head && (nextPos.$head.parent.type.name === "codeMirror" || nextPos.$head.parent.type.name === "html_block" || nextPos.$head.parent.type.name === "mermaid_node")) {
|
|
14635
|
-
dispatch?.(tr.setSelection(nextPos));
|
|
14636
|
-
return true;
|
|
14637
|
-
}
|
|
14638
|
-
return false;
|
|
14639
|
-
};
|
|
14640
|
-
}
|
|
14641
|
-
|
|
14642
14918
|
// src/editor/extensions/HtmlNode/html-block-extension.ts
|
|
14643
14919
|
var LineHtmlBlockExtension = class extends NodeExtension3 {
|
|
14644
14920
|
get name() {
|
|
@@ -14671,7 +14947,7 @@ var LineHtmlBlockExtension = class extends NodeExtension3 {
|
|
|
14671
14947
|
}
|
|
14672
14948
|
createNodeViews() {
|
|
14673
14949
|
return (node, view, getPos) => {
|
|
14674
|
-
return new HtmlNodeView(node, view, getPos);
|
|
14950
|
+
return new HtmlNodeView(node, view, getPos, this.options);
|
|
14675
14951
|
};
|
|
14676
14952
|
}
|
|
14677
14953
|
createInputRules() {
|
|
@@ -14717,25 +14993,35 @@ var LineHtmlBlockExtension = class extends NodeExtension3 {
|
|
|
14717
14993
|
state.ensureNewLine();
|
|
14718
14994
|
}
|
|
14719
14995
|
};
|
|
14996
|
+
LineHtmlBlockExtension = __decorateClass([
|
|
14997
|
+
extension4({
|
|
14998
|
+
defaultOptions: {
|
|
14999
|
+
customCopyFunction: () => true
|
|
15000
|
+
},
|
|
15001
|
+
staticKeys: [],
|
|
15002
|
+
handlerKeys: [],
|
|
15003
|
+
customHandlerKeys: []
|
|
15004
|
+
})
|
|
15005
|
+
], LineHtmlBlockExtension);
|
|
14720
15006
|
|
|
14721
15007
|
// src/editor/extensions/HtmlNode/html-inline-node.tsx
|
|
14722
15008
|
import block_names2 from "markdown-it/lib/common/html_blocks.mjs";
|
|
14723
15009
|
import {
|
|
14724
15010
|
ExtensionTag as ExtensionTag3,
|
|
14725
15011
|
NodeExtension as NodeExtension4,
|
|
14726
|
-
extension as
|
|
15012
|
+
extension as extension5,
|
|
14727
15013
|
nodeInputRule as nodeInputRule3
|
|
14728
15014
|
} from "remirror";
|
|
14729
15015
|
|
|
14730
15016
|
// src/editor/extensions/HtmlNode/html-inline-view.ts
|
|
15017
|
+
import { history as history2, redo as redo2, undo as undo2 } from "@remirror/pm/history";
|
|
15018
|
+
import { keymap as keymap3 } from "@remirror/pm/keymap";
|
|
14731
15019
|
import {
|
|
14732
15020
|
EditorState as EditorState2,
|
|
14733
|
-
|
|
14734
|
-
|
|
15021
|
+
Plugin,
|
|
15022
|
+
TextSelection as TextSelection5
|
|
14735
15023
|
} from "@remirror/pm/state";
|
|
14736
15024
|
import { EditorView as EditorView6 } from "@remirror/pm/view";
|
|
14737
|
-
import { keymap as keymap3 } from "@remirror/pm/keymap";
|
|
14738
|
-
import { history as history2, redo as redo2, undo as undo2 } from "@remirror/pm/history";
|
|
14739
15025
|
function collapseCmd(outerView, dir, requireOnBorder, requireEmptySelection = true) {
|
|
14740
15026
|
return (innerState, dispatch) => {
|
|
14741
15027
|
let outerState = outerView.state;
|
|
@@ -14773,10 +15059,10 @@ var HTMLInlineView = class {
|
|
|
14773
15059
|
this._isEditing = false;
|
|
14774
15060
|
this._tagName = "span";
|
|
14775
15061
|
this.dom = document.createElement(this._tagName);
|
|
14776
|
-
this.dom.classList.add("inline-
|
|
15062
|
+
this.dom.classList.add("inline-input");
|
|
14777
15063
|
this._htmlRenderElt = document.createElement("span");
|
|
14778
15064
|
this._htmlRenderElt.textContent = "";
|
|
14779
|
-
this._htmlRenderElt.classList.add("inline-
|
|
15065
|
+
this._htmlRenderElt.classList.add("inline-input-render");
|
|
14780
15066
|
this.dom.appendChild(this._htmlRenderElt);
|
|
14781
15067
|
this._htmlSrcElt = document.createElement("span");
|
|
14782
15068
|
this._htmlSrcElt.spellcheck = false;
|
|
@@ -14870,7 +15156,7 @@ var HTMLInlineView = class {
|
|
|
14870
15156
|
if (this._htmlRenderElt) {
|
|
14871
15157
|
this.dom.append(this._htmlRenderElt);
|
|
14872
15158
|
if (preview) {
|
|
14873
|
-
this._htmlRenderElt.classList.add("inline-
|
|
15159
|
+
this._htmlRenderElt.classList.add("inline-input-preview");
|
|
14874
15160
|
}
|
|
14875
15161
|
}
|
|
14876
15162
|
} catch (err) {
|
|
@@ -14939,7 +15225,7 @@ var HTMLInlineView = class {
|
|
|
14939
15225
|
}),
|
|
14940
15226
|
dispatchTransaction: this.dispatchInner.bind(this)
|
|
14941
15227
|
});
|
|
14942
|
-
this._innerView.dom.classList.add("inline-
|
|
15228
|
+
this._innerView.dom.classList.add("inline-input-src");
|
|
14943
15229
|
this._innerView.dom.classList.remove("ProseMirror");
|
|
14944
15230
|
let innerState = this._innerView.state;
|
|
14945
15231
|
this._innerView.focus();
|
|
@@ -14947,7 +15233,7 @@ var HTMLInlineView = class {
|
|
|
14947
15233
|
this._innerView.dispatch(
|
|
14948
15234
|
innerState.tr.setSelection(TextSelection5.create(innerState.doc, innerPos))
|
|
14949
15235
|
);
|
|
14950
|
-
this._htmlRenderElt?.classList.add("inline-
|
|
15236
|
+
this._htmlRenderElt?.classList.add("inline-input-preview");
|
|
14951
15237
|
this._isEditing = true;
|
|
14952
15238
|
}
|
|
14953
15239
|
/**
|
|
@@ -14967,8 +15253,8 @@ var HTMLInlineView = class {
|
|
|
14967
15253
|
}
|
|
14968
15254
|
if (render) {
|
|
14969
15255
|
this.renderHtml();
|
|
14970
|
-
this._htmlRenderElt?.classList.add("inline-
|
|
14971
|
-
this._htmlRenderElt?.classList.remove("inline-
|
|
15256
|
+
this._htmlRenderElt?.classList.add("inline-input-render");
|
|
15257
|
+
this._htmlRenderElt?.classList.remove("inline-input-preview");
|
|
14972
15258
|
}
|
|
14973
15259
|
this._isEditing = false;
|
|
14974
15260
|
}
|
|
@@ -15010,7 +15296,7 @@ var HtmlInlineNodeExtension = class extends NodeExtension4 {
|
|
|
15010
15296
|
},
|
|
15011
15297
|
toDOM: (node) => {
|
|
15012
15298
|
const dom = document.createElement("span");
|
|
15013
|
-
dom.classList.add("inline-
|
|
15299
|
+
dom.classList.add("inline-input-render");
|
|
15014
15300
|
dom.innerHTML = node.attrs.htmlText;
|
|
15015
15301
|
return dom;
|
|
15016
15302
|
}
|
|
@@ -15067,7 +15353,10 @@ var HtmlInlineNodeExtension = class extends NodeExtension4 {
|
|
|
15067
15353
|
};
|
|
15068
15354
|
HtmlInlineNodeExtension.disableExtraAttributes = true;
|
|
15069
15355
|
HtmlInlineNodeExtension = __decorateClass([
|
|
15070
|
-
|
|
15356
|
+
extension5({
|
|
15357
|
+
staticKeys: [],
|
|
15358
|
+
handlerKeys: [],
|
|
15359
|
+
customHandlerKeys: [],
|
|
15071
15360
|
defaultOptions: {
|
|
15072
15361
|
handleViewImgSrcUrl: async (src) => src
|
|
15073
15362
|
}
|
|
@@ -15079,7 +15368,7 @@ var import_querystringify = __toESM(require_querystringify(), 1);
|
|
|
15079
15368
|
import {
|
|
15080
15369
|
command as command2,
|
|
15081
15370
|
cx as cx2,
|
|
15082
|
-
extension as
|
|
15371
|
+
extension as extension6,
|
|
15083
15372
|
ExtensionTag as ExtensionTag4,
|
|
15084
15373
|
findSelectedNodeOfType,
|
|
15085
15374
|
NodeExtension as NodeExtension5,
|
|
@@ -15091,10 +15380,6 @@ import {
|
|
|
15091
15380
|
// src/editor/extensions/Iframe/Iframe-nodeview.tsx
|
|
15092
15381
|
import { Popover } from "zens";
|
|
15093
15382
|
|
|
15094
|
-
// src/editor/components/Resizable/Resizable.tsx
|
|
15095
|
-
import styled5 from "styled-components";
|
|
15096
|
-
import { useRef as useRef2, useEffect as useEffect2, useCallback, memo as memo2, useState as useState2 } from "react";
|
|
15097
|
-
|
|
15098
15383
|
// node_modules/@remirror/core-helpers/dist/remirror-core-helpers.js
|
|
15099
15384
|
var import_make_error = __toESM(require_make_error(), 1);
|
|
15100
15385
|
|
|
@@ -15273,6 +15558,10 @@ var errorMessageMap = {
|
|
|
15273
15558
|
[ErrorConstant.I18N_CONTEXT]: "You called `useI18n()` outside of an `I18nProvider` context."
|
|
15274
15559
|
};
|
|
15275
15560
|
|
|
15561
|
+
// src/editor/components/Resizable/Resizable.tsx
|
|
15562
|
+
import { memo as memo2, useCallback, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
15563
|
+
import styled5 from "styled-components";
|
|
15564
|
+
|
|
15276
15565
|
// src/editor/components/Resizable/ResizableHandle.tsx
|
|
15277
15566
|
import styled4, { css as css4 } from "styled-components";
|
|
15278
15567
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
@@ -15400,7 +15689,6 @@ var ResizableContainer = styled5.div`
|
|
|
15400
15689
|
display: inline-block;
|
|
15401
15690
|
position: relative;
|
|
15402
15691
|
max-width: 100%;
|
|
15403
|
-
line-height: 0;
|
|
15404
15692
|
user-select: none;
|
|
15405
15693
|
-webkit-user-select: none; /* Safari */
|
|
15406
15694
|
-moz-user-select: none; /* Firefox */
|
|
@@ -15755,7 +16043,7 @@ __decorateClass([
|
|
|
15755
16043
|
command2()
|
|
15756
16044
|
], IframeExtension.prototype, "updateYouTubeVideo", 1);
|
|
15757
16045
|
IframeExtension = __decorateClass([
|
|
15758
|
-
|
|
16046
|
+
extension6({
|
|
15759
16047
|
defaultOptions: {
|
|
15760
16048
|
defaultSource: "",
|
|
15761
16049
|
class: "remirror-iframe",
|
|
@@ -15799,7 +16087,7 @@ function createYouTubeUrl(props) {
|
|
|
15799
16087
|
import {
|
|
15800
16088
|
command as command3,
|
|
15801
16089
|
ErrorConstant as ErrorConstant2,
|
|
15802
|
-
extension as
|
|
16090
|
+
extension as extension7,
|
|
15803
16091
|
ExtensionTag as ExtensionTag5,
|
|
15804
16092
|
getTextSelection,
|
|
15805
16093
|
invariant,
|
|
@@ -16083,7 +16371,7 @@ __decorateClass([
|
|
|
16083
16371
|
command3()
|
|
16084
16372
|
], HtmlImageExtension.prototype, "uploadImage", 1);
|
|
16085
16373
|
HtmlImageExtension = __decorateClass([
|
|
16086
|
-
|
|
16374
|
+
extension7({
|
|
16087
16375
|
defaultOptions: {
|
|
16088
16376
|
createPlaceholder,
|
|
16089
16377
|
handleViewImgSrcUrl: async (src) => src,
|
|
@@ -16159,7 +16447,7 @@ import { isTextSelection as isTextSelection2, PlainExtension as PlainExtension4
|
|
|
16159
16447
|
import { Decoration as Decoration4, DecorationSet as DecorationSet3 } from "@remirror/pm/view";
|
|
16160
16448
|
|
|
16161
16449
|
// src/editor/extensions/Inline/inline-mark-extensions.ts
|
|
16162
|
-
import { MarkExtension, extension as
|
|
16450
|
+
import { MarkExtension, extension as extension8 } from "@remirror/core";
|
|
16163
16451
|
|
|
16164
16452
|
// src/editor/extensions/Inline/format-href.ts
|
|
16165
16453
|
function formatHref(location2) {
|
|
@@ -17170,7 +17458,7 @@ var ImgUri = class extends MarkExtension {
|
|
|
17170
17458
|
};
|
|
17171
17459
|
ImgUri.disableExtraAttributes = true;
|
|
17172
17460
|
ImgUri = __decorateClass([
|
|
17173
|
-
|
|
17461
|
+
extension8({
|
|
17174
17462
|
defaultOptions: {
|
|
17175
17463
|
handleViewImgSrcUrl: async (src) => src
|
|
17176
17464
|
},
|
|
@@ -20120,30 +20408,668 @@ function isOrderedListNode(node) {
|
|
|
20120
20408
|
return node.type.name === "list" && node.attrs.kind === "ordered";
|
|
20121
20409
|
}
|
|
20122
20410
|
|
|
20123
|
-
// src/editor/extensions/
|
|
20124
|
-
import {
|
|
20125
|
-
|
|
20126
|
-
// src/editor/extensions/Mermaid/mermaid-view.ts
|
|
20127
|
-
import { Compartment as Compartment3 } from "@codemirror/state";
|
|
20128
|
-
import mermaid from "mermaid";
|
|
20129
|
-
|
|
20130
|
-
// src/editor/utils/eventbus.ts
|
|
20131
|
-
import EventBus from "js-event-bus";
|
|
20132
|
-
var eventBus = new EventBus();
|
|
20411
|
+
// src/editor/extensions/Math/math-inline-extension.tsx
|
|
20412
|
+
import { extension as extension9, ExtensionTag as ExtensionTag6, NodeExtension as NodeExtension7, nodeInputRule as nodeInputRule6, omitExtraAttributes as omitExtraAttributes3 } from "@remirror/core";
|
|
20133
20413
|
|
|
20134
|
-
// src/editor/extensions/
|
|
20135
|
-
|
|
20136
|
-
|
|
20137
|
-
|
|
20138
|
-
|
|
20139
|
-
|
|
20140
|
-
|
|
20141
|
-
|
|
20142
|
-
|
|
20143
|
-
|
|
20144
|
-
};
|
|
20145
|
-
|
|
20146
|
-
|
|
20414
|
+
// src/editor/extensions/Math/math-inline-nodeview.tsx
|
|
20415
|
+
import { history as history3, redo as redo3, undo as undo3 } from "@remirror/pm/history";
|
|
20416
|
+
import { keymap as keymap4 } from "@remirror/pm/keymap";
|
|
20417
|
+
import { EditorState as EditorState3, Plugin as Plugin2, TextSelection as TextSelection8 } from "@remirror/pm/state";
|
|
20418
|
+
import { EditorView as EditorView7 } from "@remirror/pm/view";
|
|
20419
|
+
import katex from "katex";
|
|
20420
|
+
function collapseCmd2(outerView, dir, requireOnBorder, requireEmptySelection = true) {
|
|
20421
|
+
return (innerState, dispatch) => {
|
|
20422
|
+
const outerState = outerView.state;
|
|
20423
|
+
const { to: outerTo, from: outerFrom } = outerState.selection;
|
|
20424
|
+
const { to: innerTo, from: innerFrom } = innerState.selection;
|
|
20425
|
+
if (requireEmptySelection && innerTo !== innerFrom) return false;
|
|
20426
|
+
const currentPos = dir > 0 ? innerTo : innerFrom;
|
|
20427
|
+
if (requireOnBorder) {
|
|
20428
|
+
const nodeSize2 = innerState.doc.nodeSize - 2;
|
|
20429
|
+
if (dir > 0 && currentPos < nodeSize2) return false;
|
|
20430
|
+
if (dir < 0 && currentPos > 0) return false;
|
|
20431
|
+
}
|
|
20432
|
+
if (dispatch) {
|
|
20433
|
+
const targetPos = dir > 0 ? outerTo : outerFrom;
|
|
20434
|
+
outerView.dispatch(
|
|
20435
|
+
outerState.tr.setSelection(TextSelection8.create(outerState.doc, targetPos))
|
|
20436
|
+
);
|
|
20437
|
+
outerView.focus();
|
|
20438
|
+
}
|
|
20439
|
+
return true;
|
|
20440
|
+
};
|
|
20441
|
+
}
|
|
20442
|
+
var MathInlineView = class {
|
|
20443
|
+
constructor(node, view, getPos) {
|
|
20444
|
+
this.openEditor = () => {
|
|
20445
|
+
if (this._innerView) return;
|
|
20446
|
+
const currentTex = this._node.attrs.tex ?? "";
|
|
20447
|
+
this._innerView = new EditorView7(this._srcElt, {
|
|
20448
|
+
state: EditorState3.create({
|
|
20449
|
+
doc: this._outerView.state.schema.node(
|
|
20450
|
+
"paragraph",
|
|
20451
|
+
null,
|
|
20452
|
+
currentTex ? [this._outerView.state.schema.text(currentTex)] : [this._outerView.state.schema.text("\u200B")]
|
|
20453
|
+
),
|
|
20454
|
+
plugins: [
|
|
20455
|
+
history3(),
|
|
20456
|
+
keymap4({
|
|
20457
|
+
ArrowLeft: collapseCmd2(this._outerView, -1, true),
|
|
20458
|
+
ArrowRight: collapseCmd2(this._outerView, 1, true),
|
|
20459
|
+
ArrowUp: collapseCmd2(this._outerView, -1, true),
|
|
20460
|
+
ArrowDown: collapseCmd2(this._outerView, 1, true),
|
|
20461
|
+
"Mod-z": (state, dispatch, view) => undo3(state, dispatch, view),
|
|
20462
|
+
"Shift-Mod-z": (state, dispatch, view) => redo3(state, dispatch, view),
|
|
20463
|
+
Backspace: (state) => {
|
|
20464
|
+
const { from, to } = state.selection;
|
|
20465
|
+
if (from === 0 && to === state.doc.content.size) {
|
|
20466
|
+
const pos = this._getPos();
|
|
20467
|
+
if (pos !== void 0) {
|
|
20468
|
+
const tr = this._outerView.state.tr.delete(pos, pos + this._node.nodeSize);
|
|
20469
|
+
this._outerView.dispatch(tr);
|
|
20470
|
+
this._outerView.focus();
|
|
20471
|
+
return true;
|
|
20472
|
+
}
|
|
20473
|
+
}
|
|
20474
|
+
return false;
|
|
20475
|
+
}
|
|
20476
|
+
}),
|
|
20477
|
+
new Plugin2({
|
|
20478
|
+
props: {
|
|
20479
|
+
handleDOMEvents: {
|
|
20480
|
+
blur: () => {
|
|
20481
|
+
const pos = this._getPos();
|
|
20482
|
+
if (pos !== void 0) {
|
|
20483
|
+
const text = (this._innerView?.state.doc.textContent || "").replace(
|
|
20484
|
+
/\u200b/g,
|
|
20485
|
+
""
|
|
20486
|
+
);
|
|
20487
|
+
const tr = this._outerView.state.tr;
|
|
20488
|
+
tr.setNodeAttribute(pos, "fromInput", false);
|
|
20489
|
+
tr.setNodeAttribute(pos, "tex", text);
|
|
20490
|
+
this._outerView.dispatch(tr);
|
|
20491
|
+
}
|
|
20492
|
+
this.closeEditor();
|
|
20493
|
+
return true;
|
|
20494
|
+
}
|
|
20495
|
+
}
|
|
20496
|
+
}
|
|
20497
|
+
})
|
|
20498
|
+
]
|
|
20499
|
+
}),
|
|
20500
|
+
dispatchTransaction: this.dispatchInner.bind(this)
|
|
20501
|
+
});
|
|
20502
|
+
this._innerView.dom.classList.add("inline-input-src");
|
|
20503
|
+
this._innerView.dom.classList.remove("ProseMirror");
|
|
20504
|
+
this._srcElt.style.display = "inline";
|
|
20505
|
+
const innerState = this._innerView.state;
|
|
20506
|
+
this._innerView.focus();
|
|
20507
|
+
const innerPos = innerState.doc.textContent.length || 0;
|
|
20508
|
+
this._innerView.dispatch(
|
|
20509
|
+
innerState.tr.setSelection(TextSelection8.create(innerState.doc, innerPos))
|
|
20510
|
+
);
|
|
20511
|
+
this._renderElt?.classList.add("inline-input-preview");
|
|
20512
|
+
this._isEditing = true;
|
|
20513
|
+
};
|
|
20514
|
+
this.closeEditor = (render = true) => {
|
|
20515
|
+
if (this._srcElt) {
|
|
20516
|
+
this._srcElt.style.display = "none";
|
|
20517
|
+
}
|
|
20518
|
+
if (this._innerView) {
|
|
20519
|
+
this._innerView.destroy();
|
|
20520
|
+
this._innerView = void 0;
|
|
20521
|
+
}
|
|
20522
|
+
if (render) {
|
|
20523
|
+
this.renderTex();
|
|
20524
|
+
}
|
|
20525
|
+
this._isEditing = false;
|
|
20526
|
+
};
|
|
20527
|
+
this._node = node;
|
|
20528
|
+
this._outerView = view;
|
|
20529
|
+
this._getPos = getPos;
|
|
20530
|
+
this._isEditing = false;
|
|
20531
|
+
this.dom = document.createElement("span");
|
|
20532
|
+
this.dom.classList.add("inline-input");
|
|
20533
|
+
this._renderElt = document.createElement("span");
|
|
20534
|
+
this._renderElt.classList.add("inline-input-render");
|
|
20535
|
+
this.dom.appendChild(this._renderElt);
|
|
20536
|
+
this._srcElt = document.createElement("span");
|
|
20537
|
+
this._srcElt.spellcheck = false;
|
|
20538
|
+
this._srcElt.style.display = "none";
|
|
20539
|
+
this.dom.appendChild(this._srcElt);
|
|
20540
|
+
this.dom.addEventListener("click", () => this.ensureFocus());
|
|
20541
|
+
if (node.attrs.fromInput) {
|
|
20542
|
+
setTimeout(() => this.openEditor());
|
|
20543
|
+
} else {
|
|
20544
|
+
this.renderTex();
|
|
20545
|
+
}
|
|
20546
|
+
}
|
|
20547
|
+
destroy() {
|
|
20548
|
+
this.closeEditor(false);
|
|
20549
|
+
if (this._renderElt) {
|
|
20550
|
+
this._renderElt.remove();
|
|
20551
|
+
delete this._renderElt;
|
|
20552
|
+
}
|
|
20553
|
+
if (this._srcElt) {
|
|
20554
|
+
this._srcElt.remove();
|
|
20555
|
+
delete this._srcElt;
|
|
20556
|
+
}
|
|
20557
|
+
this.dom.remove();
|
|
20558
|
+
}
|
|
20559
|
+
ensureFocus() {
|
|
20560
|
+
if (this._innerView && this._outerView.hasFocus()) {
|
|
20561
|
+
this._innerView.focus();
|
|
20562
|
+
}
|
|
20563
|
+
}
|
|
20564
|
+
update(node, _decorations) {
|
|
20565
|
+
if (!node.sameMarkup(this._node)) return false;
|
|
20566
|
+
this._node = node;
|
|
20567
|
+
if (!this._isEditing) this.renderTex();
|
|
20568
|
+
return true;
|
|
20569
|
+
}
|
|
20570
|
+
selectNode() {
|
|
20571
|
+
if (!this._outerView.editable) return;
|
|
20572
|
+
if (!this._isEditing) this.openEditor();
|
|
20573
|
+
}
|
|
20574
|
+
deselectNode() {
|
|
20575
|
+
if (this._isEditing) this.closeEditor();
|
|
20576
|
+
}
|
|
20577
|
+
stopEvent(event) {
|
|
20578
|
+
return this._innerView !== void 0 && event.target !== void 0 && this._innerView.dom.contains(event.target);
|
|
20579
|
+
}
|
|
20580
|
+
ignoreMutation() {
|
|
20581
|
+
return true;
|
|
20582
|
+
}
|
|
20583
|
+
renderTex(preview = false) {
|
|
20584
|
+
if (!this._renderElt) return;
|
|
20585
|
+
const raw = this._innerView?.state.doc.textContent ?? this._node.attrs.tex ?? "";
|
|
20586
|
+
const tex = raw.replace(/\u200b/g, "").trim();
|
|
20587
|
+
try {
|
|
20588
|
+
while (this._renderElt.firstChild) {
|
|
20589
|
+
this._renderElt.firstChild.remove();
|
|
20590
|
+
}
|
|
20591
|
+
const container = document.createElement("span");
|
|
20592
|
+
container.setAttribute("data-type", "math-inline");
|
|
20593
|
+
katex.render(tex || "", container, {
|
|
20594
|
+
throwOnError: false,
|
|
20595
|
+
displayMode: false,
|
|
20596
|
+
output: "mathml"
|
|
20597
|
+
});
|
|
20598
|
+
let newRenderEl = container;
|
|
20599
|
+
if (container.childElementCount === 1 && container.firstElementChild) {
|
|
20600
|
+
newRenderEl = container.firstElementChild;
|
|
20601
|
+
}
|
|
20602
|
+
this._renderElt.replaceWith(newRenderEl);
|
|
20603
|
+
this._renderElt = newRenderEl;
|
|
20604
|
+
console.log("this.renderElt", this._renderElt.outerHTML);
|
|
20605
|
+
this.dom.appendChild(this._renderElt);
|
|
20606
|
+
if (preview) {
|
|
20607
|
+
this._renderElt.classList.add("inline-input-preview");
|
|
20608
|
+
} else {
|
|
20609
|
+
this._renderElt.classList.add("inline-input-render");
|
|
20610
|
+
this._renderElt.classList.remove("inline-input-preview");
|
|
20611
|
+
}
|
|
20612
|
+
} catch (err) {
|
|
20613
|
+
console.error(err);
|
|
20614
|
+
this._renderElt.classList.add("parse-error");
|
|
20615
|
+
this.dom.setAttribute("title", String(err));
|
|
20616
|
+
}
|
|
20617
|
+
}
|
|
20618
|
+
dispatchInner(tr) {
|
|
20619
|
+
if (!this._innerView) return;
|
|
20620
|
+
const { state } = this._innerView.state.applyTransaction(tr);
|
|
20621
|
+
this._innerView.updateState(state);
|
|
20622
|
+
this.renderTex(true);
|
|
20623
|
+
}
|
|
20624
|
+
};
|
|
20625
|
+
|
|
20626
|
+
// src/editor/extensions/Math/math-inline-extension.tsx
|
|
20627
|
+
var MathInlineExtension = class extends NodeExtension7 {
|
|
20628
|
+
get name() {
|
|
20629
|
+
return "math_inline";
|
|
20630
|
+
}
|
|
20631
|
+
createTags() {
|
|
20632
|
+
return [ExtensionTag6.InlineNode];
|
|
20633
|
+
}
|
|
20634
|
+
createNodeSpec(extra, override) {
|
|
20635
|
+
return {
|
|
20636
|
+
inline: true,
|
|
20637
|
+
atom: true,
|
|
20638
|
+
selectable: true,
|
|
20639
|
+
// disallow marks on the inline atom similar to html-inline-node
|
|
20640
|
+
marks: "",
|
|
20641
|
+
...override,
|
|
20642
|
+
attrs: {
|
|
20643
|
+
...extra.defaults(),
|
|
20644
|
+
tex: { default: "" },
|
|
20645
|
+
fromInput: { default: false }
|
|
20646
|
+
},
|
|
20647
|
+
parseDOM: [
|
|
20648
|
+
{
|
|
20649
|
+
tag: 'span[data-type="math-inline"]',
|
|
20650
|
+
getAttrs: (dom) => {
|
|
20651
|
+
const el = dom;
|
|
20652
|
+
return { ...extra.parse(dom), tex: el.getAttribute("data-tex") ?? "" };
|
|
20653
|
+
}
|
|
20654
|
+
},
|
|
20655
|
+
...override.parseDOM ?? []
|
|
20656
|
+
],
|
|
20657
|
+
toDOM: (node) => {
|
|
20658
|
+
const attrs = omitExtraAttributes3(node.attrs, extra);
|
|
20659
|
+
return ["span", { ...extra.dom(node), "data-type": "math-inline", "data-tex": attrs.tex }];
|
|
20660
|
+
}
|
|
20661
|
+
};
|
|
20662
|
+
}
|
|
20663
|
+
createInputRules() {
|
|
20664
|
+
return [
|
|
20665
|
+
// Typed inline math trigger: $$ -> insert empty inline math and focus inside
|
|
20666
|
+
nodeInputRule6({
|
|
20667
|
+
regexp: /\$\$(?!\$)/,
|
|
20668
|
+
type: this.type,
|
|
20669
|
+
getAttributes: () => ({ tex: "", fromInput: true })
|
|
20670
|
+
}),
|
|
20671
|
+
// Pasted HTML span -> inline math node
|
|
20672
|
+
nodeInputRule6({
|
|
20673
|
+
regexp: /<span[^>]*data-type=["']math-inline["'][^>]*><\/span>/,
|
|
20674
|
+
type: this.type,
|
|
20675
|
+
getAttributes: () => ({ fromInput: false })
|
|
20676
|
+
}),
|
|
20677
|
+
// Typed inline math: $...$
|
|
20678
|
+
// Avoids $$...$$ by requiring at least one non-$ char between delimiters
|
|
20679
|
+
nodeInputRule6({
|
|
20680
|
+
regexp: /\$([^$\n]+?)\$/,
|
|
20681
|
+
type: this.type,
|
|
20682
|
+
getAttributes: (match) => {
|
|
20683
|
+
console.log(match);
|
|
20684
|
+
return { tex: match[1] ?? "", fromInput: true };
|
|
20685
|
+
}
|
|
20686
|
+
})
|
|
20687
|
+
];
|
|
20688
|
+
}
|
|
20689
|
+
fromMarkdown() {
|
|
20690
|
+
return [
|
|
20691
|
+
{
|
|
20692
|
+
type: 6 /* inline */,
|
|
20693
|
+
token: "math_inline",
|
|
20694
|
+
node: this.name,
|
|
20695
|
+
getAttrs: (tok) => {
|
|
20696
|
+
return { tex: tok.attrs?.tex || "" };
|
|
20697
|
+
}
|
|
20698
|
+
}
|
|
20699
|
+
];
|
|
20700
|
+
}
|
|
20701
|
+
toMarkdown({ state, node }) {
|
|
20702
|
+
const tex = node.attrs.tex;
|
|
20703
|
+
state.text(`$${tex}$`, false);
|
|
20704
|
+
}
|
|
20705
|
+
createNodeViews() {
|
|
20706
|
+
return (node, view, getPos) => new MathInlineView(node, view, getPos);
|
|
20707
|
+
}
|
|
20708
|
+
};
|
|
20709
|
+
MathInlineExtension.disableExtraAttributes = true;
|
|
20710
|
+
MathInlineExtension = __decorateClass([
|
|
20711
|
+
extension9({
|
|
20712
|
+
defaultOptions: {}
|
|
20713
|
+
})
|
|
20714
|
+
], MathInlineExtension);
|
|
20715
|
+
|
|
20716
|
+
// src/editor/extensions/Math/math-block-extension.tsx
|
|
20717
|
+
import { extension as extension10, ExtensionTag as ExtensionTag7, NodeExtension as NodeExtension8, nodeInputRule as nodeInputRule7 } from "@remirror/core";
|
|
20718
|
+
|
|
20719
|
+
// src/editor/extensions/Math/math-block-nodeview.tsx
|
|
20720
|
+
import { exitCode as exitCode3 } from "@remirror/pm/commands";
|
|
20721
|
+
import { history as history4, redo as redo4, undo as undo4 } from "@remirror/pm/history";
|
|
20722
|
+
import { keymap as keymap5 } from "@remirror/pm/keymap";
|
|
20723
|
+
import {
|
|
20724
|
+
EditorState as EditorState4,
|
|
20725
|
+
Plugin as Plugin3,
|
|
20726
|
+
Selection as Selection3,
|
|
20727
|
+
TextSelection as TextSelection9
|
|
20728
|
+
} from "@remirror/pm/state";
|
|
20729
|
+
import { EditorView as EditorView8 } from "@remirror/pm/view";
|
|
20730
|
+
import katex2 from "katex";
|
|
20731
|
+
function collapseCmd3(outerView, dir, requireOnBorder, requireEmptySelection = true, getPos, node) {
|
|
20732
|
+
return (innerState, dispatch) => {
|
|
20733
|
+
const outerState = outerView.state;
|
|
20734
|
+
const { to: innerTo, from: innerFrom } = innerState.selection;
|
|
20735
|
+
if (requireEmptySelection && innerTo !== innerFrom) return false;
|
|
20736
|
+
const currentPos = dir > 0 ? innerTo : innerFrom;
|
|
20737
|
+
if (requireOnBorder) {
|
|
20738
|
+
const nodeSize2 = innerState.doc.nodeSize - 2;
|
|
20739
|
+
if (dir > 0 && currentPos < nodeSize2) return false;
|
|
20740
|
+
if (dir < 0 && currentPos > 0) return false;
|
|
20741
|
+
}
|
|
20742
|
+
if (dispatch) {
|
|
20743
|
+
const pos = getPos?.();
|
|
20744
|
+
if (pos === void 0 || !node) return false;
|
|
20745
|
+
let targetPos;
|
|
20746
|
+
if (dir > 0) {
|
|
20747
|
+
targetPos = pos + node.nodeSize;
|
|
20748
|
+
} else {
|
|
20749
|
+
targetPos = pos;
|
|
20750
|
+
}
|
|
20751
|
+
if (targetPos < 0 || targetPos > outerState.doc.content.size) {
|
|
20752
|
+
return false;
|
|
20753
|
+
}
|
|
20754
|
+
if (dir === 1 && exitCode3(outerView.state, outerView.dispatch)) {
|
|
20755
|
+
outerView.focus();
|
|
20756
|
+
} else {
|
|
20757
|
+
const selection = Selection3.near(outerState.doc.resolve(targetPos), dir);
|
|
20758
|
+
const tr = outerView.state.tr.setSelection(selection).scrollIntoView();
|
|
20759
|
+
outerView.dispatch(tr);
|
|
20760
|
+
outerView.focus();
|
|
20761
|
+
}
|
|
20762
|
+
return true;
|
|
20763
|
+
}
|
|
20764
|
+
return true;
|
|
20765
|
+
};
|
|
20766
|
+
}
|
|
20767
|
+
var MathBlockView = class {
|
|
20768
|
+
constructor(node, view, getPos) {
|
|
20769
|
+
this.openEditor = () => {
|
|
20770
|
+
if (this._innerView) return;
|
|
20771
|
+
const currentTex = this._node.attrs.tex ?? "";
|
|
20772
|
+
this._innerView = new EditorView8(this._srcElt, {
|
|
20773
|
+
state: EditorState4.create({
|
|
20774
|
+
doc: this._outerView.state.schema.node(
|
|
20775
|
+
"paragraph",
|
|
20776
|
+
null,
|
|
20777
|
+
currentTex ? [this._outerView.state.schema.text(currentTex)] : [this._outerView.state.schema.text("\u200B")]
|
|
20778
|
+
),
|
|
20779
|
+
plugins: [
|
|
20780
|
+
history4(),
|
|
20781
|
+
keymap5({
|
|
20782
|
+
Tab: (state, dispatch) => {
|
|
20783
|
+
if (dispatch) dispatch(state.tr.insertText(" "));
|
|
20784
|
+
return true;
|
|
20785
|
+
},
|
|
20786
|
+
ArrowLeft: collapseCmd3(this._outerView, -1, true, true, this._getPos, this._node),
|
|
20787
|
+
ArrowRight: collapseCmd3(this._outerView, 1, true, true, this._getPos, this._node),
|
|
20788
|
+
ArrowUp: collapseCmd3(this._outerView, -1, true, true, this._getPos, this._node),
|
|
20789
|
+
ArrowDown: collapseCmd3(this._outerView, 1, true, true, this._getPos, this._node),
|
|
20790
|
+
"Mod-z": (state, dispatch, view) => undo4(state, dispatch, view),
|
|
20791
|
+
"Shift-Mod-z": (state, dispatch, view) => redo4(state, dispatch, view),
|
|
20792
|
+
Backspace: (state, dispatch) => {
|
|
20793
|
+
const { from, to } = state.selection;
|
|
20794
|
+
if (from === 0 && to === state.doc.content.size) {
|
|
20795
|
+
const pos = this._getPos();
|
|
20796
|
+
if (pos !== void 0) {
|
|
20797
|
+
const tr = this._outerView.state.tr.delete(pos, pos + this._node.nodeSize);
|
|
20798
|
+
this._outerView.dispatch(tr);
|
|
20799
|
+
this._outerView.focus();
|
|
20800
|
+
return true;
|
|
20801
|
+
}
|
|
20802
|
+
}
|
|
20803
|
+
return false;
|
|
20804
|
+
}
|
|
20805
|
+
}),
|
|
20806
|
+
new Plugin3({
|
|
20807
|
+
props: {
|
|
20808
|
+
handleDOMEvents: {
|
|
20809
|
+
blur: () => {
|
|
20810
|
+
const pos = this._getPos();
|
|
20811
|
+
if (pos !== void 0) {
|
|
20812
|
+
const text = (this._innerView?.state.doc.textContent || "").replace(
|
|
20813
|
+
/\u200b/g,
|
|
20814
|
+
""
|
|
20815
|
+
);
|
|
20816
|
+
const tr = this._outerView.state.tr;
|
|
20817
|
+
tr.setNodeAttribute(pos, "fromInput", false);
|
|
20818
|
+
tr.setNodeAttribute(pos, "tex", text);
|
|
20819
|
+
this._outerView.dispatch(tr);
|
|
20820
|
+
}
|
|
20821
|
+
this.closeEditor();
|
|
20822
|
+
return true;
|
|
20823
|
+
}
|
|
20824
|
+
}
|
|
20825
|
+
}
|
|
20826
|
+
})
|
|
20827
|
+
]
|
|
20828
|
+
}),
|
|
20829
|
+
dispatchTransaction: this.dispatchInner.bind(this)
|
|
20830
|
+
});
|
|
20831
|
+
this._innerView.dom.classList.add("inline-input-src");
|
|
20832
|
+
this._innerView.dom.classList.remove("ProseMirror");
|
|
20833
|
+
this._srcElt.style.display = "inline";
|
|
20834
|
+
const innerState = this._innerView.state;
|
|
20835
|
+
this._innerView.focus();
|
|
20836
|
+
const innerPos = innerState.doc.textContent.length || 0;
|
|
20837
|
+
this._innerView.dispatch(
|
|
20838
|
+
innerState.tr.setSelection(TextSelection9.create(innerState.doc, innerPos))
|
|
20839
|
+
);
|
|
20840
|
+
this._renderElt?.classList.add("math-block-preview");
|
|
20841
|
+
this._isEditing = true;
|
|
20842
|
+
};
|
|
20843
|
+
this.closeEditor = (render = true) => {
|
|
20844
|
+
if (this._srcElt) {
|
|
20845
|
+
this._srcElt.style.display = "none";
|
|
20846
|
+
}
|
|
20847
|
+
if (this._innerView) {
|
|
20848
|
+
this._innerView.destroy();
|
|
20849
|
+
this._innerView = void 0;
|
|
20850
|
+
}
|
|
20851
|
+
if (render) {
|
|
20852
|
+
this.renderTex();
|
|
20853
|
+
}
|
|
20854
|
+
this._isEditing = false;
|
|
20855
|
+
};
|
|
20856
|
+
this._node = node;
|
|
20857
|
+
this._outerView = view;
|
|
20858
|
+
this._getPos = getPos;
|
|
20859
|
+
this._isEditing = false;
|
|
20860
|
+
this.dom = document.createElement("div");
|
|
20861
|
+
this.dom.classList.add("math-block-nodeview");
|
|
20862
|
+
this._renderElt = document.createElement("div");
|
|
20863
|
+
this._renderElt.classList.add("math-block-render");
|
|
20864
|
+
this.dom.appendChild(this._renderElt);
|
|
20865
|
+
this._srcElt = document.createElement("div");
|
|
20866
|
+
this._srcElt.spellcheck = false;
|
|
20867
|
+
this._srcElt.style.display = "none";
|
|
20868
|
+
this.dom.appendChild(this._srcElt);
|
|
20869
|
+
this.dom.addEventListener("click", () => this.ensureFocus());
|
|
20870
|
+
if (node.attrs.fromInput) {
|
|
20871
|
+
setTimeout(() => this.openEditor());
|
|
20872
|
+
} else {
|
|
20873
|
+
this.renderTex();
|
|
20874
|
+
}
|
|
20875
|
+
}
|
|
20876
|
+
destroy() {
|
|
20877
|
+
this.closeEditor(false);
|
|
20878
|
+
if (this._renderElt) {
|
|
20879
|
+
this._renderElt.remove();
|
|
20880
|
+
delete this._renderElt;
|
|
20881
|
+
}
|
|
20882
|
+
if (this._srcElt) {
|
|
20883
|
+
this._srcElt.remove();
|
|
20884
|
+
delete this._srcElt;
|
|
20885
|
+
}
|
|
20886
|
+
this.dom.remove();
|
|
20887
|
+
}
|
|
20888
|
+
ensureFocus() {
|
|
20889
|
+
if (this._outerView.hasFocus()) {
|
|
20890
|
+
if (this._innerView) {
|
|
20891
|
+
this._innerView.focus();
|
|
20892
|
+
} else {
|
|
20893
|
+
this.openEditor();
|
|
20894
|
+
}
|
|
20895
|
+
}
|
|
20896
|
+
}
|
|
20897
|
+
update(node, _decorations) {
|
|
20898
|
+
if (!node.sameMarkup(this._node)) return false;
|
|
20899
|
+
this._node = node;
|
|
20900
|
+
if (!this._isEditing) this.renderTex();
|
|
20901
|
+
return true;
|
|
20902
|
+
}
|
|
20903
|
+
selectNode() {
|
|
20904
|
+
if (!this._outerView.editable) return;
|
|
20905
|
+
if (!this._isEditing) this.openEditor();
|
|
20906
|
+
}
|
|
20907
|
+
deselectNode() {
|
|
20908
|
+
if (this._isEditing) this.closeEditor();
|
|
20909
|
+
}
|
|
20910
|
+
setSelection() {
|
|
20911
|
+
if (!this._innerView) {
|
|
20912
|
+
this.openEditor();
|
|
20913
|
+
} else {
|
|
20914
|
+
}
|
|
20915
|
+
}
|
|
20916
|
+
stopEvent() {
|
|
20917
|
+
return true;
|
|
20918
|
+
}
|
|
20919
|
+
ignoreMutation() {
|
|
20920
|
+
return true;
|
|
20921
|
+
}
|
|
20922
|
+
renderTex(preview = false) {
|
|
20923
|
+
if (!this._renderElt) return;
|
|
20924
|
+
const raw = this._innerView?.state.doc.textContent ?? this._node.attrs.tex ?? "";
|
|
20925
|
+
const tex = raw.replace(/\u200b/g, "").trim();
|
|
20926
|
+
try {
|
|
20927
|
+
while (this._renderElt.firstChild) {
|
|
20928
|
+
this._renderElt.firstChild.remove();
|
|
20929
|
+
}
|
|
20930
|
+
const container = document.createElement("div");
|
|
20931
|
+
container.setAttribute("data-type", "math-block");
|
|
20932
|
+
katex2.render(tex || "", container, {
|
|
20933
|
+
throwOnError: false,
|
|
20934
|
+
displayMode: false,
|
|
20935
|
+
output: "mathml"
|
|
20936
|
+
});
|
|
20937
|
+
let newRenderEl = container;
|
|
20938
|
+
if (container.childElementCount === 1 && container.firstElementChild) {
|
|
20939
|
+
newRenderEl = container.firstElementChild;
|
|
20940
|
+
}
|
|
20941
|
+
this._renderElt.replaceWith(newRenderEl);
|
|
20942
|
+
this._renderElt = newRenderEl;
|
|
20943
|
+
console.log("this.renderElt", this._renderElt.outerHTML);
|
|
20944
|
+
this.dom.appendChild(this._renderElt);
|
|
20945
|
+
if (preview) {
|
|
20946
|
+
this._renderElt.classList.add("math-block-preview");
|
|
20947
|
+
} else {
|
|
20948
|
+
this._renderElt.classList.add("math-block-render");
|
|
20949
|
+
this._renderElt.classList.remove("math-block-preview");
|
|
20950
|
+
}
|
|
20951
|
+
} catch (err) {
|
|
20952
|
+
console.error(err);
|
|
20953
|
+
this._renderElt.classList.add("parse-error");
|
|
20954
|
+
this.dom.setAttribute("title", String(err));
|
|
20955
|
+
}
|
|
20956
|
+
}
|
|
20957
|
+
dispatchInner(tr) {
|
|
20958
|
+
if (!this._innerView) return;
|
|
20959
|
+
const newState = this._innerView.state.apply(tr);
|
|
20960
|
+
this._innerView.updateState(newState);
|
|
20961
|
+
this.renderTex(true);
|
|
20962
|
+
}
|
|
20963
|
+
};
|
|
20964
|
+
|
|
20965
|
+
// src/editor/extensions/Math/math-block-extension.tsx
|
|
20966
|
+
var MathBlockExtension = class extends NodeExtension8 {
|
|
20967
|
+
get name() {
|
|
20968
|
+
return "math_block";
|
|
20969
|
+
}
|
|
20970
|
+
createTags() {
|
|
20971
|
+
return [ExtensionTag7.Block];
|
|
20972
|
+
}
|
|
20973
|
+
createNodeSpec(extra, override) {
|
|
20974
|
+
return {
|
|
20975
|
+
group: "block",
|
|
20976
|
+
content: "text*",
|
|
20977
|
+
defining: true,
|
|
20978
|
+
code: true,
|
|
20979
|
+
marks: "",
|
|
20980
|
+
...override,
|
|
20981
|
+
attrs: {
|
|
20982
|
+
...extra.defaults(),
|
|
20983
|
+
tex: { default: "" },
|
|
20984
|
+
fromInput: { default: false }
|
|
20985
|
+
},
|
|
20986
|
+
parseDOM: [
|
|
20987
|
+
{
|
|
20988
|
+
tag: 'div[data-type="math-block"]',
|
|
20989
|
+
getAttrs: (dom) => extra.parse(dom)
|
|
20990
|
+
},
|
|
20991
|
+
...override.parseDOM ?? []
|
|
20992
|
+
],
|
|
20993
|
+
toDOM: () => ["div", { "data-type": "math-block" }, 0],
|
|
20994
|
+
isolating: true
|
|
20995
|
+
};
|
|
20996
|
+
}
|
|
20997
|
+
createNodeViews() {
|
|
20998
|
+
return (node, view, getPos) => new MathBlockView(node, view, getPos);
|
|
20999
|
+
}
|
|
21000
|
+
createInputRules() {
|
|
21001
|
+
return [
|
|
21002
|
+
nodeInputRule7({
|
|
21003
|
+
regexp: /^\$\$$/,
|
|
21004
|
+
type: this.type,
|
|
21005
|
+
getAttributes: (match) => {
|
|
21006
|
+
return { tex: match[1] ?? "", fromInput: true };
|
|
21007
|
+
}
|
|
21008
|
+
})
|
|
21009
|
+
];
|
|
21010
|
+
}
|
|
21011
|
+
createKeymap() {
|
|
21012
|
+
return {
|
|
21013
|
+
ArrowLeft: arrowHandler("left"),
|
|
21014
|
+
ArrowRight: arrowHandler("right"),
|
|
21015
|
+
ArrowUp: arrowHandler("up"),
|
|
21016
|
+
ArrowDown: arrowHandler("down")
|
|
21017
|
+
};
|
|
21018
|
+
}
|
|
21019
|
+
fromMarkdown() {
|
|
21020
|
+
return [
|
|
21021
|
+
{
|
|
21022
|
+
type: 2 /* block */,
|
|
21023
|
+
token: "math_block",
|
|
21024
|
+
node: this.name,
|
|
21025
|
+
hasOpenClose: false,
|
|
21026
|
+
getAttrs: (tok) => {
|
|
21027
|
+
return { tex: tok.attrs?.tex || "" };
|
|
21028
|
+
}
|
|
21029
|
+
}
|
|
21030
|
+
];
|
|
21031
|
+
}
|
|
21032
|
+
toMarkdown({ state, node }) {
|
|
21033
|
+
state.write("$$\n");
|
|
21034
|
+
const tex = node.attrs.tex || "";
|
|
21035
|
+
state.text(tex, false);
|
|
21036
|
+
if (!tex.endsWith("\n")) {
|
|
21037
|
+
state.text("\n");
|
|
21038
|
+
}
|
|
21039
|
+
state.write("$$");
|
|
21040
|
+
state.closeBlock(node);
|
|
21041
|
+
state.ensureNewLine();
|
|
21042
|
+
}
|
|
21043
|
+
};
|
|
21044
|
+
MathBlockExtension = __decorateClass([
|
|
21045
|
+
extension10({
|
|
21046
|
+
defaultOptions: {}
|
|
21047
|
+
})
|
|
21048
|
+
], MathBlockExtension);
|
|
21049
|
+
|
|
21050
|
+
// src/editor/extensions/Mermaid/mermaid-extension.ts
|
|
21051
|
+
import { NodeExtension as NodeExtension9, extension as extension11, isElementDomNode as isElementDomNode3, nodeInputRule as nodeInputRule8 } from "@remirror/core";
|
|
21052
|
+
import { TextSelection as TextSelection10 } from "@remirror/pm/state";
|
|
21053
|
+
|
|
21054
|
+
// src/editor/utils/eventbus.ts
|
|
21055
|
+
import EventBus from "js-event-bus";
|
|
21056
|
+
var eventBus = new EventBus();
|
|
21057
|
+
|
|
21058
|
+
// src/editor/extensions/Mermaid/mermaid-view.ts
|
|
21059
|
+
import { Compartment as Compartment3 } from "@codemirror/state";
|
|
21060
|
+
import mermaid from "mermaid";
|
|
21061
|
+
var renderCount = { count: 0 };
|
|
21062
|
+
var MermaidNodeView = class {
|
|
21063
|
+
constructor(node, view, getPos, options) {
|
|
21064
|
+
this._htmlSrcElt = null;
|
|
21065
|
+
this.destroying = false;
|
|
21066
|
+
this.renderViewId = null;
|
|
21067
|
+
this.ignoreMutation = () => true;
|
|
21068
|
+
this.handleMouseEnter = () => {
|
|
21069
|
+
this.dom.classList.add("node-enter");
|
|
21070
|
+
};
|
|
21071
|
+
this.handleMouseLeave = () => {
|
|
21072
|
+
this.dom.classList.remove("node-enter");
|
|
20147
21073
|
};
|
|
20148
21074
|
// == Rendering ===================================== //
|
|
20149
21075
|
this.changeTheme = () => {
|
|
@@ -20153,6 +21079,7 @@ var MermaidNodeView = class {
|
|
|
20153
21079
|
this._outerView = view;
|
|
20154
21080
|
this._getPos = getPos;
|
|
20155
21081
|
this.schema = node.type.schema;
|
|
21082
|
+
this.options = options;
|
|
20156
21083
|
this.dom = document.createElement("div");
|
|
20157
21084
|
this.dom.classList.add("mermaid-node");
|
|
20158
21085
|
this._htmlRenderElt = document.createElement("p");
|
|
@@ -20248,6 +21175,10 @@ var MermaidNodeView = class {
|
|
|
20248
21175
|
useProsemirrorHistoryKey: true,
|
|
20249
21176
|
codemirrorEditorViewConfig: {
|
|
20250
21177
|
parent: this._htmlSrcElt
|
|
21178
|
+
},
|
|
21179
|
+
copyButton: {
|
|
21180
|
+
enabled: true,
|
|
21181
|
+
customCopyFunction: this.options?.customCopyFunction
|
|
20251
21182
|
}
|
|
20252
21183
|
}
|
|
20253
21184
|
});
|
|
@@ -20295,8 +21226,7 @@ var MermaidNodeView = class {
|
|
|
20295
21226
|
};
|
|
20296
21227
|
|
|
20297
21228
|
// src/editor/extensions/Mermaid/mermaid-extension.ts
|
|
20298
|
-
|
|
20299
|
-
var MermaidBlockExtension = class extends NodeExtension7 {
|
|
21229
|
+
var MermaidBlockExtension = class extends NodeExtension9 {
|
|
20300
21230
|
get name() {
|
|
20301
21231
|
return "mermaid_node";
|
|
20302
21232
|
}
|
|
@@ -20326,17 +21256,17 @@ var MermaidBlockExtension = class extends NodeExtension7 {
|
|
|
20326
21256
|
}
|
|
20327
21257
|
createNodeViews() {
|
|
20328
21258
|
return (node, view, getPos) => {
|
|
20329
|
-
return new MermaidNodeView(node, view, getPos);
|
|
21259
|
+
return new MermaidNodeView(node, view, getPos, this.options);
|
|
20330
21260
|
};
|
|
20331
21261
|
}
|
|
20332
21262
|
createInputRules() {
|
|
20333
21263
|
const rules = [
|
|
20334
|
-
|
|
21264
|
+
nodeInputRule8({
|
|
20335
21265
|
regexp: /^```mermaid$/,
|
|
20336
21266
|
type: this.type,
|
|
20337
21267
|
beforeDispatch: ({ tr, start, match }) => {
|
|
20338
21268
|
const $pos = tr.doc.resolve(start);
|
|
20339
|
-
tr.setSelection(
|
|
21269
|
+
tr.setSelection(TextSelection10.near($pos));
|
|
20340
21270
|
}
|
|
20341
21271
|
})
|
|
20342
21272
|
];
|
|
@@ -20369,6 +21299,16 @@ var MermaidBlockExtension = class extends NodeExtension7 {
|
|
|
20369
21299
|
state.ensureNewLine();
|
|
20370
21300
|
}
|
|
20371
21301
|
};
|
|
21302
|
+
MermaidBlockExtension = __decorateClass([
|
|
21303
|
+
extension11({
|
|
21304
|
+
defaultOptions: {
|
|
21305
|
+
customCopyFunction: void 0
|
|
21306
|
+
},
|
|
21307
|
+
staticKeys: [],
|
|
21308
|
+
handlerKeys: [],
|
|
21309
|
+
customHandlerKeys: []
|
|
21310
|
+
})
|
|
21311
|
+
], MermaidBlockExtension);
|
|
20372
21312
|
|
|
20373
21313
|
// src/editor/extensions/Paragraph/paragraph-extension.ts
|
|
20374
21314
|
import { ParagraphExtension } from "remirror/extensions";
|
|
@@ -20394,8 +21334,8 @@ var LineParagraphExtension = class extends ParagraphExtension {
|
|
|
20394
21334
|
};
|
|
20395
21335
|
|
|
20396
21336
|
// src/editor/extensions/Placeholder/index.ts
|
|
20397
|
-
import { extension as
|
|
20398
|
-
import { Decoration as
|
|
21337
|
+
import { extension as extension12, ManagerPhase, PlainExtension as PlainExtension6 } from "@remirror/core";
|
|
21338
|
+
import { Decoration as Decoration7, DecorationSet as DecorationSet4 } from "@remirror/pm/view";
|
|
20399
21339
|
import { ExtensionPlaceholderTheme } from "@remirror/theme";
|
|
20400
21340
|
var PlaceholderExtension = class extends PlainExtension6 {
|
|
20401
21341
|
get name() {
|
|
@@ -20419,7 +21359,7 @@ var PlaceholderExtension = class extends PlainExtension6 {
|
|
|
20419
21359
|
}
|
|
20420
21360
|
};
|
|
20421
21361
|
PlaceholderExtension = __decorateClass([
|
|
20422
|
-
|
|
21362
|
+
extension12({
|
|
20423
21363
|
defaultOptions: {
|
|
20424
21364
|
emptyNodeClass: ExtensionPlaceholderTheme.IS_EMPTY,
|
|
20425
21365
|
placeholder: ""
|
|
@@ -20435,7 +21375,7 @@ function createDecorationSet(props) {
|
|
|
20435
21375
|
const decorations = [];
|
|
20436
21376
|
state.doc.descendants((node, pos) => {
|
|
20437
21377
|
if (node.type.name === "paragraph" && node.content.size === 0 && placeholder && state.selection.from - 1 === pos) {
|
|
20438
|
-
const placeholderDecoration =
|
|
21378
|
+
const placeholderDecoration = Decoration7.node(pos, pos + node.nodeSize, {
|
|
20439
21379
|
class: emptyNodeClass,
|
|
20440
21380
|
"data-placeholder": placeholder
|
|
20441
21381
|
});
|
|
@@ -20446,7 +21386,7 @@ function createDecorationSet(props) {
|
|
|
20446
21386
|
}
|
|
20447
21387
|
|
|
20448
21388
|
// src/editor/extensions/Shortcuts/shortcuts-extension.ts
|
|
20449
|
-
import { extension as
|
|
21389
|
+
import { extension as extension13, PlainExtension as PlainExtension7 } from "@remirror/core";
|
|
20450
21390
|
|
|
20451
21391
|
// src/editor/extensions/Shortcuts/configs/shortcuts.ts
|
|
20452
21392
|
import pkg2 from "lodash";
|
|
@@ -20502,7 +21442,7 @@ var ShortcutManager = class _ShortcutManager {
|
|
|
20502
21442
|
};
|
|
20503
21443
|
|
|
20504
21444
|
// src/editor/extensions/Shortcuts/shortcuts-extension.ts
|
|
20505
|
-
import { keymap as
|
|
21445
|
+
import { keymap as keymap6 } from "@remirror/pm/keymap";
|
|
20506
21446
|
var ShortcutsExtension = class extends PlainExtension7 {
|
|
20507
21447
|
get name() {
|
|
20508
21448
|
return "shortcuts";
|
|
@@ -20530,13 +21470,13 @@ var ShortcutsExtension = class extends PlainExtension7 {
|
|
|
20530
21470
|
disableAllBuildInShortcuts: this.options.disableAllBuildInShortcuts
|
|
20531
21471
|
});
|
|
20532
21472
|
const newState = view.state.reconfigure({
|
|
20533
|
-
plugins: [...view.state.plugins,
|
|
21473
|
+
plugins: [...view.state.plugins, keymap6(keyBinds)]
|
|
20534
21474
|
});
|
|
20535
21475
|
view.updateState(newState);
|
|
20536
21476
|
}
|
|
20537
21477
|
};
|
|
20538
21478
|
ShortcutsExtension = __decorateClass([
|
|
20539
|
-
|
|
21479
|
+
extension13({
|
|
20540
21480
|
defaultOptions: {
|
|
20541
21481
|
shortcuts: void 0,
|
|
20542
21482
|
disableAllBuildInShortcuts: false
|
|
@@ -20549,6 +21489,9 @@ ShortcutsExtension = __decorateClass([
|
|
|
20549
21489
|
|
|
20550
21490
|
// src/editor/extensions/SlashMenu/utils.ts
|
|
20551
21491
|
var dispatchWithMeta = (view, key2, meta) => view.dispatch(view.state.tr.setMeta(key2, meta));
|
|
21492
|
+
var isSlashKey = (event) => {
|
|
21493
|
+
return event.key === "/" || event.code === "Slash";
|
|
21494
|
+
};
|
|
20552
21495
|
var defaultIgnoredKeys = [
|
|
20553
21496
|
"Unidentified",
|
|
20554
21497
|
"Alt",
|
|
@@ -20675,7 +21618,7 @@ var defaultIgnoredKeys = [
|
|
|
20675
21618
|
];
|
|
20676
21619
|
|
|
20677
21620
|
// src/editor/extensions/SlashMenu/slashmenu-extension.ts
|
|
20678
|
-
import { extension as
|
|
21621
|
+
import { extension as extension14, PlainExtension as PlainExtension8 } from "remirror";
|
|
20679
21622
|
|
|
20680
21623
|
// src/editor/extensions/SlashMenu/case.ts
|
|
20681
21624
|
var defaultConditions = (openInSelection = false) => {
|
|
@@ -20695,9 +21638,9 @@ var defaultConditions = (openInSelection = false) => {
|
|
|
20695
21638
|
);
|
|
20696
21639
|
const inEmptyPar = inParagraph && parentNode?.textContent === prevCharacter;
|
|
20697
21640
|
const spaceBeforePos = prevCharacter === "\u200A" || prevCharacter === "" || prevCharacter === " ";
|
|
20698
|
-
return !state.open && event
|
|
21641
|
+
return !state.open && isSlashKey(event) && inParagraph && (inEmptyPar || spaceBeforePos || editorState.selection.from !== editorState.selection.to && openInSelection);
|
|
20699
21642
|
},
|
|
20700
|
-
shouldClose: (state, event) => state.open && (event
|
|
21643
|
+
shouldClose: (state, event) => state.open && (isSlashKey(event) || event.key === "Escape" || event.key === "Backspace") && state.filter.length === 0
|
|
20701
21644
|
};
|
|
20702
21645
|
};
|
|
20703
21646
|
var getCase = (state, event, view, ignoredKeys, customConditions, shouldOpenInSelection) => {
|
|
@@ -20779,7 +21722,7 @@ var SlashMenuExtension = class extends PlainExtension8 {
|
|
|
20779
21722
|
dispatchWithMeta(view, this.spec.key, {
|
|
20780
21723
|
type: "close" /* close */
|
|
20781
21724
|
});
|
|
20782
|
-
} else if (event
|
|
21725
|
+
} else if (isSlashKey(event)) {
|
|
20783
21726
|
view.dispatch(
|
|
20784
21727
|
editorState.tr.insertText("/").setMeta(this.spec.key, {
|
|
20785
21728
|
type: "close" /* close */
|
|
@@ -20831,7 +21774,7 @@ var SlashMenuExtension = class extends PlainExtension8 {
|
|
|
20831
21774
|
}
|
|
20832
21775
|
};
|
|
20833
21776
|
SlashMenuExtension = __decorateClass([
|
|
20834
|
-
|
|
21777
|
+
extension14({
|
|
20835
21778
|
defaultOptions: {}
|
|
20836
21779
|
})
|
|
20837
21780
|
], SlashMenuExtension);
|
|
@@ -20864,7 +21807,7 @@ var LineTextExtension = class extends TextExtension {
|
|
|
20864
21807
|
};
|
|
20865
21808
|
|
|
20866
21809
|
// src/editor/extensions/Transformer/transformer-extension.ts
|
|
20867
|
-
import { PlainExtension as PlainExtension9, extension as
|
|
21810
|
+
import { PlainExtension as PlainExtension9, extension as extension15 } from "remirror";
|
|
20868
21811
|
var TransformerExtension = class extends PlainExtension9 {
|
|
20869
21812
|
get name() {
|
|
20870
21813
|
return "transformer";
|
|
@@ -20897,7 +21840,7 @@ var TransformerExtension = class extends PlainExtension9 {
|
|
|
20897
21840
|
}
|
|
20898
21841
|
};
|
|
20899
21842
|
TransformerExtension = __decorateClass([
|
|
20900
|
-
|
|
21843
|
+
extension15({
|
|
20901
21844
|
defaultOptions: {}
|
|
20902
21845
|
})
|
|
20903
21846
|
], TransformerExtension);
|
|
@@ -20931,7 +21874,14 @@ function extensions(options) {
|
|
|
20931
21874
|
new LineListExtension(),
|
|
20932
21875
|
new LineCodeMirrorExtension({
|
|
20933
21876
|
extensions: [minimalSetup],
|
|
20934
|
-
useProsemirrorHistoryKey: true
|
|
21877
|
+
useProsemirrorHistoryKey: true,
|
|
21878
|
+
customCopyFunction: options.customCopyFunction
|
|
21879
|
+
}),
|
|
21880
|
+
new LineHtmlBlockExtension({
|
|
21881
|
+
customCopyFunction: options.customCopyFunction
|
|
21882
|
+
}),
|
|
21883
|
+
new MermaidBlockExtension({
|
|
21884
|
+
customCopyFunction: options.customCopyFunction
|
|
20935
21885
|
}),
|
|
20936
21886
|
new LineTableExtension({ resizable: false }),
|
|
20937
21887
|
new LineTableRowExtension(),
|
|
@@ -20941,7 +21891,6 @@ function extensions(options) {
|
|
|
20941
21891
|
decoration: { style: "background-color: yellow; color: black" },
|
|
20942
21892
|
activeDecoration: { style: "background-color: orange; color: black" }
|
|
20943
21893
|
}),
|
|
20944
|
-
new LineHtmlBlockExtension(),
|
|
20945
21894
|
new HtmlInlineNodeExtension({
|
|
20946
21895
|
handleViewImgSrcUrl
|
|
20947
21896
|
}),
|
|
@@ -20951,7 +21900,8 @@ function extensions(options) {
|
|
|
20951
21900
|
new SlashMenuExtension(),
|
|
20952
21901
|
new LineInlineMarkExtension(),
|
|
20953
21902
|
new LineInlineDecorationExtension(),
|
|
20954
|
-
new
|
|
21903
|
+
new MathBlockExtension({}),
|
|
21904
|
+
new MathInlineExtension({}),
|
|
20955
21905
|
new ShortcutsExtension({
|
|
20956
21906
|
disableAllBuildInShortcuts: options.disableAllBuildInShortcuts
|
|
20957
21907
|
}),
|
|
@@ -21121,9 +22071,6 @@ var MarkdownSerializer = class {
|
|
|
21121
22071
|
}
|
|
21122
22072
|
};
|
|
21123
22073
|
|
|
21124
|
-
// src/editor/extensions/CodeMirror/codemirror-extension.ts
|
|
21125
|
-
import { Decoration as Decoration6, DecorationSet as DecorationSet5 } from "@remirror/pm/view";
|
|
21126
|
-
|
|
21127
22074
|
// src/editor/extensions/CodeMirror/codemirror-lang-menu.tsx
|
|
21128
22075
|
import { languages as languages2 } from "@codemirror/language-data";
|
|
21129
22076
|
import Fuse from "fuse.js";
|
|
@@ -21943,21 +22890,6 @@ var createCodeMirrorMenuDecorations = (found2) => {
|
|
|
21943
22890
|
};
|
|
21944
22891
|
var codemirror_lang_menu_default = createCodeMirrorMenuDecorations;
|
|
21945
22892
|
|
|
21946
|
-
// src/editor/extensions/CodeMirror/codemirror-extension.ts
|
|
21947
|
-
import {
|
|
21948
|
-
command as command4,
|
|
21949
|
-
extension as extension12,
|
|
21950
|
-
findParentNodeOfType as findParentNodeOfType5,
|
|
21951
|
-
isElementDomNode as isElementDomNode4,
|
|
21952
|
-
isEqual,
|
|
21953
|
-
isTextSelection as isTextSelection3,
|
|
21954
|
-
keyBinding,
|
|
21955
|
-
NodeExtension as NodeExtension8,
|
|
21956
|
-
nodeInputRule as nodeInputRule7,
|
|
21957
|
-
setBlockType as setBlockType3
|
|
21958
|
-
} from "@remirror/core";
|
|
21959
|
-
import { TextSelection as TextSelection9 } from "@remirror/pm/state";
|
|
21960
|
-
|
|
21961
22893
|
// src/editor/extensions/CodeMirror/codemirror-node-view.ts
|
|
21962
22894
|
var CodeMirror6NodeView = class {
|
|
21963
22895
|
constructor({
|
|
@@ -22012,9 +22944,8 @@ var CodeMirror6NodeView = class {
|
|
|
22012
22944
|
};
|
|
22013
22945
|
|
|
22014
22946
|
// src/editor/extensions/CodeMirror/codemirror-extension.ts
|
|
22015
|
-
import { languages as languages3 } from "@codemirror/language-data";
|
|
22016
22947
|
var fakeIndentedLanguage = "indent-code";
|
|
22017
|
-
var LineCodeMirrorExtension = class extends
|
|
22948
|
+
var LineCodeMirrorExtension = class extends NodeExtension10 {
|
|
22018
22949
|
get name() {
|
|
22019
22950
|
return "codeMirror";
|
|
22020
22951
|
}
|
|
@@ -22053,7 +22984,11 @@ var LineCodeMirrorExtension = class extends NodeExtension8 {
|
|
|
22053
22984
|
extensions: this.options.extensions,
|
|
22054
22985
|
toggleName: this.options.toggleName,
|
|
22055
22986
|
options: {
|
|
22056
|
-
useProsemirrorHistoryKey: this.options.useProsemirrorHistoryKey
|
|
22987
|
+
useProsemirrorHistoryKey: this.options.useProsemirrorHistoryKey,
|
|
22988
|
+
copyButton: {
|
|
22989
|
+
enabled: this.options.showCopyButton,
|
|
22990
|
+
customCopyFunction: this.options.customCopyFunction
|
|
22991
|
+
}
|
|
22057
22992
|
},
|
|
22058
22993
|
onCodemirrorViewLoad: this.options.onCodemirrorViewLoad
|
|
22059
22994
|
});
|
|
@@ -22079,12 +23014,12 @@ var LineCodeMirrorExtension = class extends NodeExtension8 {
|
|
|
22079
23014
|
return { language };
|
|
22080
23015
|
};
|
|
22081
23016
|
return [
|
|
22082
|
-
|
|
23017
|
+
nodeInputRule9({
|
|
22083
23018
|
regexp,
|
|
22084
23019
|
type: this.type,
|
|
22085
23020
|
beforeDispatch: ({ tr, start }) => {
|
|
22086
23021
|
const $pos = tr.doc.resolve(start);
|
|
22087
|
-
tr.setSelection(
|
|
23022
|
+
tr.setSelection(TextSelection11.near($pos));
|
|
22088
23023
|
},
|
|
22089
23024
|
getAttributes
|
|
22090
23025
|
})
|
|
@@ -22113,7 +23048,7 @@ var LineCodeMirrorExtension = class extends NodeExtension8 {
|
|
|
22113
23048
|
const pos = tr.selection.$from.before();
|
|
22114
23049
|
const end = pos + nodeSize2 + 1;
|
|
22115
23050
|
tr.replaceWith(pos, end, this.type.create({ language }));
|
|
22116
|
-
tr.setSelection(
|
|
23051
|
+
tr.setSelection(TextSelection11.near(tr.doc.resolve(pos + 1)));
|
|
22117
23052
|
if (dispatch) {
|
|
22118
23053
|
dispatch(tr);
|
|
22119
23054
|
}
|
|
@@ -22188,7 +23123,7 @@ var LineCodeMirrorExtension = class extends NodeExtension8 {
|
|
|
22188
23123
|
return DecorationSet5.empty;
|
|
22189
23124
|
}
|
|
22190
23125
|
const { create, destroy } = codemirror_lang_menu_default(found2);
|
|
22191
|
-
const deco =
|
|
23126
|
+
const deco = Decoration8.widget(found2.pos, create, {
|
|
22192
23127
|
ignoreSelection: true,
|
|
22193
23128
|
stopEvent: () => true,
|
|
22194
23129
|
key: "language-menu",
|
|
@@ -22207,14 +23142,15 @@ __decorateClass([
|
|
|
22207
23142
|
command4()
|
|
22208
23143
|
], LineCodeMirrorExtension.prototype, "updateCodeMirror", 1);
|
|
22209
23144
|
LineCodeMirrorExtension = __decorateClass([
|
|
22210
|
-
|
|
23145
|
+
extension16({
|
|
22211
23146
|
defaultOptions: {
|
|
22212
23147
|
hideDecoration: false,
|
|
22213
23148
|
extensions: null,
|
|
22214
23149
|
toggleName: "paragraph",
|
|
22215
23150
|
useProsemirrorHistoryKey: false,
|
|
22216
23151
|
onCodemirrorViewLoad: () => {
|
|
22217
|
-
}
|
|
23152
|
+
},
|
|
23153
|
+
showCopyButton: true
|
|
22218
23154
|
},
|
|
22219
23155
|
staticKeys: [],
|
|
22220
23156
|
handlerKeys: [],
|
|
@@ -22396,7 +23332,8 @@ import { Input as Input2, Space as Space2 } from "zens";
|
|
|
22396
23332
|
import Color from "color";
|
|
22397
23333
|
var darken = (color, amount) => Color(color).darken(amount).string();
|
|
22398
23334
|
|
|
22399
|
-
// src/editor/utils/getOS.
|
|
23335
|
+
// src/editor/utils/getOS.tsx
|
|
23336
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
22400
23337
|
function getOS() {
|
|
22401
23338
|
const userAgent = window.navigator.userAgent;
|
|
22402
23339
|
const platform2 = window.navigator.platform;
|
|
@@ -22408,15 +23345,19 @@ function getOS() {
|
|
|
22408
23345
|
return "Unknown";
|
|
22409
23346
|
}
|
|
22410
23347
|
}
|
|
22411
|
-
function
|
|
23348
|
+
function getModKeyIconName() {
|
|
23349
|
+
const os = getOS();
|
|
23350
|
+
return os === "macOS" ? /* @__PURE__ */ jsx14("i", { className: "ri-command-line" }) : "Ctrl";
|
|
23351
|
+
}
|
|
23352
|
+
function getModEventKey() {
|
|
22412
23353
|
const os = getOS();
|
|
22413
|
-
return os === "macOS" ? "
|
|
23354
|
+
return os === "macOS" ? "metaKey" : "ctrlKey";
|
|
22414
23355
|
}
|
|
22415
23356
|
|
|
22416
23357
|
// src/editor/toolbar/SlashMenu/TablePanel.tsx
|
|
22417
23358
|
import { forwardRef, useState as useState5, useImperativeHandle, memo as memo4 } from "react";
|
|
22418
23359
|
import styled7 from "styled-components";
|
|
22419
|
-
import { jsx as
|
|
23360
|
+
import { jsx as jsx15, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
22420
23361
|
var TablePanelCell = styled7.div.attrs((p) => p)`
|
|
22421
23362
|
border: 1px solid ${(props) => props.theme.borderColor};
|
|
22422
23363
|
margin-right: 1px;
|
|
@@ -22479,9 +23420,9 @@ var TablePanel = memo4(
|
|
|
22479
23420
|
columnsCount
|
|
22480
23421
|
] }),
|
|
22481
23422
|
Array.from({ length: displayRows }).map((_, i) => {
|
|
22482
|
-
return /* @__PURE__ */
|
|
23423
|
+
return /* @__PURE__ */ jsx15("div", { style: { display: "flex" }, children: Array.from({ length: displayCols }).map((_2, j) => {
|
|
22483
23424
|
const inScope = i < rowsCount && j < columnsCount;
|
|
22484
|
-
return /* @__PURE__ */
|
|
23425
|
+
return /* @__PURE__ */ jsx15(
|
|
22485
23426
|
TablePanelCell,
|
|
22486
23427
|
{
|
|
22487
23428
|
inScope,
|
|
@@ -22504,7 +23445,7 @@ var TablePanel = memo4(
|
|
|
22504
23445
|
var TablePanel_default = TablePanel;
|
|
22505
23446
|
|
|
22506
23447
|
// src/editor/toolbar/SlashMenu/SlashMenuRoot.tsx
|
|
22507
|
-
import { Fragment as Fragment5, jsx as
|
|
23448
|
+
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
22508
23449
|
var SlashMenuRoot = memo5(
|
|
22509
23450
|
({ rootRef, commands, closeMenu }) => {
|
|
22510
23451
|
const componentRefMap = useRef5({});
|
|
@@ -22536,7 +23477,7 @@ var SlashMenuRoot = memo5(
|
|
|
22536
23477
|
},
|
|
22537
23478
|
Renderer: {
|
|
22538
23479
|
id: "table",
|
|
22539
|
-
Component: /* @__PURE__ */
|
|
23480
|
+
Component: /* @__PURE__ */ jsx16(
|
|
22540
23481
|
TablePanel_default,
|
|
22541
23482
|
{
|
|
22542
23483
|
ref: (el) => componentRefMap.current.table = el,
|
|
@@ -22678,7 +23619,7 @@ var SlashMenuRoot = memo5(
|
|
|
22678
23619
|
if (event.key === "Escape") {
|
|
22679
23620
|
return closeMenu();
|
|
22680
23621
|
}
|
|
22681
|
-
if (searchText && event
|
|
23622
|
+
if (searchText && event[getModEventKey()] === false) {
|
|
22682
23623
|
return;
|
|
22683
23624
|
}
|
|
22684
23625
|
if (activeItemId) {
|
|
@@ -22732,7 +23673,7 @@ var SlashMenuRoot = memo5(
|
|
|
22732
23673
|
searchText
|
|
22733
23674
|
]);
|
|
22734
23675
|
return /* @__PURE__ */ jsxs6("div", { ref: rootRef, style: { display: "flex", flexDirection: "column" }, children: [
|
|
22735
|
-
/* @__PURE__ */
|
|
23676
|
+
/* @__PURE__ */ jsx16(SearchContainer, { children: /* @__PURE__ */ jsx16(
|
|
22736
23677
|
Input2,
|
|
22737
23678
|
{
|
|
22738
23679
|
type: "text",
|
|
@@ -22749,12 +23690,12 @@ var SlashMenuRoot = memo5(
|
|
|
22749
23690
|
if (searchText === "") {
|
|
22750
23691
|
e.preventDefault();
|
|
22751
23692
|
e.stopPropagation();
|
|
22752
|
-
closeMenu();
|
|
23693
|
+
closeMenu?.();
|
|
22753
23694
|
}
|
|
22754
|
-
} else if (e
|
|
23695
|
+
} else if (isSlashKey(e) && (searchText === "" || searchText === "/")) {
|
|
22755
23696
|
e.preventDefault();
|
|
22756
23697
|
e.stopPropagation();
|
|
22757
|
-
closeMenu({
|
|
23698
|
+
closeMenu?.({
|
|
22758
23699
|
insertSlash: true
|
|
22759
23700
|
});
|
|
22760
23701
|
}
|
|
@@ -22765,13 +23706,13 @@ var SlashMenuRoot = memo5(
|
|
|
22765
23706
|
/* @__PURE__ */ jsxs6(MenuPanel, { active: true, location: "left", children: [
|
|
22766
23707
|
filteredMenuItems.map((item) => {
|
|
22767
23708
|
const selected = item.id === activeGroupId;
|
|
22768
|
-
return /* @__PURE__ */
|
|
23709
|
+
return /* @__PURE__ */ jsx16(
|
|
22769
23710
|
MenuItem,
|
|
22770
23711
|
{
|
|
22771
23712
|
onClick: () => setActiveGroupId(item.id),
|
|
22772
23713
|
selected,
|
|
22773
23714
|
children: /* @__PURE__ */ jsxs6(Space2, { size: 4, children: [
|
|
22774
|
-
/* @__PURE__ */
|
|
23715
|
+
/* @__PURE__ */ jsx16("i", { className: item.iconName }),
|
|
22775
23716
|
" ",
|
|
22776
23717
|
item.title
|
|
22777
23718
|
] })
|
|
@@ -22779,11 +23720,11 @@ var SlashMenuRoot = memo5(
|
|
|
22779
23720
|
item.id
|
|
22780
23721
|
);
|
|
22781
23722
|
}),
|
|
22782
|
-
filteredMenuItems.length === 0 && /* @__PURE__ */
|
|
23723
|
+
filteredMenuItems.length === 0 && /* @__PURE__ */ jsx16("div", { children: /* @__PURE__ */ jsx16("span", { children: t18("slashMenu.noResults") }) })
|
|
22783
23724
|
] }),
|
|
22784
|
-
currentMenuItem?.children || currentMenuItem?.Renderer?.Component ? /* @__PURE__ */
|
|
23725
|
+
currentMenuItem?.children || currentMenuItem?.Renderer?.Component ? /* @__PURE__ */ jsx16(MenuPanel, { active: !!activeItemId, location: "right", children: currentMenuItem?.Renderer ? currentMenuItem.Renderer.Component : currentMenuItem?.children?.map((item) => {
|
|
22785
23726
|
const selected = item.id === activeItemId;
|
|
22786
|
-
return /* @__PURE__ */
|
|
23727
|
+
return /* @__PURE__ */ jsx16(
|
|
22787
23728
|
MenuItem,
|
|
22788
23729
|
{
|
|
22789
23730
|
selected,
|
|
@@ -22801,10 +23742,10 @@ var SlashMenuRoot = memo5(
|
|
|
22801
23742
|
/* @__PURE__ */ jsxs6(SlashMenuFooter, { children: [
|
|
22802
23743
|
/* @__PURE__ */ jsxs6(Shortcut, { children: [
|
|
22803
23744
|
searchText ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
22804
|
-
/* @__PURE__ */
|
|
22805
|
-
/* @__PURE__ */
|
|
23745
|
+
/* @__PURE__ */ jsx16("kbd", { children: getModKeyIconName() }),
|
|
23746
|
+
/* @__PURE__ */ jsx16("span", { children: " + " })
|
|
22806
23747
|
] }) : null,
|
|
22807
|
-
/* @__PURE__ */
|
|
23748
|
+
/* @__PURE__ */ jsx16("kbd", { "aria-label": "Up Arrow", children: /* @__PURE__ */ jsxs6(
|
|
22808
23749
|
"svg",
|
|
22809
23750
|
{
|
|
22810
23751
|
width: "14",
|
|
@@ -22812,16 +23753,16 @@ var SlashMenuRoot = memo5(
|
|
|
22812
23753
|
viewBox: "0 0 24 24",
|
|
22813
23754
|
fill: "none",
|
|
22814
23755
|
stroke: "currentColor",
|
|
22815
|
-
|
|
22816
|
-
|
|
22817
|
-
|
|
23756
|
+
strokeWidth: "2",
|
|
23757
|
+
strokeLinecap: "round",
|
|
23758
|
+
strokeLinejoin: "round",
|
|
22818
23759
|
children: [
|
|
22819
|
-
/* @__PURE__ */
|
|
22820
|
-
/* @__PURE__ */
|
|
23760
|
+
/* @__PURE__ */ jsx16("path", { d: "m5 12 7-7 7 7" }),
|
|
23761
|
+
/* @__PURE__ */ jsx16("path", { d: "M12 19V5" })
|
|
22821
23762
|
]
|
|
22822
23763
|
}
|
|
22823
23764
|
) }),
|
|
22824
|
-
/* @__PURE__ */
|
|
23765
|
+
/* @__PURE__ */ jsx16("kbd", { "aria-label": "Down Arrow", children: /* @__PURE__ */ jsxs6(
|
|
22825
23766
|
"svg",
|
|
22826
23767
|
{
|
|
22827
23768
|
width: "14",
|
|
@@ -22829,17 +23770,17 @@ var SlashMenuRoot = memo5(
|
|
|
22829
23770
|
viewBox: "0 0 24 24",
|
|
22830
23771
|
fill: "none",
|
|
22831
23772
|
stroke: "currentColor",
|
|
22832
|
-
|
|
22833
|
-
|
|
22834
|
-
|
|
23773
|
+
strokeWidth: "2",
|
|
23774
|
+
strokeLinecap: "round",
|
|
23775
|
+
strokeLinejoin: "round",
|
|
22835
23776
|
children: [
|
|
22836
|
-
/* @__PURE__ */
|
|
22837
|
-
/* @__PURE__ */
|
|
23777
|
+
/* @__PURE__ */ jsx16("path", { d: "M12 5v14" }),
|
|
23778
|
+
/* @__PURE__ */ jsx16("path", { d: "m19 12-7 7-7-7" })
|
|
22838
23779
|
]
|
|
22839
23780
|
}
|
|
22840
23781
|
) }),
|
|
22841
23782
|
currentMenuItem?.children || currentMenuItem?.Renderer ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
22842
|
-
/* @__PURE__ */
|
|
23783
|
+
/* @__PURE__ */ jsx16("kbd", { "aria-label": "Left Arrow", children: /* @__PURE__ */ jsxs6(
|
|
22843
23784
|
"svg",
|
|
22844
23785
|
{
|
|
22845
23786
|
width: "14",
|
|
@@ -22847,16 +23788,16 @@ var SlashMenuRoot = memo5(
|
|
|
22847
23788
|
viewBox: "0 0 24 24",
|
|
22848
23789
|
fill: "none",
|
|
22849
23790
|
stroke: "currentColor",
|
|
22850
|
-
|
|
22851
|
-
|
|
22852
|
-
|
|
23791
|
+
strokeWidth: "2",
|
|
23792
|
+
strokeLinecap: "round",
|
|
23793
|
+
strokeLinejoin: "round",
|
|
22853
23794
|
children: [
|
|
22854
|
-
/* @__PURE__ */
|
|
22855
|
-
/* @__PURE__ */
|
|
23795
|
+
/* @__PURE__ */ jsx16("path", { d: "m12 19-7-7 7-7" }),
|
|
23796
|
+
/* @__PURE__ */ jsx16("path", { d: "M19 12H5" })
|
|
22856
23797
|
]
|
|
22857
23798
|
}
|
|
22858
23799
|
) }),
|
|
22859
|
-
/* @__PURE__ */
|
|
23800
|
+
/* @__PURE__ */ jsx16("kbd", { "aria-label": "Right Arrow", children: /* @__PURE__ */ jsxs6(
|
|
22860
23801
|
"svg",
|
|
22861
23802
|
{
|
|
22862
23803
|
width: "14",
|
|
@@ -22864,12 +23805,12 @@ var SlashMenuRoot = memo5(
|
|
|
22864
23805
|
viewBox: "0 0 24 24",
|
|
22865
23806
|
fill: "none",
|
|
22866
23807
|
stroke: "currentColor",
|
|
22867
|
-
|
|
22868
|
-
|
|
22869
|
-
|
|
23808
|
+
strokeWidth: "2",
|
|
23809
|
+
strokeLinecap: "round",
|
|
23810
|
+
strokeLinejoin: "round",
|
|
22870
23811
|
children: [
|
|
22871
|
-
/* @__PURE__ */
|
|
22872
|
-
/* @__PURE__ */
|
|
23812
|
+
/* @__PURE__ */ jsx16("path", { d: "M5 12h14" }),
|
|
23813
|
+
/* @__PURE__ */ jsx16("path", { d: "m12 5 7 7-7 7" })
|
|
22873
23814
|
]
|
|
22874
23815
|
}
|
|
22875
23816
|
) })
|
|
@@ -22878,10 +23819,10 @@ var SlashMenuRoot = memo5(
|
|
|
22878
23819
|
] }),
|
|
22879
23820
|
/* @__PURE__ */ jsxs6(Shortcut, { children: [
|
|
22880
23821
|
searchText ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
22881
|
-
/* @__PURE__ */
|
|
22882
|
-
/* @__PURE__ */
|
|
23822
|
+
/* @__PURE__ */ jsx16("kbd", { children: getModKeyIconName() }),
|
|
23823
|
+
/* @__PURE__ */ jsx16("span", { children: " + " })
|
|
22883
23824
|
] }) : null,
|
|
22884
|
-
/* @__PURE__ */
|
|
23825
|
+
/* @__PURE__ */ jsx16("kbd", { "aria-label": "Enter", children: /* @__PURE__ */ jsxs6(
|
|
22885
23826
|
"svg",
|
|
22886
23827
|
{
|
|
22887
23828
|
width: "14",
|
|
@@ -22889,12 +23830,12 @@ var SlashMenuRoot = memo5(
|
|
|
22889
23830
|
viewBox: "0 0 24 24",
|
|
22890
23831
|
fill: "none",
|
|
22891
23832
|
stroke: "currentColor",
|
|
22892
|
-
|
|
22893
|
-
|
|
22894
|
-
|
|
23833
|
+
strokeWidth: "2",
|
|
23834
|
+
strokeLinecap: "round",
|
|
23835
|
+
strokeLinejoin: "round",
|
|
22895
23836
|
children: [
|
|
22896
|
-
/* @__PURE__ */
|
|
22897
|
-
/* @__PURE__ */
|
|
23837
|
+
/* @__PURE__ */ jsx16("polyline", { points: "9 10 4 15 9 20" }),
|
|
23838
|
+
/* @__PURE__ */ jsx16("path", { d: "M20 4v7a4 4 0 0 1-4 4H4" })
|
|
22898
23839
|
]
|
|
22899
23840
|
}
|
|
22900
23841
|
) }),
|
|
@@ -22923,7 +23864,7 @@ var Shortcut = styled8.div`
|
|
|
22923
23864
|
display: flex;
|
|
22924
23865
|
justify-content: center;
|
|
22925
23866
|
align-items: center;
|
|
22926
|
-
font-size:
|
|
23867
|
+
font-size: 12px;
|
|
22927
23868
|
}
|
|
22928
23869
|
`;
|
|
22929
23870
|
var MenuPanel = styled8.div.attrs((p) => p)`
|
|
@@ -22975,7 +23916,7 @@ var MenuContainer = styled8.div`
|
|
|
22975
23916
|
`;
|
|
22976
23917
|
|
|
22977
23918
|
// src/editor/toolbar/SlashMenu/index.tsx
|
|
22978
|
-
import { Fragment as Fragment6, jsx as
|
|
23919
|
+
import { Fragment as Fragment6, jsx as jsx17 } from "react/jsx-runtime";
|
|
22979
23920
|
var SlashMenu = () => {
|
|
22980
23921
|
const { view: editorView, getState, commands } = useRemirrorContext3({ autoUpdate: true });
|
|
22981
23922
|
if (!editorView) {
|
|
@@ -23055,7 +23996,7 @@ var SlashMenu = () => {
|
|
|
23055
23996
|
editorView.focus();
|
|
23056
23997
|
}
|
|
23057
23998
|
}, [editorView, menuState.open, slashMenuExtension.pluginKey]);
|
|
23058
|
-
return /* @__PURE__ */
|
|
23999
|
+
return /* @__PURE__ */ jsx17(Fragment6, { children: menuState.open ? /* @__PURE__ */ jsx17(
|
|
23059
24000
|
Container2,
|
|
23060
24001
|
{
|
|
23061
24002
|
ref: setPopperElement,
|
|
@@ -23063,7 +24004,7 @@ var SlashMenu = () => {
|
|
|
23063
24004
|
...styles.popper
|
|
23064
24005
|
},
|
|
23065
24006
|
...attributes.popper,
|
|
23066
|
-
children: /* @__PURE__ */
|
|
24007
|
+
children: /* @__PURE__ */ jsx17(SlashMenuRoot, { rootRef, commands, closeMenu })
|
|
23067
24008
|
}
|
|
23068
24009
|
) : null });
|
|
23069
24010
|
};
|
|
@@ -23091,7 +24032,7 @@ import {
|
|
|
23091
24032
|
import { useCommands } from "@remirror/react";
|
|
23092
24033
|
import styled10 from "styled-components";
|
|
23093
24034
|
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
23094
|
-
import { jsx as
|
|
24035
|
+
import { jsx as jsx18, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
23095
24036
|
var Container3 = styled10.div`
|
|
23096
24037
|
position: absolute;
|
|
23097
24038
|
|
|
@@ -23160,8 +24101,8 @@ var ActiveCellMenu = (props) => {
|
|
|
23160
24101
|
setOpen(true);
|
|
23161
24102
|
},
|
|
23162
24103
|
children: [
|
|
23163
|
-
/* @__PURE__ */
|
|
23164
|
-
/* @__PURE__ */
|
|
24104
|
+
/* @__PURE__ */ jsx18("div", { ref: anchorRef, children: /* @__PURE__ */ jsx18("i", { className: "ri-equalizer-line" }) }),
|
|
24105
|
+
/* @__PURE__ */ jsx18(
|
|
23165
24106
|
Popper,
|
|
23166
24107
|
{
|
|
23167
24108
|
sx: {
|
|
@@ -23172,21 +24113,21 @@ var ActiveCellMenu = (props) => {
|
|
|
23172
24113
|
role: void 0,
|
|
23173
24114
|
transition: true,
|
|
23174
24115
|
disablePortal: true,
|
|
23175
|
-
children: ({ TransitionProps, placement }) => /* @__PURE__ */
|
|
24116
|
+
children: ({ TransitionProps, placement }) => /* @__PURE__ */ jsx18(
|
|
23176
24117
|
Grow,
|
|
23177
24118
|
{
|
|
23178
24119
|
...TransitionProps,
|
|
23179
24120
|
style: {
|
|
23180
24121
|
transformOrigin: placement === "bottom" ? "center top" : "center bottom"
|
|
23181
24122
|
},
|
|
23182
|
-
children: /* @__PURE__ */
|
|
24123
|
+
children: /* @__PURE__ */ jsx18(Paper, { children: /* @__PURE__ */ jsx18(ClickAwayListener, { onClickAway: handleClose, children: /* @__PURE__ */ jsx18(MenuList, { dense: true, autoFocusItem: true, children: options.map((option) => /* @__PURE__ */ jsx18(
|
|
23183
24124
|
MenuItem2,
|
|
23184
24125
|
{
|
|
23185
24126
|
onClick: () => {
|
|
23186
24127
|
option.handler();
|
|
23187
24128
|
setOpen(false);
|
|
23188
24129
|
},
|
|
23189
|
-
children: /* @__PURE__ */
|
|
24130
|
+
children: /* @__PURE__ */ jsx18(ListItemText, { children: t18(option.i18nKey) })
|
|
23190
24131
|
},
|
|
23191
24132
|
option.label
|
|
23192
24133
|
)) }) }) })
|
|
@@ -23205,7 +24146,7 @@ var ActiveCellMenu_default = ActiveCellMenu;
|
|
|
23205
24146
|
import { useCommands as useCommands2 } from "@remirror/react";
|
|
23206
24147
|
import styled11 from "styled-components";
|
|
23207
24148
|
import { Tooltip as Tooltip2 } from "zens";
|
|
23208
|
-
import { jsx as
|
|
24149
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
23209
24150
|
var Container4 = styled11.div`
|
|
23210
24151
|
position: absolute;
|
|
23211
24152
|
color: ${(props) => props.theme.dangerColor};
|
|
@@ -23214,7 +24155,7 @@ function TableBar(props) {
|
|
|
23214
24155
|
const { positioner } = props;
|
|
23215
24156
|
const commands = useCommands2();
|
|
23216
24157
|
const { ref, key: key2, x, y } = positioner;
|
|
23217
|
-
return /* @__PURE__ */
|
|
24158
|
+
return /* @__PURE__ */ jsx19(
|
|
23218
24159
|
Container4,
|
|
23219
24160
|
{
|
|
23220
24161
|
ref,
|
|
@@ -23229,7 +24170,7 @@ function TableBar(props) {
|
|
|
23229
24170
|
e.preventDefault();
|
|
23230
24171
|
commands.deleteTable();
|
|
23231
24172
|
},
|
|
23232
|
-
children: /* @__PURE__ */
|
|
24173
|
+
children: /* @__PURE__ */ jsx19(Tooltip2, { title: "delete", children: /* @__PURE__ */ jsx19("i", { className: "ri-delete-bin-line" }) })
|
|
23233
24174
|
},
|
|
23234
24175
|
key2
|
|
23235
24176
|
);
|
|
@@ -23319,7 +24260,7 @@ var activeCellColumnAndRowPositioner = Positioner.create({
|
|
|
23319
24260
|
});
|
|
23320
24261
|
|
|
23321
24262
|
// src/editor/toolbar/TableToolbar/index.tsx
|
|
23322
|
-
import { Fragment as Fragment7, jsx as
|
|
24263
|
+
import { Fragment as Fragment7, jsx as jsx20 } from "react/jsx-runtime";
|
|
23323
24264
|
var MultiPositionerIllustration = ({ positioner }) => {
|
|
23324
24265
|
const positioners = useMultiPositioner(positioner, []);
|
|
23325
24266
|
const { forceUpdatePositioners } = useCommands3();
|
|
@@ -23328,13 +24269,13 @@ var MultiPositionerIllustration = ({ positioner }) => {
|
|
|
23328
24269
|
}, [forceUpdatePositioners]);
|
|
23329
24270
|
if (positioners.length === 0) return null;
|
|
23330
24271
|
const positionersRender = [TableBar_default, ActiveCellMenu_default];
|
|
23331
|
-
return /* @__PURE__ */
|
|
24272
|
+
return /* @__PURE__ */ jsx20(Fragment7, { children: positioners.map((pos, i) => {
|
|
23332
24273
|
const Component = positionersRender[i];
|
|
23333
|
-
return /* @__PURE__ */
|
|
24274
|
+
return /* @__PURE__ */ jsx20(Component, { positioner: pos }, pos.key);
|
|
23334
24275
|
}) });
|
|
23335
24276
|
};
|
|
23336
24277
|
var TableToolbar = () => {
|
|
23337
|
-
return /* @__PURE__ */
|
|
24278
|
+
return /* @__PURE__ */ jsx20(Fragment7, { children: /* @__PURE__ */ jsx20(PositionerPortal, { children: /* @__PURE__ */ jsx20(MultiPositionerIllustration, { positioner: activeCellColumnAndRowPositioner }) }) });
|
|
23338
24279
|
};
|
|
23339
24280
|
var TableToolbar_default = TableToolbar;
|
|
23340
24281
|
|
|
@@ -23388,16 +24329,16 @@ var useCommandOptionValues = ({
|
|
|
23388
24329
|
|
|
23389
24330
|
// src/editor/toolbar/toolbar/command-btns/command-button-icon.tsx
|
|
23390
24331
|
import { isString as isString4 } from "@remirror/core";
|
|
23391
|
-
import { jsx as
|
|
24332
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
23392
24333
|
var CommandButtonIcon = ({ icon }) => {
|
|
23393
24334
|
if (isString4(icon)) {
|
|
23394
|
-
return /* @__PURE__ */
|
|
24335
|
+
return /* @__PURE__ */ jsx21("i", { className: icon });
|
|
23395
24336
|
}
|
|
23396
24337
|
return icon;
|
|
23397
24338
|
};
|
|
23398
24339
|
|
|
23399
24340
|
// src/editor/toolbar/toolbar/command-btns/command-button.tsx
|
|
23400
|
-
import { jsx as
|
|
24341
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
23401
24342
|
var CommandButton = ({
|
|
23402
24343
|
commandName,
|
|
23403
24344
|
active = false,
|
|
@@ -23426,7 +24367,7 @@ var CommandButton = ({
|
|
|
23426
24367
|
const labelText = ariaLabel ?? commandOptions.label ?? "";
|
|
23427
24368
|
const tooltipText = label ?? labelText;
|
|
23428
24369
|
const shortcutText = displayShortcut && commandOptions.shortcut ? ` (${commandOptions.shortcut})` : "";
|
|
23429
|
-
return /* @__PURE__ */
|
|
24370
|
+
return /* @__PURE__ */ jsx22(Tooltip3, { title: `${tooltipText}${shortcutText}`, children: /* @__PURE__ */ jsx22(
|
|
23430
24371
|
Container5,
|
|
23431
24372
|
{
|
|
23432
24373
|
"aria-label": labelText,
|
|
@@ -23434,7 +24375,7 @@ var CommandButton = ({
|
|
|
23434
24375
|
...rest,
|
|
23435
24376
|
value: commandName,
|
|
23436
24377
|
onClick: handleChange,
|
|
23437
|
-
children: /* @__PURE__ */
|
|
24378
|
+
children: /* @__PURE__ */ jsx22(CommandButtonIcon, { icon: icon ?? fallbackIcon })
|
|
23438
24379
|
}
|
|
23439
24380
|
) });
|
|
23440
24381
|
};
|
|
@@ -23463,7 +24404,7 @@ import { Ariakit as Ariakit2 } from "zens";
|
|
|
23463
24404
|
import { useActive, useCommands as useCommands4 } from "@remirror/react-core";
|
|
23464
24405
|
import { useCallback as useCallback6 } from "react";
|
|
23465
24406
|
import { t as t6 } from "i18next";
|
|
23466
|
-
import { jsx as
|
|
24407
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
23467
24408
|
var InsertSeparatorButton = ({ attrs = {}, ...rest }) => {
|
|
23468
24409
|
const { insertHorizontalRule } = useCommands4();
|
|
23469
24410
|
const handleSelect = useCallback6(() => {
|
|
@@ -23473,7 +24414,7 @@ var InsertSeparatorButton = ({ attrs = {}, ...rest }) => {
|
|
|
23473
24414
|
}, [insertHorizontalRule, attrs]);
|
|
23474
24415
|
const active = useActive().codeMirror();
|
|
23475
24416
|
const enabled = insertHorizontalRule.enabled(attrs);
|
|
23476
|
-
return /* @__PURE__ */
|
|
24417
|
+
return /* @__PURE__ */ jsx23(
|
|
23477
24418
|
CommandButton,
|
|
23478
24419
|
{
|
|
23479
24420
|
...rest,
|
|
@@ -23492,17 +24433,17 @@ var InsertSeparatorButton = ({ attrs = {}, ...rest }) => {
|
|
|
23492
24433
|
import { useCommands as useCommands5, useHelpers as useHelpers2 } from "@remirror/react-core";
|
|
23493
24434
|
import { t as t7 } from "i18next";
|
|
23494
24435
|
import { useCallback as useCallback7 } from "react";
|
|
23495
|
-
import { jsx as
|
|
24436
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
23496
24437
|
var RedoButton = (props) => {
|
|
23497
|
-
const { redo:
|
|
23498
|
-
const { redoDepth
|
|
24438
|
+
const { redo: redo5 } = useCommands5();
|
|
24439
|
+
const { redoDepth } = useHelpers2(true);
|
|
23499
24440
|
const handleSelect = useCallback7(() => {
|
|
23500
|
-
if (
|
|
23501
|
-
|
|
24441
|
+
if (redo5.enabled()) {
|
|
24442
|
+
redo5();
|
|
23502
24443
|
}
|
|
23503
|
-
}, [
|
|
23504
|
-
const enabled =
|
|
23505
|
-
return /* @__PURE__ */
|
|
24444
|
+
}, [redo5]);
|
|
24445
|
+
const enabled = redoDepth() > 0;
|
|
24446
|
+
return /* @__PURE__ */ jsx24(
|
|
23506
24447
|
CommandButton,
|
|
23507
24448
|
{
|
|
23508
24449
|
...props,
|
|
@@ -23520,7 +24461,7 @@ var RedoButton = (props) => {
|
|
|
23520
24461
|
import { useActive as useActive2, useCommands as useCommands6 } from "@remirror/react-core";
|
|
23521
24462
|
import { useCallback as useCallback8 } from "react";
|
|
23522
24463
|
import { t as t8 } from "i18next";
|
|
23523
|
-
import { jsx as
|
|
24464
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
23524
24465
|
var ToggleBlockquoteButton = ({ ...rest }) => {
|
|
23525
24466
|
const { toggleBlockquote } = useCommands6();
|
|
23526
24467
|
const handleSelect = useCallback8(() => {
|
|
@@ -23530,7 +24471,7 @@ var ToggleBlockquoteButton = ({ ...rest }) => {
|
|
|
23530
24471
|
}, [toggleBlockquote]);
|
|
23531
24472
|
const active = useActive2().blockquote();
|
|
23532
24473
|
const enabled = toggleBlockquote.enabled();
|
|
23533
|
-
return /* @__PURE__ */
|
|
24474
|
+
return /* @__PURE__ */ jsx25(
|
|
23534
24475
|
CommandButton,
|
|
23535
24476
|
{
|
|
23536
24477
|
...rest,
|
|
@@ -23548,7 +24489,7 @@ var ToggleBlockquoteButton = ({ ...rest }) => {
|
|
|
23548
24489
|
import { useActive as useActive3, useCommands as useCommands7 } from "@remirror/react-core";
|
|
23549
24490
|
import { useCallback as useCallback9 } from "react";
|
|
23550
24491
|
import { t as t9 } from "i18next";
|
|
23551
|
-
import { jsx as
|
|
24492
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
23552
24493
|
var ToggleBoldButton = (props) => {
|
|
23553
24494
|
const { toggleStrong } = useCommands7();
|
|
23554
24495
|
const handleSelect = useCallback9(() => {
|
|
@@ -23558,7 +24499,7 @@ var ToggleBoldButton = (props) => {
|
|
|
23558
24499
|
}, [toggleStrong]);
|
|
23559
24500
|
const active = useActive3().mdStrong();
|
|
23560
24501
|
const enabled = toggleStrong.enabled();
|
|
23561
|
-
return /* @__PURE__ */
|
|
24502
|
+
return /* @__PURE__ */ jsx26(
|
|
23562
24503
|
CommandButton,
|
|
23563
24504
|
{
|
|
23564
24505
|
...props,
|
|
@@ -23576,7 +24517,7 @@ var ToggleBoldButton = (props) => {
|
|
|
23576
24517
|
import { useActive as useActive4, useCommands as useCommands8 } from "@remirror/react-core";
|
|
23577
24518
|
import { useCallback as useCallback10 } from "react";
|
|
23578
24519
|
import { t as t10 } from "i18next";
|
|
23579
|
-
import { jsx as
|
|
24520
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
23580
24521
|
var ToggleBulletListButton = (props) => {
|
|
23581
24522
|
const { toggleList } = useCommands8();
|
|
23582
24523
|
const handleSelect = useCallback10(() => {
|
|
@@ -23586,7 +24527,7 @@ var ToggleBulletListButton = (props) => {
|
|
|
23586
24527
|
}, [toggleList]);
|
|
23587
24528
|
const active = useActive4().list();
|
|
23588
24529
|
const enabled = true;
|
|
23589
|
-
return /* @__PURE__ */
|
|
24530
|
+
return /* @__PURE__ */ jsx27(
|
|
23590
24531
|
CommandButton,
|
|
23591
24532
|
{
|
|
23592
24533
|
...props,
|
|
@@ -23604,7 +24545,7 @@ var ToggleBulletListButton = (props) => {
|
|
|
23604
24545
|
import { useActive as useActive5, useCommands as useCommands9 } from "@remirror/react-core";
|
|
23605
24546
|
import { useCallback as useCallback11 } from "react";
|
|
23606
24547
|
import { t as t11 } from "i18next";
|
|
23607
|
-
import { jsx as
|
|
24548
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
23608
24549
|
var ToggleCodeBlockButton = ({ attrs = {}, ...rest }) => {
|
|
23609
24550
|
const { createCodeMirror } = useCommands9();
|
|
23610
24551
|
const handleSelect = useCallback11(() => {
|
|
@@ -23614,7 +24555,7 @@ var ToggleCodeBlockButton = ({ attrs = {}, ...rest }) => {
|
|
|
23614
24555
|
}, [createCodeMirror, attrs]);
|
|
23615
24556
|
const active = useActive5().codeMirror();
|
|
23616
24557
|
const enabled = createCodeMirror.enabled(attrs);
|
|
23617
|
-
return /* @__PURE__ */
|
|
24558
|
+
return /* @__PURE__ */ jsx28(
|
|
23618
24559
|
CommandButton,
|
|
23619
24560
|
{
|
|
23620
24561
|
...rest,
|
|
@@ -23633,7 +24574,7 @@ var ToggleCodeBlockButton = ({ attrs = {}, ...rest }) => {
|
|
|
23633
24574
|
import { useActive as useActive6, useCommands as useCommands10 } from "@remirror/react-core";
|
|
23634
24575
|
import { useCallback as useCallback12 } from "react";
|
|
23635
24576
|
import { t as t12 } from "i18next";
|
|
23636
|
-
import { jsx as
|
|
24577
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
23637
24578
|
var ToggleCodeButton = (props) => {
|
|
23638
24579
|
const { toggleCodeText } = useCommands10();
|
|
23639
24580
|
const handleSelect = useCallback12(() => {
|
|
@@ -23643,7 +24584,7 @@ var ToggleCodeButton = (props) => {
|
|
|
23643
24584
|
}, [toggleCodeText]);
|
|
23644
24585
|
const active = useActive6().mdCodeText();
|
|
23645
24586
|
const enabled = toggleCodeText.enabled();
|
|
23646
|
-
return /* @__PURE__ */
|
|
24587
|
+
return /* @__PURE__ */ jsx29(
|
|
23647
24588
|
CommandButton,
|
|
23648
24589
|
{
|
|
23649
24590
|
...props,
|
|
@@ -23661,7 +24602,7 @@ var ToggleCodeButton = (props) => {
|
|
|
23661
24602
|
import { useActive as useActive7, useCommands as useCommands11 } from "@remirror/react-core";
|
|
23662
24603
|
import { useCallback as useCallback13 } from "react";
|
|
23663
24604
|
import { t as t13 } from "i18next";
|
|
23664
|
-
import { jsx as
|
|
24605
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
23665
24606
|
var ToggleHeadingButton = ({ attrs, ...rest }) => {
|
|
23666
24607
|
const { toggleHeading } = useCommands11();
|
|
23667
24608
|
const handleSelect = useCallback13(() => {
|
|
@@ -23671,7 +24612,7 @@ var ToggleHeadingButton = ({ attrs, ...rest }) => {
|
|
|
23671
24612
|
}, [toggleHeading, attrs]);
|
|
23672
24613
|
const active = useActive7().heading(attrs);
|
|
23673
24614
|
const enabled = toggleHeading.enabled(attrs);
|
|
23674
|
-
return /* @__PURE__ */
|
|
24615
|
+
return /* @__PURE__ */ jsx30(
|
|
23675
24616
|
CommandButton,
|
|
23676
24617
|
{
|
|
23677
24618
|
...rest,
|
|
@@ -23690,7 +24631,7 @@ var ToggleHeadingButton = ({ attrs, ...rest }) => {
|
|
|
23690
24631
|
import { useActive as useActive8, useCommands as useCommands12 } from "@remirror/react-core";
|
|
23691
24632
|
import { useCallback as useCallback14 } from "react";
|
|
23692
24633
|
import { t as t14 } from "i18next";
|
|
23693
|
-
import { jsx as
|
|
24634
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
23694
24635
|
var ToggleItalicButton = (props) => {
|
|
23695
24636
|
const { toggleEmphasis } = useCommands12();
|
|
23696
24637
|
const handleSelect = useCallback14(() => {
|
|
@@ -23700,7 +24641,7 @@ var ToggleItalicButton = (props) => {
|
|
|
23700
24641
|
}, [toggleEmphasis]);
|
|
23701
24642
|
const active = useActive8().mdEm();
|
|
23702
24643
|
const enabled = toggleEmphasis.enabled();
|
|
23703
|
-
return /* @__PURE__ */
|
|
24644
|
+
return /* @__PURE__ */ jsx31(
|
|
23704
24645
|
CommandButton,
|
|
23705
24646
|
{
|
|
23706
24647
|
...props,
|
|
@@ -23718,7 +24659,7 @@ var ToggleItalicButton = (props) => {
|
|
|
23718
24659
|
import { useActive as useActive9, useCommands as useCommands13 } from "@remirror/react-core";
|
|
23719
24660
|
import { useCallback as useCallback15 } from "react";
|
|
23720
24661
|
import { t as t15 } from "i18next";
|
|
23721
|
-
import { jsx as
|
|
24662
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
23722
24663
|
var ToggleOrderedListButton = (props) => {
|
|
23723
24664
|
const { toggleList } = useCommands13();
|
|
23724
24665
|
const handleSelect = useCallback15(() => {
|
|
@@ -23730,7 +24671,7 @@ var ToggleOrderedListButton = (props) => {
|
|
|
23730
24671
|
}, [toggleList]);
|
|
23731
24672
|
const active = useActive9().list();
|
|
23732
24673
|
const enabled = true;
|
|
23733
|
-
return /* @__PURE__ */
|
|
24674
|
+
return /* @__PURE__ */ jsx32(
|
|
23734
24675
|
CommandButton,
|
|
23735
24676
|
{
|
|
23736
24677
|
...props,
|
|
@@ -23748,7 +24689,7 @@ var ToggleOrderedListButton = (props) => {
|
|
|
23748
24689
|
import { useActive as useActive10, useCommands as useCommands14 } from "@remirror/react-core";
|
|
23749
24690
|
import { useCallback as useCallback16 } from "react";
|
|
23750
24691
|
import { t as t16 } from "i18next";
|
|
23751
|
-
import { jsx as
|
|
24692
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
23752
24693
|
var ToggleTaskListButton = (props) => {
|
|
23753
24694
|
const { toggleList } = useCommands14();
|
|
23754
24695
|
const handleSelect = useCallback16(() => {
|
|
@@ -23760,7 +24701,7 @@ var ToggleTaskListButton = (props) => {
|
|
|
23760
24701
|
}, [toggleList]);
|
|
23761
24702
|
const active = useActive10().list();
|
|
23762
24703
|
const enabled = true;
|
|
23763
|
-
return /* @__PURE__ */
|
|
24704
|
+
return /* @__PURE__ */ jsx33(
|
|
23764
24705
|
CommandButton,
|
|
23765
24706
|
{
|
|
23766
24707
|
...props,
|
|
@@ -23778,17 +24719,17 @@ var ToggleTaskListButton = (props) => {
|
|
|
23778
24719
|
import { useCommands as useCommands15, useHelpers as useHelpers3 } from "@remirror/react-core";
|
|
23779
24720
|
import { t as t17 } from "i18next";
|
|
23780
24721
|
import { useCallback as useCallback17 } from "react";
|
|
23781
|
-
import { jsx as
|
|
24722
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
23782
24723
|
var UndoButton = (props) => {
|
|
23783
|
-
const { undo:
|
|
23784
|
-
const { undoDepth
|
|
24724
|
+
const { undo: undo5 } = useCommands15();
|
|
24725
|
+
const { undoDepth } = useHelpers3(true);
|
|
23785
24726
|
const handleSelect = useCallback17(() => {
|
|
23786
|
-
if (
|
|
23787
|
-
|
|
24727
|
+
if (undo5.enabled()) {
|
|
24728
|
+
undo5();
|
|
23788
24729
|
}
|
|
23789
|
-
}, [
|
|
23790
|
-
const enabled =
|
|
23791
|
-
return /* @__PURE__ */
|
|
24730
|
+
}, [undo5]);
|
|
24731
|
+
const enabled = undoDepth() > 0;
|
|
24732
|
+
return /* @__PURE__ */ jsx34(
|
|
23792
24733
|
CommandButton,
|
|
23793
24734
|
{
|
|
23794
24735
|
...props,
|
|
@@ -23803,25 +24744,25 @@ var UndoButton = (props) => {
|
|
|
23803
24744
|
};
|
|
23804
24745
|
|
|
23805
24746
|
// src/editor/toolbar/toolbar/wysiwyg-toolbar.tsx
|
|
23806
|
-
import { jsx as
|
|
24747
|
+
import { jsx as jsx35, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
23807
24748
|
var WysiwygToolbar = (props) => {
|
|
23808
24749
|
const { prevActions = null, nextActions = null } = props;
|
|
23809
24750
|
return /* @__PURE__ */ jsxs8(ToolBar, { className: props.className, style: props.style, children: [
|
|
23810
24751
|
prevActions,
|
|
23811
|
-
/* @__PURE__ */
|
|
23812
|
-
/* @__PURE__ */
|
|
23813
|
-
/* @__PURE__ */
|
|
23814
|
-
/* @__PURE__ */
|
|
23815
|
-
/* @__PURE__ */
|
|
23816
|
-
/* @__PURE__ */
|
|
23817
|
-
/* @__PURE__ */
|
|
23818
|
-
/* @__PURE__ */
|
|
23819
|
-
/* @__PURE__ */
|
|
23820
|
-
/* @__PURE__ */
|
|
23821
|
-
/* @__PURE__ */
|
|
23822
|
-
/* @__PURE__ */
|
|
23823
|
-
/* @__PURE__ */
|
|
23824
|
-
/* @__PURE__ */
|
|
24752
|
+
/* @__PURE__ */ jsx35(UndoButton, {}),
|
|
24753
|
+
/* @__PURE__ */ jsx35(RedoButton, {}),
|
|
24754
|
+
/* @__PURE__ */ jsx35(ToolbarSeparator, { render: /* @__PURE__ */ jsx35("div", {}) }),
|
|
24755
|
+
/* @__PURE__ */ jsx35(ToggleHeadingButton, {}),
|
|
24756
|
+
/* @__PURE__ */ jsx35(ToggleBoldButton, {}),
|
|
24757
|
+
/* @__PURE__ */ jsx35(ToggleItalicButton, {}),
|
|
24758
|
+
/* @__PURE__ */ jsx35(ToggleBlockquoteButton, {}),
|
|
24759
|
+
/* @__PURE__ */ jsx35(ToggleCodeBlockButton, {}),
|
|
24760
|
+
/* @__PURE__ */ jsx35(ToggleCodeButton, {}),
|
|
24761
|
+
/* @__PURE__ */ jsx35(InsertSeparatorButton, {}),
|
|
24762
|
+
/* @__PURE__ */ jsx35(ToolbarSeparator, { render: /* @__PURE__ */ jsx35("div", {}) }),
|
|
24763
|
+
/* @__PURE__ */ jsx35(ToggleBulletListButton, {}),
|
|
24764
|
+
/* @__PURE__ */ jsx35(ToggleOrderedListButton, {}),
|
|
24765
|
+
/* @__PURE__ */ jsx35(ToggleTaskListButton, {}),
|
|
23825
24766
|
nextActions
|
|
23826
24767
|
] });
|
|
23827
24768
|
};
|
|
@@ -23846,23 +24787,23 @@ var ToolbarSeparator = styled13(Ariakit2.ToolbarSeparator)`
|
|
|
23846
24787
|
// src/editor/components/WysiwygEditor/delegate.ts
|
|
23847
24788
|
import { isExtension } from "@remirror/core";
|
|
23848
24789
|
import { createReactManager as createReactManager2 } from "@remirror/react";
|
|
23849
|
-
function isMarkdownNodeExtension(
|
|
23850
|
-
return !!(isExtension(
|
|
24790
|
+
function isMarkdownNodeExtension(extension17) {
|
|
24791
|
+
return !!(isExtension(extension17) && extension17.fromMarkdown && extension17.toMarkdown);
|
|
23851
24792
|
}
|
|
23852
24793
|
function buildMarkdownParser(manager) {
|
|
23853
24794
|
const parserRules = [];
|
|
23854
|
-
for (const
|
|
23855
|
-
if (isMarkdownNodeExtension(
|
|
23856
|
-
parserRules.push(...
|
|
24795
|
+
for (const extension17 of manager.extensions) {
|
|
24796
|
+
if (isMarkdownNodeExtension(extension17)) {
|
|
24797
|
+
parserRules.push(...extension17.fromMarkdown());
|
|
23857
24798
|
}
|
|
23858
24799
|
}
|
|
23859
24800
|
return new MarkdownParser(manager.schema, parserRules);
|
|
23860
24801
|
}
|
|
23861
24802
|
function buildMarkdownSerializer(manager) {
|
|
23862
24803
|
const specs = {};
|
|
23863
|
-
for (const
|
|
23864
|
-
if (isMarkdownNodeExtension(
|
|
23865
|
-
specs[
|
|
24804
|
+
for (const extension17 of manager.extensions) {
|
|
24805
|
+
if (isMarkdownNodeExtension(extension17)) {
|
|
24806
|
+
specs[extension17.name] = extension17.toMarkdown;
|
|
23866
24807
|
}
|
|
23867
24808
|
}
|
|
23868
24809
|
return new MarkdownSerializer(specs);
|
|
@@ -23891,7 +24832,7 @@ var createWysiwygDelegate = (options = {}) => {
|
|
|
23891
24832
|
};
|
|
23892
24833
|
|
|
23893
24834
|
// src/editor/components/WysiwygEditor/index.tsx
|
|
23894
|
-
import { jsx as
|
|
24835
|
+
import { jsx as jsx36, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
23895
24836
|
var WysiwygEditor = (props) => {
|
|
23896
24837
|
const {
|
|
23897
24838
|
content,
|
|
@@ -23929,9 +24870,9 @@ var WysiwygEditor = (props) => {
|
|
|
23929
24870
|
try {
|
|
23930
24871
|
initialContent = editorDelegate.stringToDoc(content);
|
|
23931
24872
|
} catch (error) {
|
|
23932
|
-
return /* @__PURE__ */
|
|
24873
|
+
return /* @__PURE__ */ jsx36(ErrorBoundary_default, { hasError: true, error, ...props.errorHandler || {} });
|
|
23933
24874
|
}
|
|
23934
|
-
return /* @__PURE__ */
|
|
24875
|
+
return /* @__PURE__ */ jsx36(ErrorBoundary_default, { ...props.errorHandler || {}, children: /* @__PURE__ */ jsx36(WysiwygThemeWrapper, { ...styleToken, children: /* @__PURE__ */ jsxs9(
|
|
23935
24876
|
Remirror2,
|
|
23936
24877
|
{
|
|
23937
24878
|
manager: editorDelegate.manager,
|
|
@@ -23940,12 +24881,12 @@ var WysiwygEditor = (props) => {
|
|
|
23940
24881
|
editable,
|
|
23941
24882
|
onChange: handleChange,
|
|
23942
24883
|
children: [
|
|
23943
|
-
wysiwygToolBarOptions?.enable ? /* @__PURE__ */
|
|
23944
|
-
/* @__PURE__ */
|
|
23945
|
-
/* @__PURE__ */
|
|
23946
|
-
/* @__PURE__ */
|
|
24884
|
+
wysiwygToolBarOptions?.enable ? /* @__PURE__ */ jsx36(WysiwygToolbar, { ...wysiwygToolBarOptions?.compProps }) : null,
|
|
24885
|
+
/* @__PURE__ */ jsx36(Text_default, {}),
|
|
24886
|
+
/* @__PURE__ */ jsx36(TableToolbar_default, {}),
|
|
24887
|
+
/* @__PURE__ */ jsx36(SlashMenu, {}),
|
|
23947
24888
|
wysiwygToolBar || null,
|
|
23948
|
-
isTesting ? /* @__PURE__ */
|
|
24889
|
+
isTesting ? /* @__PURE__ */ jsx36(ProsemirrorDevTools2, {}) : null
|
|
23949
24890
|
]
|
|
23950
24891
|
}
|
|
23951
24892
|
) }) });
|
|
@@ -23955,7 +24896,7 @@ var WysiwygEditor_default = memo6(WysiwygEditor);
|
|
|
23955
24896
|
// src/editor/components/Editor.tsx
|
|
23956
24897
|
import HTML2 from "html-parse-stringify";
|
|
23957
24898
|
import { nanoid as nanoid3 } from "nanoid";
|
|
23958
|
-
import { jsx as
|
|
24899
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
23959
24900
|
var Editor = memo7(
|
|
23960
24901
|
forwardRef2((props, ref) => {
|
|
23961
24902
|
const {
|
|
@@ -24015,9 +24956,9 @@ var Editor = memo7(
|
|
|
24015
24956
|
return [() => useContextMounted(onContextMounted), ...hooks];
|
|
24016
24957
|
}, [hooks, onContextMounted]);
|
|
24017
24958
|
if (type === "preview") {
|
|
24018
|
-
return /* @__PURE__ */
|
|
24959
|
+
return /* @__PURE__ */ jsx37(Preview, { doc: otherProps.content, delegateOptions: otherProps.delegateOptions });
|
|
24019
24960
|
}
|
|
24020
|
-
return type === "sourceCode" ? /* @__PURE__ */
|
|
24961
|
+
return type === "sourceCode" ? /* @__PURE__ */ jsx37(SourceEditor_default, { ...otherProps, hooks: editorHooks }) : /* @__PURE__ */ jsx37(WysiwygEditor_default, { ...otherProps, hooks: editorHooks });
|
|
24021
24962
|
})
|
|
24022
24963
|
);
|
|
24023
24964
|
var defaultStyleToken = {
|
|
@@ -24104,7 +25045,7 @@ function changeLng(lng) {
|
|
|
24104
25045
|
|
|
24105
25046
|
// src/editor/components/ThemeProvider.tsx
|
|
24106
25047
|
import mermaid2 from "mermaid";
|
|
24107
|
-
import { jsx as
|
|
25048
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
24108
25049
|
var ThemeProvider = memo8(({ theme, i18n, children }) => {
|
|
24109
25050
|
const mode = theme?.mode || "light";
|
|
24110
25051
|
const defaultThemeToken = mode === "dark" ? darkTheme.styledConstants : lightTheme.styledConstants;
|
|
@@ -24126,7 +25067,7 @@ var ThemeProvider = memo8(({ theme, i18n, children }) => {
|
|
|
24126
25067
|
});
|
|
24127
25068
|
eventBus.emit("change-theme");
|
|
24128
25069
|
}, [mode, theme?.codemirrorTheme, changeTheme]);
|
|
24129
|
-
return /* @__PURE__ */
|
|
25070
|
+
return /* @__PURE__ */ jsx38(ScThemeProvider, { theme: themeToken, children });
|
|
24130
25071
|
});
|
|
24131
25072
|
|
|
24132
25073
|
// src/editor/components/Preview/preview.tsx
|
|
@@ -24210,7 +25151,7 @@ var rmeProsemirrorNodeToHtml = async (doc, delegateOptions) => {
|
|
|
24210
25151
|
};
|
|
24211
25152
|
|
|
24212
25153
|
// src/editor/components/Preview/preview.tsx
|
|
24213
|
-
import { jsx as
|
|
25154
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
24214
25155
|
var Preview = (props) => {
|
|
24215
25156
|
const { doc, delegateOptions } = props;
|
|
24216
25157
|
const [processedHtml, setProcessedHtml] = useState10("");
|
|
@@ -24227,7 +25168,7 @@ var Preview = (props) => {
|
|
|
24227
25168
|
});
|
|
24228
25169
|
}, [props.onError]);
|
|
24229
25170
|
if (!processedHtml) {
|
|
24230
|
-
return /* @__PURE__ */
|
|
25171
|
+
return /* @__PURE__ */ jsx39(
|
|
24231
25172
|
"div",
|
|
24232
25173
|
{
|
|
24233
25174
|
style: {
|
|
@@ -24237,11 +25178,11 @@ var Preview = (props) => {
|
|
|
24237
25178
|
justifyContent: "center",
|
|
24238
25179
|
alignItems: "center"
|
|
24239
25180
|
},
|
|
24240
|
-
children: /* @__PURE__ */
|
|
25181
|
+
children: /* @__PURE__ */ jsx39(Icon.Loading3QuartersOutlined, { spin: true, size: 40 })
|
|
24241
25182
|
}
|
|
24242
25183
|
);
|
|
24243
25184
|
}
|
|
24244
|
-
return /* @__PURE__ */
|
|
25185
|
+
return /* @__PURE__ */ jsx39(WysiwygThemeWrapper, { dangerouslySetInnerHTML: { __html: processedHtml } });
|
|
24245
25186
|
};
|
|
24246
25187
|
|
|
24247
25188
|
// src/editor/hooks/index.ts
|