@uiw/react-md-editor 3.11.2 → 3.12.1
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 +2 -1
- package/dist/mdeditor.js +115 -149
- package/dist/mdeditor.min.js +1 -1
- package/dist/mdeditor.min.js.LICENSE.txt +10 -9
- package/esm/Editor.d.ts +5 -1
- package/esm/Editor.js +9 -7
- package/esm/Editor.js.map +3 -2
- package/esm/commands/code.js +10 -1
- package/esm/commands/code.js.map +2 -2
- package/lib/Editor.d.ts +5 -1
- package/lib/Editor.js +13 -9
- package/lib/Editor.js.map +3 -2
- package/lib/commands/code.js +10 -1
- package/lib/commands/code.js.map +2 -2
- package/package.json +1 -1
- package/src/Editor.tsx +13 -4
- package/src/__test__/editor.test.tsx +28 -3
- package/src/commands/code.tsx +8 -1
package/README.md
CHANGED
|
@@ -478,7 +478,8 @@ Inherit custom color variables by adding [`.wmde-markdown-var`](https://github.c
|
|
|
478
478
|
### Props
|
|
479
479
|
|
|
480
480
|
- `value: string`: The Markdown value.
|
|
481
|
-
- `onChange?: (value
|
|
481
|
+
- `onChange?: (value?: string, event?: React.ChangeEvent<HTMLTextAreaElement>, state?: ContextStore)`: Event handler for the `onChange` event.
|
|
482
|
+
- `onHeightChange?: (value?: number, oldValue?: number, state?: ContextStore)`: editor height change listener.
|
|
482
483
|
- `commands?: ICommand[]`: An array of [`ICommand`](https://github.com/uiwjs/react-md-editor/blob/d02543050c9abd8f7c72ae02b6421ac2e6ae421a/src/commands/index.ts#L39-L57), which, each one, contain a [`commands`](https://github.com/uiwjs/react-md-editor/blob/d02543050c9abd8f7c72ae02b6421ac2e6ae421a/src/commands/index.ts#L155-L180) property. If no commands are specified, the default will be used. Commands are explained in more details below.
|
|
483
484
|
- `commandsFilter?: (command: ICommand, isExtra: boolean) => false | ICommand`: Filter or modify your commands.
|
|
484
485
|
- `extraCommands?: ICommand[]`: Displayed on the right side of the toolbar.
|
package/dist/mdeditor.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
exports["@uiw/react-md-editor"] = factory(require("react"));
|
|
8
8
|
else
|
|
9
9
|
root["@uiw/react-md-editor"] = factory(root["React"]);
|
|
10
|
-
})(self,
|
|
10
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE__787__) => {
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ var __webpack_modules__ = ({
|
|
13
13
|
|
|
@@ -10990,7 +10990,8 @@ module.exports = ReactPropTypesSecret;
|
|
|
10990
10990
|
/***/ ((__unused_webpack_module, exports) => {
|
|
10991
10991
|
|
|
10992
10992
|
"use strict";
|
|
10993
|
-
/**
|
|
10993
|
+
/**
|
|
10994
|
+
* @license React
|
|
10994
10995
|
* react-is.production.min.js
|
|
10995
10996
|
*
|
|
10996
10997
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -10998,12 +10999,11 @@ module.exports = ReactPropTypesSecret;
|
|
|
10998
10999
|
* This source code is licensed under the MIT license found in the
|
|
10999
11000
|
* LICENSE file in the root directory of this source tree.
|
|
11000
11001
|
*/
|
|
11001
|
-
var b=
|
|
11002
|
-
if("
|
|
11003
|
-
function
|
|
11004
|
-
exports.
|
|
11005
|
-
exports.
|
|
11006
|
-
exports.typeOf=y;
|
|
11002
|
+
var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u=Symbol.for("react.module.reference");
|
|
11003
|
+
function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}exports.ContextConsumer=h;exports.ContextProvider=g;exports.Element=b;exports.ForwardRef=l;exports.Fragment=d;exports.Lazy=q;exports.Memo=p;exports.Portal=c;exports.Profiler=f;exports.StrictMode=e;exports.Suspense=m;
|
|
11004
|
+
exports.SuspenseList=n;exports.isAsyncMode=function(){return!1};exports.isConcurrentMode=function(){return!1};exports.isContextConsumer=function(a){return v(a)===h};exports.isContextProvider=function(a){return v(a)===g};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===b};exports.isForwardRef=function(a){return v(a)===l};exports.isFragment=function(a){return v(a)===d};exports.isLazy=function(a){return v(a)===q};exports.isMemo=function(a){return v(a)===p};
|
|
11005
|
+
exports.isPortal=function(a){return v(a)===c};exports.isProfiler=function(a){return v(a)===f};exports.isStrictMode=function(a){return v(a)===e};exports.isSuspense=function(a){return v(a)===m};exports.isSuspenseList=function(a){return v(a)===n};
|
|
11006
|
+
exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?!0:!1};exports.typeOf=v;
|
|
11007
11007
|
|
|
11008
11008
|
|
|
11009
11009
|
/***/ }),
|
|
@@ -21872,7 +21872,7 @@ const pointEnd = unist_util_position_point('end')
|
|
|
21872
21872
|
/**
|
|
21873
21873
|
* Get the positional info of `node`.
|
|
21874
21874
|
*
|
|
21875
|
-
* @param {NodeLike} [node]
|
|
21875
|
+
* @param {NodeLike|Node} [node]
|
|
21876
21876
|
* @returns {Position}
|
|
21877
21877
|
*/
|
|
21878
21878
|
function unist_util_position_position(node) {
|
|
@@ -21890,12 +21890,10 @@ function unist_util_position_point(type) {
|
|
|
21890
21890
|
/**
|
|
21891
21891
|
* Get the positional info of `node`.
|
|
21892
21892
|
*
|
|
21893
|
-
* @param {NodeLike} [node]
|
|
21893
|
+
* @param {NodeLike|Node} [node]
|
|
21894
21894
|
* @returns {Point}
|
|
21895
21895
|
*/
|
|
21896
21896
|
function point(node) {
|
|
21897
|
-
/** @type {Point} */
|
|
21898
|
-
// @ts-expect-error looks like a point
|
|
21899
21897
|
const point = (node && node.position && node.position[type]) || {}
|
|
21900
21898
|
|
|
21901
21899
|
return {
|
|
@@ -25755,7 +25753,7 @@ function flattenPosition(pos) {
|
|
|
25755
25753
|
* @typedef PluginOptions
|
|
25756
25754
|
* @property {PluggableList} [remarkPlugins=[]]
|
|
25757
25755
|
* @property {PluggableList} [rehypePlugins=[]]
|
|
25758
|
-
* @property {import('remark-rehype').Options} [remarkRehypeOptions={}]
|
|
25756
|
+
* @property {import('remark-rehype').Options | undefined} [remarkRehypeOptions={}]
|
|
25759
25757
|
*
|
|
25760
25758
|
* @typedef LayoutOptions
|
|
25761
25759
|
* @property {string} [className]
|
|
@@ -57669,27 +57667,22 @@ function indexedSearch(query, parent, state, from, firstElementOnly) {
|
|
|
57669
57667
|
* @typedef {Array<Tag>} Tags
|
|
57670
57668
|
* @typedef {string} Range
|
|
57671
57669
|
* @typedef {Array<Range>} Ranges
|
|
57672
|
-
|
|
57673
|
-
|
|
57674
|
-
/**
|
|
57670
|
+
*
|
|
57675
57671
|
* @callback Check
|
|
57676
57672
|
* @param {Tag} tag
|
|
57677
57673
|
* @param {Range} range
|
|
57678
57674
|
* @returns {boolean}
|
|
57675
|
+
*
|
|
57676
|
+
* @typedef {FilterOrLookup<true>} Filter
|
|
57677
|
+
* @typedef {FilterOrLookup<false>} Lookup
|
|
57679
57678
|
*/
|
|
57680
57679
|
|
|
57681
57680
|
/**
|
|
57682
|
-
* @
|
|
57683
|
-
* @
|
|
57684
|
-
* @param {
|
|
57685
|
-
* @
|
|
57686
|
-
|
|
57687
|
-
|
|
57688
|
-
/**
|
|
57689
|
-
* @callback Lookup
|
|
57690
|
-
* @param {Tag|Tags} tag
|
|
57691
|
-
* @param {Range|Ranges} [ranges]
|
|
57692
|
-
* @returns {Tag}
|
|
57681
|
+
* @template {boolean} IsFilter
|
|
57682
|
+
* @callback FilterOrLookup
|
|
57683
|
+
* @param {Tag|Tags} tags
|
|
57684
|
+
* @param {Range|Ranges} [ranges='*']
|
|
57685
|
+
* @returns {IsFilter extends true ? Tags : Tag|undefined}
|
|
57693
57686
|
*/
|
|
57694
57687
|
|
|
57695
57688
|
/**
|
|
@@ -57701,163 +57694,136 @@ function indexedSearch(query, parent, state, from, firstElementOnly) {
|
|
|
57701
57694
|
* iterates over tags. That way, earlier ranges matching any tag have
|
|
57702
57695
|
* precedence over later ranges.
|
|
57703
57696
|
*
|
|
57704
|
-
* @
|
|
57705
|
-
*
|
|
57706
|
-
*
|
|
57707
|
-
* }
|
|
57708
|
-
*/
|
|
57709
|
-
|
|
57710
|
-
|
|
57711
|
-
|
|
57712
|
-
|
|
57713
|
-
|
|
57714
|
-
|
|
57715
|
-
|
|
57716
|
-
|
|
57717
|
-
|
|
57718
|
-
|
|
57719
|
-
* @param {Tag|Tags} tags
|
|
57720
|
-
* @param {Range|Ranges} [ranges='*']
|
|
57721
|
-
* @returns {Tag|Tags|undefined}
|
|
57722
|
-
*/
|
|
57723
|
-
function match(tags, ranges) {
|
|
57724
|
-
let left = cast(tags, 'tag')
|
|
57725
|
-
const right = cast(
|
|
57726
|
-
ranges === null || ranges === undefined ? '*' : ranges,
|
|
57727
|
-
'range'
|
|
57728
|
-
)
|
|
57729
|
-
/** @type {Tags} */
|
|
57730
|
-
const matches = []
|
|
57731
|
-
let rightIndex = -1
|
|
57732
|
-
|
|
57733
|
-
while (++rightIndex < right.length) {
|
|
57734
|
-
const range = right[rightIndex].toLowerCase()
|
|
57697
|
+
* @template {boolean} IsFilter
|
|
57698
|
+
* @param {Check} check
|
|
57699
|
+
* @param {IsFilter} filter
|
|
57700
|
+
* @returns {FilterOrLookup<IsFilter>}
|
|
57701
|
+
*/
|
|
57702
|
+
function bcp_47_match_factory(check, filter) {
|
|
57703
|
+
return function (tags, ranges) {
|
|
57704
|
+
let left = cast(tags, 'tag')
|
|
57705
|
+
const right = cast(
|
|
57706
|
+
ranges === null || ranges === undefined ? '*' : ranges,
|
|
57707
|
+
'range'
|
|
57708
|
+
)
|
|
57709
|
+
/** @type {Tags} */
|
|
57710
|
+
const matches = []
|
|
57711
|
+
let rightIndex = -1
|
|
57735
57712
|
|
|
57736
|
-
|
|
57737
|
-
|
|
57713
|
+
while (++rightIndex < right.length) {
|
|
57714
|
+
const range = right[rightIndex].toLowerCase()
|
|
57738
57715
|
|
|
57739
|
-
|
|
57740
|
-
|
|
57741
|
-
const next = []
|
|
57716
|
+
// Ignore wildcards in lookup mode.
|
|
57717
|
+
if (!filter && range === '*') continue
|
|
57742
57718
|
|
|
57743
|
-
|
|
57744
|
-
|
|
57745
|
-
|
|
57746
|
-
|
|
57747
|
-
|
|
57748
|
-
|
|
57749
|
-
|
|
57719
|
+
let leftIndex = -1
|
|
57720
|
+
/** @type {Tags} */
|
|
57721
|
+
const next = []
|
|
57722
|
+
|
|
57723
|
+
while (++leftIndex < left.length) {
|
|
57724
|
+
if (check(left[leftIndex].toLowerCase(), range)) {
|
|
57725
|
+
// Exit if this is a lookup and we have a match.
|
|
57726
|
+
if (!filter) {
|
|
57727
|
+
return /** @type {IsFilter extends true ? Tags : Tag|undefined} */ (
|
|
57728
|
+
left[leftIndex]
|
|
57729
|
+
)
|
|
57750
57730
|
}
|
|
57751
|
-
}
|
|
57752
57731
|
|
|
57753
|
-
|
|
57732
|
+
matches.push(left[leftIndex])
|
|
57733
|
+
} else {
|
|
57734
|
+
next.push(left[leftIndex])
|
|
57735
|
+
}
|
|
57754
57736
|
}
|
|
57755
57737
|
|
|
57756
|
-
|
|
57757
|
-
// a match, so return `undefined`.
|
|
57758
|
-
return filter ? matches : undefined
|
|
57738
|
+
left = next
|
|
57759
57739
|
}
|
|
57740
|
+
|
|
57741
|
+
// If this is a filter, return the list. If it’s a lookup, we didn’t find
|
|
57742
|
+
// a match, so return `undefined`.
|
|
57743
|
+
return /** @type {IsFilter extends true ? Tags : Tag|undefined} */ (
|
|
57744
|
+
filter ? matches : undefined
|
|
57745
|
+
)
|
|
57760
57746
|
}
|
|
57761
|
-
|
|
57747
|
+
}
|
|
57762
57748
|
|
|
57763
57749
|
/**
|
|
57764
57750
|
* Basic Filtering (Section 3.3.1) matches a language priority list consisting
|
|
57765
57751
|
* of basic language ranges (Section 2.1) to sets of language tags.
|
|
57766
|
-
* @param {Tag|Tags} tags
|
|
57767
|
-
* @param {Range|Ranges} [ranges]
|
|
57768
|
-
* @returns {Tags}
|
|
57769
57752
|
*/
|
|
57770
|
-
const basicFilter = bcp_47_match_factory(
|
|
57771
|
-
|
|
57772
|
-
|
|
57773
|
-
return range === '*' || tag === range || tag.includes(range + '-')
|
|
57774
|
-
},
|
|
57775
|
-
true
|
|
57776
|
-
)
|
|
57753
|
+
const basicFilter = bcp_47_match_factory(function (tag, range) {
|
|
57754
|
+
return range === '*' || tag === range || tag.includes(range + '-')
|
|
57755
|
+
}, true)
|
|
57777
57756
|
|
|
57778
57757
|
/**
|
|
57779
57758
|
* Extended Filtering (Section 3.3.2) matches a language priority list
|
|
57780
57759
|
* consisting of extended language ranges (Section 2.2) to sets of language
|
|
57781
57760
|
* tags.
|
|
57782
|
-
|
|
57783
|
-
|
|
57784
|
-
|
|
57785
|
-
|
|
57786
|
-
const
|
|
57787
|
-
|
|
57788
|
-
|
|
57789
|
-
// 3.3.2.1
|
|
57790
|
-
const left = tag.split('-')
|
|
57791
|
-
const right = range.split('-')
|
|
57792
|
-
let leftIndex = 0
|
|
57793
|
-
let rightIndex = 0
|
|
57794
|
-
|
|
57795
|
-
// 3.3.2.2
|
|
57796
|
-
if (right[rightIndex] !== '*' && left[leftIndex] !== right[rightIndex]) {
|
|
57797
|
-
return false
|
|
57798
|
-
}
|
|
57799
|
-
|
|
57800
|
-
leftIndex++
|
|
57801
|
-
rightIndex++
|
|
57761
|
+
*/
|
|
57762
|
+
const extendedFilter = bcp_47_match_factory(function (tag, range) {
|
|
57763
|
+
// 3.3.2.1
|
|
57764
|
+
const left = tag.split('-')
|
|
57765
|
+
const right = range.split('-')
|
|
57766
|
+
let leftIndex = 0
|
|
57767
|
+
let rightIndex = 0
|
|
57802
57768
|
|
|
57803
|
-
|
|
57804
|
-
|
|
57805
|
-
|
|
57806
|
-
|
|
57807
|
-
rightIndex++
|
|
57808
|
-
continue
|
|
57809
|
-
}
|
|
57769
|
+
// 3.3.2.2
|
|
57770
|
+
if (right[rightIndex] !== '*' && left[leftIndex] !== right[rightIndex]) {
|
|
57771
|
+
return false
|
|
57772
|
+
}
|
|
57810
57773
|
|
|
57811
|
-
|
|
57812
|
-
|
|
57774
|
+
leftIndex++
|
|
57775
|
+
rightIndex++
|
|
57813
57776
|
|
|
57814
|
-
|
|
57815
|
-
|
|
57816
|
-
|
|
57817
|
-
|
|
57818
|
-
|
|
57819
|
-
|
|
57777
|
+
// 3.3.2.3
|
|
57778
|
+
while (rightIndex < right.length) {
|
|
57779
|
+
// 3.3.2.3.A
|
|
57780
|
+
if (right[rightIndex] === '*') {
|
|
57781
|
+
rightIndex++
|
|
57782
|
+
continue
|
|
57783
|
+
}
|
|
57820
57784
|
|
|
57821
|
-
|
|
57822
|
-
|
|
57785
|
+
// 3.3.2.3.B
|
|
57786
|
+
if (!left[leftIndex]) return false
|
|
57823
57787
|
|
|
57824
|
-
|
|
57788
|
+
// 3.3.2.3.C
|
|
57789
|
+
if (left[leftIndex] === right[rightIndex]) {
|
|
57825
57790
|
leftIndex++
|
|
57791
|
+
rightIndex++
|
|
57792
|
+
continue
|
|
57826
57793
|
}
|
|
57827
57794
|
|
|
57828
|
-
// 3.3.2.
|
|
57829
|
-
return
|
|
57830
|
-
|
|
57831
|
-
|
|
57832
|
-
|
|
57795
|
+
// 3.3.2.3.D
|
|
57796
|
+
if (left[leftIndex].length === 1) return false
|
|
57797
|
+
|
|
57798
|
+
// 3.3.2.3.E
|
|
57799
|
+
leftIndex++
|
|
57800
|
+
}
|
|
57801
|
+
|
|
57802
|
+
// 3.3.2.4
|
|
57803
|
+
return true
|
|
57804
|
+
}, true)
|
|
57833
57805
|
|
|
57834
57806
|
/**
|
|
57835
57807
|
* Lookup (Section 3.4) matches a language priority list consisting of basic
|
|
57836
57808
|
* language ranges to sets of language tags to find the one exact language tag
|
|
57837
57809
|
* that best matches the range.
|
|
57838
|
-
* @param {Tag|Tags} tags
|
|
57839
|
-
* @param {Range|Ranges} [ranges]
|
|
57840
|
-
* @returns {Tag}
|
|
57841
57810
|
*/
|
|
57842
|
-
const lookup = bcp_47_match_factory(
|
|
57843
|
-
|
|
57844
|
-
function (tag, range) {
|
|
57845
|
-
let right = range
|
|
57811
|
+
const lookup = bcp_47_match_factory(function (tag, range) {
|
|
57812
|
+
let right = range
|
|
57846
57813
|
|
|
57847
|
-
|
|
57848
|
-
|
|
57849
|
-
|
|
57814
|
+
/* eslint-disable-next-line no-constant-condition */
|
|
57815
|
+
while (true) {
|
|
57816
|
+
if (right === '*' || tag === right) return true
|
|
57850
57817
|
|
|
57851
|
-
|
|
57818
|
+
let index = right.lastIndexOf('-')
|
|
57852
57819
|
|
|
57853
|
-
|
|
57820
|
+
if (index < 0) return false
|
|
57854
57821
|
|
|
57855
|
-
|
|
57822
|
+
if (right.charAt(index - 2) === '-') index -= 2
|
|
57856
57823
|
|
|
57857
|
-
|
|
57858
|
-
}
|
|
57824
|
+
right = right.slice(0, index)
|
|
57859
57825
|
}
|
|
57860
|
-
)
|
|
57826
|
+
}, false)
|
|
57861
57827
|
|
|
57862
57828
|
/**
|
|
57863
57829
|
* Validate tags or ranges, and cast them to arrays.
|
|
@@ -61366,7 +61332,7 @@ api.setSelectionRange({start:state2.selection.end-2-state1.selectedText.length,e
|
|
|
61366
61332
|
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
|
|
61367
61333
|
var newSelectionRange=selectWord({text:tate.text,selection:tate.selection});var state1=api.setSelectionRange(newSelectionRange);// when there's no breaking line
|
|
61368
61334
|
if(state1.selectedText.indexOf('\n')===-1){api.replaceSelection("`".concat(state1.selectedText,"`"));// Adjust the selection to not contain the **
|
|
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:
|
|
61335
|
+
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:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"12",height:"12",role:"img",viewBox:"0 0 156 156",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M110.85 120.575 43.7 120.483333 43.7083334 110.091667 110.85 110.191667 110.841667 120.583333 110.85 120.575ZM85.1333334 87.1916666 43.625 86.7083332 43.7083334 76.3166666 85.2083334 76.7916666 85.1333334 87.1916666 85.1333334 87.1916666ZM110.841667 53.4166666 43.7 53.3166666 43.7083334 42.925 110.85 43.025 110.841667 53.4166666ZM36 138C27.2916666 138 20.75 136.216667 16.4 132.666667 12.1333334 129.2 10 124.308333 10 118L10 95.3333332C10 91.0666666 9.25 88.1333332 7.7333334 86.5333332 6.3166668 84.8416666 3.7333334 84 0 84L0 72C3.7333334 72 6.3083334 71.2 7.7333334 69.6 9.2416668 67.9083334 10 64.9333334 10 60.6666666L10 38C10 31.775 12.1333334 26.8833334 16.4 23.3333332 20.7583334 19.7749998 27.2916666 18 36 18L40.6666668 18 40.6666668 30 36 30C34.0212222 29.9719277 32.1263151 30.7979128 30.8 32.2666666 29.3605875 33.8216362 28.5938182 35.8823287 28.6666668 38L28.6666668 60.6666666C28.6666668 67.5083332 26.6666668 72.4 22.6666668 75.3333332 20.9317416 76.7274684 18.8640675 77.6464347 16.6666668 78 18.8916668 78.35 20.8916668 79.2416666 22.6666668 80.6666666 26.6666668 83.95 28.6666668 88.8416666 28.6666668 95.3333332L28.6666668 118C28.6666668 120.308333 29.3750002 122.216667 30.8 123.733333 32.2166666 125.241667 33.9583334 126 36 126L40.6666668 126 40.6666668 138 36 138 36 138ZM114.116667 126 118.783333 126C120.833333 126 122.566667 125.241667 123.983333 123.733333 125.422746 122.178364 126.189515 120.117671 126.116667 118L126.116667 95.3333332C126.116667 88.8333332 128.116667 83.9499998 132.116667 80.6666666 133.9 79.2416666 135.9 78.35 138.116667 78 135.919156 77.6468047 133.851391 76.7277979 132.116667 75.3333332 128.116667 72.3999998 126.116667 67.5 126.116667 60.6666666L126.116667 38C126.189515 35.8823287 125.422746 33.8216361 123.983333 32.2666666 122.657018 30.7979128 120.762111 29.9719277 118.783333 30L114.116667 30 114.116667 18 118.783333 18C127.5 18 133.983333 19.775 138.25 23.3333332 142.608333 26.8833332 144.783333 31.7749998 144.783333 38L144.783333 60.6666666C144.783333 64.9333332 145.5 67.9083332 146.916667 69.6 148.433333 71.2 151.05 72 154.783333 72L154.783333 84C151.05 84 148.433333 84.8333334 146.916667 86.5333332 145.5 88.1333332 144.783333 91.0666666 144.783333 95.3333332L144.783333 118C144.783333 124.308333 142.616667 129.2 138.25 132.666667 133.983333 136.216667 127.5 138 118.783333 138L114.116667 138 114.116667 126 114.116667 126Z"})}),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
|
|
61370
61336
|
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});}};
|
|
61371
61337
|
;// CONCATENATED MODULE: ./src/commands/italic.tsx
|
|
61372
61338
|
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
|
|
@@ -61521,14 +61487,14 @@ var DragBar_DragBar=function DragBar(props){var _ref=props||{},prefixCls=_ref.pr
|
|
|
61521
61487
|
// extracted by mini-css-extract-plugin
|
|
61522
61488
|
/* harmony default export */ const src = ({});
|
|
61523
61489
|
;// CONCATENATED MODULE: ./src/Editor.tsx
|
|
61524
|
-
var Editor_excluded=["prefixCls","className","value","commands","commandsFilter","extraCommands","height","toolbarHeight","enableScroll","visiableDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","tabSize","defaultTabEnable","onChange","hideToolbar","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}var InternalMDEditor=function InternalMDEditor(props,ref){var _ref=props||{},_ref$prefixCls=_ref.prefixCls,prefixCls=_ref$prefixCls===void 0?'w-md-editor':_ref$prefixCls,className=_ref.className,propsValue=_ref.value,_ref$commands=_ref.commands,commands=_ref$commands===void 0?commands_getCommands():_ref$commands,commandsFilter=_ref.commandsFilter,_ref$extraCommands=_ref.extraCommands,extraCommands=_ref$extraCommands===void 0?getExtraCommands():_ref$extraCommands,_ref$height=_ref.height,height=_ref$height===void 0?200:_ref$height,_ref$toolbarHeight=_ref.toolbarHeight,toolbarHeight=_ref$toolbarHeight===void 0?29:_ref$toolbarHeight,_ref$enableScroll=_ref.enableScroll,enableScroll=_ref$enableScroll===void 0?true:_ref$enableScroll,_ref$visiableDragbar=_ref.visiableDragbar,visiableDragbar=_ref$visiableDragbar===void 0?true:_ref$visiableDragbar,_ref$highlightEnable=_ref.highlightEnable,highlightEnable=_ref$highlightEnable===void 0?true:_ref$highlightEnable,_ref$preview=_ref.preview,previewType=_ref$preview===void 0?'live':_ref$preview,_ref$fullscreen=_ref.fullscreen,fullscreen=_ref$fullscreen===void 0?false:_ref$fullscreen,_ref$overflow=_ref.overflow,overflow=_ref$overflow===void 0?true:_ref$overflow,_ref$previewOptions=_ref.previewOptions,previewOptions=_ref$previewOptions===void 0?{}:_ref$previewOptions,textareaProps=_ref.textareaProps,_ref$maxHeight=_ref.maxHeight,maxHeight=_ref$maxHeight===void 0?1200:_ref$maxHeight,_ref$minHeight=_ref.minHeight,minHeight=_ref$minHeight===void 0?100:_ref$minHeight,autoFocus=_ref.autoFocus,_ref$tabSize=_ref.tabSize,tabSize=_ref$tabSize===void 0?2:_ref$tabSize,_ref$defaultTabEnable=_ref.defaultTabEnable,defaultTabEnable=_ref$defaultTabEnable===void 0?false:_ref$defaultTabEnable,_onChange=_ref.onChange,hideToolbar=_ref.hideToolbar,renderTextarea=_ref.renderTextarea,other=_objectWithoutProperties(_ref,Editor_excluded);var cmds=commands.map(function(item){return commandsFilter?commandsFilter(item,false):item;}).filter(Boolean);var extraCmds=extraCommands.map(function(item){return commandsFilter?commandsFilter(item,true):item;}).filter(Boolean);var _useReducer=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useReducer)(reducer,{markdown:propsValue,preview:previewType,height:height,highlightEnable:highlightEnable,tabSize:tabSize,defaultTabEnable:defaultTabEnable,scrollTop:0,scrollTopPreview:0,commands:cmds,extraCommands:extraCmds,fullscreen:fullscreen,barPopup:{}}),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var container=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return _objectSpread2({},state);});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var stateInit={};if(container.current){stateInit.container=container.current||undefined;}stateInit.markdown=propsValue||'';stateInit.barPopup={};if(dispatch){dispatch(_objectSpread2(_objectSpread2({},state),stateInit));}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61490
|
+
var Editor_excluded=["prefixCls","className","value","commands","commandsFilter","extraCommands","height","toolbarHeight","enableScroll","visiableDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","tabSize","defaultTabEnable","onChange","onHeightChange","hideToolbar","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}var InternalMDEditor=function InternalMDEditor(props,ref){var _ref=props||{},_ref$prefixCls=_ref.prefixCls,prefixCls=_ref$prefixCls===void 0?'w-md-editor':_ref$prefixCls,className=_ref.className,propsValue=_ref.value,_ref$commands=_ref.commands,commands=_ref$commands===void 0?commands_getCommands():_ref$commands,commandsFilter=_ref.commandsFilter,_ref$extraCommands=_ref.extraCommands,extraCommands=_ref$extraCommands===void 0?getExtraCommands():_ref$extraCommands,_ref$height=_ref.height,height=_ref$height===void 0?200:_ref$height,_ref$toolbarHeight=_ref.toolbarHeight,toolbarHeight=_ref$toolbarHeight===void 0?29:_ref$toolbarHeight,_ref$enableScroll=_ref.enableScroll,enableScroll=_ref$enableScroll===void 0?true:_ref$enableScroll,_ref$visiableDragbar=_ref.visiableDragbar,visiableDragbar=_ref$visiableDragbar===void 0?true:_ref$visiableDragbar,_ref$highlightEnable=_ref.highlightEnable,highlightEnable=_ref$highlightEnable===void 0?true:_ref$highlightEnable,_ref$preview=_ref.preview,previewType=_ref$preview===void 0?'live':_ref$preview,_ref$fullscreen=_ref.fullscreen,fullscreen=_ref$fullscreen===void 0?false:_ref$fullscreen,_ref$overflow=_ref.overflow,overflow=_ref$overflow===void 0?true:_ref$overflow,_ref$previewOptions=_ref.previewOptions,previewOptions=_ref$previewOptions===void 0?{}:_ref$previewOptions,textareaProps=_ref.textareaProps,_ref$maxHeight=_ref.maxHeight,maxHeight=_ref$maxHeight===void 0?1200:_ref$maxHeight,_ref$minHeight=_ref.minHeight,minHeight=_ref$minHeight===void 0?100:_ref$minHeight,autoFocus=_ref.autoFocus,_ref$tabSize=_ref.tabSize,tabSize=_ref$tabSize===void 0?2:_ref$tabSize,_ref$defaultTabEnable=_ref.defaultTabEnable,defaultTabEnable=_ref$defaultTabEnable===void 0?false:_ref$defaultTabEnable,_onChange=_ref.onChange,onHeightChange=_ref.onHeightChange,hideToolbar=_ref.hideToolbar,renderTextarea=_ref.renderTextarea,other=_objectWithoutProperties(_ref,Editor_excluded);var cmds=commands.map(function(item){return commandsFilter?commandsFilter(item,false):item;}).filter(Boolean);var extraCmds=extraCommands.map(function(item){return commandsFilter?commandsFilter(item,true):item;}).filter(Boolean);var _useReducer=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useReducer)(reducer,{markdown:propsValue,preview:previewType,height:height,highlightEnable:highlightEnable,tabSize:tabSize,defaultTabEnable:defaultTabEnable,scrollTop:0,scrollTopPreview:0,commands:cmds,extraCommands:extraCmds,fullscreen:fullscreen,barPopup:{}}),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var container=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return _objectSpread2({},state);});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var stateInit={};if(container.current){stateInit.container=container.current||undefined;}stateInit.markdown=propsValue||'';stateInit.barPopup={};if(dispatch){dispatch(_objectSpread2(_objectSpread2({},state),stateInit));}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61525
61491
|
},[]);var cls=[className,'wmde-markdown-var',prefixCls,state.preview?"".concat(prefixCls,"-show-").concat(state.preview):null,state.fullscreen?"".concat(prefixCls,"-fullscreen"):null].filter(Boolean).join(' ').trim();(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return propsValue!==state.markdown&&dispatch({markdown:propsValue||''});},[propsValue,state.markdown]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61526
61492
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return previewType!==state.preview&&dispatch({preview:previewType});},[previewType]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61527
|
-
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61528
61493
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return tabSize!==state.tabSize&&dispatch({tabSize:tabSize});},[tabSize]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return highlightEnable!==state.highlightEnable&&dispatch({highlightEnable:highlightEnable});},// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61529
61494
|
[highlightEnable]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61530
61495
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return autoFocus!==state.autoFocus&&dispatch({autoFocus:autoFocus});},[autoFocus]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return fullscreen!==state.fullscreen&&dispatch({fullscreen:fullscreen});},// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61531
|
-
[fullscreen])
|
|
61496
|
+
[fullscreen]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61497
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&onHeightChange&&onHeightChange(state.height,height,state);},[height,onHeightChange,state]);var textareaDomRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();var active=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('preview');var initScroll=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){textareaDomRef.current=state.textareaWarp;if(state.textareaWarp){state.textareaWarp.addEventListener('mouseover',function(){active.current='text';});state.textareaWarp.addEventListener('mouseleave',function(){active.current='preview';});}},[state.textareaWarp]);var handleScroll=function handleScroll(e,type){if(!enableScrollRef.current)return;var textareaDom=textareaDomRef.current;var previewDom=previewRef.current?previewRef.current.mdp.current:undefined;if(!initScroll.current){active.current=type;initScroll.current=true;}if(textareaDom&&previewDom){var scale=(textareaDom.scrollHeight-textareaDom.offsetHeight)/(previewDom.scrollHeight-previewDom.offsetHeight);if(e.target===textareaDom&&active.current==='text'){previewDom.scrollTop=textareaDom.scrollTop/scale;}if(e.target===previewDom&&active.current==='preview'){textareaDom.scrollTop=previewDom.scrollTop*scale;}var scrollTop=0;if(active.current==='text'){scrollTop=textareaDom.scrollTop||0;}else if(active.current==='preview'){scrollTop=previewDom.scrollTop||0;}dispatch({scrollTop:scrollTop});}};var mdPreview=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)(esm,_objectSpread2(_objectSpread2({},previewOptions),{},{onScroll:function onScroll(e){return handleScroll(e,'preview');},ref:previewRef,source:state.markdown||'',className:"".concat(prefixCls,"-preview ").concat(previewOptions.className||'')}));},[prefixCls,previewOptions,state.markdown]);return/*#__PURE__*/(0,jsx_runtime.jsx)(EditorContext.Provider,{value:_objectSpread2(_objectSpread2({},state),{},{dispatch:dispatch}),children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",_objectSpread2(_objectSpread2({ref:container,className:cls},other),{},{onClick:function onClick(){dispatch({barPopup:_objectSpread2({},setGroupPopFalse(state.barPopup))});},style:_objectSpread2(_objectSpread2({},other.style),{},{height:state.fullscreen?'100%':hideToolbar?Number(state.height)-toolbarHeight:state.height}),children:[!hideToolbar&&/*#__PURE__*/(0,jsx_runtime.jsx)(Toolbar_Toolbar,{prefixCls:prefixCls,height:toolbarHeight,overflow:overflow}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{className:"".concat(prefixCls,"-content"),style:{height:state.fullscreen?"calc(100% - ".concat(toolbarHeight,"px)"):Number(state.height)-toolbarHeight},children:[/(edit|live)/.test(state.preview||'')&&/*#__PURE__*/(0,jsx_runtime.jsx)(TextArea_TextArea,_objectSpread2(_objectSpread2({className:"".concat(prefixCls,"-input"),prefixCls:prefixCls,autoFocus:autoFocus},textareaProps),{},{onChange:function onChange(evn){_onChange&&_onChange(evn.target.value,evn,state);if(textareaProps&&textareaProps.onChange){textareaProps.onChange(evn);}},renderTextarea:renderTextarea,onScroll:function onScroll(e){return handleScroll(e,'text');}})),/(live|preview)/.test(state.preview||'')&&mdPreview]}),visiableDragbar&&!state.fullscreen&&/*#__PURE__*/(0,jsx_runtime.jsx)(components_DragBar,{prefixCls:prefixCls,height:state.height,maxHeight:maxHeight,minHeight:minHeight,onChange:function onChange(newHeight){dispatch({height:newHeight});}})]}))});};var mdEditor=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef(InternalMDEditor);mdEditor.Markdown=esm;/* harmony default export */ const Editor = (mdEditor);
|
|
61532
61498
|
;// CONCATENATED MODULE: ./src/index.tsx
|
|
61533
61499
|
/* harmony default export */ const src_0 = (Editor);
|
|
61534
61500
|
})();
|