@uiw/react-md-editor 3.11.1 → 3.11.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/README.md +1 -0
- package/dist/mdeditor.js +8 -9
- package/dist/mdeditor.min.js +1 -1
- package/esm/commands/code.js +4 -0
- package/esm/commands/code.js.map +2 -2
- package/lib/commands/code.js +4 -0
- package/lib/commands/code.js.map +2 -2
- package/package.json +1 -1
- package/src/commands/code.tsx +2 -0
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ A simple markdown editor with preview, implemented with React.js and TypeScript.
|
|
|
43
43
|
- 🚧 Does not depend on the [`uiw`](https://github.com/uiwjs/uiw) component library.
|
|
44
44
|
- 🚘 Automatic list on new lines.
|
|
45
45
|
- 😻 GitHub flavored markdown support.
|
|
46
|
+
- 🌒 Support dark-mode/night-mode **@v3.11.0+**.
|
|
46
47
|
- 💡 Support [next.js](https://github.com/uiwjs/react-md-editor/issues/52#issuecomment-848969341), [Use examples](#support-nextjs) in [next.js](https://nextjs.org/).
|
|
47
48
|
|
|
48
49
|
### Quick Start
|
package/dist/mdeditor.js
CHANGED
|
@@ -21855,20 +21855,19 @@ const visit =
|
|
|
21855
21855
|
;// CONCATENATED MODULE: ./node_modules/unist-util-position/index.js
|
|
21856
21856
|
/**
|
|
21857
21857
|
* @typedef {import('unist').Position} Position
|
|
21858
|
+
* @typedef {import('unist').Node} Node
|
|
21859
|
+
* @typedef {Record<string, unknown> & {type: string, position?: PositionLike|undefined}} NodeLike
|
|
21858
21860
|
* @typedef {import('unist').Point} Point
|
|
21859
21861
|
*
|
|
21860
21862
|
* @typedef {Partial<Point>} PointLike
|
|
21861
21863
|
*
|
|
21862
|
-
* @typedef
|
|
21864
|
+
* @typedef PositionLike
|
|
21863
21865
|
* @property {PointLike} [start]
|
|
21864
21866
|
* @property {PointLike} [end]
|
|
21865
|
-
*
|
|
21866
|
-
* @typedef {Object} NodeLike
|
|
21867
|
-
* @property {PositionLike} [position]
|
|
21868
21867
|
*/
|
|
21869
21868
|
|
|
21870
|
-
|
|
21871
|
-
|
|
21869
|
+
const pointStart = unist_util_position_point('start')
|
|
21870
|
+
const pointEnd = unist_util_position_point('end')
|
|
21872
21871
|
|
|
21873
21872
|
/**
|
|
21874
21873
|
* Get the positional info of `node`.
|
|
@@ -21896,8 +21895,8 @@ function unist_util_position_point(type) {
|
|
|
21896
21895
|
*/
|
|
21897
21896
|
function point(node) {
|
|
21898
21897
|
/** @type {Point} */
|
|
21899
|
-
// @ts-
|
|
21900
|
-
|
|
21898
|
+
// @ts-expect-error looks like a point
|
|
21899
|
+
const point = (node && node.position && node.position[type]) || {}
|
|
21901
21900
|
|
|
21902
21901
|
return {
|
|
21903
21902
|
line: point.line || null,
|
|
@@ -61367,7 +61366,7 @@ api.setSelectionRange({start:state2.selection.end-2-state1.selectedText.length,e
|
|
|
61367
61366
|
var code_code={name:'code',keyCommand:'code',shortcuts:'ctrlcmd+j',buttonProps:{'aria-label':'Insert code'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"12",height:"12",role:"img",viewBox:"0 0 640 512",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z"})}),execute:function execute(tate,api){// Adjust the selection to encompass the whole word if the caret is inside one
|
|
61368
61367
|
var newSelectionRange=selectWord({text:tate.text,selection:tate.selection});var state1=api.setSelectionRange(newSelectionRange);// when there's no breaking line
|
|
61369
61368
|
if(state1.selectedText.indexOf('\n')===-1){api.replaceSelection("`".concat(state1.selectedText,"`"));// Adjust the selection to not contain the **
|
|
61370
|
-
var _selectionStart=state1.selection.start+1;var _selectionEnd=_selectionStart+state1.selectedText.length;api.setSelectionRange({start:_selectionStart,end:_selectionEnd});return;}var breaksBeforeCount=getBreaksNeededForEmptyLineBefore(state1.text,state1.selection.start);var breaksBefore=Array(breaksBeforeCount+1).join('\n');var breaksAfterCount=getBreaksNeededForEmptyLineAfter(state1.text,state1.selection.end);var breaksAfter=Array(breaksAfterCount+1).join('\n');api.replaceSelection("".concat(breaksBefore,"```\n").concat(state1.selectedText,"\n```").concat(breaksAfter));var selectionStart=state1.selection.start+breaksBeforeCount+4;var selectionEnd=selectionStart+state1.selectedText.length;api.setSelectionRange({start:selectionStart,end:selectionEnd});}};var codeBlock={name:'codeBlock',keyCommand:'codeBlock',shortcuts:'ctrlcmd+shift+j',execute:function execute(tate,api){// Adjust the selection to encompass the whole word if the caret is inside one
|
|
61369
|
+
var _selectionStart=state1.selection.start+1;var _selectionEnd=_selectionStart+state1.selectedText.length;api.setSelectionRange({start:_selectionStart,end:_selectionEnd});return;}var breaksBeforeCount=getBreaksNeededForEmptyLineBefore(state1.text,state1.selection.start);var breaksBefore=Array(breaksBeforeCount+1).join('\n');var breaksAfterCount=getBreaksNeededForEmptyLineAfter(state1.text,state1.selection.end);var breaksAfter=Array(breaksAfterCount+1).join('\n');api.replaceSelection("".concat(breaksBefore,"```\n").concat(state1.selectedText,"\n```").concat(breaksAfter));var selectionStart=state1.selection.start+breaksBeforeCount+4;var selectionEnd=selectionStart+state1.selectedText.length;api.setSelectionRange({start:selectionStart,end:selectionEnd});}};var codeBlock={name:'codeBlock',keyCommand:'codeBlock',shortcuts:'ctrlcmd+shift+j',icon:code_code['icon'],buttonProps:{'aria-label':'Insert Code Block'},execute:function execute(tate,api){// Adjust the selection to encompass the whole word if the caret is inside one
|
|
61371
61370
|
var newSelectionRange=selectWord({text:tate.text,selection:tate.selection});var state1=api.setSelectionRange(newSelectionRange);var breaksBeforeCount=getBreaksNeededForEmptyLineBefore(state1.text,state1.selection.start);var breaksBefore=Array(breaksBeforeCount+1).join('\n');var breaksAfterCount=getBreaksNeededForEmptyLineAfter(state1.text,state1.selection.end);var breaksAfter=Array(breaksAfterCount+1).join('\n');api.replaceSelection("".concat(breaksBefore,"```\n").concat(state1.selectedText,"\n```").concat(breaksAfter));var selectionStart=state1.selection.start+breaksBeforeCount+4;var selectionEnd=selectionStart+state1.selectedText.length;api.setSelectionRange({start:selectionStart,end:selectionEnd});}};
|
|
61372
61371
|
;// CONCATENATED MODULE: ./src/commands/italic.tsx
|
|
61373
61372
|
var italic={name:'italic',keyCommand:'italic',shortcuts:'ctrlcmd+i',buttonProps:{'aria-label':'Add italic text',title:'Add italic text'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{"data-name":"italic",width:"12",height:"12",role:"img",viewBox:"0 0 320 512",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M204.758 416h-33.849l62.092-320h40.725a16 16 0 0 0 15.704-12.937l6.242-32C297.599 41.184 290.034 32 279.968 32H120.235a16 16 0 0 0-15.704 12.937l-6.242 32C96.362 86.816 103.927 96 113.993 96h33.846l-62.09 320H46.278a16 16 0 0 0-15.704 12.935l-6.245 32C22.402 470.815 29.967 480 40.034 480h158.479a16 16 0 0 0 15.704-12.935l6.245-32c1.927-9.88-5.638-19.065-15.704-19.065z"})}),execute:function execute(state,api){// Adjust the selection to encompass the whole word if the caret is inside one
|