(core) updates from grist-core

This commit is contained in:
Paul Fitzpatrick
2024-10-01 11:54:40 -04:00
19 changed files with 116 additions and 250 deletions

View File

@@ -107,6 +107,7 @@ Base.setBaseFor(Clipboard);
Clipboard.commands = {
contextMenuCopy: function() { this._doContextMenuCopy(); },
contextMenuCopyWithHeaders: function() { this._doContextMenuCopyWithHeaders(); },
contextMenuCut: function() { this._doContextMenuCut(); },
contextMenuPaste: function() { this._doContextMenuPaste(); },
};
@@ -126,7 +127,13 @@ Clipboard.prototype._onCopy = function(elem, event) {
Clipboard.prototype._doContextMenuCopy = function() {
let pasteObj = commands.allCommands.copy.run();
this._copyToClipboard(pasteObj, 'copy');
this._copyToClipboard(pasteObj, 'copy', false);
};
Clipboard.prototype._doContextMenuCopyWithHeaders = function() {
let pasteObj = commands.allCommands.copy.run();
this._copyToClipboard(pasteObj, 'copy', true);
};
Clipboard.prototype._onCut = function(elem, event) {
@@ -146,21 +153,21 @@ Clipboard.prototype._doContextMenuCut = function() {
Clipboard.prototype._setCBdata = function(pasteObj, clipboardData) {
if (!pasteObj) { return; }
const plainText = tableUtil.makePasteText(pasteObj.data, pasteObj.selection);
const plainText = tableUtil.makePasteText(pasteObj.data, pasteObj.selection, false);
clipboardData.setData('text/plain', plainText);
const htmlText = tableUtil.makePasteHtml(pasteObj.data, pasteObj.selection);
const htmlText = tableUtil.makePasteHtml(pasteObj.data, pasteObj.selection, false);
clipboardData.setData('text/html', htmlText);
this._setCutCallback(pasteObj, plainText);
};
Clipboard.prototype._copyToClipboard = async function(pasteObj, action) {
Clipboard.prototype._copyToClipboard = async function(pasteObj, action, includeColHeaders) {
if (!pasteObj) { return; }
const plainText = tableUtil.makePasteText(pasteObj.data, pasteObj.selection);
const plainText = tableUtil.makePasteText(pasteObj.data, pasteObj.selection, includeColHeaders);
let data;
if (typeof ClipboardItem === 'function') {
const htmlText = tableUtil.makePasteHtml(pasteObj.data, pasteObj.selection);
const htmlText = tableUtil.makePasteHtml(pasteObj.data, pasteObj.selection, includeColHeaders);
// eslint-disable-next-line no-undef
data = new ClipboardItem({
// eslint-disable-next-line no-undef

View File

@@ -63,6 +63,7 @@ export type CommandName =
| 'cut'
| 'paste'
| 'contextMenuCopy'
| 'contextMenuCopyWithHeaders'
| 'contextMenuCut'
| 'contextMenuPaste'
| 'fillSelectionDown'
@@ -470,6 +471,10 @@ export const groups: CommendGroupDef[] = [{
keys: ['Mod+C'],
desc: 'Copy current selection to clipboard',
bindKeys: false,
}, {
name: 'contextMenuCopyWithHeaders',
keys: [],
desc: 'Copy current selection to clipboard including headers',
}, {
name: 'contextMenuCut',
keys: ['Mod+X'],