markupeditor 0.9.3 → 0.9.4
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 -2
- package/dist/custom-elements.json +23 -13
- package/dist/markup-editor.js +30 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,11 +100,11 @@ created dist/markup-editor.js in 300ms
|
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
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
|
|
103
|
+
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
104
|
is part of the docs:
|
|
105
105
|
|
|
106
106
|
```
|
|
107
|
-
$ muedit docs/demo/demo.html
|
|
107
|
+
$ npx muedit docs/demo/demo.html
|
|
108
108
|
Server listening at http://localhost:3000
|
|
109
109
|
```
|
|
110
110
|
|
|
@@ -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
|
/**
|
|
@@ -24191,7 +24197,7 @@ class MessageHandler {
|
|
|
24191
24197
|
// if it exists, and return. Input happens with every keystroke and editing operation,
|
|
24192
24198
|
// so generally delegate should be doing very little, except perhaps noting that the
|
|
24193
24199
|
// document has changed. However, what your delegate does is very application-specific.
|
|
24194
|
-
delegate?.markupInput && delegate?.markupInput(
|
|
24200
|
+
delegate?.markupInput && delegate?.markupInput();
|
|
24195
24201
|
return
|
|
24196
24202
|
}
|
|
24197
24203
|
switch (message) {
|
|
@@ -24206,18 +24212,18 @@ class MessageHandler {
|
|
|
24206
24212
|
delegate?.markupDidFocus && delegate?.markupDidFocus();
|
|
24207
24213
|
return
|
|
24208
24214
|
case 'blur':
|
|
24209
|
-
delegate?.
|
|
24215
|
+
delegate?.markupDidBlur && delegate?.markupDidBlur();
|
|
24210
24216
|
return
|
|
24211
|
-
case
|
|
24217
|
+
case 'updateHeight':
|
|
24212
24218
|
delegate?.markupUpdateHeight && delegate?.markupUpdateHeight(getHeight());
|
|
24213
24219
|
return
|
|
24214
|
-
case
|
|
24220
|
+
case 'selectionChanged':
|
|
24215
24221
|
delegate?.markupSelectionChanged && delegate?.markupSelectionChanged();
|
|
24216
24222
|
return
|
|
24217
|
-
case
|
|
24223
|
+
case 'clicked':
|
|
24218
24224
|
delegate?.markupClicked && delegate?.markupClicked();
|
|
24219
24225
|
return
|
|
24220
|
-
case
|
|
24226
|
+
case 'searched':
|
|
24221
24227
|
delegate?.markupSearched && delegate?.markupSearched();
|
|
24222
24228
|
return
|
|
24223
24229
|
default:
|
|
@@ -24231,7 +24237,7 @@ class MessageHandler {
|
|
|
24231
24237
|
const messageData = JSON.parse(message);
|
|
24232
24238
|
this.receivedMessageData(messageData);
|
|
24233
24239
|
} catch {
|
|
24234
|
-
console.log(
|
|
24240
|
+
console.log('Unhandled message: ' + message);
|
|
24235
24241
|
}
|
|
24236
24242
|
}
|
|
24237
24243
|
}
|
|
@@ -24247,44 +24253,44 @@ class MessageHandler {
|
|
|
24247
24253
|
let delegate = config.delegate;
|
|
24248
24254
|
let messageType = messageData.messageType;
|
|
24249
24255
|
switch (messageType) {
|
|
24250
|
-
case
|
|
24256
|
+
case 'log':
|
|
24251
24257
|
console.log(messageData.log);
|
|
24252
24258
|
return
|
|
24253
|
-
case
|
|
24259
|
+
case 'error': {
|
|
24254
24260
|
let code = messageData.code;
|
|
24255
24261
|
let message = messageData.message;
|
|
24256
24262
|
if (!code || !message) {
|
|
24257
|
-
console.log(
|
|
24263
|
+
console.log('Bad error message.');
|
|
24258
24264
|
return
|
|
24259
24265
|
}
|
|
24260
24266
|
let info = messageData.info;
|
|
24261
24267
|
let alert = messageData.alert ?? true;
|
|
24262
|
-
delegate?.markupError && delegate?.markupError(code, message, info, alert);
|
|
24268
|
+
delegate?.markupError && delegate?.markupError(code, message, info, alert, this.editor);
|
|
24263
24269
|
return
|
|
24264
24270
|
}
|
|
24265
|
-
case
|
|
24266
|
-
console.log(
|
|
24271
|
+
case 'copyImage':
|
|
24272
|
+
console.log('fix copyImage ' + messageData.src);
|
|
24267
24273
|
return
|
|
24268
|
-
case
|
|
24274
|
+
case 'addedImage': {
|
|
24269
24275
|
if (!delegate?.markupImageAdded) return;
|
|
24270
24276
|
let divId = messageData.divId;
|
|
24271
24277
|
// Even if divid is identified, if it's empty or the editor element, then
|
|
24272
24278
|
// use the old call without divid to maintain compatibility with earlier versions
|
|
24273
24279
|
// that did not support multi-contenteditable divs.
|
|
24274
|
-
if ((divId.length == 0) || (divId ==
|
|
24275
|
-
delegate.markupImageAdded(messageData.src);
|
|
24280
|
+
if ((divId.length == 0) || (divId == 'editor')) {
|
|
24281
|
+
delegate.markupImageAdded(messageData.src, 'editor');
|
|
24276
24282
|
} else if (!divId.length == 0) {
|
|
24277
24283
|
delegate.markupImageAdded(messageData.src, divId);
|
|
24278
24284
|
} else {
|
|
24279
|
-
console.log(
|
|
24285
|
+
console.log('Error: The div id for the image could not be decoded.');
|
|
24280
24286
|
}
|
|
24281
24287
|
return
|
|
24282
24288
|
}
|
|
24283
|
-
case
|
|
24284
|
-
console.log(
|
|
24289
|
+
case 'deletedImage':
|
|
24290
|
+
console.log('fix deletedImage ' + messageData.src);
|
|
24285
24291
|
return
|
|
24286
|
-
case
|
|
24287
|
-
console.log(
|
|
24292
|
+
case 'buttonClicked':
|
|
24293
|
+
console.log('fix buttonClicked ' + messageData.src);
|
|
24288
24294
|
return
|
|
24289
24295
|
default:
|
|
24290
24296
|
console.log(`Unknown message of type ${messageType}: ${messageData}.`);
|
|
@@ -24756,6 +24762,7 @@ const MU = {
|
|
|
24756
24762
|
resetSelection,
|
|
24757
24763
|
savedDataImage,
|
|
24758
24764
|
searchFor,
|
|
24765
|
+
setActiveView,
|
|
24759
24766
|
setHTML,
|
|
24760
24767
|
setStyle,
|
|
24761
24768
|
setTestHTML,
|