mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Check document ID when parsing pasted references
Summary: Add doc-id attribute to copied HTML columns next to column type. Only use the raw value (rather than the display value) when the parsed doc-id from pasted HTML matches the current document ID, similar to ensuring that the type matches. This only applies to references and reflists. Test Plan: Extended CopyPaste.ts Reviewers: dsagal Reviewed By: dsagal Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D3154
This commit is contained in:
@@ -373,12 +373,17 @@ BaseView.prototype._parsePasteForView = function(data, fields) {
|
||||
const updateColIds = updateCols.map(c => c && c.colId());
|
||||
const updateColTypes = updateCols.map(c => c && c.type());
|
||||
const parsers = fields.map(field => field && field.valueParser() || (x => x));
|
||||
const docIdHash = tableUtil.getDocIdHash();
|
||||
|
||||
const richData = data.map((col, idx) => {
|
||||
if (!col.length) {
|
||||
return col;
|
||||
}
|
||||
const typeMatches = col[0] && col[0].colType === updateColTypes[idx];
|
||||
const typeMatches = col[0] && col[0].colType === updateColTypes[idx] && (
|
||||
// When copying references, only use the row ID (raw value) when copying within the same document
|
||||
// to avoid referencing the wrong rows.
|
||||
col[0].docIdHash === docIdHash || !gristTypes.isFullReferencingType(updateColTypes[idx])
|
||||
);
|
||||
const parser = parsers[idx];
|
||||
return col.map(v => {
|
||||
if (v) {
|
||||
|
||||
Reference in New Issue
Block a user