wysimark-lite 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -13
- package/dist/index.js +2 -6
- package/dist/index.mjs +58 -90
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,23 +26,16 @@ const Editor: React.FC = () => {
|
|
|
26
26
|
};
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
With initial value:
|
|
30
|
-
|
|
31
|
-
```tsx
|
|
32
|
-
const Editor: React.FC = () => {
|
|
33
|
-
const [value, setValue] = React.useState(`# Welcome to Wysimark
|
|
34
|
-
|
|
35
|
-
This is a **rich text editor** with _markdown_ support.`);
|
|
36
|
-
const editor = useEditor({});
|
|
37
|
-
|
|
38
|
-
return <Editable editor={editor} value={value} onChange={setValue} />;
|
|
39
|
-
};
|
|
40
|
-
```
|
|
41
|
-
|
|
42
29
|
### Direct Initialization
|
|
43
30
|
|
|
44
31
|
You can also initialize the editor directly on an HTML element:
|
|
45
32
|
|
|
33
|
+
# you use rails importmap, add the following line to your importmap.rb
|
|
34
|
+
※ @latest is the latest version of wysimark-lite. If you want to specify a version, replace @latest with the version you want to use.
|
|
35
|
+
```
|
|
36
|
+
pin "wysimark-lite", to: "https://cdn.jsdelivr.net/npm/wysimark-lite@latest/dist/index.js"
|
|
37
|
+
```
|
|
38
|
+
|
|
46
39
|
```html
|
|
47
40
|
<div id="editor"></div>
|
|
48
41
|
<script type="module">
|
package/dist/index.js
CHANGED
|
@@ -901,12 +901,8 @@ Error generating stack: `+n.message+`
|
|
|
901
901
|
}
|
|
902
902
|
border-radius: 8px;
|
|
903
903
|
}
|
|
904
|
-
`;function $B(e){return e.children.length===1&&Y.string(e.children[0]).length===0}var YB=O(N());function GB({element:e,attributes:t,children:n}){let r=Pn(),i=$B(e);return(0,YB.jsx)(VB,{...t,className:ct({"--selected":r,"--empty":i,"--collapsible":!!e.__collapsible}),children:n})}var QB=O(N()),KB=xe(e=>{let{insertBreak:t}=e
|
|
905
|
-
|
|
906
|
-
`).filter(u=>u.trim()),o=a.map(u=>({type:"paragraph",children:[{text:u.trim()}]}));return d.withoutNormalizing(e,()=>{k.removeNodes(e,{at:i}),k.insertNodes(e,o,{at:i})}),a};if(e.insertBreak=()=>{let{selection:r}=e;if(r&&r.anchor.path[0]===r.focus.path[0]){let i=d.string(e,[r.anchor.path[0]]),a=r.anchor.offset;if(i.slice(0,a).match(/\n$/))t();else if(i.includes(`
|
|
907
|
-
|
|
908
|
-
`)){let u=[r.anchor.path[0]],l=n(i,u),s=a,f=0,m=0;for(let p=0;p<l.length;p++){if(m+l[p].length+2>a){s=a-m,f=p;break}m+=l[p].length+2}e.selection={anchor:{path:[u[0]+f,0],offset:s},focus:{path:[u[0]+f,0],offset:s}}}else e.insertText(`
|
|
909
|
-
`)}else t()},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:ee(qB,e)},editableProps:{renderElement:({element:r,attributes:i,children:a})=>{switch(r.type){case"paragraph":return(0,QB.jsx)(GB,{element:r,attributes:i,children:a})}},onKeyDown:zt({"super+0":e.collapsibleParagraph.convertParagraph})}}});function XB(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}function WB(e,t,n,r){let i=Array.from(d.nodes(e,{match:o=>X.isElement(o)&&e.convertElement.isConvertibleElement(o)}));return i.length===0?!1:(r&&i.every(o=>t(o[0]))?d.withoutNormalizing(e,()=>{for(let o of i)Us(e,{type:"paragraph"},o[1])}):d.withoutNormalizing(e,()=>{for(let o of i)Us(e,n,o[1])}),!0)}function ZB(e,t){return e.convertElement.convertElementTypes.includes(t.type)}function JB(e){return{convertElementTypes:[],addConvertElementType:ee(XB,e),isConvertibleElement:ee(ZB,e),convertElements:ee(WB,e)}}var e3=xe(e=>(e.convertElement=JB(e),{name:"convert-element"}));function t3(e){let t=be(e,"heading");if(!t||!e.selection||R.isExpanded(e.selection)||!d.isEnd(e,e.selection.anchor,t[1]))return!1;let n=A.next(t[1]);return k.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:n}),k.select(e,{anchor:d.start(e,n),focus:d.start(e,n)}),!0}function qN(e,t,n){e.convertElement.convertElements(r=>r.type==="heading"&&r.level==t,{type:"heading",level:t},n)}function VN(e,t){let[n]=d.nodes(e,{match:r=>"type"in r&&"level"in r&&r.type==="heading"&&r.level===t});return!!n}function n3(e){return{convertHeading:ee(qN,e),isHeadingActive:ee(VN,e)}}var Fu=np`
|
|
904
|
+
`;function $B(e){return e.children.length===1&&Y.string(e.children[0]).length===0}var YB=O(N());function GB({element:e,attributes:t,children:n}){let r=Pn(),i=$B(e);return(0,YB.jsx)(VB,{...t,className:ct({"--selected":r,"--empty":i,"--collapsible":!!e.__collapsible}),children:n})}var QB=O(N()),KB=xe(e=>{let{insertBreak:t}=e;if(e.insertBreak=()=>{let{selection:n}=e;n&&n.anchor.path[0]===n.focus.path[0]?d.string(e,[n.anchor.path[0]]).match(/\n$/)?t():e.insertText(`
|
|
905
|
+
`):t()},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:ee(qB,e)},editableProps:{renderElement:({element:n,attributes:r,children:i})=>{switch(n.type){case"paragraph":return(0,QB.jsx)(GB,{element:n,attributes:r,children:i})}},onKeyDown:zt({"super+0":e.collapsibleParagraph.convertParagraph})}}});function XB(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}function WB(e,t,n,r){let i=Array.from(d.nodes(e,{match:o=>X.isElement(o)&&e.convertElement.isConvertibleElement(o)}));return i.length===0?!1:(r&&i.every(o=>t(o[0]))?d.withoutNormalizing(e,()=>{for(let o of i)Us(e,{type:"paragraph"},o[1])}):d.withoutNormalizing(e,()=>{for(let o of i)Us(e,n,o[1])}),!0)}function ZB(e,t){return e.convertElement.convertElementTypes.includes(t.type)}function JB(e){return{convertElementTypes:[],addConvertElementType:ee(XB,e),isConvertibleElement:ee(ZB,e),convertElements:ee(WB,e)}}var e3=xe(e=>(e.convertElement=JB(e),{name:"convert-element"}));function t3(e){let t=be(e,"heading");if(!t||!e.selection||R.isExpanded(e.selection)||!d.isEnd(e,e.selection.anchor,t[1]))return!1;let n=A.next(t[1]);return k.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:n}),k.select(e,{anchor:d.start(e,n),focus:d.start(e,n)}),!0}function qN(e,t,n){e.convertElement.convertElements(r=>r.type==="heading"&&r.level==t,{type:"heading",level:t},n)}function VN(e,t){let[n]=d.nodes(e,{match:r=>"type"in r&&"level"in r&&r.type==="heading"&&r.level===t});return!!n}function n3(e){return{convertHeading:ee(qN,e),isHeadingActive:ee(VN,e)}}var Fu=np`
|
|
910
906
|
margin-top: 1em;
|
|
911
907
|
&:first-child {
|
|
912
908
|
margin-top: 0;
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { createRoot } from "react-dom/client";
|
|
|
11
11
|
// src/entry/index.tsx
|
|
12
12
|
import throttle3 from "lodash.throttle";
|
|
13
13
|
import { useCallback as useCallback15, useRef as useRef12 } from "react";
|
|
14
|
-
import { Editor as Editor58, Transforms as
|
|
14
|
+
import { Editor as Editor58, Transforms as Transforms40 } from "slate";
|
|
15
15
|
import { ReactEditor as ReactEditor16, Slate as Slate2 } from "slate-react";
|
|
16
16
|
|
|
17
17
|
// src/convert/parse/index.ts
|
|
@@ -4490,7 +4490,7 @@ var BlockQuotePlugin = createPlugin(
|
|
|
4490
4490
|
);
|
|
4491
4491
|
|
|
4492
4492
|
// src/collapsible-paragraph-plugin/index.tsx
|
|
4493
|
-
import { Editor as Editor27
|
|
4493
|
+
import { Editor as Editor27 } from "slate";
|
|
4494
4494
|
|
|
4495
4495
|
// src/collapsible-paragraph-plugin/normalize-node/index.ts
|
|
4496
4496
|
import { Element as Element14 } from "slate";
|
|
@@ -4621,44 +4621,12 @@ function Paragraph({
|
|
|
4621
4621
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
4622
4622
|
var CollapsibleParagraphPlugin = createPlugin((editor) => {
|
|
4623
4623
|
const { insertBreak: insertBreak3 } = editor;
|
|
4624
|
-
const splitParagraphsAtEmptyLines = (text, path) => {
|
|
4625
|
-
const paragraphs = text.split("\n\n").filter((p) => p.trim());
|
|
4626
|
-
const nodes = paragraphs.map((p) => ({
|
|
4627
|
-
type: "paragraph",
|
|
4628
|
-
children: [{ text: p.trim() }]
|
|
4629
|
-
}));
|
|
4630
|
-
Editor27.withoutNormalizing(editor, () => {
|
|
4631
|
-
Transforms19.removeNodes(editor, { at: path });
|
|
4632
|
-
Transforms19.insertNodes(editor, nodes, { at: path });
|
|
4633
|
-
});
|
|
4634
|
-
return paragraphs;
|
|
4635
|
-
};
|
|
4636
4624
|
editor.insertBreak = () => {
|
|
4637
4625
|
const { selection } = editor;
|
|
4638
4626
|
if (selection && selection.anchor.path[0] === selection.focus.path[0]) {
|
|
4639
4627
|
const text = Editor27.string(editor, [selection.anchor.path[0]]);
|
|
4640
|
-
|
|
4641
|
-
const beforeCursor = text.slice(0, currentOffset);
|
|
4642
|
-
if (beforeCursor.match(/\n$/)) {
|
|
4628
|
+
if (text.match(/\n$/)) {
|
|
4643
4629
|
insertBreak3();
|
|
4644
|
-
} else if (text.includes("\n\n")) {
|
|
4645
|
-
const path = [selection.anchor.path[0]];
|
|
4646
|
-
const paragraphs = splitParagraphsAtEmptyLines(text, path);
|
|
4647
|
-
let newOffset = currentOffset;
|
|
4648
|
-
let paragraphIndex = 0;
|
|
4649
|
-
let accumulatedLength = 0;
|
|
4650
|
-
for (let i = 0; i < paragraphs.length; i++) {
|
|
4651
|
-
if (accumulatedLength + paragraphs[i].length + 2 > currentOffset) {
|
|
4652
|
-
newOffset = currentOffset - accumulatedLength;
|
|
4653
|
-
paragraphIndex = i;
|
|
4654
|
-
break;
|
|
4655
|
-
}
|
|
4656
|
-
accumulatedLength += paragraphs[i].length + 2;
|
|
4657
|
-
}
|
|
4658
|
-
editor.selection = {
|
|
4659
|
-
anchor: { path: [path[0] + paragraphIndex, 0], offset: newOffset },
|
|
4660
|
-
focus: { path: [path[0] + paragraphIndex, 0], offset: newOffset }
|
|
4661
|
-
};
|
|
4662
4630
|
} else {
|
|
4663
4631
|
editor.insertText("\n");
|
|
4664
4632
|
}
|
|
@@ -4766,7 +4734,7 @@ var ConvertElementPlugin = createPlugin((editor) => {
|
|
|
4766
4734
|
});
|
|
4767
4735
|
|
|
4768
4736
|
// src/heading-plugin/insert-break.ts
|
|
4769
|
-
import { Editor as Editor29, Path as Path7, Range as Range4, Transforms as
|
|
4737
|
+
import { Editor as Editor29, Path as Path7, Range as Range4, Transforms as Transforms19 } from "slate";
|
|
4770
4738
|
function insertBreak(editor) {
|
|
4771
4739
|
const entry = findElementUp(editor, "heading");
|
|
4772
4740
|
if (!entry)
|
|
@@ -4778,12 +4746,12 @@ function insertBreak(editor) {
|
|
|
4778
4746
|
if (!Editor29.isEnd(editor, editor.selection.anchor, entry[1]))
|
|
4779
4747
|
return false;
|
|
4780
4748
|
const nextPath = Path7.next(entry[1]);
|
|
4781
|
-
|
|
4749
|
+
Transforms19.insertNodes(
|
|
4782
4750
|
editor,
|
|
4783
4751
|
{ type: "paragraph", children: [{ text: "" }] },
|
|
4784
4752
|
{ at: nextPath }
|
|
4785
4753
|
);
|
|
4786
|
-
|
|
4754
|
+
Transforms19.select(editor, {
|
|
4787
4755
|
anchor: Editor29.start(editor, nextPath),
|
|
4788
4756
|
focus: Editor29.start(editor, nextPath)
|
|
4789
4757
|
});
|
|
@@ -5156,7 +5124,7 @@ function indent(editor) {
|
|
|
5156
5124
|
}
|
|
5157
5125
|
|
|
5158
5126
|
// src/list-plugin/methods/insert-break.ts
|
|
5159
|
-
import { Editor as Editor31, Transforms as
|
|
5127
|
+
import { Editor as Editor31, Transforms as Transforms20 } from "slate";
|
|
5160
5128
|
function insertBreak2(editor) {
|
|
5161
5129
|
const entry = findElementUp(editor, isListItem);
|
|
5162
5130
|
if (!entry)
|
|
@@ -5164,19 +5132,19 @@ function insertBreak2(editor) {
|
|
|
5164
5132
|
const [element, path] = entry;
|
|
5165
5133
|
if (Editor31.isEmpty(editor, element)) {
|
|
5166
5134
|
if (element.depth > 0) {
|
|
5167
|
-
|
|
5135
|
+
Transforms20.setNodes(editor, { depth: element.depth - 1 }, { at: path });
|
|
5168
5136
|
return true;
|
|
5169
5137
|
} else {
|
|
5170
5138
|
rewrapElement(editor, { type: "paragraph" }, path);
|
|
5171
5139
|
return true;
|
|
5172
5140
|
}
|
|
5173
5141
|
}
|
|
5174
|
-
|
|
5142
|
+
Transforms20.splitNodes(editor, { always: true });
|
|
5175
5143
|
const nextEntry = findElementUp(editor, isListItem);
|
|
5176
5144
|
if (!nextEntry)
|
|
5177
5145
|
return true;
|
|
5178
5146
|
if (nextEntry[0].type === "task-list-item" && nextEntry[0].checked === true) {
|
|
5179
|
-
|
|
5147
|
+
Transforms20.setNodes(editor, { checked: false }, { at: nextEntry[1] });
|
|
5180
5148
|
}
|
|
5181
5149
|
return true;
|
|
5182
5150
|
}
|
|
@@ -5203,7 +5171,7 @@ function outdent(editor) {
|
|
|
5203
5171
|
}
|
|
5204
5172
|
|
|
5205
5173
|
// src/list-plugin/methods/toggleTaskListItem.ts
|
|
5206
|
-
import { Transforms as
|
|
5174
|
+
import { Transforms as Transforms21 } from "slate";
|
|
5207
5175
|
function toggleTaskListItem(editor, { at = editor.selection } = {}) {
|
|
5208
5176
|
const taskListItem = findElementUp(
|
|
5209
5177
|
editor,
|
|
@@ -5213,7 +5181,7 @@ function toggleTaskListItem(editor, { at = editor.selection } = {}) {
|
|
|
5213
5181
|
if (!taskListItem)
|
|
5214
5182
|
return false;
|
|
5215
5183
|
const nextChecked = !taskListItem[0].checked;
|
|
5216
|
-
|
|
5184
|
+
Transforms21.setNodes(
|
|
5217
5185
|
editor,
|
|
5218
5186
|
{ checked: nextChecked },
|
|
5219
5187
|
{ at: taskListItem[1] }
|
|
@@ -5239,7 +5207,7 @@ function createListMethods(editor) {
|
|
|
5239
5207
|
}
|
|
5240
5208
|
|
|
5241
5209
|
// src/list-plugin/normalize-node/normalize-ordered-first-at-depth.ts
|
|
5242
|
-
import { Element as Element17, Transforms as
|
|
5210
|
+
import { Element as Element17, Transforms as Transforms22 } from "slate";
|
|
5243
5211
|
var isOrderedListItem = createIsElementType([
|
|
5244
5212
|
"ordered-list-item"
|
|
5245
5213
|
]);
|
|
@@ -5252,7 +5220,7 @@ function normalizeOrderedFirstAtDepth(editor, entry) {
|
|
|
5252
5220
|
return false;
|
|
5253
5221
|
const __firstAtDepth = isOrderedListItem(a[0]) ? b[0].depth > a[0].depth : isListItem(a[0]) ? b[0].depth > a[0].depth : true;
|
|
5254
5222
|
if (b[0].__firstAtDepth !== __firstAtDepth) {
|
|
5255
|
-
|
|
5223
|
+
Transforms22.setNodes(editor, { __firstAtDepth }, { at: b[1] });
|
|
5256
5224
|
return true;
|
|
5257
5225
|
}
|
|
5258
5226
|
return false;
|
|
@@ -5522,7 +5490,7 @@ import { clsx as clsx7 } from "clsx";
|
|
|
5522
5490
|
import { Editor as Editor38, Point as Point2, Range as Range6 } from "slate";
|
|
5523
5491
|
|
|
5524
5492
|
// src/marks-plugin/methods/removeMarks.ts
|
|
5525
|
-
import { Editor as Editor36, Text as Text4, Transforms as
|
|
5493
|
+
import { Editor as Editor36, Text as Text4, Transforms as Transforms23 } from "slate";
|
|
5526
5494
|
function removeMarks(editor, { at = editor.selection } = {}) {
|
|
5527
5495
|
if (at == null)
|
|
5528
5496
|
return;
|
|
@@ -5540,7 +5508,7 @@ function removeMarks(editor, { at = editor.selection } = {}) {
|
|
|
5540
5508
|
setter[key2] = null;
|
|
5541
5509
|
}
|
|
5542
5510
|
}
|
|
5543
|
-
|
|
5511
|
+
Transforms23.setNodes(editor, setter, {
|
|
5544
5512
|
match: (n) => Text4.isText(n),
|
|
5545
5513
|
split: true,
|
|
5546
5514
|
at
|
|
@@ -5727,7 +5695,7 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
|
|
|
5727
5695
|
import { Element as Element19 } from "slate";
|
|
5728
5696
|
|
|
5729
5697
|
// src/table-plugin/delete-fragment/index.ts
|
|
5730
|
-
import { Editor as Editor41, Path as Path10, Transforms as
|
|
5698
|
+
import { Editor as Editor41, Path as Path10, Transforms as Transforms25 } from "slate";
|
|
5731
5699
|
|
|
5732
5700
|
// src/table-plugin/delete-fragment/get-reversed-delete-safe-ranges.ts
|
|
5733
5701
|
import { Editor as Editor40, Path as Path9 } from "slate";
|
|
@@ -5782,15 +5750,15 @@ function deleteFragmentWithProtectedTypes(editor, protectedTypes) {
|
|
|
5782
5750
|
);
|
|
5783
5751
|
Editor41.withoutNormalizing(editor, () => {
|
|
5784
5752
|
for (const range of reversedRanges) {
|
|
5785
|
-
|
|
5753
|
+
Transforms25.delete(editor, { at: range });
|
|
5786
5754
|
}
|
|
5787
|
-
|
|
5755
|
+
Transforms25.collapse(editor, { edge: "start" });
|
|
5788
5756
|
});
|
|
5789
5757
|
return true;
|
|
5790
5758
|
}
|
|
5791
5759
|
|
|
5792
5760
|
// src/table-plugin/methods/index.ts
|
|
5793
|
-
import { Transforms as
|
|
5761
|
+
import { Transforms as Transforms33 } from "slate";
|
|
5794
5762
|
|
|
5795
5763
|
// src/table-plugin/methods/get-table-info.ts
|
|
5796
5764
|
function getTableInfo(editor, { at = editor.selection } = {}) {
|
|
@@ -5828,7 +5796,7 @@ function getTableInfo(editor, { at = editor.selection } = {}) {
|
|
|
5828
5796
|
}
|
|
5829
5797
|
|
|
5830
5798
|
// src/table-plugin/methods/insert-column.ts
|
|
5831
|
-
import { Editor as Editor42, Transforms as
|
|
5799
|
+
import { Editor as Editor42, Transforms as Transforms26 } from "slate";
|
|
5832
5800
|
|
|
5833
5801
|
// src/table-plugin/methods/utils.ts
|
|
5834
5802
|
function createCell(index, children = [
|
|
@@ -5854,9 +5822,9 @@ function insertColumn(editor, { offset = 0, at = editor.selection } = {}) {
|
|
|
5854
5822
|
const { columns } = tableElement;
|
|
5855
5823
|
const nextColumns = [...columns];
|
|
5856
5824
|
nextColumns.splice(nextCellIndex, 0, columns[nextCellIndex]);
|
|
5857
|
-
|
|
5825
|
+
Transforms26.setNodes(editor, { columns: nextColumns }, { at: tablePath });
|
|
5858
5826
|
tableElement.children.forEach((rowElement, i) => {
|
|
5859
|
-
|
|
5827
|
+
Transforms26.insertNodes(editor, createCell(nextCellIndex), {
|
|
5860
5828
|
at: [...tablePath, i, nextCellIndex]
|
|
5861
5829
|
});
|
|
5862
5830
|
});
|
|
@@ -5865,7 +5833,7 @@ function insertColumn(editor, { offset = 0, at = editor.selection } = {}) {
|
|
|
5865
5833
|
}
|
|
5866
5834
|
|
|
5867
5835
|
// src/table-plugin/methods/insert-row.ts
|
|
5868
|
-
import { Transforms as
|
|
5836
|
+
import { Transforms as Transforms27 } from "slate";
|
|
5869
5837
|
function createRow(columnCount) {
|
|
5870
5838
|
return {
|
|
5871
5839
|
type: "table-row",
|
|
@@ -5877,7 +5845,7 @@ function insertRow(editor, { at = editor.selection, offset = 0 } = {}) {
|
|
|
5877
5845
|
if (!t2)
|
|
5878
5846
|
return false;
|
|
5879
5847
|
const nextRowElement = createRow(t2.tableElement.columns.length);
|
|
5880
|
-
|
|
5848
|
+
Transforms27.insertNodes(editor, nextRowElement, {
|
|
5881
5849
|
at: [...t2.tablePath, t2.rowIndex + offset]
|
|
5882
5850
|
});
|
|
5883
5851
|
return true;
|
|
@@ -5887,7 +5855,7 @@ function insertRowBelow(editor, { at } = {}) {
|
|
|
5887
5855
|
}
|
|
5888
5856
|
|
|
5889
5857
|
// src/table-plugin/methods/insert-table.ts
|
|
5890
|
-
import { Editor as Editor44, Element as Element18, Path as Path11, Transforms as
|
|
5858
|
+
import { Editor as Editor44, Element as Element18, Path as Path11, Transforms as Transforms28 } from "slate";
|
|
5891
5859
|
function createRange(size) {
|
|
5892
5860
|
return [...Array(size).keys()];
|
|
5893
5861
|
}
|
|
@@ -5921,17 +5889,17 @@ function insertRootElement2(editor, element, { at = editor.selection } = {}) {
|
|
|
5921
5889
|
if (entry == null) {
|
|
5922
5890
|
const selection = editor.selection;
|
|
5923
5891
|
Editor44.withoutNormalizing(editor, () => {
|
|
5924
|
-
|
|
5892
|
+
Transforms28.insertNodes(editor, element, { at });
|
|
5925
5893
|
if (selection) {
|
|
5926
|
-
|
|
5927
|
-
|
|
5894
|
+
Transforms28.select(editor, selection);
|
|
5895
|
+
Transforms28.move(editor);
|
|
5928
5896
|
}
|
|
5929
5897
|
});
|
|
5930
5898
|
} else {
|
|
5931
5899
|
const nextPath = Path11.next(entry[1]);
|
|
5932
5900
|
Editor44.withoutNormalizing(editor, () => {
|
|
5933
|
-
|
|
5934
|
-
|
|
5901
|
+
Transforms28.insertNodes(editor, element, { at: nextPath });
|
|
5902
|
+
Transforms28.select(editor, Editor44.start(editor, nextPath));
|
|
5935
5903
|
});
|
|
5936
5904
|
}
|
|
5937
5905
|
return true;
|
|
@@ -6011,15 +5979,15 @@ function up(editor) {
|
|
|
6011
5979
|
}
|
|
6012
5980
|
|
|
6013
5981
|
// src/table-plugin/methods/remove-column.ts
|
|
6014
|
-
import { Editor as Editor47, Transforms as
|
|
5982
|
+
import { Editor as Editor47, Transforms as Transforms30 } from "slate";
|
|
6015
5983
|
|
|
6016
5984
|
// src/table-plugin/methods/remove-table.ts
|
|
6017
|
-
import { Transforms as
|
|
5985
|
+
import { Transforms as Transforms29 } from "slate";
|
|
6018
5986
|
function removeTable(editor) {
|
|
6019
5987
|
const t2 = editor.tablePlugin.getTableInfo();
|
|
6020
5988
|
if (t2 === void 0)
|
|
6021
5989
|
return false;
|
|
6022
|
-
|
|
5990
|
+
Transforms29.removeNodes(editor, { at: t2.tablePath });
|
|
6023
5991
|
return true;
|
|
6024
5992
|
}
|
|
6025
5993
|
|
|
@@ -6035,9 +6003,9 @@ function removeColumn(editor, { at = editor.selection } = {}) {
|
|
|
6035
6003
|
Editor47.withoutNormalizing(editor, () => {
|
|
6036
6004
|
const columns = [...tableElement.columns];
|
|
6037
6005
|
columns.splice(cellIndex, 1);
|
|
6038
|
-
|
|
6006
|
+
Transforms30.setNodes(editor, { columns }, { at: tablePath });
|
|
6039
6007
|
tableElement.children.forEach((rowElement, rowIndex2) => {
|
|
6040
|
-
|
|
6008
|
+
Transforms30.removeNodes(editor, {
|
|
6041
6009
|
at: [...tablePath, rowIndex2, cellIndex]
|
|
6042
6010
|
});
|
|
6043
6011
|
});
|
|
@@ -6046,12 +6014,12 @@ function removeColumn(editor, { at = editor.selection } = {}) {
|
|
|
6046
6014
|
rowIndex,
|
|
6047
6015
|
Math.min(cellIndex, cellCount - 2)
|
|
6048
6016
|
]);
|
|
6049
|
-
|
|
6017
|
+
Transforms30.select(editor, selection);
|
|
6050
6018
|
});
|
|
6051
6019
|
}
|
|
6052
6020
|
|
|
6053
6021
|
// src/table-plugin/methods/remove-row.ts
|
|
6054
|
-
import { Editor as Editor48, Transforms as
|
|
6022
|
+
import { Editor as Editor48, Transforms as Transforms31 } from "slate";
|
|
6055
6023
|
function removeRow(editor, { at = editor.selection } = {}) {
|
|
6056
6024
|
const t2 = getTableInfo(editor, { at });
|
|
6057
6025
|
if (t2 === void 0)
|
|
@@ -6061,8 +6029,8 @@ function removeRow(editor, { at = editor.selection } = {}) {
|
|
|
6061
6029
|
return true;
|
|
6062
6030
|
}
|
|
6063
6031
|
Editor48.withoutNormalizing(editor, () => {
|
|
6064
|
-
|
|
6065
|
-
|
|
6032
|
+
Transforms31.removeNodes(editor, { at: t2.rowPath });
|
|
6033
|
+
Transforms31.select(
|
|
6066
6034
|
editor,
|
|
6067
6035
|
Editor48.start(editor, [
|
|
6068
6036
|
...t2.tablePath,
|
|
@@ -6075,7 +6043,7 @@ function removeRow(editor, { at = editor.selection } = {}) {
|
|
|
6075
6043
|
}
|
|
6076
6044
|
|
|
6077
6045
|
// src/table-plugin/methods/setTableColumnAlign.ts
|
|
6078
|
-
import { Transforms as
|
|
6046
|
+
import { Transforms as Transforms32 } from "slate";
|
|
6079
6047
|
function setTableColumnAlign(editor, options) {
|
|
6080
6048
|
const t2 = getTableInfo(editor);
|
|
6081
6049
|
if (t2 === void 0)
|
|
@@ -6083,7 +6051,7 @@ function setTableColumnAlign(editor, options) {
|
|
|
6083
6051
|
const { tableElement, tablePath, cellIndex } = t2;
|
|
6084
6052
|
const nextColumns = tableElement.columns.slice();
|
|
6085
6053
|
nextColumns.splice(cellIndex, 1, { align: options.align });
|
|
6086
|
-
|
|
6054
|
+
Transforms32.setNodes(editor, { columns: nextColumns }, { at: tablePath });
|
|
6087
6055
|
return true;
|
|
6088
6056
|
}
|
|
6089
6057
|
|
|
@@ -6143,12 +6111,12 @@ function selectCell(editor, { at = editor.selection } = {}) {
|
|
|
6143
6111
|
if (t2 === void 0)
|
|
6144
6112
|
return false;
|
|
6145
6113
|
const { cellPath } = t2;
|
|
6146
|
-
|
|
6114
|
+
Transforms33.select(editor, cellPath);
|
|
6147
6115
|
return true;
|
|
6148
6116
|
}
|
|
6149
6117
|
|
|
6150
6118
|
// src/table-plugin/normalize/normalize-table.ts
|
|
6151
|
-
import { Transforms as
|
|
6119
|
+
import { Transforms as Transforms34 } from "slate";
|
|
6152
6120
|
function normalizeTableIndexes(editor, entry) {
|
|
6153
6121
|
let isTransformed = false;
|
|
6154
6122
|
const rowElements = entry[0].children;
|
|
@@ -6156,7 +6124,7 @@ function normalizeTableIndexes(editor, entry) {
|
|
|
6156
6124
|
const cellElements = rowElement.children;
|
|
6157
6125
|
cellElements.forEach((cellElement, x) => {
|
|
6158
6126
|
if (cellElement.x !== x || cellElement.y !== y) {
|
|
6159
|
-
|
|
6127
|
+
Transforms34.setNodes(editor, { x, y }, { at: [...entry[1], y, x] });
|
|
6160
6128
|
isTransformed = true;
|
|
6161
6129
|
}
|
|
6162
6130
|
});
|
|
@@ -6165,14 +6133,14 @@ function normalizeTableIndexes(editor, entry) {
|
|
|
6165
6133
|
}
|
|
6166
6134
|
|
|
6167
6135
|
// src/table-plugin/normalize/normalize-table-cell.ts
|
|
6168
|
-
import { Editor as Editor52, Transforms as
|
|
6136
|
+
import { Editor as Editor52, Transforms as Transforms35 } from "slate";
|
|
6169
6137
|
function normalizeTableCell(editor, entry) {
|
|
6170
6138
|
const [node, path] = entry;
|
|
6171
6139
|
if (node.children.length === 1 && node.children[0].type === "table-content") {
|
|
6172
6140
|
return false;
|
|
6173
6141
|
}
|
|
6174
6142
|
Editor52.withoutNormalizing(editor, () => {
|
|
6175
|
-
|
|
6143
|
+
Transforms35.insertNodes(
|
|
6176
6144
|
editor,
|
|
6177
6145
|
{
|
|
6178
6146
|
type: "table-content",
|
|
@@ -6181,9 +6149,9 @@ function normalizeTableCell(editor, entry) {
|
|
|
6181
6149
|
{ at: [...entry[1], 0] }
|
|
6182
6150
|
);
|
|
6183
6151
|
for (let i = node.children.length; i >= 0; i--) {
|
|
6184
|
-
|
|
6152
|
+
Transforms35.mergeNodes(editor, { at: [...path, i] });
|
|
6185
6153
|
}
|
|
6186
|
-
|
|
6154
|
+
Transforms35.delete(editor, {
|
|
6187
6155
|
at: { path: [...path, 0, 0], offset: 0 },
|
|
6188
6156
|
unit: "character"
|
|
6189
6157
|
});
|
|
@@ -6869,7 +6837,7 @@ var ThemePlugin = createPlugin((editor) => {
|
|
|
6869
6837
|
// src/toolbar-plugin/render-editable/index.tsx
|
|
6870
6838
|
import { clsx as clsx10 } from "clsx";
|
|
6871
6839
|
import { useCallback as useCallback14, useRef as useRef11 } from "react";
|
|
6872
|
-
import { Editor as Editor54, Transforms as
|
|
6840
|
+
import { Editor as Editor54, Transforms as Transforms36 } from "slate";
|
|
6873
6841
|
import { ReactEditor as ReactEditor14, useFocused, useSlateStatic as useSlateStatic21 } from "slate-react";
|
|
6874
6842
|
|
|
6875
6843
|
// src/toolbar-plugin/components/dialog/table-dialog.tsx
|
|
@@ -7587,7 +7555,7 @@ function renderEditable({ attributes, Editable: Editable3 }) {
|
|
|
7587
7555
|
(e) => {
|
|
7588
7556
|
if (e.target !== e.currentTarget)
|
|
7589
7557
|
return;
|
|
7590
|
-
|
|
7558
|
+
Transforms36.select(editor, Editor54.end(editor, []));
|
|
7591
7559
|
ReactEditor14.focus(editor);
|
|
7592
7560
|
},
|
|
7593
7561
|
[editor]
|
|
@@ -7637,7 +7605,7 @@ var ToolbarPlugin = createPlugin(
|
|
|
7637
7605
|
);
|
|
7638
7606
|
|
|
7639
7607
|
// src/trailing-block-plugin/index.tsx
|
|
7640
|
-
import { Editor as Editor55, Node as Node10, Path as Path13, Transforms as
|
|
7608
|
+
import { Editor as Editor55, Node as Node10, Path as Path13, Transforms as Transforms37 } from "slate";
|
|
7641
7609
|
var TrailingBlockPlugin = createPlugin(
|
|
7642
7610
|
(editor) => {
|
|
7643
7611
|
editor.allowTrailingBlock = true;
|
|
@@ -7653,7 +7621,7 @@ var TrailingBlockPlugin = createPlugin(
|
|
|
7653
7621
|
editor.children.length - 1
|
|
7654
7622
|
);
|
|
7655
7623
|
if (Editor55.hasBlocks(editor, lastElement) || Editor55.isVoid(editor, lastElement)) {
|
|
7656
|
-
|
|
7624
|
+
Transforms37.insertNodes(
|
|
7657
7625
|
editor,
|
|
7658
7626
|
{ type: "paragraph", children: [{ text: "" }] },
|
|
7659
7627
|
{
|
|
@@ -7669,10 +7637,10 @@ var TrailingBlockPlugin = createPlugin(
|
|
|
7669
7637
|
);
|
|
7670
7638
|
|
|
7671
7639
|
// src/paste-markdown-plugin/methods/index.ts
|
|
7672
|
-
import { Transforms as
|
|
7640
|
+
import { Transforms as Transforms38 } from "slate";
|
|
7673
7641
|
function pasteMarkdown(editor, markdown) {
|
|
7674
7642
|
const fragment = parse(markdown);
|
|
7675
|
-
|
|
7643
|
+
Transforms38.insertNodes(editor, fragment);
|
|
7676
7644
|
}
|
|
7677
7645
|
function createPasteMarkdownMethods(editor) {
|
|
7678
7646
|
return {
|
|
@@ -7756,7 +7724,7 @@ var { withSink, SinkEditable: SinkEditable2 } = Sink;
|
|
|
7756
7724
|
|
|
7757
7725
|
// src/entry/useEditor.tsx
|
|
7758
7726
|
import { useState as useState10 } from "react";
|
|
7759
|
-
import { createEditor, Editor as Editor57, Transforms as
|
|
7727
|
+
import { createEditor, Editor as Editor57, Transforms as Transforms39 } from "slate";
|
|
7760
7728
|
import { withHistory } from "slate-history";
|
|
7761
7729
|
import { withReact } from "slate-react";
|
|
7762
7730
|
function useEditor({
|
|
@@ -7791,7 +7759,7 @@ function useEditor({
|
|
|
7791
7759
|
const documentValue = parse(markdown);
|
|
7792
7760
|
editor2.children = documentValue;
|
|
7793
7761
|
editor2.selection = null;
|
|
7794
|
-
|
|
7762
|
+
Transforms39.select(editor2, Editor57.start(editor2, [0]));
|
|
7795
7763
|
};
|
|
7796
7764
|
return nextEditor;
|
|
7797
7765
|
});
|
|
@@ -7851,7 +7819,7 @@ function Editable2({
|
|
|
7851
7819
|
const documentValue = parse(value);
|
|
7852
7820
|
editor.children = documentValue;
|
|
7853
7821
|
editor.selection = null;
|
|
7854
|
-
|
|
7822
|
+
Transforms40.select(editor, Editor58.start(editor, [0]));
|
|
7855
7823
|
}
|
|
7856
7824
|
}
|
|
7857
7825
|
const onSinkeEditableMouseDown = useCallback15(() => {
|