markupeditor 0.9.3 → 0.9.5
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 +23 -7
- package/dist/custom-elements.json +23 -13
- package/dist/markup-editor.js +37 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,20 @@ a [VSCode extension](https://github.com/stevengharris/markupeditor-vs).
|
|
|
63
63
|
You can try the MarkupEditor out right from the [project web site](https://stevengharris.github.io/markupeditor-base/). The web site has all
|
|
64
64
|
the information you need to use the MarkupEditor in your application.
|
|
65
65
|
|
|
66
|
+
If you have `npx` installed, you can open the MarkupEditor on the demo page using
|
|
67
|
+
`npx markupeditor https://stevengharris.github.io/markupeditor-base/demo/demo.html`.
|
|
68
|
+
This uses the `muedit` script provided with the project and starts a node/express server
|
|
69
|
+
on port 3000 by default.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
$ npx markupeditor https://stevengharris.github.io/markupeditor-base/demo/demo.html
|
|
73
|
+
Need to install the following packages:
|
|
74
|
+
markupeditor@0.9.4
|
|
75
|
+
Ok to proceed? (y) y
|
|
76
|
+
|
|
77
|
+
Server listening at http://localhost:3000
|
|
78
|
+
```
|
|
79
|
+
|
|
66
80
|
## Install
|
|
67
81
|
|
|
68
82
|
Clone the repository.
|
|
@@ -91,7 +105,7 @@ Build the project.
|
|
|
91
105
|
```
|
|
92
106
|
$ npm run build
|
|
93
107
|
|
|
94
|
-
> markupeditor@0.9.
|
|
108
|
+
> markupeditor@0.9.4 build
|
|
95
109
|
> rollup -c
|
|
96
110
|
|
|
97
111
|
|
|
@@ -100,11 +114,11 @@ created dist/markup-editor.js in 300ms
|
|
|
100
114
|
```
|
|
101
115
|
|
|
102
116
|
The installation identifies `muedit` in the package.json `bin` property. You can open the editor on a doc using node.js with
|
|
103
|
-
the `muedit` command, providing a filename to edit (and optionally a port for node.js). You can use the demo.html file that
|
|
117
|
+
the `npx muedit` command, providing a filename to edit (and optionally a port for node.js). You can use the demo.html file that
|
|
104
118
|
is part of the docs:
|
|
105
119
|
|
|
106
120
|
```
|
|
107
|
-
$ muedit docs/demo/demo.html
|
|
121
|
+
$ npx muedit docs/demo/demo.html
|
|
108
122
|
Server listening at http://localhost:3000
|
|
109
123
|
```
|
|
110
124
|
|
|
@@ -122,7 +136,7 @@ contents of the "home" page.
|
|
|
122
136
|
```
|
|
123
137
|
$ npm run docs
|
|
124
138
|
|
|
125
|
-
> markupeditor@0.9.
|
|
139
|
+
> markupeditor@0.9.4 predocs
|
|
126
140
|
> sh predocs.sh && jsdoc -c jsdoc.json
|
|
127
141
|
|
|
128
142
|
Updating ./docs dependencies...
|
|
@@ -132,7 +146,7 @@ cp -f ./styles/markup.css ./docs/styles/markup.css
|
|
|
132
146
|
cp -f ./styles/mirror.css ./docs/styles/mirror.css
|
|
133
147
|
cp -f ./styles/toolbar.css ./docs/styles/toolbar.css
|
|
134
148
|
|
|
135
|
-
> markupeditor@0.9.
|
|
149
|
+
> markupeditor@0.9.4 docs
|
|
136
150
|
> node ./docs/index.js
|
|
137
151
|
|
|
138
152
|
Server listening at http://localhost:3000
|
|
@@ -145,8 +159,10 @@ test the web site locally.
|
|
|
145
159
|
|
|
146
160
|
## Resources
|
|
147
161
|
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
You can start with the [MarkupEditor Developer's Guide](https://stevengharris.github.io/markupeditor-base/guide/index.html),
|
|
163
|
+
or you can check out the [Resources](https://stevengharris.github.io/markupeditor-base/#resources) section of
|
|
164
|
+
the [project web site](https://stevengharris.github.io/markupeditor-base/) for links to documentation, demos, and
|
|
165
|
+
other projects using the MarkupEditor.
|
|
150
166
|
|
|
151
167
|
## Acknowledgements
|
|
152
168
|
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"type": {
|
|
139
139
|
"text": "object"
|
|
140
140
|
},
|
|
141
|
-
"default": "{ activeConfig, activeView, addButton, addCol, addDiv, addHeader, addRow, borderTable, cancelSearch, consoleLog, cutImage, deactivateSearch, deleteLink, deleteTableArea, doRedo, doUndo, emptyDocument, focus, focusOn, focused, getDataImages, getHTML, getHeight, getImageAttributes, getLinkAttributes, getSelectionState, getTestHTML, indent, insertImage, insertLink, insertTable, loadUserFiles, modifyImage, openImageDialog, openLinkDialog, outdent, padBottom, pasteHTML, pasteText, removeAllDivs, removeButton, removeDiv, resetSelection, savedDataImage, searchFor, setHTML, setStyle, setTestHTML, setTopLevelAttributes, testBlockquoteEnter, testExtractContents, testListEnter, testPasteHTMLPreprocessing, testPasteTextPreprocessing, toggleBold, toggleCode, toggleItalic, toggleListItem, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, // Helpers to create custom toolbar items MenuItem, Dropdown, DropdownSubmenu, cmdItem, renderGrouped, renderDropdownItems, toggleSearch, // Config access ToolbarConfig, KeymapConfig, BehaviorConfig, // Registry access registerAugmentation, registerConfig, registerDelegate, registerMessageHandler, }",
|
|
141
|
+
"default": "{ activeConfig, activeView, addButton, addCol, addDiv, addHeader, addRow, borderTable, cancelSearch, consoleLog, cutImage, deactivateSearch, deleteLink, deleteTableArea, doRedo, doUndo, emptyDocument, focus, focusOn, focused, getDataImages, getHTML, getHeight, getImageAttributes, getLinkAttributes, getSelectionState, getTestHTML, indent, insertImage, insertLink, insertTable, loadUserFiles, modifyImage, openImageDialog, openLinkDialog, outdent, padBottom, pasteHTML, pasteText, removeAllDivs, removeButton, removeDiv, resetSelection, savedDataImage, searchFor, setActiveView, setHTML, setStyle, setTestHTML, setTopLevelAttributes, testBlockquoteEnter, testExtractContents, testListEnter, testPasteHTMLPreprocessing, testPasteTextPreprocessing, toggleBold, toggleCode, toggleItalic, toggleListItem, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, // Helpers to create custom toolbar items MenuItem, Dropdown, DropdownSubmenu, cmdItem, renderGrouped, renderDropdownItems, toggleSearch, // Config access ToolbarConfig, KeymapConfig, BehaviorConfig, // Registry access registerAugmentation, registerConfig, registerDelegate, registerMessageHandler, }",
|
|
142
142
|
"description": "The object whose methods comprise the MarkupEditor API."
|
|
143
143
|
}
|
|
144
144
|
],
|
|
@@ -3750,6 +3750,20 @@
|
|
|
3750
3750
|
}
|
|
3751
3751
|
}
|
|
3752
3752
|
},
|
|
3753
|
+
{
|
|
3754
|
+
"kind": "function",
|
|
3755
|
+
"name": "setActiveView",
|
|
3756
|
+
"parameters": [
|
|
3757
|
+
{
|
|
3758
|
+
"name": "view",
|
|
3759
|
+
"description": "The ProseMirror EditorView that should be active.",
|
|
3760
|
+
"type": {
|
|
3761
|
+
"text": "EditorView"
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
],
|
|
3765
|
+
"description": "Set the active editor's active view."
|
|
3766
|
+
},
|
|
3753
3767
|
{
|
|
3754
3768
|
"kind": "function",
|
|
3755
3769
|
"name": "registerAugmentation",
|
|
@@ -3878,10 +3892,6 @@
|
|
|
3878
3892
|
"kind": "variable",
|
|
3879
3893
|
"name": "activeEditor"
|
|
3880
3894
|
},
|
|
3881
|
-
{
|
|
3882
|
-
"kind": "variable",
|
|
3883
|
-
"name": "setActiveView"
|
|
3884
|
-
},
|
|
3885
3895
|
{
|
|
3886
3896
|
"kind": "variable",
|
|
3887
3897
|
"name": "activeDocument"
|
|
@@ -3928,6 +3938,14 @@
|
|
|
3928
3938
|
"module": "src/registry.js"
|
|
3929
3939
|
}
|
|
3930
3940
|
},
|
|
3941
|
+
{
|
|
3942
|
+
"kind": "js",
|
|
3943
|
+
"name": "setActiveView",
|
|
3944
|
+
"declaration": {
|
|
3945
|
+
"name": "setActiveView",
|
|
3946
|
+
"module": "src/registry.js"
|
|
3947
|
+
}
|
|
3948
|
+
},
|
|
3931
3949
|
{
|
|
3932
3950
|
"kind": "js",
|
|
3933
3951
|
"name": "registerAugmentation",
|
|
@@ -4048,14 +4066,6 @@
|
|
|
4048
4066
|
"module": "src/registry.js"
|
|
4049
4067
|
}
|
|
4050
4068
|
},
|
|
4051
|
-
{
|
|
4052
|
-
"kind": "js",
|
|
4053
|
-
"name": "setActiveView",
|
|
4054
|
-
"declaration": {
|
|
4055
|
-
"name": "setActiveView",
|
|
4056
|
-
"module": "src/registry.js"
|
|
4057
|
-
}
|
|
4058
|
-
},
|
|
4059
4069
|
{
|
|
4060
4070
|
"kind": "js",
|
|
4061
4071
|
"name": "activeDocument",
|
package/dist/markup-editor.js
CHANGED
|
@@ -251,6 +251,13 @@ function activeConfig() {return _registry.activeConfig.bind(_registry)()}
|
|
|
251
251
|
*/
|
|
252
252
|
function activeView() {return _registry.activeView.bind(_registry)()}
|
|
253
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Set the active editor's active view.
|
|
256
|
+
*
|
|
257
|
+
* @param {EditorView} view The ProseMirror EditorView that should be active.
|
|
258
|
+
*/
|
|
259
|
+
function setActiveView(view) {_registry.setActiveView.bind(_registry)(view);}
|
|
260
|
+
|
|
254
261
|
/**
|
|
255
262
|
* Add the `toolbar` to the registry.
|
|
256
263
|
* A toolbar holds `cmdItems` that can either be prepended or appended to
|
|
@@ -310,7 +317,6 @@ const getMessageHandler = _registry.getMessageHandler.bind(_registry);
|
|
|
310
317
|
_registry.unregisterAugmentation.bind(_registry);
|
|
311
318
|
const getAugmentation = _registry.getAugmentation.bind(_registry);
|
|
312
319
|
_registry.activeEditor.bind(_registry);
|
|
313
|
-
const setActiveView = _registry.setActiveView.bind(_registry);
|
|
314
320
|
const activeDocument = _registry.activeDocument.bind(_registry);
|
|
315
321
|
const setActiveDocument = _registry.setActiveDocument.bind(_registry);
|
|
316
322
|
const activeEditorElement = _registry.activeEditorElement.bind(_registry);
|
|
@@ -21923,7 +21929,7 @@ class ImageItem extends DialogItem {
|
|
|
21923
21929
|
/** Tell the delegate to select an image to insert, because we don't know how to do that */
|
|
21924
21930
|
selectImage(state, dispatch, view) {
|
|
21925
21931
|
this.closeDialog();
|
|
21926
|
-
if (this.config.delegate?.markupSelectImage) this.config.delegate?.markupSelectImage(view);
|
|
21932
|
+
if (this.config.delegate?.markupSelectImage) this.config.delegate?.markupSelectImage(state, dispatch, view);
|
|
21927
21933
|
}
|
|
21928
21934
|
|
|
21929
21935
|
/**
|
|
@@ -23013,31 +23019,27 @@ const undoInputRule = (state, dispatch) => {
|
|
|
23013
23019
|
/**
|
|
23014
23020
|
Converts double dashes to an emdash.
|
|
23015
23021
|
*/
|
|
23016
|
-
|
|
23022
|
+
new InputRule(/--$/, "—", { inCodeMark: false });
|
|
23017
23023
|
/**
|
|
23018
23024
|
Converts three dots to an ellipsis character.
|
|
23019
23025
|
*/
|
|
23020
|
-
|
|
23026
|
+
new InputRule(/\.\.\.$/, "…", { inCodeMark: false });
|
|
23021
23027
|
/**
|
|
23022
23028
|
“Smart” opening double quotes.
|
|
23023
23029
|
*/
|
|
23024
|
-
|
|
23030
|
+
new InputRule(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/, "“", { inCodeMark: false });
|
|
23025
23031
|
/**
|
|
23026
23032
|
“Smart” closing double quotes.
|
|
23027
23033
|
*/
|
|
23028
|
-
|
|
23034
|
+
new InputRule(/"$/, "”", { inCodeMark: false });
|
|
23029
23035
|
/**
|
|
23030
23036
|
“Smart” opening single quotes.
|
|
23031
23037
|
*/
|
|
23032
|
-
|
|
23038
|
+
new InputRule(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/, "‘", { inCodeMark: false });
|
|
23033
23039
|
/**
|
|
23034
23040
|
“Smart” closing single quotes.
|
|
23035
23041
|
*/
|
|
23036
|
-
|
|
23037
|
-
/**
|
|
23038
|
-
Smart-quote related input rules.
|
|
23039
|
-
*/
|
|
23040
|
-
const smartQuotes = [openDoubleQuote, closeDoubleQuote, openSingleQuote, closeSingleQuote];
|
|
23042
|
+
new InputRule(/'$/, "’", { inCodeMark: false });
|
|
23041
23043
|
|
|
23042
23044
|
/**
|
|
23043
23045
|
Build an input rule for automatically wrapping a textblock when a
|
|
@@ -23335,7 +23337,7 @@ function headingRule(nodeType, maxLevel) {
|
|
|
23335
23337
|
// A set of input rules for creating the basic block quotes, lists,
|
|
23336
23338
|
// code blocks, and heading.
|
|
23337
23339
|
function buildInputRules(schema) {
|
|
23338
|
-
let rules =
|
|
23340
|
+
let rules = [], type;
|
|
23339
23341
|
if (type = schema.nodes.blockquote) rules.push(blockQuoteRule(type));
|
|
23340
23342
|
if (type = schema.nodes.ordered_list) rules.push(orderedListRule(type));
|
|
23341
23343
|
if (type = schema.nodes.bullet_list) rules.push(bulletListRule(type));
|
|
@@ -24191,7 +24193,7 @@ class MessageHandler {
|
|
|
24191
24193
|
// if it exists, and return. Input happens with every keystroke and editing operation,
|
|
24192
24194
|
// so generally delegate should be doing very little, except perhaps noting that the
|
|
24193
24195
|
// document has changed. However, what your delegate does is very application-specific.
|
|
24194
|
-
delegate?.markupInput && delegate?.markupInput(
|
|
24196
|
+
delegate?.markupInput && delegate?.markupInput();
|
|
24195
24197
|
return
|
|
24196
24198
|
}
|
|
24197
24199
|
switch (message) {
|
|
@@ -24206,18 +24208,18 @@ class MessageHandler {
|
|
|
24206
24208
|
delegate?.markupDidFocus && delegate?.markupDidFocus();
|
|
24207
24209
|
return
|
|
24208
24210
|
case 'blur':
|
|
24209
|
-
delegate?.
|
|
24211
|
+
delegate?.markupDidBlur && delegate?.markupDidBlur();
|
|
24210
24212
|
return
|
|
24211
|
-
case
|
|
24213
|
+
case 'updateHeight':
|
|
24212
24214
|
delegate?.markupUpdateHeight && delegate?.markupUpdateHeight(getHeight());
|
|
24213
24215
|
return
|
|
24214
|
-
case
|
|
24216
|
+
case 'selectionChanged':
|
|
24215
24217
|
delegate?.markupSelectionChanged && delegate?.markupSelectionChanged();
|
|
24216
24218
|
return
|
|
24217
|
-
case
|
|
24219
|
+
case 'clicked':
|
|
24218
24220
|
delegate?.markupClicked && delegate?.markupClicked();
|
|
24219
24221
|
return
|
|
24220
|
-
case
|
|
24222
|
+
case 'searched':
|
|
24221
24223
|
delegate?.markupSearched && delegate?.markupSearched();
|
|
24222
24224
|
return
|
|
24223
24225
|
default:
|
|
@@ -24231,7 +24233,7 @@ class MessageHandler {
|
|
|
24231
24233
|
const messageData = JSON.parse(message);
|
|
24232
24234
|
this.receivedMessageData(messageData);
|
|
24233
24235
|
} catch {
|
|
24234
|
-
console.log(
|
|
24236
|
+
console.log('Unhandled message: ' + message);
|
|
24235
24237
|
}
|
|
24236
24238
|
}
|
|
24237
24239
|
}
|
|
@@ -24247,44 +24249,44 @@ class MessageHandler {
|
|
|
24247
24249
|
let delegate = config.delegate;
|
|
24248
24250
|
let messageType = messageData.messageType;
|
|
24249
24251
|
switch (messageType) {
|
|
24250
|
-
case
|
|
24252
|
+
case 'log':
|
|
24251
24253
|
console.log(messageData.log);
|
|
24252
24254
|
return
|
|
24253
|
-
case
|
|
24255
|
+
case 'error': {
|
|
24254
24256
|
let code = messageData.code;
|
|
24255
24257
|
let message = messageData.message;
|
|
24256
24258
|
if (!code || !message) {
|
|
24257
|
-
console.log(
|
|
24259
|
+
console.log('Bad error message.');
|
|
24258
24260
|
return
|
|
24259
24261
|
}
|
|
24260
24262
|
let info = messageData.info;
|
|
24261
24263
|
let alert = messageData.alert ?? true;
|
|
24262
|
-
delegate?.markupError && delegate?.markupError(code, message, info, alert);
|
|
24264
|
+
delegate?.markupError && delegate?.markupError(code, message, info, alert, this.editor);
|
|
24263
24265
|
return
|
|
24264
24266
|
}
|
|
24265
|
-
case
|
|
24266
|
-
console.log(
|
|
24267
|
+
case 'copyImage':
|
|
24268
|
+
console.log('fix copyImage ' + messageData.src);
|
|
24267
24269
|
return
|
|
24268
|
-
case
|
|
24270
|
+
case 'addedImage': {
|
|
24269
24271
|
if (!delegate?.markupImageAdded) return;
|
|
24270
24272
|
let divId = messageData.divId;
|
|
24271
24273
|
// Even if divid is identified, if it's empty or the editor element, then
|
|
24272
24274
|
// use the old call without divid to maintain compatibility with earlier versions
|
|
24273
24275
|
// that did not support multi-contenteditable divs.
|
|
24274
|
-
if ((divId.length == 0) || (divId ==
|
|
24275
|
-
delegate.markupImageAdded(messageData.src);
|
|
24276
|
+
if ((divId.length == 0) || (divId == 'editor')) {
|
|
24277
|
+
delegate.markupImageAdded(messageData.src, 'editor');
|
|
24276
24278
|
} else if (!divId.length == 0) {
|
|
24277
24279
|
delegate.markupImageAdded(messageData.src, divId);
|
|
24278
24280
|
} else {
|
|
24279
|
-
console.log(
|
|
24281
|
+
console.log('Error: The div id for the image could not be decoded.');
|
|
24280
24282
|
}
|
|
24281
24283
|
return
|
|
24282
24284
|
}
|
|
24283
|
-
case
|
|
24284
|
-
console.log(
|
|
24285
|
+
case 'deletedImage':
|
|
24286
|
+
console.log('fix deletedImage ' + messageData.src);
|
|
24285
24287
|
return
|
|
24286
|
-
case
|
|
24287
|
-
console.log(
|
|
24288
|
+
case 'buttonClicked':
|
|
24289
|
+
console.log('fix buttonClicked ' + messageData.src);
|
|
24288
24290
|
return
|
|
24289
24291
|
default:
|
|
24290
24292
|
console.log(`Unknown message of type ${messageType}: ${messageData}.`);
|
|
@@ -24756,6 +24758,7 @@ const MU = {
|
|
|
24756
24758
|
resetSelection,
|
|
24757
24759
|
savedDataImage,
|
|
24758
24760
|
searchFor,
|
|
24761
|
+
setActiveView,
|
|
24759
24762
|
setHTML,
|
|
24760
24763
|
setStyle,
|
|
24761
24764
|
setTestHTML,
|