markupeditor 0.9.17 → 0.9.19
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/config/toolbarconfig.json +5 -2
- package/dist/markup-editor.js +70 -11
- package/package.json +1 -1
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"insertBar": {
|
|
25
25
|
"link": true,
|
|
26
26
|
"image": true,
|
|
27
|
-
"tableMenu": true
|
|
27
|
+
"tableMenu": true,
|
|
28
|
+
"hRule": false
|
|
28
29
|
},
|
|
29
30
|
"formatBar": {
|
|
30
31
|
"bold": true,
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
"link": "Insert/edit link",
|
|
66
67
|
"image": "Insert/edit image",
|
|
67
68
|
"table": "Insert/edit table",
|
|
69
|
+
"hRule": "Insert horizontal rule",
|
|
68
70
|
"search": "Toggle search",
|
|
69
71
|
"searchForward": "Search forward",
|
|
70
72
|
"searchBackward": "Search backward",
|
|
@@ -107,6 +109,7 @@
|
|
|
107
109
|
"searchBackward": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z\"/></svg>",
|
|
108
110
|
"matchCase": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"m131-252 165-440h79l165 440h-76l-39-112H247l-40 112h-76Zm139-176h131l-64-182h-4l-63 182Zm395 186q-51 0-81-27.5T554-342q0-44 34.5-72.5T677-443q23 0 45 4t38 11v-12q0-29-20.5-47T685-505q-23 0-42 9.5T610-468l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T689-393q-32 0-50 14t-18 37q0 20 16 33t40 13Z\"/></svg>",
|
|
109
111
|
"paragraphStyle": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M360-160v-240q-83 0-141.5-58.5T160-600q0-83 58.5-141.5T360-800h360v80h-80v560h-80v-560H440v560h-80Z\"/></svg>",
|
|
110
|
-
"more": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z\"/></svg>"
|
|
112
|
+
"more": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z\"/></svg>",
|
|
113
|
+
"hRule": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\"> <path d=\"M160-440v-80h640v80H160Z\" fill=\"currentColor\"/> <path fill-rule=\"evenodd\" d=\"M935-760 A175,175,0,0,1,760-585 A175,175,0,0,1,585-760 A175,175,0,0,1,760-935 A175,175,0,0,1,935-760 Z M895-760 A135,135,0,0,1,760-625 A135,135,0,0,1,625-760 A135,135,0,0,1,760-895 A135,135,0,0,1,895-760 Z\" fill=\"currentColor\"/> <path d=\"M660-780H860V-740H660ZM740-860H780V-660H740Z\" fill=\"currentColor\"/></svg>"
|
|
111
114
|
}
|
|
112
115
|
}
|
package/dist/markup-editor.js
CHANGED
|
@@ -18296,10 +18296,11 @@ function paragraphStyle(state) {
|
|
|
18296
18296
|
|
|
18297
18297
|
/**
|
|
18298
18298
|
* Given a ProseMirror Node, return the HTML tag it corresponds to in the MarkupEditor.
|
|
18299
|
+
* Default is "P" if node.type.name is not recognized (e.g., for HR).
|
|
18299
18300
|
*
|
|
18300
18301
|
* @ignore
|
|
18301
18302
|
* @param {Node} node The node we want the paragraph style for
|
|
18302
|
-
* @returns { "P" | "H1" | "H2" | "H3" | "H4" | "H5" | "H6" | "PRE"
|
|
18303
|
+
* @returns { "P" | "H1" | "H2" | "H3" | "H4" | "H5" | "H6" | "PRE" }
|
|
18303
18304
|
*/
|
|
18304
18305
|
function _paragraphStyleFor(node) {
|
|
18305
18306
|
var style;
|
|
@@ -18313,6 +18314,8 @@ function _paragraphStyleFor(node) {
|
|
|
18313
18314
|
case 'code_block':
|
|
18314
18315
|
style = "PRE";
|
|
18315
18316
|
break;
|
|
18317
|
+
default:
|
|
18318
|
+
style = "P";
|
|
18316
18319
|
} return style;
|
|
18317
18320
|
}
|
|
18318
18321
|
function isIndented(activeState) {
|
|
@@ -18908,6 +18911,31 @@ function selectFullLink(view) {
|
|
|
18908
18911
|
view.dispatch(transaction);
|
|
18909
18912
|
}
|
|
18910
18913
|
|
|
18914
|
+
/********************************************************************************
|
|
18915
|
+
* Horizontal rule
|
|
18916
|
+
*/
|
|
18917
|
+
//MARK: Horizontal rile
|
|
18918
|
+
|
|
18919
|
+
/**
|
|
18920
|
+
* Insert the horizontal rule at the selection.
|
|
18921
|
+
*/
|
|
18922
|
+
function insertHRule() {
|
|
18923
|
+
const view = activeView();
|
|
18924
|
+
let command = insertHRuleCommand();
|
|
18925
|
+
return command(view.state, view.dispatch, view)
|
|
18926
|
+
}
|
|
18927
|
+
function insertHRuleCommand() {
|
|
18928
|
+
const commandAdapter = (state, dispatch, view) => {
|
|
18929
|
+
const hRuleNode = view.state.schema.nodes.horizontal_rule.create();
|
|
18930
|
+
const transaction = view.state.tr.replaceSelectionWith(hRuleNode, true);
|
|
18931
|
+
view.dispatch(transaction);
|
|
18932
|
+
stateChanged(view);
|
|
18933
|
+
return true;
|
|
18934
|
+
};
|
|
18935
|
+
|
|
18936
|
+
return commandAdapter
|
|
18937
|
+
}
|
|
18938
|
+
|
|
18911
18939
|
/********************************************************************************
|
|
18912
18940
|
* Images
|
|
18913
18941
|
*/
|
|
@@ -19323,6 +19351,17 @@ function _mergeHeaders(state, dispatch) {
|
|
|
19323
19351
|
const newState = state.apply(transaction);
|
|
19324
19352
|
mergeCells(newState, dispatch);
|
|
19325
19353
|
}}
|
|
19354
|
+
function isHRuleSelected(state) {
|
|
19355
|
+
let hRuleSelected = false;
|
|
19356
|
+
state.doc.nodesBetween(state.selection.from, state.selection.to, (node) => {
|
|
19357
|
+
if (node.type === state.schema.nodes.horizontal_rule) {
|
|
19358
|
+
hRuleSelected = true;
|
|
19359
|
+
return false;
|
|
19360
|
+
} return false;
|
|
19361
|
+
});
|
|
19362
|
+
return hRuleSelected
|
|
19363
|
+
}
|
|
19364
|
+
|
|
19326
19365
|
function isTableSelected(state) {
|
|
19327
19366
|
let tableSelected = false;
|
|
19328
19367
|
state.doc.nodesBetween(state.selection.from, state.selection.to, (node) => {
|
|
@@ -19595,7 +19634,8 @@ var menus = {
|
|
|
19595
19634
|
var insertBar = {
|
|
19596
19635
|
link: true,
|
|
19597
19636
|
image: true,
|
|
19598
|
-
tableMenu: true
|
|
19637
|
+
tableMenu: true,
|
|
19638
|
+
hRule: false
|
|
19599
19639
|
};
|
|
19600
19640
|
var formatBar = {
|
|
19601
19641
|
bold: true,
|
|
@@ -19636,6 +19676,7 @@ var help = {
|
|
|
19636
19676
|
link: "Insert/edit link",
|
|
19637
19677
|
image: "Insert/edit image",
|
|
19638
19678
|
table: "Insert/edit table",
|
|
19679
|
+
hRule: "Insert horizontal rule",
|
|
19639
19680
|
search: "Toggle search",
|
|
19640
19681
|
searchForward: "Search forward",
|
|
19641
19682
|
searchBackward: "Search backward",
|
|
@@ -19693,7 +19734,8 @@ var icons = {
|
|
|
19693
19734
|
searchBackward: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z\"/></svg>",
|
|
19694
19735
|
matchCase: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"m131-252 165-440h79l165 440h-76l-39-112H247l-40 112h-76Zm139-176h131l-64-182h-4l-63 182Zm395 186q-51 0-81-27.5T554-342q0-44 34.5-72.5T677-443q23 0 45 4t38 11v-12q0-29-20.5-47T685-505q-23 0-42 9.5T610-468l-47-35q24-29 54.5-43t68.5-14q69 0 103 32.5t34 97.5v178h-63v-37h-4q-14 23-38 35t-53 12Zm12-54q35 0 59.5-24t24.5-56q-14-8-33.5-12.5T689-393q-32 0-50 14t-18 37q0 20 16 33t40 13Z\"/></svg>",
|
|
19695
19736
|
paragraphStyle: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M360-160v-240q-83 0-141.5-58.5T160-600q0-83 58.5-141.5T360-800h360v80h-80v560h-80v-560H440v560h-80Z\"/></svg>",
|
|
19696
|
-
more: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z\"/></svg>"
|
|
19737
|
+
more: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z\"/></svg>",
|
|
19738
|
+
hRule: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\"> <path d=\"M160-440v-80h640v80H160Z\" fill=\"currentColor\"/> <path fill-rule=\"evenodd\" d=\"M935-760 A175,175,0,0,1,760-585 A175,175,0,0,1,585-760 A175,175,0,0,1,760-935 A175,175,0,0,1,935-760 Z M895-760 A135,135,0,0,1,760-625 A135,135,0,0,1,625-760 A135,135,0,0,1,760-895 A135,135,0,0,1,895-760 Z\" fill=\"currentColor\"/> <path d=\"M660-780H860V-740H660ZM740-860H780V-660H740Z\" fill=\"currentColor\"/></svg>"
|
|
19697
19739
|
};
|
|
19698
19740
|
var toolbarConfig = {
|
|
19699
19741
|
visibility: visibility,
|
|
@@ -19750,7 +19792,7 @@ var toolbarConfig = {
|
|
|
19750
19792
|
* "styleMenu": true, // Whether the style menu (p, h1-h6, code) is visible
|
|
19751
19793
|
* "styleBar": true, // Whether the style bar (bullet/numbered lists) is visible
|
|
19752
19794
|
* "formatBar": true, // Whether the format bar (b, i, u, etc) is visible
|
|
19753
|
-
* "search": true
|
|
19795
|
+
* "search": true // Whether the search item (hide/show search bar) is visible
|
|
19754
19796
|
* },
|
|
19755
19797
|
* "ordering": { // Control the ordering of toolbars, etc, ascending left-to-right
|
|
19756
19798
|
* "correctionBar": 10, // Correction bar order if it is visible
|
|
@@ -19758,17 +19800,18 @@ var toolbarConfig = {
|
|
|
19758
19800
|
* "styleMenu": 30, // Style menu (p, h1-h6, code) order if it is visible
|
|
19759
19801
|
* "styleBar": 40, // Style bar (bullet/numbered lists) order if it is visible
|
|
19760
19802
|
* "formatBar": 50, // Format bar (b, i, u, etc) order if it is visible
|
|
19761
|
-
* "search": 60
|
|
19803
|
+
* "search": 60 // Search item (hide/show search bar) order if it is visible
|
|
19762
19804
|
* },
|
|
19763
19805
|
* "menus": {
|
|
19764
19806
|
* "styleName": true // Whether to show the style name or just use a paragraph symbol
|
|
19765
19807
|
* "tableHeader": true, // Whether the "Header" item is visible in the "Table->Add" menu
|
|
19766
|
-
* "tableBorder": true
|
|
19808
|
+
* "tableBorder": true // Whether the "Border" item is visible in the "Table" menu
|
|
19767
19809
|
* },
|
|
19768
19810
|
* "insertBar": {
|
|
19769
19811
|
* "link": true, // Whether the link menu item is visible
|
|
19770
19812
|
* "image": true, // Whether the image menu item is visible
|
|
19771
19813
|
* "tableMenu": true, // Whether the table menu is visible
|
|
19814
|
+
* "hRule": true // Whether the horizontal rule menu item is visible
|
|
19772
19815
|
* },
|
|
19773
19816
|
* "formatBar": {
|
|
19774
19817
|
* "bold": true, // Whether the bold menu item is visible
|
|
@@ -19777,7 +19820,7 @@ var toolbarConfig = {
|
|
|
19777
19820
|
* "code": true, // Whether the code menu item is visible
|
|
19778
19821
|
* "strikethrough": true, // Whether the strikethrough menu item is visible
|
|
19779
19822
|
* "subscript": true, // Whether the subscript menu item is visible
|
|
19780
|
-
* "superscript": true
|
|
19823
|
+
* "superscript": true // Whether the superscript menu item is visible
|
|
19781
19824
|
* },
|
|
19782
19825
|
* "styleMenu": {
|
|
19783
19826
|
* "p": "Body", // The label in the menu for "P" style
|
|
@@ -19787,11 +19830,11 @@ var toolbarConfig = {
|
|
|
19787
19830
|
* "h4": "H4", // The label in the menu for "H4" style
|
|
19788
19831
|
* "h5": "H5", // The label in the menu for "H5" style
|
|
19789
19832
|
* "h6": "H6", // The label in the menu for "H6" style
|
|
19790
|
-
* "pre": "Code"
|
|
19833
|
+
* "pre": "Code" // The label in the menu for "PRE" aka code_block style
|
|
19791
19834
|
* },
|
|
19792
19835
|
* "styleBar": {
|
|
19793
19836
|
* "list": true, // Whether bullet and numbered list items are visible
|
|
19794
|
-
* "dent": true
|
|
19837
|
+
* "dent": true // Whether indent and outdent items are visible
|
|
19795
19838
|
* },
|
|
19796
19839
|
* "augmentation": {
|
|
19797
19840
|
* "prepend": null, // Name of a registered array of cmdItems to prepend
|
|
@@ -19850,7 +19893,9 @@ var toolbarConfig = {
|
|
|
19850
19893
|
* // format_paragraph
|
|
19851
19894
|
* "paragraphStyle": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M360-160v-240q-83 0-141.5-58.5T160-600q0-83 58.5-141.5T360-800h360v80h-80v560h-80v-560H440v560h-80Z\"/></svg>",
|
|
19852
19895
|
* // more_horiz
|
|
19853
|
-
* "more": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z\"/></svg>"
|
|
19896
|
+
* "more": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#1f1f1f\"><path d=\"M240-400q-33 0-56.5-23.5T160-480q0-33 23.5-56.5T240-560q33 0 56.5 23.5T320-480q0 33-23.5 56.5T240-400Zm240 0q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm240 0q-33 0-56.5-23.5T640-480q0-33 23.5-56.5T720-560q33 0 56.5 23.5T800-480q0 33-23.5 56.5T720-400Z\"/></svg>",
|
|
19897
|
+
* // adapted from horizontal_rule
|
|
19898
|
+
* "hRule": "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\"> <path d=\"M160-440v-80h640v80H160Z\" fill=\"currentColor\"/> <path fill-rule=\"evenodd\" d=\"M935-760 A175,175,0,0,1,760-585 A175,175,0,0,1,585-760 A175,175,0,0,1,760-935 A175,175,0,0,1,935-760 Z M895-760 A135,135,0,0,1,760-625 A135,135,0,0,1,625-760 A135,135,0,0,1,760-895 A135,135,0,0,1,895-760 Z\" fill=\"currentColor\"/> <path d=\"M660-780H860V-740H660ZM740-860H780V-660H740Z\" fill=\"currentColor\"/></svg>"
|
|
19854
19899
|
* }
|
|
19855
19900
|
* }
|
|
19856
19901
|
* ```
|
|
@@ -22851,7 +22896,7 @@ function redoItem(options) {
|
|
|
22851
22896
|
*/
|
|
22852
22897
|
function insertBarItems(config) {
|
|
22853
22898
|
let items = [];
|
|
22854
|
-
let { link, image, tableMenu } = config.toolbar.insertBar;
|
|
22899
|
+
let { link, image, tableMenu, hRule } = config.toolbar.insertBar;
|
|
22855
22900
|
if (link) {
|
|
22856
22901
|
items.push(new LinkItem(config));
|
|
22857
22902
|
}
|
|
@@ -22860,9 +22905,22 @@ function insertBarItems(config) {
|
|
|
22860
22905
|
items.push(new ImageItem(config, imageCommands));
|
|
22861
22906
|
}
|
|
22862
22907
|
if (tableMenu) items.push(tableMenuItems(config));
|
|
22908
|
+
if (hRule) items.push(hRuleItem(config));
|
|
22863
22909
|
return items;
|
|
22864
22910
|
}
|
|
22865
22911
|
|
|
22912
|
+
function hRuleItem(config) {
|
|
22913
|
+
let icon = config.toolbar.icons.hRule;
|
|
22914
|
+
let title = config.toolbar.help.hRule + keyString('hRule', config.keymap);
|
|
22915
|
+
let options = {
|
|
22916
|
+
icon: icon,
|
|
22917
|
+
title: title,
|
|
22918
|
+
active: (state) => { return isHRuleSelected(state) },
|
|
22919
|
+
enable: () => { return true } // TODO: should be conditional?
|
|
22920
|
+
};
|
|
22921
|
+
return cmdItem(insertHRuleCommand(), options)
|
|
22922
|
+
}
|
|
22923
|
+
|
|
22866
22924
|
function tableMenuItems(config) {
|
|
22867
22925
|
let icons = config.toolbar.icons;
|
|
22868
22926
|
let help = config.toolbar.help;
|
|
@@ -24985,6 +25043,7 @@ const MU = {
|
|
|
24985
25043
|
insertImage: insertImage$1,
|
|
24986
25044
|
insertLink: insertLink$1,
|
|
24987
25045
|
insertTable,
|
|
25046
|
+
insertHRule,
|
|
24988
25047
|
loadUserFiles,
|
|
24989
25048
|
modifyImage,
|
|
24990
25049
|
openImageDialog,
|