@ishibashi0112/spreadsheet-grid-core 1.11.0 → 1.12.0
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/controllers/clipboardController.cjs +3 -1
- package/dist/controllers/clipboardController.d.ts +8 -0
- package/dist/controllers/clipboardController.js +251 -135
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +109 -103
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +17 -0
- package/dist/controllers/findController.js +149 -93
- package/dist/controllers/findReplaceController.cjs +1 -0
- package/dist/controllers/findReplaceController.d.ts +61 -0
- package/dist/controllers/findReplaceController.js +324 -0
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +4 -0
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +52 -51
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +10 -10
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +5 -0
- package/dist/engine/features.js +39 -15
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +29 -27
- package/dist/engine/gridApi.cjs +2 -2
- package/dist/engine/gridApi.d.ts +6 -1
- package/dist/engine/gridApi.js +29 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +20 -0
- package/dist/logic/clipboardHtml.cjs +1 -0
- package/dist/logic/clipboardHtml.d.ts +40 -0
- package/dist/logic/clipboardHtml.js +168 -0
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.js +35 -11
- package/dist/logic/findReplace.cjs +1 -0
- package/dist/logic/findReplace.d.ts +35 -0
- package/dist/logic/findReplace.js +84 -0
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +22 -0
- package/dist/logic/localeTextFeatures.js +24 -3
- package/dist/logic/selectionOverlayGeometry.cjs +1 -1
- package/dist/logic/selectionOverlayGeometry.d.ts +14 -0
- package/dist/logic/selectionOverlayGeometry.js +36 -4
- package/dist/model/gridTypes.core.d.ts +95 -3
- package/dist/utils/clipboard.cjs +5 -4
- package/dist/utils/clipboard.d.ts +10 -1
- package/dist/utils/clipboard.js +48 -33
- package/package.json +1 -1
|
@@ -2059,6 +2059,53 @@ export type GridLocaleText = {
|
|
|
2059
2059
|
findClose: string;
|
|
2060
2060
|
/** 検索の × のツールチップ。既定 `閉じる(Esc)`、英語 `Close (Esc)`。 */
|
|
2061
2061
|
findCloseHint: string;
|
|
2062
|
+
/** 置換の段を開く ▸ の読み上げの名前。既定 `置換の欄を開く`、英語 `Show replace`。 */
|
|
2063
|
+
findReplaceShow: string;
|
|
2064
|
+
/** 置換の段を閉じる ▸ の読み上げの名前。既定 `置換の欄を閉じる`、英語 `Hide replace`。 */
|
|
2065
|
+
findReplaceHide: string;
|
|
2066
|
+
/** 置換の段を開く ▸ のツールチップ。既定 `置換(Ctrl+H)`、英語 `Replace (Ctrl+H)`。 */
|
|
2067
|
+
findReplaceToggleHint: string;
|
|
2068
|
+
/** 置換後の入力欄の placeholder。既定 `置換後`、英語 `Replace`。 */
|
|
2069
|
+
findReplacePlaceholder: string;
|
|
2070
|
+
/** 置換後の入力欄の読み上げの名前。既定 `置換後の文字`、英語 `Replacement text`。 */
|
|
2071
|
+
findReplaceInput: string;
|
|
2072
|
+
/** 置換のボタン。既定 `置換`、英語 `Replace`。 */
|
|
2073
|
+
findReplace: string;
|
|
2074
|
+
/** 置換のボタンのツールチップ。既定 `今の当たりを置換して次へ(Enter)`、英語 `Replace this match and go to the next (Enter)`。 */
|
|
2075
|
+
findReplaceHint: string;
|
|
2076
|
+
/** すべて置換のボタン。既定 `すべて置換`、英語 `Replace all`。 */
|
|
2077
|
+
findReplaceAll: string;
|
|
2078
|
+
/** 「選んだ範囲だけ」のチェックボックス。既定 `選んだ範囲だけ`、英語 `In selection`。 */
|
|
2079
|
+
findInSelection: string;
|
|
2080
|
+
/** すべて置換の途中。既定 `置換中…`、英語 `Replacing…`。 */
|
|
2081
|
+
findReplacing: string;
|
|
2082
|
+
/** 置換の結果(飛ばしたセルが無いとき。`{replaced}` = 置換した数)。既定 `{replaced} 件を置換しました`、英語 `Replaced {replaced}`。 */
|
|
2083
|
+
findReplaced: GridLocaleTextTemplate<{
|
|
2084
|
+
replaced: number;
|
|
2085
|
+
}>;
|
|
2086
|
+
/** 置換の結果(飛ばしたセルがあるとき)。既定 `{replaced} 件を置換、{skipped} 件は置換できないため飛ばしました`、英語 `Replaced {replaced}, skipped {skipped} that cannot be replaced`。 */
|
|
2087
|
+
findReplacedSkipped: GridLocaleTextTemplate<{
|
|
2088
|
+
replaced: number;
|
|
2089
|
+
skipped: number;
|
|
2090
|
+
}>;
|
|
2091
|
+
/** すべて置換で当たりが無かったとき。既定 `置換するものがありません`、英語 `Nothing to replace`。 */
|
|
2092
|
+
findReplaceNothing: string;
|
|
2093
|
+
/** 今の当たりのセルを飛ばしたとき(変更できないセル)。既定 `このセルは変更できないため飛ばしました`、英語 `Skipped: this cell cannot be changed`。 */
|
|
2094
|
+
findReplaceCellSkipped: string;
|
|
2095
|
+
/** 今の当たりのセルを飛ばしたとき(置換できない種類の列。数値・日付・表示を書き換えた列など)。既定 `この列は置換できないため飛ばしました`、英語 `Skipped: this column cannot be replaced`。 */
|
|
2096
|
+
findReplaceCellUnsupported: string;
|
|
2097
|
+
/** 今の当たりのセルを飛ばしたとき(選択の列で、候補に無い名前になる)。既定 `候補に無い名前になるため飛ばしました`、英語 `Skipped: the result is not one of the options`。 */
|
|
2098
|
+
findReplaceCellNotOption: string;
|
|
2099
|
+
/** 今の当たりのセルを飛ばしたとき(入力の検査で断られた。`{message}` = 検査のメッセージ)。既定 `入力の検査で断られたため飛ばしました({message})`、英語 `Skipped: {message}`。 */
|
|
2100
|
+
findReplaceCellInvalid: GridLocaleTextTemplate<{
|
|
2101
|
+
message: string;
|
|
2102
|
+
}>;
|
|
2103
|
+
/** 今の当たりのセルを飛ばしたとき(置き換えても値が変わらない)。既定 `置き換えても値が変わらないため飛ばしました`、英語 `Skipped: the value would not change`。 */
|
|
2104
|
+
findReplaceCellUnchanged: string;
|
|
2105
|
+
/** 「選んだ範囲だけ」を入れるのに範囲が無いとき。既定 `先に表で 2 つ以上のセルを選んでください`、英語 `Select two or more cells first`。 */
|
|
2106
|
+
findInSelectionNeedsRange: string;
|
|
2107
|
+
/** すべて置換の間に表が変わり続けて、置換をやめたとき。既定 `表が変わり続けたため置換をやめました(何も置換していません)`、英語 `Stopped: the table kept changing (nothing was replaced)`。 */
|
|
2108
|
+
findReplaceInterrupted: string;
|
|
2062
2109
|
/** フィルのボタンのツールチップとメニューの名前。既定 `オートフィル オプション`、英語 `Auto Fill Options`。 */
|
|
2063
2110
|
fillOptions: string;
|
|
2064
2111
|
/** フィルのボタンの読み上げの名前(`{kind}` = `fillSeries` / `fillCopy`)。既定 `オートフィル オプション({kind})`、英語 `Auto Fill Options ({kind})`。 */
|
|
@@ -2964,15 +3011,33 @@ export type SpreadsheetGridHandle<T> = {
|
|
|
2964
3011
|
closeFilterManager: () => void;
|
|
2965
3012
|
/**
|
|
2966
3013
|
* 検索バーを開く(`find` が無効なら何もしない)。`query` を渡すとその文字列で検索し、
|
|
2967
|
-
*
|
|
3014
|
+
* 先頭のヒットへ移動する。省略時は空の欄で開く(閉じると探す文字は消える。
|
|
3015
|
+
* 開いているときは今の文字のまま)。`{ query?, replace? }`(`GridFindOpenOptions`)も渡せて、
|
|
3016
|
+
* `replace: true` で置換の段も開く(置換が使える表だけ。1.12.0 から)。
|
|
3017
|
+
* 開いているときに呼ぶと検索の欄へフォーカスを移す(1.12.0 から)。
|
|
2968
3018
|
*/
|
|
2969
|
-
openFind: (query?: string) => void;
|
|
3019
|
+
openFind: (query?: string | GridFindOpenOptions) => void;
|
|
2970
3020
|
/** 検索バーを閉じる(クエリとヒットの強調が消える。開いていなければ何もしない)。 */
|
|
2971
3021
|
closeFind: () => void;
|
|
2972
3022
|
/** 次のヒットへ(循環)。カレントのヒットへアクティブセルとスクロールが追従する。 */
|
|
2973
3023
|
findNext: () => void;
|
|
2974
3024
|
/** 前のヒットへ(循環)。 */
|
|
2975
3025
|
findPrev: () => void;
|
|
3026
|
+
/**
|
|
3027
|
+
* 今のヒットのセルを `text` で置換して、そのセルより後ろのヒットへ移る(`find={{ replace: true }}`
|
|
3028
|
+
* で置換が使えるときだけ。1.12.0 から)。戻り値は置換した数と飛ばした数(`GridFindReplaceResult` =
|
|
3029
|
+
* `{ replaced, skipped }`。変更できないセルは飛ばす)。`openFind({ query })`
|
|
3030
|
+
* の直後は検索が終わるまで当たりが無く 0 件(`onFindChange` で件数が出てから呼ぶ)。
|
|
3031
|
+
*/
|
|
3032
|
+
replaceNext: (text: string) => GridFindReplaceResult;
|
|
3033
|
+
/**
|
|
3034
|
+
* 今の検索の文字をすべて `text` で置換する(1 回の変更 = 元に戻すも 1 回。1.12.0 から)。
|
|
3035
|
+
* すべての行を時間で分けて調べ、終わったら置換した数と飛ばした数で解決する
|
|
3036
|
+
* `Promise<GridFindReplaceResult>` を返す。
|
|
3037
|
+
* 途中で検索バーを閉じた・表が変わり続けたなどでやめたときは何も書かずに
|
|
3038
|
+
* `{ replaced: 0, skipped: 0 }`。
|
|
3039
|
+
*/
|
|
3040
|
+
replaceAll: (text: string) => Promise<GridFindReplaceResult>;
|
|
2976
3041
|
/**
|
|
2977
3042
|
* 指定したグループを開く(`true`)/ 閉じる(`false`。1.6.0 から)。開閉できない(`collapsible` の無い)
|
|
2978
3043
|
* グループと、無いキーのときは何もせず開発時に警告する。今の開閉は
|
|
@@ -3073,6 +3138,15 @@ export type GridConditionalFormat<T, F extends GridFrameworkTypes = GridFramewor
|
|
|
3073
3138
|
export type FindOptions = {
|
|
3074
3139
|
shortcut?: boolean | undefined;
|
|
3075
3140
|
caseSensitive?: boolean | undefined;
|
|
3141
|
+
replace?: boolean | undefined;
|
|
3142
|
+
};
|
|
3143
|
+
export type GridFindOpenOptions = {
|
|
3144
|
+
query?: string | undefined;
|
|
3145
|
+
replace?: boolean | undefined;
|
|
3146
|
+
};
|
|
3147
|
+
export type GridFindReplaceResult = {
|
|
3148
|
+
replaced: number;
|
|
3149
|
+
skipped: number;
|
|
3076
3150
|
};
|
|
3077
3151
|
export type FindChangeParams = {
|
|
3078
3152
|
query: string;
|
|
@@ -3338,6 +3412,24 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
|
|
|
3338
3412
|
* @defaultValue `true`
|
|
3339
3413
|
*/
|
|
3340
3414
|
pasteFillsSelection?: boolean | undefined;
|
|
3415
|
+
/**
|
|
3416
|
+
* コピー(`Ctrl/Cmd+C`)と切り取り(`Ctrl/Cmd+X`)でクリップボードへ書く形(1.12.0 から)。`'text'`
|
|
3417
|
+
* は今までどおりの TSV だけ。`'rich'` は TSV と一緒に罫線・寄せ・色の付いた表(text/html)も書き、
|
|
3418
|
+
* Excel・Google スプレッドシート・Word・メールに貼ると表の形になる(このグリッドへの貼り付けは TSV
|
|
3419
|
+
* を読む)。20,000 セルを超える範囲は TSV だけ。中身は「書式つきのコピー(`copyFormat` /
|
|
3420
|
+
* `copyHeaders`)」節。
|
|
3421
|
+
*
|
|
3422
|
+
* @defaultValue `'text'`
|
|
3423
|
+
*/
|
|
3424
|
+
copyFormat?: 'text' | 'rich' | undefined;
|
|
3425
|
+
/**
|
|
3426
|
+
* コピーの先頭に列の名前の行(列のグループ(`columnGroups`)の段も)を入れる(1.12.0 から。
|
|
3427
|
+
* `copyFormat` が `'text'` でも効く)。切り取りと 1 セルだけのコピーには入れない。
|
|
3428
|
+
* このグリッドでコピーした見出しつきの文字をそのままこのグリッドへ貼ったときは見出しの行を飛ばす。
|
|
3429
|
+
*
|
|
3430
|
+
* @defaultValue `false`
|
|
3431
|
+
*/
|
|
3432
|
+
copyHeaders?: boolean | undefined;
|
|
3341
3433
|
/**
|
|
3342
3434
|
* Excel と同じキーの操作(1.10.0 から)。何も渡さないときは `Ctrl` / `⌘+X`
|
|
3343
3435
|
* の切り取りだけが効く(今までは何も起きなかったキー)。`true` で 7 つ(切り取り・`Ctrl+D`
|
|
@@ -3534,7 +3626,7 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
|
|
|
3534
3626
|
* 適用後)への部分一致で、ヒットをすべて `<mark class="ssg-find-mark">` で強調し、`Enter` / `↓`
|
|
3535
3627
|
* で次、`Shift+Enter` / `↑` で前へ(アクティブセルとスクロールが追従)、`Esc` で閉じる。
|
|
3536
3628
|
* 行は消さない(絞り込みのフィルターとは別)。`FindOptions` =
|
|
3537
|
-
* `{ shortcut?: boolean(既定 true。false でブラウザ標準の検索に譲る), caseSensitive?: boolean(既定 false) }`。
|
|
3629
|
+
* `{ shortcut?: boolean(既定 true。false でブラウザ標準の検索に譲る), caseSensitive?: boolean(既定 false), replace?: boolean(既定 false。true で置換の段と `Ctrl+H`。1.12.0 から。「検索と置換」節) }`。
|
|
3538
3630
|
* 走査は時間分割(1 チャンク 10ms)で入力を止めない。SSRM はロード済み範囲だけが対象。ヒットは 10,
|
|
3539
3631
|
* 000 件で打ち切り(件数に `+`)。詳細は「セル内検索」節。
|
|
3540
3632
|
*
|
package/dist/utils/clipboard.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./permissions.cjs"),t=require("./shadowDom.cjs"),n=require("../logic/detailRow.cjs"),r=require("../model/gridSelectors.cjs"),i=require("../logic/selectLabels.cjs"),a=require("../logic/editorValues.cjs"),o=require("../logic/validation.cjs");var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./permissions.cjs"),t=require("./shadowDom.cjs"),n=require("../logic/detailRow.cjs"),r=require("../model/gridSelectors.cjs"),i=require("../logic/selectLabels.cjs"),a=require("../logic/editorValues.cjs"),o=require("../logic/validation.cjs"),s=require("../logic/columnGroupCells.cjs");var c=e=>{let t=e.replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
3
|
`);if(!t)return[];let n=[],r=[],i=``,a=0,o=t.length,s=-1,c=0;for(;a<o;){let e=t[a];if(i===``&&e===`"`&&a===c&&a!==s){let e=a+1,n=``,r=!1;for(;e<o;){let i=t[e];if(i===`"`){if(t[e+1]===`"`){n+=`"`,e+=2;continue}r=!0,e+=1;break}n+=i,e+=1}if(!r){s=a;continue}i=n,a=e;continue}if(e===` `){r.push(i),i=``,a+=1,c=a;continue}if(e===`
|
|
4
4
|
`){r.push(i),n.push(r),r=[],i=``,a+=1,c=a;continue}i+=e,a+=1}return i===``&&r.length===0&&t.endsWith(`
|
|
5
|
-
`)||(r.push(i),n.push(r)),n},
|
|
6
|
-
`);return t!==void 0&&/^\t*$/.test(t)?`${n}\n`:n},
|
|
7
|
-
[
|
|
5
|
+
`)||(r.push(i),n.push(r)),n},l=e=>/[\t\n\r"]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,u=e=>e.map(l).join(` `),d=e=>{let t=e[e.length-1],n=e.join(`
|
|
6
|
+
`);return t!==void 0&&/^\t*$/.test(t)?`${n}\n`:n},f=e=>e!==void 0&&!n.isSyntheticColumnKey(e.key),p=(e,t,n)=>{let r=[];for(let i=t;r.length<n;i+=1){let t=e[i];(t===void 0||f(t))&&r.push(i)}return r},m=(t,n,r)=>i.formatCellClipboardText(n,e.getCellValue(t,n),t,r),h=e=>e.filter(f),g=(e,t)=>{let n=e?s.buildColumnGroupExportRows(e,t.map(e=>e.key)).filter(e=>e.length>0):[];return{groupRows:n,depths:t.map(t=>Math.min(e?.pathByColumn.get(t.key)?.length??0,n.length))}},_=2e4,v=e=>e.title||e.key,y=(e,t)=>[...e.groupRows.map(e=>{let n=t.map(()=>``);for(let t of e)n[t.start]=t.title;return u(n)}),u(t.map(v))].join(`
|
|
7
|
+
`),b=(e,t,n,a,o,s,c)=>{if(!a)return``;let l=[],p=(e,t,n)=>{let r=s?.(n);return r!==void 0&&t.key in r?i.formatCellClipboardText(t,r[t.key],e,c):m(e,t,c)};if(a.type===`cell`){let t=r.normalizeCellRange(a.range),i=n.slice(t.start.col,t.end.col+1).filter(f);if(i.length===0)return``;for(let n=t.start.row;n<=t.end.row;n+=1){let t=e(n);t&&(o&&!o(t,n)||l.push(u(i.map(e=>p(t,e,n)))))}return d(l)}if(a.type===`row`){let t=r.normalizeRowRange(a.startRow,a.endRow),i=n.filter(f);if(i.length===0)return``;for(let n=t.startRow;n<=t.endRow;n+=1){let t=e(n);t&&(o&&!o(t,n)||l.push(u(i.map(e=>p(t,e,n)))))}return d(l)}let h=r.normalizeColumnRange(a.startCol,a.endCol),g=n.slice(h.startCol,h.endCol+1).filter(f);if(g.length===0)return``;for(let n=0;n<t;n+=1){let t=e(n);t&&(o&&!o(t,n)||l.push(u(g.map(e=>p(t,e,n)))))}return d(l)},x=(t,n,r,i,s,c,l,u,d)=>{if(i.length===0)return t;let f=[...t],m=!1,h=p(r,c,i.reduce((e,t)=>Math.max(e,t.length),0));for(let t=0;t<i.length;t+=1){let c=s+t,p=n(c);if(p===void 0)continue;let g=f[p];if(!g)continue;let _=e.createCellWriteDraft(g),v=!1;for(let n=0;n<i[t].length;n+=1){let s=h[n],f=r[s];if(!f)continue;let m=i[t][n];if(!l(p,s,g,f,c)){u?.({rowIndex:c,sourceRowIndex:p,colIndex:s,row:g,column:f,text:m,reason:`readOnly`});continue}let y=a.resolveCellParser(f,d?.multiSelectSeparator)(m,g),b=o.decideCellWrite(f,g,y,d);if(b.action===`reject`){u?.({rowIndex:c,sourceRowIndex:p,colIndex:s,row:g,column:f,text:m,reason:`invalid`,value:y,message:b.message});continue}e.writeCellValue(_,f,y),v=!0}v&&(f[p]=_.row,m=!0)}return m?f:t},S=(e,t,n,r,i,s,c,l)=>{let u=[],d=p(t,i,n.reduce((e,t)=>Math.max(e,t.length),0));for(let i=0;i<n.length;i+=1){let f=r+i,p=e(f);if(p)for(let e=0;e<n[i].length;e+=1){let r=d[e],m=t[r];if(!m)continue;let h=n[i][e];if(!s(f,r,p,m)){c?.({rowIndex:f,sourceRowIndex:void 0,colIndex:r,row:p,column:m,text:h,reason:`readOnly`});continue}let g=a.resolveCellParser(m,l?.multiSelectSeparator)(h,p),_=o.decideCellWrite(m,p,g,l);if(_.action===`reject`){c?.({rowIndex:f,sourceRowIndex:void 0,colIndex:r,row:p,column:m,text:h,reason:`invalid`,value:g,message:_.message});continue}u.push({viewIndex:f,column:m,value:g})}}return u},C=(e,n)=>{let{body:r}=document,i=t.getDeepActiveElement();if(!r)return!1;let a=document.createElement(`textarea`);a.value=e,a.setAttribute(`readonly`,``),a.style.position=`fixed`,a.style.top=`0`,a.style.left=`-9999px`,a.style.opacity=`0`,r.appendChild(a);let o=!1,s=t=>{n===void 0||!t.clipboardData||(t.clipboardData.setData(`text/plain`,e),t.clipboardData.setData(`text/html`,n),t.preventDefault(),t.stopImmediatePropagation(),o=!0)};n!==void 0&&document.addEventListener(`copy`,s,!0);let c;try{a.select(),c=document.execCommand(`copy`)}catch{c=!1}finally{n!==void 0&&document.removeEventListener(`copy`,s,!0),r.removeChild(a),i instanceof HTMLElement&&i.focus()}return n===void 0?c:c&&o},w=async e=>{if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}return C(e)?!0:(console.warn(`[SpreadsheetGrid] クリップボードへのコピーに失敗しました(navigator.clipboard が利用できず、execCommand フォールバックも失敗)。
|
|
8
|
+
[SpreadsheetGrid] Failed to copy to the clipboard (navigator.clipboard is unavailable and the execCommand fallback failed).`),!1)};exports.RICH_COPY_MAX_CELLS=_,exports.applyClipboardMatrixToRows=x,exports.buildClipboardCellEdits=S,exports.buildClipboardHeaderText=y,exports.clipboardHeaderTitle=v,exports.copyTextViaExecCommand=C,exports.escapeTsvField=l,exports.filterClipboardColumns=h,exports.formatClipboardCell=m,exports.joinTsvLines=d,exports.joinTsvRow=u,exports.parseClipboardText=c,exports.resolveClipboardHeaderLayout=g,exports.resolvePasteColumnIndexes=p,exports.serializeSelectionToTsv=b,exports.writeTextToClipboard=w;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GridColumn } from '../model/gridTypes.unbound.js';
|
|
2
2
|
import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
|
|
3
3
|
import { type ValidationLocaleText } from '../logic/validation.js';
|
|
4
|
+
import { type ColumnGroupExportCell, type ColumnGroupTree } from '../logic/columnGroupCells.js';
|
|
4
5
|
export type ClipboardMatrix = string[][];
|
|
5
6
|
export declare const parseClipboardText: (text: string) => ClipboardMatrix;
|
|
6
7
|
export declare const escapeTsvField: (value: string) => string;
|
|
@@ -9,6 +10,14 @@ export declare const joinTsvLines: (lines: string[]) => string;
|
|
|
9
10
|
export declare const resolvePasteColumnIndexes: <T>(columns: GridColumn<T>[], startColIndex: number, width: number) => number[];
|
|
10
11
|
export declare const formatClipboardCell: <T>(row: T, column: GridColumn<T>, separator?: string) => string;
|
|
11
12
|
export declare const filterClipboardColumns: <T>(columns: GridColumn<T>[]) => GridColumn<T>[];
|
|
13
|
+
export type ClipboardHeaderLayout = {
|
|
14
|
+
groupRows: ColumnGroupExportCell[][];
|
|
15
|
+
depths: number[];
|
|
16
|
+
};
|
|
17
|
+
export declare const resolveClipboardHeaderLayout: <T>(tree: ColumnGroupTree | null | undefined, columns: readonly GridColumn<T>[]) => ClipboardHeaderLayout;
|
|
18
|
+
export declare const RICH_COPY_MAX_CELLS = 20000;
|
|
19
|
+
export declare const clipboardHeaderTitle: <T>(column: GridColumn<T>) => string;
|
|
20
|
+
export declare const buildClipboardHeaderText: <T>(layout: ClipboardHeaderLayout, columns: readonly GridColumn<T>[]) => string;
|
|
12
21
|
export declare const serializeSelectionToTsv: <T>(getRow: (viewIndex: number) => T, viewRowCount: number, columns: GridColumn<T>[], selection: {
|
|
13
22
|
type: "cell";
|
|
14
23
|
range: {
|
|
@@ -43,5 +52,5 @@ export type PasteSkip<T> = {
|
|
|
43
52
|
};
|
|
44
53
|
export declare const applyClipboardMatrixToRows: <T extends object>(rows: T[], resolveSourceIndex: (viewIndex: number) => number | undefined, columns: GridColumn<T>[], matrix: ClipboardMatrix, startRowIndex: number, startColIndex: number, canWriteCell: (originalRowIndex: number, colIndex: number, row: T, column: GridColumn<T>, filteredRowIndex: number) => boolean, onSkip?: (skip: PasteSkip<T>) => void, validationTexts?: ValidationLocaleText) => T[];
|
|
45
54
|
export declare const buildClipboardCellEdits: <T extends object>(getRow: (viewIndex: number) => T | undefined, columns: GridColumn<T>[], matrix: ClipboardMatrix, startRowIndex: number, startColIndex: number, canWriteCell: (viewIndex: number, colIndex: number, row: T, column: GridColumn<T>) => boolean, onSkip?: (skip: PasteSkip<T>) => void, validationTexts?: ValidationLocaleText) => ServerSideCellEditInput<T>[];
|
|
46
|
-
export declare const copyTextViaExecCommand: (text: string) => boolean;
|
|
55
|
+
export declare const copyTextViaExecCommand: (text: string, html?: string) => boolean;
|
|
47
56
|
export declare const writeTextToClipboard: (text: string) => Promise<boolean>;
|
package/dist/utils/clipboard.js
CHANGED
|
@@ -5,8 +5,9 @@ import { normalizeCellRange as a, normalizeColumnRange as o, normalizeRowRange a
|
|
|
5
5
|
import { formatCellClipboardText as c } from "../logic/selectLabels.js";
|
|
6
6
|
import { resolveCellParser as l } from "../logic/editorValues.js";
|
|
7
7
|
import { decideCellWrite as u } from "../logic/validation.js";
|
|
8
|
+
import { buildColumnGroupExportRows as d } from "../logic/columnGroupCells.js";
|
|
8
9
|
//#region src/utils/clipboard.ts
|
|
9
|
-
var
|
|
10
|
+
var f = (e) => {
|
|
10
11
|
let t = e.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
11
12
|
if (!t) return [];
|
|
12
13
|
let n = [], r = [], i = "", a = 0, o = t.length, s = -1, c = 0;
|
|
@@ -44,50 +45,60 @@ var d = (e) => {
|
|
|
44
45
|
i += e, a += 1;
|
|
45
46
|
}
|
|
46
47
|
return i === "" && r.length === 0 && t.endsWith("\n") || (r.push(i), n.push(r)), n;
|
|
47
|
-
},
|
|
48
|
+
}, p = (e) => /[\t\n\r"]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e, m = (e) => e.map(p).join(" "), h = (e) => {
|
|
48
49
|
let t = e[e.length - 1], n = e.join("\n");
|
|
49
50
|
return t !== void 0 && /^\t*$/.test(t) ? `${n}\n` : n;
|
|
50
|
-
},
|
|
51
|
+
}, g = (e) => e !== void 0 && !i(e.key), _ = (e, t, n) => {
|
|
51
52
|
let r = [];
|
|
52
53
|
for (let i = t; r.length < n; i += 1) {
|
|
53
54
|
let t = e[i];
|
|
54
|
-
(t === void 0 ||
|
|
55
|
+
(t === void 0 || g(t)) && r.push(i);
|
|
55
56
|
}
|
|
56
57
|
return r;
|
|
57
|
-
},
|
|
58
|
+
}, v = (e, n, r) => c(n, t(e, n), e, r), y = (e) => e.filter(g), b = (e, t) => {
|
|
59
|
+
let n = e ? d(e, t.map((e) => e.key)).filter((e) => e.length > 0) : [];
|
|
60
|
+
return {
|
|
61
|
+
groupRows: n,
|
|
62
|
+
depths: t.map((t) => Math.min(e?.pathByColumn.get(t.key)?.length ?? 0, n.length))
|
|
63
|
+
};
|
|
64
|
+
}, x = 2e4, S = (e) => e.title || e.key, C = (e, t) => [...e.groupRows.map((e) => {
|
|
65
|
+
let n = t.map(() => "");
|
|
66
|
+
for (let t of e) n[t.start] = t.title;
|
|
67
|
+
return m(n);
|
|
68
|
+
}), m(t.map(S))].join("\n"), w = (e, t, n, r, i, l, u) => {
|
|
58
69
|
if (!r) return "";
|
|
59
70
|
let d = [], f = (e, t, n) => {
|
|
60
71
|
let r = l?.(n);
|
|
61
|
-
return r !== void 0 && t.key in r ? c(t, r[t.key], e, u) :
|
|
72
|
+
return r !== void 0 && t.key in r ? c(t, r[t.key], e, u) : v(e, t, u);
|
|
62
73
|
};
|
|
63
74
|
if (r.type === "cell") {
|
|
64
|
-
let t = a(r.range), o = n.slice(t.start.col, t.end.col + 1).filter(
|
|
75
|
+
let t = a(r.range), o = n.slice(t.start.col, t.end.col + 1).filter(g);
|
|
65
76
|
if (o.length === 0) return "";
|
|
66
77
|
for (let n = t.start.row; n <= t.end.row; n += 1) {
|
|
67
78
|
let t = e(n);
|
|
68
|
-
t && (i && !i(t, n) || d.push(
|
|
79
|
+
t && (i && !i(t, n) || d.push(m(o.map((e) => f(t, e, n)))));
|
|
69
80
|
}
|
|
70
|
-
return
|
|
81
|
+
return h(d);
|
|
71
82
|
}
|
|
72
83
|
if (r.type === "row") {
|
|
73
|
-
let t = s(r.startRow, r.endRow), a = n.filter(
|
|
84
|
+
let t = s(r.startRow, r.endRow), a = n.filter(g);
|
|
74
85
|
if (a.length === 0) return "";
|
|
75
86
|
for (let n = t.startRow; n <= t.endRow; n += 1) {
|
|
76
87
|
let t = e(n);
|
|
77
|
-
t && (i && !i(t, n) || d.push(
|
|
88
|
+
t && (i && !i(t, n) || d.push(m(a.map((e) => f(t, e, n)))));
|
|
78
89
|
}
|
|
79
|
-
return
|
|
90
|
+
return h(d);
|
|
80
91
|
}
|
|
81
|
-
let
|
|
82
|
-
if (
|
|
92
|
+
let p = o(r.startCol, r.endCol), _ = n.slice(p.startCol, p.endCol + 1).filter(g);
|
|
93
|
+
if (_.length === 0) return "";
|
|
83
94
|
for (let n = 0; n < t; n += 1) {
|
|
84
95
|
let t = e(n);
|
|
85
|
-
t && (i && !i(t, n) || d.push(
|
|
96
|
+
t && (i && !i(t, n) || d.push(m(_.map((e) => f(t, e, n)))));
|
|
86
97
|
}
|
|
87
|
-
return
|
|
88
|
-
},
|
|
98
|
+
return h(d);
|
|
99
|
+
}, T = (t, r, i, a, o, s, c, d, f) => {
|
|
89
100
|
if (a.length === 0) return t;
|
|
90
|
-
let p = [...t], m = !1, h =
|
|
101
|
+
let p = [...t], m = !1, h = _(i, s, a.reduce((e, t) => Math.max(e, t.length), 0));
|
|
91
102
|
for (let t = 0; t < a.length; t += 1) {
|
|
92
103
|
let s = o + t, g = r(s);
|
|
93
104
|
if (g === void 0) continue;
|
|
@@ -130,8 +141,8 @@ var d = (e) => {
|
|
|
130
141
|
y && (p[g] = v.row, m = !0);
|
|
131
142
|
}
|
|
132
143
|
return m ? p : t;
|
|
133
|
-
},
|
|
134
|
-
let c = [], d =
|
|
144
|
+
}, E = (e, t, n, r, i, a, o, s) => {
|
|
145
|
+
let c = [], d = _(t, i, n.reduce((e, t) => Math.max(e, t.length), 0));
|
|
135
146
|
for (let i = 0; i < n.length; i += 1) {
|
|
136
147
|
let f = r + i, p = e(f);
|
|
137
148
|
if (p) for (let e = 0; e < n[i].length; e += 1) {
|
|
@@ -173,25 +184,29 @@ var d = (e) => {
|
|
|
173
184
|
}
|
|
174
185
|
}
|
|
175
186
|
return c;
|
|
176
|
-
},
|
|
177
|
-
let { body:
|
|
178
|
-
if (!
|
|
179
|
-
let
|
|
180
|
-
|
|
181
|
-
let
|
|
187
|
+
}, D = (e, t) => {
|
|
188
|
+
let { body: n } = document, i = r();
|
|
189
|
+
if (!n) return !1;
|
|
190
|
+
let a = document.createElement("textarea");
|
|
191
|
+
a.value = e, a.setAttribute("readonly", ""), a.style.position = "fixed", a.style.top = "0", a.style.left = "-9999px", a.style.opacity = "0", n.appendChild(a);
|
|
192
|
+
let o = !1, s = (n) => {
|
|
193
|
+
t === void 0 || !n.clipboardData || (n.clipboardData.setData("text/plain", e), n.clipboardData.setData("text/html", t), n.preventDefault(), n.stopImmediatePropagation(), o = !0);
|
|
194
|
+
};
|
|
195
|
+
t !== void 0 && document.addEventListener("copy", s, !0);
|
|
196
|
+
let c;
|
|
182
197
|
try {
|
|
183
|
-
|
|
198
|
+
a.select(), c = document.execCommand("copy");
|
|
184
199
|
} catch {
|
|
185
|
-
|
|
200
|
+
c = !1;
|
|
186
201
|
} finally {
|
|
187
|
-
t.
|
|
202
|
+
t !== void 0 && document.removeEventListener("copy", s, !0), n.removeChild(a), i instanceof HTMLElement && i.focus();
|
|
188
203
|
}
|
|
189
|
-
return
|
|
190
|
-
},
|
|
204
|
+
return t === void 0 ? c : c && o;
|
|
205
|
+
}, O = async (e) => {
|
|
191
206
|
if (navigator.clipboard?.writeText) try {
|
|
192
207
|
return await navigator.clipboard.writeText(e), !0;
|
|
193
208
|
} catch {}
|
|
194
|
-
return
|
|
209
|
+
return D(e) ? !0 : (console.warn("[SpreadsheetGrid] クリップボードへのコピーに失敗しました(navigator.clipboard が利用できず、execCommand フォールバックも失敗)。\n[SpreadsheetGrid] Failed to copy to the clipboard (navigator.clipboard is unavailable and the execCommand fallback failed)."), !1);
|
|
195
210
|
};
|
|
196
211
|
//#endregion
|
|
197
|
-
export {
|
|
212
|
+
export { x as RICH_COPY_MAX_CELLS, T as applyClipboardMatrixToRows, E as buildClipboardCellEdits, C as buildClipboardHeaderText, S as clipboardHeaderTitle, D as copyTextViaExecCommand, p as escapeTsvField, y as filterClipboardColumns, v as formatClipboardCell, h as joinTsvLines, m as joinTsvRow, f as parseClipboardText, b as resolveClipboardHeaderLayout, _ as resolvePasteColumnIndexes, w as serializeSelectionToTsv, O as writeTextToClipboard };
|
package/package.json
CHANGED