markupeditor 0.9.8 → 0.9.10
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/dist/custom-elements.json +15 -13
- package/dist/markup-editor.js +174 -115
- package/package.json +1 -1
- package/styles/toolbar.css +0 -1
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"type": {
|
|
139
139
|
"text": "object"
|
|
140
140
|
},
|
|
141
|
-
"default": "{ activeConfig, activeView, addButton, addCol, addDiv, addHeader, addRow, borderTable, cancelSearch, canUndo, canRedo, 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, }",
|
|
141
|
+
"default": "{ activeConfig, activeView, addButton, addCol, addDiv, addHeader, addRow, borderTable, callbackSelectImage, cancelSearch, canUndo, canRedo, 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
|
],
|
|
@@ -722,6 +722,11 @@
|
|
|
722
722
|
}
|
|
723
723
|
]
|
|
724
724
|
},
|
|
725
|
+
{
|
|
726
|
+
"kind": "function",
|
|
727
|
+
"name": "callbackSelectImage",
|
|
728
|
+
"description": "Callback to signal that the user wants to select an image from a file.\n\nThe messageHandler will need to do something like bring up a file picker\nand in turn execute insertImage."
|
|
729
|
+
},
|
|
725
730
|
{
|
|
726
731
|
"kind": "function",
|
|
727
732
|
"name": "searchedCallback",
|
|
@@ -1505,6 +1510,14 @@
|
|
|
1505
1510
|
"module": "src/markup.js"
|
|
1506
1511
|
}
|
|
1507
1512
|
},
|
|
1513
|
+
{
|
|
1514
|
+
"kind": "js",
|
|
1515
|
+
"name": "callbackSelectImage",
|
|
1516
|
+
"declaration": {
|
|
1517
|
+
"name": "callbackSelectImage",
|
|
1518
|
+
"module": "src/markup.js"
|
|
1519
|
+
}
|
|
1520
|
+
},
|
|
1508
1521
|
{
|
|
1509
1522
|
"kind": "js",
|
|
1510
1523
|
"name": "searchedCallback",
|
|
@@ -2379,18 +2392,7 @@
|
|
|
2379
2392
|
{
|
|
2380
2393
|
"kind": "method",
|
|
2381
2394
|
"name": "selectImage",
|
|
2382
|
-
"
|
|
2383
|
-
{
|
|
2384
|
-
"name": "state"
|
|
2385
|
-
},
|
|
2386
|
-
{
|
|
2387
|
-
"name": "dispatch"
|
|
2388
|
-
},
|
|
2389
|
-
{
|
|
2390
|
-
"name": "view"
|
|
2391
|
-
}
|
|
2392
|
-
],
|
|
2393
|
-
"description": "Tell the delegate to select an image to insert, because we don't know how to do that"
|
|
2395
|
+
"description": "Call back to the messageHandler after closing the dialog. The message handler should \nlet the delegate deal with bringing up a file picker of some kind."
|
|
2394
2396
|
},
|
|
2395
2397
|
{
|
|
2396
2398
|
"kind": "method",
|
package/dist/markup-editor.js
CHANGED
|
@@ -2,7 +2,7 @@ const sheet$2 = new CSSStyleSheet();sheet$2.replaceSync("/**\n The CSS here was
|
|
|
2
2
|
|
|
3
3
|
const sheet$1 = new CSSStyleSheet();sheet$1.replaceSync("#editor, .editor {\n font-family: system-ui, sans-serif;\n background: white;\n color: black;\n background-clip: padding-box;\n margin: -8px; /* Set so that the .ProseMirror padding starts from edges */\n --padBottom: 0; /* MU.padBottom() sets this value in px based on fullHeight */\n padding-block: 0 var(--padBottom);\n overflow-x: clip;\n overflow-y: scroll;\n height: 100vh;\n padding-right: 12px;\n}\n@media (prefers-color-scheme: dark) {\n #editor, .editor {\n background: black;\n color: white;\n }\n}\n\nbody {\n font-family: system-ui, sans-serif;\n}\n\na {\n color: blue;\n text-decoration: none;\n}\n@media (prefers-color-scheme: dark) {\n a {\n color: #4183c4;\n }\n}\n\na:hover {\n text-decoration: underline;\n}\n\np, pre {\n font-size: 1.0rem;\n}\n\np, ul, ol, dl, table, pre {\n margin: 0 0 15px;\n}\n\nul, ol {\n padding-left: 30px;\n}\n\nh1 {\n font-size: 2.5rem;\n}\n\nh2 {\n font-size: 2.0rem;\n}\n\nh3 {\n font-size: 1.5rem;\n}\n\nh4 {\n font-size: 1.2rem;\n}\n\nh5 {\n font-size: 1.0rem;\n}\n\nh6 {\n font-size: .83rem;\n}\n\nh1, h2, h3, h4, h5, h6 {\n font-weight: bold;\n margin: 0 0 10px 0;\n}\n\nh1 + p, h2 + p, h3 + p {\n margin-top: 10px;\n}\n\ntable {\n table-layout: fixed;\n border-collapse: collapse;\n width: 100%;\n}\n\ntable th, table td {\n padding: 4px;\n}\n\ntable th {\n font-weight: normal; /* The default is bold, but we want to use paragraph styles and formatting */\n}\n\n/* Make the styling compact inside of a table */\ntable p, table h1, table h2, table h3, table h4, table h5, table h6 {\n margin: 0;\n}\n\n/* Table bordering options */\n.bordered-table-none {\n border: none;\n}\n\n.bordered-table-outer, .bordered-table-header, .bordered-table-cell {\n border: 1px solid #DDD;\n}\n\n.bordered-table-header th { /* border th not thead to refresh properly */\n border: 1px solid #DDD;\n}\n\n.bordered-table-cell th, .bordered-table-cell td {\n border: 1px solid #DDD;\n}\n\n/* Default table bordering is same as .bordered-table-cell but is only used when not specified */\ntable:not(.bordered-table-none, .bordered-table-outer, .bordered-table-header, .bordered-table-cell) {\n border: 1px solid #DDD;\n}\n\ntable:not(.bordered-table-none, .bordered-table-outer, .bordered-table-header, .bordered-table-cell) td {\n border: 1px solid #DDD;\n}\n\ntable:not(.bordered-table-none, .bordered-table-outer, .bordered-table-header, .bordered-table-cell) th {\n border: 1px solid #DDD;\n}\n\nli p {\n margin: 0px 0;\n}\n\nblockquote {\n margin-right: 0px; /* Because nested blockquotes just keep getting narrower */\n}\n\ncode {\n overflow-x: scroll;\n display: block;\n background-color: #F8F8F8;\n border-radius: 3px;\n font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace;\n white-space: pre;\n}\n@media (prefers-color-scheme: dark) {\n code {\n background-color: #808080;\n }\n}\n\np code, h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {\n display: inline;\n}\n\n.resize-container {\n position: relative;\n display: inline-block;\n margin: 0;\n}\n\nimg {\n max-width: 100%;\n height: auto;\n}\n\n/* Provide a slightly darkened or lightened overlay while search is active */\n.searching {\n background-color: rgba(0, 0, 0, 0.10);\n}\n@media (prefers-color-scheme: dark) {\n .searching {\n background: rgba(255, 255, 255, 0.10);\n }\n}\n\n.resize-container img {\n display: block;\n outline: 1px black dashed;\n outline-offset: 4px;\n outline-width: 1px;\n}\n@media (prefers-color-scheme: dark) {\n .resize-container img {\n outline: 1px white dashed;\n }\n}\n\n.resize-handle-nw,\n.resize-handle-ne,\n.resize-handle-sw,\n.resize-handle-se {\n position: absolute;\n display: block;\n width: 6px;\n height: 6px;\n outline: 1px black solid;\n background: white;\n z-index: 999;\n}\n@media (prefers-color-scheme: dark) {\n .resize-handle-nw,\n .resize-handle-ne,\n .resize-handle-sw,\n .resize-handle-se {\n outline: 1px white solid;\n background: black;\n }\n}\n\n/* A transparent child for each resize-handle that expands the clickable area */\n.resize-handle-nw:after,\n.resize-handle-ne:after,\n.resize-handle-sw:after,\n.resize-handle-se:after {\n content: \"\";\n position: absolute;\n left: -5px;\n top: -5px;\n width: 16px;\n height: 16px;\n}\n\n/* The *-resize cursors do not work, at least in MacCatalyst.\n * Still specifying them below. They default to a pointer instead\n */\n.resize-handle-nw {\n cursor: nw-resize;\n top: -8px;\n left: -7px;\n}\n\n.resize-handle-ne {\n cursor: ne-resize;\n top: -8px;\n right: -7px;\n}\n\n.resize-handle-sw {\n cursor: sw-resize;\n bottom: -8px;\n left: -7px;\n}\n\n.resize-handle-se {\n cursor: se-resize;\n bottom: -8px;\n right: -7px;\n}\n\n.placeholder[placeholder]:before {\n content: attr(placeholder);\n position: absolute;\n color: #ccc;\n}\n\n/* Classes set by prosemirror-search module, modified for MarkupEditor */\n/* Note the dark and light mode are the same */\n\n.ProseMirror-search-match {\n background-color: yellow;\n color: black;\n}\n\n.ProseMirror-active-search-match {\n background-color: orange;\n color: black;\n outline: 1px orangered solid;\n z-index: 2;\n}");
|
|
4
4
|
|
|
5
|
-
const sheet = new CSSStyleSheet();sheet.replaceSync("/* Spacing at the top */\n/* Note that toolbar-overlay below is also set to these values */\n\n.Markup-searchbar-showing {\n height: 38px;\n top: 76px;\n}\n\n/* The wrapper lets us automatically embed a toolbar and scroll under it */\n.Markup-toolbar-wrapper {\n margin-right: -12px; /* Prevent side scroll even when menu fits */\n height: inherit;\n overflow-y: scroll;\n position: relative; \n}\n\n/* We add Markup-prompt-showing to the wrapper to prevent scroll, and remove it when done */\n.Markup-prompt-showing {\n overflow-y: hidden;\n}\n\n/* Z-indexes in one place */\n\n.body-content { \n z-index: 1; \n}\n\n.Markup-prompt-overlay { \n z-index: 2; \n}\n\n.Markup-prompt, .Markup-selection {\n z-index: 3;\n}\n\n.Markup-searchbar {\n z-index: 4;\n}\n\n.Markup-toolbar, .Markup-toolbar-more {\n z-index: 5;\n}\n\n.Markup-toolbar-overlay { \n z-index: 6; \n}\n\n.Markup-menu-dropdown-menu {\n z-index: 7;\n}\n\n/* Toolbar, menu item, and dropdown styling */\n\n.Markup-toolbar {\n display: inline-flex;\n position: sticky;\n overflow: visible;\n width: 100%;\n font-size: 24px;\n vertical-align: middle;\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n top: 0;\n max-height: 38px;\n padding: 2px 8px;\n color: blue;\n background: rgba(250, 249, 246, 0.95);\n border-bottom: 1px solid lightgray;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-toolbar {\n color: rgb(250, 249, 246);\n background: rgba(40, 40, 43, 0.9);\n border-bottom: 1px solid gray;\n }\n}\n\n.Markup-menuitem {\n display: inline-block;\n flex-shrink: 0; /* Otherwise, the drop-downs with icons shrink */\n overflow-y: visible;\n vertical-align: middle;\n min-width: 28px;\n height: 28px;\n cursor: pointer;\n margin-right: 4px;\n border-radius: 4px;\n color: blue;\n border: 1px solid blue;\n background: white;\n fill: blue;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menuitem {\n color: lightblue;\n border: 1px solid lightblue; \n /* border: 1px solid #4183c4; */\n background: black;\n fill: lightblue;\n }\n}\n\n.Markup-menuitem-active {\n fill: white;\n color: white;\n background: blue;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menuitem-active {\n fill: black;\n color: black;\n background: lightblue;\n }\n}\n\n.Markup-menuitem-disabled {\n cursor: default;\n opacity: .3;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menuitem-disabled {\n opacity: .6;\n }\n}\n\n.Markup-icon {\n display: inline-block;\n width: 28px;\n height: 28px;\n border: 0;\n}\n\n.Markup-icon span {\n vertical-align: middle;\n}\n\n.Markup-icon svg {\n padding: 2px;\n border: 0;\n fill: inherit;\n}\n\n.Markup-menuseparator {\n display: inline-block;\n vertical-align: middle;\n height: 28px;\n border-right: 1px solid lightgray;\n margin-right: 4px;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menuseparator {\n border-right: 1px solid gray;\n }\n}\n\n.Markup-menu-disabled .Markup-icon {\n cursor: default;\n}\n\n.Markup-menu-dropdown, .Markup-menu-dropdown-menu {\n background: inherit;\n text-align: left;\n white-space: nowrap;\n}\n\n.Markup-menu-dropdown span {\n vertical-align: middle;\n}\n\n.Markup-menu-dropdown-icon span {\n vertical-align: middle;\n}\n\n.Markup-menu-dropdown-wrap {\n display: flex;\n justify-content: space-between;\n padding: 0 4px;\n width: 2.9em;\n height: inherit;\n border-radius: 4px;\n background: inherit;\n}\n\n.Markup-menu-dropdown-icon-wrap {\n display: flex;\n justify-content: space-between;\n padding-right: 4px;\n width: 1.8em;\n height: inherit;\n border-radius: 4px;\n background: inherit;\n}\n\n.Markup-menu-dropdown-icon-wrap-noindicator {\n display: inline-flex;\n padding-right: 4px;\n width: 1em;\n height: inherit;\n border-radius: 4px;\n background: inherit;\n}\n\n/* For the paragraph style dropdown with a label, make the font smaller */\n.Markup-menu-dropdown {\n display: flex;\n justify-content: space-between;\n align-items: center;\n box-sizing: border-box;\n font-size: 0.8em;\n width: inherit;\n height: inherit;\n background: inherit;\n position: absolute;\n}\n\n/* But for the indicator, bump size up to match the icon-style dropdown */\n.Markup-menu-dropdown .Markup-menu-dropdown-indicator {\n font-size: 1.25em;\n}\n\n.Markup-menu-dropdown-icon {\n display: inline-flex;\n justify-content: space-between;\n font-size: inherit;\n width: inherit;\n cursor: pointer;\n position: absolute;\n}\n\n.Markup-menu-dropdown-indicator {\n opacity: .6;\n}\n\n.Markup-tooltip .Markup-menu {\n width: -webkit-fit-content;\n width: fit-content;\n white-space: pre;\n}\n\n.Markup-menu-dropdown-menu, .Markup-menu-submenu {\n position: absolute;\n background: inherit;\n padding: 2px;\n background: inherit;\n border: 1px solid gray;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-dropdown-menu, .Markup-menu-submenu {\n border: 1px solid lightgray;\n }\n}\n\n.Markup-menu-dropdown-menu {\n margin-top: calc(1em + 6px);\n min-width: 4em;\n}\n\n.Markup-menu-dropdown-item {\n cursor: pointer;\n padding: 2px 8px 2px 4px;\n}\n\n/* Used to overlfow and ellipsis-truncate text in Dropdown menu items */\n.Markup-menuitem-clipped {\n white-space: nowrap; /* Required for text-overflow */\n overflow-x: hidden; /* Required for text-overflow */\n max-width: 30em;\n text-overflow: ellipsis;\n}\n\n.Markup-menu-dropdown-item:hover, .Markup-menu-submenu-wrap:hover {\n background: #f2f2f2;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-dropdown-item:hover, .Markup-menu-submenu-wrap:hover {\n background: rgb(80, 80, 80);\n }\n}\n\n.Markup-menu-dropdown-item p, \n.Markup-menu-dropdown-item h1, \n.Markup-menu-dropdown-item h2, \n.Markup-menu-dropdown-item h3, \n.Markup-menu-dropdown-item h4, \n.Markup-menu-dropdown-item h5, \n.Markup-menu-dropdown-item h6, \n.Markup-menu-dropdown-item pre {\n padding: 0;\n margin: 0;\n min-height: 24px;\n}\n\n.Markup-stylelabel {\n display: flex;\n justify-content: space-between;\n align-items: center;\n white-space: pre;\n width: 100%;\n}\n\n.Markup-stylelabel-keymap {\n display: flex;\n justify-content: flex-end;\n font-size: 1.0rem;\n font-weight: normal;\n color: gray;\n}\n\n.Markup-menu-submenu-wrap:hover .Markup-menu-submenu, .Markup-menu-submenu-wrap-active .Markup-menu-submenu {\n display: block;\n}\n\n.Markup-menu-submenu-wrap {\n position: relative;\n margin-right: -4px;\n background: inherit;\n}\n\n.Markup-menu-submenu {\n display: none;\n min-width: 4em;\n left: 100%;\n top: -5px;\n /* background cannot be inherited because of hover highlighting in dropdown */\n background: white;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-submenu {\n /* background cannot be inherited because of hover highlighting in dropdown */\n background: black;\n }\n}\n\n.Markup-menu-submenu-label:after {\n content: \"\";\n border-top: 4px solid transparent;\n border-bottom: 4px solid transparent;\n border-left: 4px solid currentColor;\n opacity: .6;\n position: absolute;\n right: 4px;\n top: calc(50% - 4px);\n}\n\n.Markup-selection {\n position: absolute;\n border: 1px solid blue;\n background: transparent;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-selection {\n border: 1px solid lightblue;\n }\n}\n\n/* Toolbar-more styling */\n\n.Markup-toolbar-more {\n display: inline-flex;\n position: sticky;\n overflow: visible;\n width: 100%;\n font-size: 24px;\n vertical-align: middle;\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n top: 35px;\n max-height: 38px;\n padding: 2px 8px;\n color: blue;\n background: rgba(250, 249, 246, 0.95);\n border-bottom: 1px solid lightgray;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-toolbar-more {\n color: rgb(250, 249, 246);\n background: rgba(40, 40, 43, 0.9);\n border-bottom: 1px solid gray;\n }\n}\n\n/* Searchbar styling */\n\n.Markup-searchbar {\n display: inline-block;\n font-size: 24px;\n vertical-align: middle;\n position: sticky;\n top: 35px;\n width: 100%;\n line-height: 30px;\n height: 37px;\n color: blue;\n background: rgba(250, 249, 246, 0.95);\n border-bottom: 1px solid lightgray;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n overflow: hidden;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-searchbar {\n color: rgb(250, 249, 246);\n background: rgba(40, 40, 43, 0.9);\n border-bottom: 1px solid gray;\n }\n}\n\n.Markup-searchbar input {\n appearance: none; /* Otherwise, in Safari/WebKit, the height is small and fixed */\n position: relative;\n font-size: 18px;\n line-height: 30px;\n height: 30px;\n width: calc(100% - 128px);\n margin: 0 8px;\n padding: 0 4px;\n outline: none;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n border: 1px solid lightgray;\n border-radius: 6px;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-searchbar input {\n color: rgb(250, 249, 246);\n background: rgb(40, 40, 43);\n border: 1px solid gray;\n }\n}\n\n.Markup-searchbar .Markup-searchbar-status {\n position: absolute;\n display: flex;\n justify-content: flex-end;\n align-items: center;\n white-space: nowrap;\n font-size: 12px;\n overflow-x: visible;\n height: 28px;\n top: 5px;\n left: calc(100% - 13em);\n width: 1px;\n color: gray;\n user-select: none;\n}\n\n/* Dialog/prompt styling for insert/edit actions */\n\n.Markup-prompt-overlay {\n\tposition: fixed;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbackground-color: rgba(0, 0, 0, 0.2);\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt-overlay {\n background-color: rgba(255, 255, 255, 0.2);\n }\n}\n\n.Markup-toolbar-overlay {\n\tposition: absolute;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\tbackground-color: rgba(0, 0, 0, 0.1);\n}\n@media (prefers-color-scheme: dark) {\n .Markup-toolbar-overlay {\n background-color: rgba(255, 255, 255, 0.1);\n }\n}\n\n.Markup-toolbar-overlay.Markup-searchbar-hidden {\n height: 38px;\n}\n\n.Markup-toolbar-overlay.Markup-searchbar-showing {\n height: 76px;\n}\n\n.Markup-prompt {\n margin: 0;\n font-size: 18px;\n background: white;\n padding: 8px;\n border: 1px solid silver;\n position: absolute;\n border-radius: 3px;\n box-shadow: -.5px 2px 5px rgba(0, 0, 0, 0.2);\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt {\n background: black;\n box-shadow: -.5px 2px 5px rgba(255, 255, 255, 0.8);\n }\n}\n\n.Markup-prompt-link {\n height: 96px;\n width: 300px;\n}\n\n.Markup-prompt-image {\n height: 130px;\n width: 300px;\n}\n\n.Markup-prompt img {\n display: inline-block;\n vertical-align: middle;\n min-width: 28px;\n height: 28px;\n margin-right: 4px;\n}\n\n.Markup-prompt p {\n margin: 0 0 4px 0;\n font-weight: normal;\n color: black;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt p {\n color: white;\n }\n}\n\n.Markup-prompt input[type=\"text\"] {\n font-size: 100%;\n line-height: 28px;\n margin-top: 2px;\n padding: 1px 4px;\n width: 100%;\n appearance: none;\n background: #eee;\n outline: none;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n border: 1px solid lightgray;\n border-radius: 6px;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt input[type=\"text\"] {\n color: rgb(250, 249, 246);\n background: rgb(40, 40, 43);\n border: 1px solid gray;\n }\n}\n\n.Markup-prompt input.invalid {\n color: red;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt input.invalid {\n color: pink;\n }\n}\n\n.Markup-prompt-buttons {\n display: flex;\n vertical-align: middle;\n justify-content: space-between;\n justify-items: center;\n line-height: 28px;\n height: 28px;\n margin-top: 8px;\n margin-bottom: 8px;\n}\n\n.Markup-prompt-buttongroup {\n flex-shrink: 0;\n}\n\n.Markup-prompt-buttons img {\n aspect-ratio: auto;\n height: auto;\n object-fit: contain;\n}\n\n.Markup-prompt-buttons .Markup-menuitem {\n display: inline-flex;\n padding-right: 4px;\n padding-left: 4px;\n}\n\n/* The buttongroup contains OK and Cancel menuitems on the right */\n.Markup-prompt-buttongroup .Markup-menuitem {\n margin-right: 0;\n margin-left: 4px;\n}\n\n/* .Markup-menu-tablesizer is a specialized submenu */\n.Markup-menu-tablesizer {\n display: none;\n grid-template-columns: repeat(4, 1fr);\n grid-auto-rows: 18px;\n row-gap: 1px;\n column-gap: 1px;\n padding: 0;\n left: 100%;\n top: -5px;\n /* background cannot be inherited because of hover highlighting in dropdown */\n background: white;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-tablesizer {\n /* background cannot be inherited because of hover highlighting in dropdown */\n background: black;\n }\n}\n\n.Markup-menu-submenu-wrap:hover .Markup-menu-tablesizer, .Markup-menu-submenu-wrap-active .Markup-menu-tablesizer {\n display: grid;\n}\n\n.Markup-menu-dropdown-menu, .Markup-menu-tablesizer {\n position: absolute;\n background: inherit;\n padding: 2px;\n background: inherit;\n border: 1px solid gray;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-dropdown-menu, .Markup-menu-submenu {\n border: 1px solid lightgray;\n }\n}\n\n.Markup-menu-tablesizer .Markup-menu-dropdown-item {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n border: 1px solid blue;\n width: 18px;\n height: 18px;\n padding: 0;\n font-size: 13px;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-tablesizer .Markup-menu-dropdown-item {\n border: 1px solid lightblue;\n }\n}\n\n.Markup-menu-tablesizer .Markup-menuitem-active {\n height: 13px;\n padding-top: 3px;\n fill: black;\n color: black;\n background: blue;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-tablesizer .Markup-menuitem-active {\n fill: black;\n color: black;\n background: lightblue;\n }\n}");
|
|
5
|
+
const sheet = new CSSStyleSheet();sheet.replaceSync("/* Spacing at the top */\n/* Note that toolbar-overlay below is also set to these values */\n\n.Markup-searchbar-showing {\n height: 38px;\n top: 76px;\n}\n\n/* The wrapper lets us automatically embed a toolbar and scroll under it */\n.Markup-toolbar-wrapper {\n margin-right: -12px; /* Prevent side scroll even when menu fits */\n height: inherit;\n overflow-y: scroll;\n position: relative; \n}\n\n/* We add Markup-prompt-showing to the wrapper to prevent scroll, and remove it when done */\n.Markup-prompt-showing {\n overflow-y: hidden;\n}\n\n/* Z-indexes in one place */\n\n.body-content { \n z-index: 1; \n}\n\n.Markup-prompt-overlay { \n z-index: 2; \n}\n\n.Markup-prompt, .Markup-selection {\n z-index: 3;\n}\n\n.Markup-searchbar {\n z-index: 4;\n}\n\n.Markup-toolbar, .Markup-toolbar-more {\n z-index: 5;\n}\n\n.Markup-toolbar-overlay { \n z-index: 6; \n}\n\n.Markup-menu-dropdown-menu {\n z-index: 7;\n}\n\n/* Toolbar, menu item, and dropdown styling */\n\n.Markup-toolbar {\n display: inline-flex;\n position: sticky;\n overflow: visible;\n width: 100%;\n font-size: 24px;\n vertical-align: middle;\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n top: 0;\n max-height: 38px;\n padding: 2px 8px;\n color: blue;\n background: rgba(250, 249, 246, 0.95);\n border-bottom: 1px solid lightgray;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-toolbar {\n color: rgb(250, 249, 246);\n background: rgba(40, 40, 43, 0.9);\n border-bottom: 1px solid gray;\n }\n}\n\n.Markup-menuitem {\n display: inline-block;\n flex-shrink: 0; /* Otherwise, the drop-downs with icons shrink */\n overflow-y: visible;\n vertical-align: middle;\n min-width: 28px;\n height: 28px;\n cursor: pointer;\n margin-right: 4px;\n border-radius: 4px;\n color: blue;\n border: 1px solid blue;\n background: white;\n fill: blue;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menuitem {\n color: lightblue;\n border: 1px solid lightblue; \n /* border: 1px solid #4183c4; */\n background: black;\n fill: lightblue;\n }\n}\n\n.Markup-menuitem-active {\n fill: white;\n color: white;\n background: blue;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menuitem-active {\n fill: black;\n color: black;\n background: lightblue;\n }\n}\n\n.Markup-menuitem-disabled {\n cursor: default;\n opacity: .3;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menuitem-disabled {\n opacity: .6;\n }\n}\n\n.Markup-icon {\n display: inline-block;\n width: 28px;\n height: 28px;\n border: 0;\n}\n\n.Markup-icon span {\n vertical-align: middle;\n}\n\n.Markup-icon svg {\n padding: 2px;\n border: 0;\n fill: inherit;\n}\n\n.Markup-menuseparator {\n display: inline-block;\n vertical-align: middle;\n height: 28px;\n border-right: 1px solid lightgray;\n margin-right: 4px;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menuseparator {\n border-right: 1px solid gray;\n }\n}\n\n.Markup-menu-disabled .Markup-icon {\n cursor: default;\n}\n\n.Markup-menu-dropdown, .Markup-menu-dropdown-menu {\n background: inherit;\n text-align: left;\n white-space: nowrap;\n}\n\n.Markup-menu-dropdown span {\n vertical-align: middle;\n}\n\n.Markup-menu-dropdown-icon span {\n vertical-align: middle;\n}\n\n.Markup-menu-dropdown-wrap {\n display: flex;\n justify-content: space-between;\n padding: 0 4px;\n height: inherit;\n border-radius: 4px;\n background: inherit;\n}\n\n.Markup-menu-dropdown-icon-wrap {\n display: flex;\n justify-content: space-between;\n padding-right: 4px;\n width: 1.8em;\n height: inherit;\n border-radius: 4px;\n background: inherit;\n}\n\n.Markup-menu-dropdown-icon-wrap-noindicator {\n display: inline-flex;\n padding-right: 4px;\n width: 1em;\n height: inherit;\n border-radius: 4px;\n background: inherit;\n}\n\n/* For the paragraph style dropdown with a label, make the font smaller */\n.Markup-menu-dropdown {\n display: flex;\n justify-content: space-between;\n align-items: center;\n box-sizing: border-box;\n font-size: 0.8em;\n width: inherit;\n height: inherit;\n background: inherit;\n position: absolute;\n}\n\n/* But for the indicator, bump size up to match the icon-style dropdown */\n.Markup-menu-dropdown .Markup-menu-dropdown-indicator {\n font-size: 1.25em;\n}\n\n.Markup-menu-dropdown-icon {\n display: inline-flex;\n justify-content: space-between;\n font-size: inherit;\n width: inherit;\n cursor: pointer;\n position: absolute;\n}\n\n.Markup-menu-dropdown-indicator {\n opacity: .6;\n}\n\n.Markup-tooltip .Markup-menu {\n width: -webkit-fit-content;\n width: fit-content;\n white-space: pre;\n}\n\n.Markup-menu-dropdown-menu, .Markup-menu-submenu {\n position: absolute;\n background: inherit;\n padding: 2px;\n background: inherit;\n border: 1px solid gray;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-dropdown-menu, .Markup-menu-submenu {\n border: 1px solid lightgray;\n }\n}\n\n.Markup-menu-dropdown-menu {\n margin-top: calc(1em + 6px);\n min-width: 4em;\n}\n\n.Markup-menu-dropdown-item {\n cursor: pointer;\n padding: 2px 8px 2px 4px;\n}\n\n/* Used to overlfow and ellipsis-truncate text in Dropdown menu items */\n.Markup-menuitem-clipped {\n white-space: nowrap; /* Required for text-overflow */\n overflow-x: hidden; /* Required for text-overflow */\n max-width: 30em;\n text-overflow: ellipsis;\n}\n\n.Markup-menu-dropdown-item:hover, .Markup-menu-submenu-wrap:hover {\n background: #f2f2f2;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-dropdown-item:hover, .Markup-menu-submenu-wrap:hover {\n background: rgb(80, 80, 80);\n }\n}\n\n.Markup-menu-dropdown-item p, \n.Markup-menu-dropdown-item h1, \n.Markup-menu-dropdown-item h2, \n.Markup-menu-dropdown-item h3, \n.Markup-menu-dropdown-item h4, \n.Markup-menu-dropdown-item h5, \n.Markup-menu-dropdown-item h6, \n.Markup-menu-dropdown-item pre {\n padding: 0;\n margin: 0;\n min-height: 24px;\n}\n\n.Markup-stylelabel {\n display: flex;\n justify-content: space-between;\n align-items: center;\n white-space: pre;\n width: 100%;\n}\n\n.Markup-stylelabel-keymap {\n display: flex;\n justify-content: flex-end;\n font-size: 1.0rem;\n font-weight: normal;\n color: gray;\n}\n\n.Markup-menu-submenu-wrap:hover .Markup-menu-submenu, .Markup-menu-submenu-wrap-active .Markup-menu-submenu {\n display: block;\n}\n\n.Markup-menu-submenu-wrap {\n position: relative;\n margin-right: -4px;\n background: inherit;\n}\n\n.Markup-menu-submenu {\n display: none;\n min-width: 4em;\n left: 100%;\n top: -5px;\n /* background cannot be inherited because of hover highlighting in dropdown */\n background: white;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-submenu {\n /* background cannot be inherited because of hover highlighting in dropdown */\n background: black;\n }\n}\n\n.Markup-menu-submenu-label:after {\n content: \"\";\n border-top: 4px solid transparent;\n border-bottom: 4px solid transparent;\n border-left: 4px solid currentColor;\n opacity: .6;\n position: absolute;\n right: 4px;\n top: calc(50% - 4px);\n}\n\n.Markup-selection {\n position: absolute;\n border: 1px solid blue;\n background: transparent;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-selection {\n border: 1px solid lightblue;\n }\n}\n\n/* Toolbar-more styling */\n\n.Markup-toolbar-more {\n display: inline-flex;\n position: sticky;\n overflow: visible;\n width: 100%;\n font-size: 24px;\n vertical-align: middle;\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n top: 35px;\n max-height: 38px;\n padding: 2px 8px;\n color: blue;\n background: rgba(250, 249, 246, 0.95);\n border-bottom: 1px solid lightgray;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-toolbar-more {\n color: rgb(250, 249, 246);\n background: rgba(40, 40, 43, 0.9);\n border-bottom: 1px solid gray;\n }\n}\n\n/* Searchbar styling */\n\n.Markup-searchbar {\n display: inline-block;\n font-size: 24px;\n vertical-align: middle;\n position: sticky;\n top: 35px;\n width: 100%;\n line-height: 30px;\n height: 37px;\n color: blue;\n background: rgba(250, 249, 246, 0.95);\n border-bottom: 1px solid lightgray;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n overflow: hidden;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-searchbar {\n color: rgb(250, 249, 246);\n background: rgba(40, 40, 43, 0.9);\n border-bottom: 1px solid gray;\n }\n}\n\n.Markup-searchbar input {\n appearance: none; /* Otherwise, in Safari/WebKit, the height is small and fixed */\n position: relative;\n font-size: 18px;\n line-height: 30px;\n height: 30px;\n width: calc(100% - 128px);\n margin: 0 8px;\n padding: 0 4px;\n outline: none;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n border: 1px solid lightgray;\n border-radius: 6px;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-searchbar input {\n color: rgb(250, 249, 246);\n background: rgb(40, 40, 43);\n border: 1px solid gray;\n }\n}\n\n.Markup-searchbar .Markup-searchbar-status {\n position: absolute;\n display: flex;\n justify-content: flex-end;\n align-items: center;\n white-space: nowrap;\n font-size: 12px;\n overflow-x: visible;\n height: 28px;\n top: 5px;\n left: calc(100% - 13em);\n width: 1px;\n color: gray;\n user-select: none;\n}\n\n/* Dialog/prompt styling for insert/edit actions */\n\n.Markup-prompt-overlay {\n\tposition: fixed;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\theight: 100%;\n\tbackground-color: rgba(0, 0, 0, 0.2);\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt-overlay {\n background-color: rgba(255, 255, 255, 0.2);\n }\n}\n\n.Markup-toolbar-overlay {\n\tposition: absolute;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\tbackground-color: rgba(0, 0, 0, 0.1);\n}\n@media (prefers-color-scheme: dark) {\n .Markup-toolbar-overlay {\n background-color: rgba(255, 255, 255, 0.1);\n }\n}\n\n.Markup-toolbar-overlay.Markup-searchbar-hidden {\n height: 38px;\n}\n\n.Markup-toolbar-overlay.Markup-searchbar-showing {\n height: 76px;\n}\n\n.Markup-prompt {\n margin: 0;\n font-size: 18px;\n background: white;\n padding: 8px;\n border: 1px solid silver;\n position: absolute;\n border-radius: 3px;\n box-shadow: -.5px 2px 5px rgba(0, 0, 0, 0.2);\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt {\n background: black;\n box-shadow: -.5px 2px 5px rgba(255, 255, 255, 0.8);\n }\n}\n\n.Markup-prompt-link {\n height: 96px;\n width: 300px;\n}\n\n.Markup-prompt-image {\n height: 130px;\n width: 300px;\n}\n\n.Markup-prompt img {\n display: inline-block;\n vertical-align: middle;\n min-width: 28px;\n height: 28px;\n margin-right: 4px;\n}\n\n.Markup-prompt p {\n margin: 0 0 4px 0;\n font-weight: normal;\n color: black;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt p {\n color: white;\n }\n}\n\n.Markup-prompt input[type=\"text\"] {\n font-size: 100%;\n line-height: 28px;\n margin-top: 2px;\n padding: 1px 4px;\n width: 100%;\n appearance: none;\n background: #eee;\n outline: none;\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n border: 1px solid lightgray;\n border-radius: 6px;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt input[type=\"text\"] {\n color: rgb(250, 249, 246);\n background: rgb(40, 40, 43);\n border: 1px solid gray;\n }\n}\n\n.Markup-prompt input.invalid {\n color: red;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-prompt input.invalid {\n color: pink;\n }\n}\n\n.Markup-prompt-buttons {\n display: flex;\n vertical-align: middle;\n justify-content: space-between;\n justify-items: center;\n line-height: 28px;\n height: 28px;\n margin-top: 8px;\n margin-bottom: 8px;\n}\n\n.Markup-prompt-buttongroup {\n flex-shrink: 0;\n}\n\n.Markup-prompt-buttons img {\n aspect-ratio: auto;\n height: auto;\n object-fit: contain;\n}\n\n.Markup-prompt-buttons .Markup-menuitem {\n display: inline-flex;\n padding-right: 4px;\n padding-left: 4px;\n}\n\n/* The buttongroup contains OK and Cancel menuitems on the right */\n.Markup-prompt-buttongroup .Markup-menuitem {\n margin-right: 0;\n margin-left: 4px;\n}\n\n/* .Markup-menu-tablesizer is a specialized submenu */\n.Markup-menu-tablesizer {\n display: none;\n grid-template-columns: repeat(4, 1fr);\n grid-auto-rows: 18px;\n row-gap: 1px;\n column-gap: 1px;\n padding: 0;\n left: 100%;\n top: -5px;\n /* background cannot be inherited because of hover highlighting in dropdown */\n background: white;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-tablesizer {\n /* background cannot be inherited because of hover highlighting in dropdown */\n background: black;\n }\n}\n\n.Markup-menu-submenu-wrap:hover .Markup-menu-tablesizer, .Markup-menu-submenu-wrap-active .Markup-menu-tablesizer {\n display: grid;\n}\n\n.Markup-menu-dropdown-menu, .Markup-menu-tablesizer {\n position: absolute;\n background: inherit;\n padding: 2px;\n background: inherit;\n border: 1px solid gray;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-dropdown-menu, .Markup-menu-submenu {\n border: 1px solid lightgray;\n }\n}\n\n.Markup-menu-tablesizer .Markup-menu-dropdown-item {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n border: 1px solid blue;\n width: 18px;\n height: 18px;\n padding: 0;\n font-size: 13px;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-tablesizer .Markup-menu-dropdown-item {\n border: 1px solid lightblue;\n }\n}\n\n.Markup-menu-tablesizer .Markup-menuitem-active {\n height: 13px;\n padding-top: 3px;\n fill: black;\n color: black;\n background: blue;\n}\n@media (prefers-color-scheme: dark) {\n .Markup-menu-tablesizer .Markup-menuitem-active {\n fill: black;\n color: black;\n background: lightblue;\n }\n}");
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The registry used to hold delegates, configs, handlers, and
|
|
@@ -16150,6 +16150,121 @@ A command function that redoes the last undone change, if any.
|
|
|
16150
16150
|
*/
|
|
16151
16151
|
const redo$1 = buildCommand(true, true);
|
|
16152
16152
|
|
|
16153
|
+
/**
|
|
16154
|
+
*
|
|
16155
|
+
* @param {EditorView} view
|
|
16156
|
+
* @param {string} text Text to be translated
|
|
16157
|
+
* @returns {string} The translated text if the view supports it
|
|
16158
|
+
*/
|
|
16159
|
+
function translate(view, text) {
|
|
16160
|
+
return view._props.translate ? view._props.translate(text) : text;
|
|
16161
|
+
}
|
|
16162
|
+
/**
|
|
16163
|
+
* Add or remove a class from the element.
|
|
16164
|
+
*
|
|
16165
|
+
* Apparently a workaround for classList.toggle being broken in IE11
|
|
16166
|
+
*
|
|
16167
|
+
* @param {HTMLElement} dom
|
|
16168
|
+
* @param {string} cls The class name to add or remove
|
|
16169
|
+
* @param {boolean} on True to add the class name to the `classList`
|
|
16170
|
+
*/
|
|
16171
|
+
function setClass(dom, cls, on) {
|
|
16172
|
+
if (on)
|
|
16173
|
+
dom.classList.add(cls);
|
|
16174
|
+
else
|
|
16175
|
+
dom.classList.remove(cls);
|
|
16176
|
+
}
|
|
16177
|
+
|
|
16178
|
+
/**
|
|
16179
|
+
* DOMAccess provides access to the MarkupToolbar and other well-known elements.
|
|
16180
|
+
*/
|
|
16181
|
+
class DOMAccess {
|
|
16182
|
+
|
|
16183
|
+
constructor(prefix) {
|
|
16184
|
+
this.prefix = prefix ?? 'Markup';
|
|
16185
|
+
}
|
|
16186
|
+
|
|
16187
|
+
setPrefix(prefix) {
|
|
16188
|
+
this.prefix = prefix;
|
|
16189
|
+
}
|
|
16190
|
+
|
|
16191
|
+
/**
|
|
16192
|
+
* Return the toolbar div in `view`
|
|
16193
|
+
* @param {EditorView} view
|
|
16194
|
+
* @returns {HTMLDivElement} The toolbar div in the view
|
|
16195
|
+
*/
|
|
16196
|
+
getToolbar(view) {
|
|
16197
|
+
return view.dom.getRootNode().getElementById(this.prefix + "-toolbar")
|
|
16198
|
+
}
|
|
16199
|
+
|
|
16200
|
+
getSearchItem(view) {
|
|
16201
|
+
return view.dom.getRootNode().getElementById(this.prefix + '-searchitem')
|
|
16202
|
+
}
|
|
16203
|
+
|
|
16204
|
+
getSearchbar(view) {
|
|
16205
|
+
return view.dom.getRootNode().getElementById(this.prefix + "-searchbar")
|
|
16206
|
+
}
|
|
16207
|
+
|
|
16208
|
+
getToolbarMore(view) {
|
|
16209
|
+
return view.dom.getRootNode().getElementById(this.prefix + "-toolbar-more")
|
|
16210
|
+
}
|
|
16211
|
+
|
|
16212
|
+
getWrapper(view) {
|
|
16213
|
+
return this.getToolbar(view)?.parentElement
|
|
16214
|
+
}
|
|
16215
|
+
|
|
16216
|
+
/** Adding promptShowing class on wrapper lets us suppress scroll while the prompt is showing */
|
|
16217
|
+
addPromptShowing(view) {
|
|
16218
|
+
setClass(getWrapper(view), promptShowing(), true);
|
|
16219
|
+
}
|
|
16220
|
+
|
|
16221
|
+
/** Removing promptShowing class on wrapper lets wrapper scroll again */
|
|
16222
|
+
removePromptShowing(view) {
|
|
16223
|
+
setClass(getWrapper(view), promptShowing(), false);
|
|
16224
|
+
}
|
|
16225
|
+
|
|
16226
|
+
promptShowing() {
|
|
16227
|
+
return this.prefix + "-prompt-showing"
|
|
16228
|
+
}
|
|
16229
|
+
|
|
16230
|
+
searchInput() {
|
|
16231
|
+
return this.prefix + "-searchinput"
|
|
16232
|
+
}
|
|
16233
|
+
|
|
16234
|
+
searchbarShowing() {
|
|
16235
|
+
return this.prefix + "-searchbar-showing"
|
|
16236
|
+
}
|
|
16237
|
+
|
|
16238
|
+
searchbarHidden() {
|
|
16239
|
+
return this.prefix + "-searchbar-hidden"
|
|
16240
|
+
}
|
|
16241
|
+
|
|
16242
|
+
isSearchFocused(view) {
|
|
16243
|
+
return view?.dom.getRootNode().getElementById(this.searchInput())?.matches(':focus') ?? false
|
|
16244
|
+
}
|
|
16245
|
+
|
|
16246
|
+
isPromptShowing(view) {
|
|
16247
|
+
return (view) ? this.getWrapper(view)?.classList.contains(this.promptShowing()) ?? false : false
|
|
16248
|
+
}
|
|
16249
|
+
|
|
16250
|
+
}
|
|
16251
|
+
|
|
16252
|
+
const _domAccess = new DOMAccess();
|
|
16253
|
+
const prefix = _domAccess.prefix;
|
|
16254
|
+
const setPrefix = _domAccess.setPrefix.bind(_domAccess);
|
|
16255
|
+
const getToolbar = _domAccess.getToolbar.bind(_domAccess);
|
|
16256
|
+
_domAccess.getSearchItem.bind(_domAccess);
|
|
16257
|
+
const getSearchbar = _domAccess.getSearchbar.bind(_domAccess);
|
|
16258
|
+
const getToolbarMore = _domAccess.getToolbarMore.bind(_domAccess);
|
|
16259
|
+
const getWrapper = _domAccess.getWrapper.bind(_domAccess);
|
|
16260
|
+
const addPromptShowing = _domAccess.addPromptShowing.bind(_domAccess);
|
|
16261
|
+
const removePromptShowing = _domAccess.removePromptShowing.bind(_domAccess);
|
|
16262
|
+
const promptShowing = _domAccess.promptShowing.bind(_domAccess);
|
|
16263
|
+
const searchbarShowing = _domAccess.searchbarShowing.bind(_domAccess);
|
|
16264
|
+
const searchbarHidden = _domAccess.searchbarHidden.bind(_domAccess);
|
|
16265
|
+
const isSearchFocused = _domAccess.isSearchFocused.bind(_domAccess);
|
|
16266
|
+
const isPromptShowing = _domAccess.isPromptShowing.bind(_domAccess);
|
|
16267
|
+
|
|
16153
16268
|
/**
|
|
16154
16269
|
* Define various arrays of tags used to represent MarkupEditor-specific concepts.
|
|
16155
16270
|
*
|
|
@@ -17868,9 +17983,12 @@ function _getSelectionState() {
|
|
|
17868
17983
|
// absolutely reflects the selection state at the time of the call regardless
|
|
17869
17984
|
// of whether it is editable or not.
|
|
17870
17985
|
const contentEditable = _getContentEditable();
|
|
17986
|
+
const view = activeView();
|
|
17871
17987
|
state['divid'] = contentEditable.id; // Will be 'editor' or a div ID
|
|
17872
|
-
|
|
17873
|
-
|
|
17988
|
+
// Valid means the selection is in something editable and
|
|
17989
|
+
// neither search is focused nor is a prompt showing
|
|
17990
|
+
state['valid'] = contentEditable.editable && !(isSearchFocused(view) || isPromptShowing(view));
|
|
17991
|
+
if (!state['valid']) return state; // No need to do more with state if it's not editable
|
|
17874
17992
|
|
|
17875
17993
|
// Selected text
|
|
17876
17994
|
state['selection'] = _getSelectionText();
|
|
@@ -18198,6 +18316,17 @@ function _getIndented(state) {
|
|
|
18198
18316
|
function callbackInput(element) {
|
|
18199
18317
|
_callback('input' + (selectedID() ?? ''), element);
|
|
18200
18318
|
}
|
|
18319
|
+
/**
|
|
18320
|
+
* Callback to signal that the user wants to select an image from a file.
|
|
18321
|
+
*
|
|
18322
|
+
* The messageHandler will need to do something like bring up a file picker
|
|
18323
|
+
* and in turn execute insertImage.
|
|
18324
|
+
*/
|
|
18325
|
+
function callbackSelectImage() {
|
|
18326
|
+
let messageDict = { 'messageType' : 'selectImage' };
|
|
18327
|
+
_callback(JSON.stringify(messageDict));
|
|
18328
|
+
}
|
|
18329
|
+
|
|
18201
18330
|
/**
|
|
18202
18331
|
* Callback to signal that user-provided CSS and/or script files have
|
|
18203
18332
|
* been loaded.
|
|
@@ -20806,107 +20935,6 @@ function add(elt, child) {
|
|
|
20806
20935
|
}
|
|
20807
20936
|
}
|
|
20808
20937
|
|
|
20809
|
-
/**
|
|
20810
|
-
*
|
|
20811
|
-
* @param {EditorView} view
|
|
20812
|
-
* @param {string} text Text to be translated
|
|
20813
|
-
* @returns {string} The translated text if the view supports it
|
|
20814
|
-
*/
|
|
20815
|
-
function translate(view, text) {
|
|
20816
|
-
return view._props.translate ? view._props.translate(text) : text;
|
|
20817
|
-
}
|
|
20818
|
-
/**
|
|
20819
|
-
* Add or remove a class from the element.
|
|
20820
|
-
*
|
|
20821
|
-
* Apparently a workaround for classList.toggle being broken in IE11
|
|
20822
|
-
*
|
|
20823
|
-
* @param {HTMLElement} dom
|
|
20824
|
-
* @param {string} cls The class name to add or remove
|
|
20825
|
-
* @param {boolean} on True to add the class name to the `classList`
|
|
20826
|
-
*/
|
|
20827
|
-
function setClass(dom, cls, on) {
|
|
20828
|
-
if (on)
|
|
20829
|
-
dom.classList.add(cls);
|
|
20830
|
-
else
|
|
20831
|
-
dom.classList.remove(cls);
|
|
20832
|
-
}
|
|
20833
|
-
|
|
20834
|
-
/**
|
|
20835
|
-
* DOMAccess provides access to the MarkupToolbar and other well-known elements.
|
|
20836
|
-
*/
|
|
20837
|
-
class DOMAccess {
|
|
20838
|
-
|
|
20839
|
-
constructor(prefix) {
|
|
20840
|
-
this.prefix = prefix ?? 'Markup';
|
|
20841
|
-
}
|
|
20842
|
-
|
|
20843
|
-
setPrefix(prefix) {
|
|
20844
|
-
this.prefix = prefix;
|
|
20845
|
-
}
|
|
20846
|
-
|
|
20847
|
-
/**
|
|
20848
|
-
* Return the toolbar div in `view`
|
|
20849
|
-
* @param {EditorView} view
|
|
20850
|
-
* @returns {HTMLDivElement} The toolbar div in the view
|
|
20851
|
-
*/
|
|
20852
|
-
getToolbar(view) {
|
|
20853
|
-
return view.dom.getRootNode().getElementById(this.prefix + "-toolbar");
|
|
20854
|
-
}
|
|
20855
|
-
|
|
20856
|
-
getSearchItem(view) {
|
|
20857
|
-
return view.dom.getRootNode().getElementById(this.prefix + '-searchitem')
|
|
20858
|
-
}
|
|
20859
|
-
|
|
20860
|
-
getSearchbar(view) {
|
|
20861
|
-
return view.dom.getRootNode().getElementById(this.prefix + "-searchbar");
|
|
20862
|
-
}
|
|
20863
|
-
|
|
20864
|
-
getToolbarMore(view) {
|
|
20865
|
-
return view.dom.getRootNode().getElementById(this.prefix + "-toolbar-more")
|
|
20866
|
-
}
|
|
20867
|
-
|
|
20868
|
-
getWrapper(view) {
|
|
20869
|
-
return this.getToolbar(view).parentElement;
|
|
20870
|
-
}
|
|
20871
|
-
|
|
20872
|
-
/** Adding promptShowing class on wrapper lets us suppress scroll while the prompt is showing */
|
|
20873
|
-
addPromptShowing(view) {
|
|
20874
|
-
setClass(getWrapper(view), promptShowing(), true);
|
|
20875
|
-
}
|
|
20876
|
-
|
|
20877
|
-
/** Removing promptShowing class on wrapper lets wrapper scroll again */
|
|
20878
|
-
removePromptShowing(view) {
|
|
20879
|
-
setClass(getWrapper(view), promptShowing(), false);
|
|
20880
|
-
}
|
|
20881
|
-
|
|
20882
|
-
promptShowing() {
|
|
20883
|
-
return this.prefix + "-prompt-showing"
|
|
20884
|
-
}
|
|
20885
|
-
|
|
20886
|
-
searchbarShowing() {
|
|
20887
|
-
return this.prefix + "-searchbar-showing"
|
|
20888
|
-
}
|
|
20889
|
-
|
|
20890
|
-
searchbarHidden() {
|
|
20891
|
-
return this.prefix + "-searchbar-hidden"
|
|
20892
|
-
}
|
|
20893
|
-
|
|
20894
|
-
}
|
|
20895
|
-
|
|
20896
|
-
const _domAccess = new DOMAccess();
|
|
20897
|
-
const prefix = _domAccess.prefix;
|
|
20898
|
-
const setPrefix = _domAccess.setPrefix.bind(_domAccess);
|
|
20899
|
-
const getToolbar = _domAccess.getToolbar.bind(_domAccess);
|
|
20900
|
-
_domAccess.getSearchItem.bind(_domAccess);
|
|
20901
|
-
const getSearchbar = _domAccess.getSearchbar.bind(_domAccess);
|
|
20902
|
-
const getToolbarMore = _domAccess.getToolbarMore.bind(_domAccess);
|
|
20903
|
-
const getWrapper = _domAccess.getWrapper.bind(_domAccess);
|
|
20904
|
-
const addPromptShowing = _domAccess.addPromptShowing.bind(_domAccess);
|
|
20905
|
-
const removePromptShowing = _domAccess.removePromptShowing.bind(_domAccess);
|
|
20906
|
-
const promptShowing = _domAccess.promptShowing.bind(_domAccess);
|
|
20907
|
-
const searchbarShowing = _domAccess.searchbarShowing.bind(_domAccess);
|
|
20908
|
-
const searchbarHidden = _domAccess.searchbarHidden.bind(_domAccess);
|
|
20909
|
-
|
|
20910
20938
|
function getIcon(root, icon) {
|
|
20911
20939
|
let doc = (root.nodeType == 9 ? root : root.ownerDocument) || document;
|
|
20912
20940
|
let node = doc.createElement("span");
|
|
@@ -21044,6 +21072,7 @@ class Dropdown {
|
|
|
21044
21072
|
* | `Function(EditorState): string` | `titleUpdate` | Function to execute that returns a label based on `state`. |
|
|
21045
21073
|
* | `Function(): boolean` | `enable` | Function to return true if MenuItem is enabled, else false |
|
|
21046
21074
|
* | `string` | `label` | The string to show in the MenuItem |
|
|
21075
|
+
* | `string[]` | `labels` | All possible label strings; used to size the dropdown to the widest label at render time. |
|
|
21047
21076
|
* | `KeymapConfig` | `keymap` | The KeymapConfig to use for the MenuItem |
|
|
21048
21077
|
* | `Command` | `run` | The Command to run when the item is pressed |
|
|
21049
21078
|
* | `Function(): boolean` | `active` | Function to return true if MenuItem is active, else false. |
|
|
@@ -21087,6 +21116,18 @@ class Dropdown {
|
|
|
21087
21116
|
let iconWrapClass = this.options.indicator ? "-dropdown-icon-wrap" : "-dropdown-icon-wrap-noindicator";
|
|
21088
21117
|
let wrapClass = (this.options.icon) ? this.prefix + iconWrapClass : this.prefix + "-dropdown-wrap";
|
|
21089
21118
|
let wrap = crelt("span", { class: wrapClass }, label);
|
|
21119
|
+
if (!this.options.icon && options.labels && options.labels.length > 0) {
|
|
21120
|
+
let container = getToolbar(view) || view.dom.parentNode || document.body;
|
|
21121
|
+
let sizer = crelt("span", { style: "visibility:hidden;position:absolute;white-space:nowrap;font-size:0.8em" });
|
|
21122
|
+
container.appendChild(sizer);
|
|
21123
|
+
let maxWidth = 0;
|
|
21124
|
+
for (let lbl of options.labels) {
|
|
21125
|
+
sizer.textContent = lbl + "\u25BE";
|
|
21126
|
+
maxWidth = Math.max(maxWidth, sizer.getBoundingClientRect().width);
|
|
21127
|
+
}
|
|
21128
|
+
container.removeChild(sizer);
|
|
21129
|
+
wrap.style.width = Math.ceil(maxWidth) + "px";
|
|
21130
|
+
}
|
|
21090
21131
|
let open = null;
|
|
21091
21132
|
let listeningOnClose = null;
|
|
21092
21133
|
let close = () => {
|
|
@@ -21270,8 +21311,9 @@ class DialogItem {
|
|
|
21270
21311
|
* @param {EditorView} view
|
|
21271
21312
|
*/
|
|
21272
21313
|
openDialog(state, dispatch, view) {
|
|
21273
|
-
|
|
21314
|
+
setActiveView(view);
|
|
21274
21315
|
this.createDialog(view);
|
|
21316
|
+
selectionChanged(); // Since it's pseudo modal, we can do it once
|
|
21275
21317
|
this.dialog.show();
|
|
21276
21318
|
}
|
|
21277
21319
|
|
|
@@ -21358,6 +21400,7 @@ class DialogItem {
|
|
|
21358
21400
|
*/
|
|
21359
21401
|
closeDialog() {
|
|
21360
21402
|
removePromptShowing(activeView());
|
|
21403
|
+
selectionChanged(); // Since it's pseudo modal, we can do it once
|
|
21361
21404
|
this.toolbarOverlay?.parentElement?.removeChild(this.toolbarOverlay);
|
|
21362
21405
|
this.overlay?.parentElement?.removeChild(this.overlay);
|
|
21363
21406
|
this.selectionDiv?.parentElement?.removeChild(this.selectionDiv);
|
|
@@ -21579,7 +21622,8 @@ class LinkItem extends DialogItem {
|
|
|
21579
21622
|
if (localRefItems.length == 0) { return null }
|
|
21580
21623
|
return new Dropdown(localRefItems, {
|
|
21581
21624
|
title: 'Insert link to header',
|
|
21582
|
-
label: 'H1-6'
|
|
21625
|
+
label: 'H1-6',
|
|
21626
|
+
labels: ['H1-6']
|
|
21583
21627
|
// Note: enable doesn't work for Dropdown
|
|
21584
21628
|
})
|
|
21585
21629
|
}
|
|
@@ -21852,10 +21896,10 @@ class ImageItem extends DialogItem {
|
|
|
21852
21896
|
this.dialog.appendChild(buttonsDiv);
|
|
21853
21897
|
|
|
21854
21898
|
// When local images are allowed, we insert a "Select..." button that will bring up a
|
|
21855
|
-
// file chooser. However, the MarkupEditor can't do that itself, so it
|
|
21856
|
-
//
|
|
21857
|
-
//
|
|
21858
|
-
// and then invoke `MU.insertImage`.
|
|
21899
|
+
// file chooser. However, the MarkupEditor can't do that itself, so it calls back to
|
|
21900
|
+
// the messageHandler, which in turn should invoke the delegate's `markupSelectImage`
|
|
21901
|
+
// method if it exists. Thus, when `selectImage` is true in BehaviorConfig, that method
|
|
21902
|
+
// should exist. It should bring up a file chooser and then invoke `MU.insertImage`.
|
|
21859
21903
|
if (this.config.behavior.selectImage) {
|
|
21860
21904
|
this.preview = null;
|
|
21861
21905
|
let selectItem = cmdItem(this.selectImage.bind(this), {
|
|
@@ -21953,10 +21997,13 @@ class ImageItem extends DialogItem {
|
|
|
21953
21997
|
return this.altArea.value
|
|
21954
21998
|
}
|
|
21955
21999
|
|
|
21956
|
-
/**
|
|
21957
|
-
|
|
22000
|
+
/**
|
|
22001
|
+
* Call back to the messageHandler after closing the dialog. The message handler should
|
|
22002
|
+
* let the delegate deal with bringing up a file picker of some kind.
|
|
22003
|
+
*/
|
|
22004
|
+
selectImage() {
|
|
21958
22005
|
this.closeDialog();
|
|
21959
|
-
|
|
22006
|
+
callbackSelectImage();
|
|
21960
22007
|
}
|
|
21961
22008
|
|
|
21962
22009
|
/**
|
|
@@ -22192,7 +22239,8 @@ class SearchItem {
|
|
|
22192
22239
|
showSearchbar(state, dispatch, view) {
|
|
22193
22240
|
let toolbar = getToolbar(view);
|
|
22194
22241
|
if (!toolbar) return;
|
|
22195
|
-
let
|
|
22242
|
+
let inputId = prefix + "-searchinput";
|
|
22243
|
+
let input = crelt('input', { id: inputId, type: 'search', placeholder: 'Search document...' });
|
|
22196
22244
|
input.addEventListener('keydown', e => { // Use keydown because 'input' isn't triggered for Enter
|
|
22197
22245
|
if (e.key === 'Enter') {
|
|
22198
22246
|
let direction = (e.shiftKey) ? 'backward' : 'forward';
|
|
@@ -22210,6 +22258,12 @@ class SearchItem {
|
|
|
22210
22258
|
this.text = e.target.value;
|
|
22211
22259
|
this.stopSearching(false); // Stop searching but leave focus in the input field
|
|
22212
22260
|
});
|
|
22261
|
+
input.addEventListener('focus', () => {
|
|
22262
|
+
selectionChanged();
|
|
22263
|
+
});
|
|
22264
|
+
input.addEventListener('blur', () => {
|
|
22265
|
+
selectionChanged();
|
|
22266
|
+
});
|
|
22213
22267
|
let idClass = prefix + "-searchbar";
|
|
22214
22268
|
let searchbar = crelt("div", { class: idClass, id: idClass }, input);
|
|
22215
22269
|
this.addSearchButtons(view, searchbar);
|
|
@@ -22913,7 +22967,8 @@ function styleMenuItems(config, schema) {
|
|
|
22913
22967
|
let label = config.toolbar.styleMenu[singleElement];
|
|
22914
22968
|
return label ? (multiple ? label + '+' : label) : styleElement
|
|
22915
22969
|
};
|
|
22916
|
-
|
|
22970
|
+
let allLabels = [p, h1, h2, h3, h4, h5, h6, pre].filter(Boolean).flatMap(l => [l, l + '+']);
|
|
22971
|
+
return [new Dropdown(items, { title: 'Set paragraph style', label: 'Style', titleUpdate: titleUpdate, labels: allLabels})]
|
|
22917
22972
|
} else {
|
|
22918
22973
|
let icons = config.toolbar.icons;
|
|
22919
22974
|
return [new Dropdown(items, { title: 'Set paragraph style', icon: icons.paragraphStyle })]
|
|
@@ -24325,6 +24380,9 @@ class MessageHandler {
|
|
|
24325
24380
|
case 'copyImage':
|
|
24326
24381
|
console.log('fix copyImage ' + messageData.src);
|
|
24327
24382
|
return
|
|
24383
|
+
case 'selectImage':
|
|
24384
|
+
delegate?.markupSelectImage && delegate?.markupSelectImage();
|
|
24385
|
+
return
|
|
24328
24386
|
case 'addedImage': {
|
|
24329
24387
|
if (!delegate?.markupImageAdded) return;
|
|
24330
24388
|
let divId = messageData.divId;
|
|
@@ -24779,6 +24837,7 @@ const MU = {
|
|
|
24779
24837
|
addHeader,
|
|
24780
24838
|
addRow,
|
|
24781
24839
|
borderTable,
|
|
24840
|
+
callbackSelectImage,
|
|
24782
24841
|
cancelSearch,
|
|
24783
24842
|
canUndo,
|
|
24784
24843
|
canRedo,
|
package/package.json
CHANGED