【コンポ】機能拡張版テンプレの登録方法!
1. キーボードで Ctrl + Shift + B を押してください
2. 下の「登録はこちら」を、画面上のブックマークバーへドラッグ&ドロップしてください
i;)a.cvImportMedia.splice(a.cvImportMedia.length-1,1);setTimeout(function(){var a=I();e.forEach(function(e,t){a.cvImportMedia[t]&&(a.cvImportMedia[t].mediaName=e.mediaName,a.cvImportMedia[t].mediaNumber=e.mediaNumber,a.cvImportMedia[t].sortIndex=e.sortIndex)}),t()},500)}(r,e):e()};d=function(){o(function(){p()})},i.length>0?setTimeout(function(){i.forEach(function(e){N(e.def,e.saved)}),d()},500):d();var d}(e)},t?500:0)}function O(){h.innerHTML="";var e=D("div","tpl-header"),t={list:"📋 "+m+"テンプレ",save:"💾 "+m+"テンプレ保存",manage:"⚙️ "+m+"テンプレ管理",edit:"📝 "+m+"テンプレ編集"};e.innerHTML=""+t[y]+"
";var a=D("button","tpl-close");a.textContent="✕",a.onclick=function(){f.remove()},e.appendChild(a),h.appendChild(e);var i=D("div","tpl-body");if("edit"!==y){var n=D("div","tpl-tab-bar");[{id:"list",label:"適用"},{id:"save",label:"保存"},{id:"manage",label:"管理"}].forEach(function(e){var t=D("div","tpl-tab"+(y===e.id?" active":""));t.textContent=e.label,t.onclick=function(){y=e.id,O()},n.appendChild(t)}),i.appendChild(n)}"list"===y?function(e){var t=V();if(0===t.length){var a=D("div","tpl-empty");return a.style.whiteSpace="pre-line",a.textContent="テンプレがありません。\n「保存」タブから現在の入力内容を\nテンプレとして保存できます。",void e.appendChild(a)}t.forEach(function(t){var a=D("div","tpl-list-item"),i=D("span","tpl-list-name");if(i.textContent=t.name,a.appendChild(i),"import"===l&&t.importType){var n=D("span","tpl-import-type-badge");n.textContent=C(t.importType),a.appendChild(n)}var r=D("span","tpl-list-meta"),p=Object.keys(t.fields).filter(function(e){return t.fields[e].enabled}).length;r.textContent=p+"項目",a.appendChild(r),a.onclick=function(){L(t)},e.appendChild(a)})}(i):"save"===y?function(e){var t=D("div");t.textContent="テンプレ名",t.style.cssText="font-size:13px;font-weight:600;margin-bottom:6px;color:%23333",e.appendChild(t);var a=document.createElement("input");a.className="tpl-name-input",a.placeholder="例: 社会部",e.appendChild(a);var i={},n={};s.forEach(function(t){var a=c.filter(function(e){if(e.group!==t)return!1;if("import"===l&&e.importTypeOnly){var a=I().type;if(e.importTypeOnly!==a)return!1}return!0});if(0!==a.length){var r=D("div","tpl-group-title"),p=D("div");p.style.cssText="display:flex;align-items:center;justify-content:space-between";var o=D("span");o.textContent=u[t],p.appendChild(o);var d=D("span","tpl-select-all");d.textContent="全選択",d.onclick=function(){var e=a.every(function(e){return n[e.id]&&n[e.id].checked});a.forEach(function(t){n[t.id]&&(n[t.id].checked=!e)})},p.appendChild(d),r.appendChild(p),e.appendChild(r),a.forEach(function(t){var a=D("div","tpl-field-row"),r=document.createElement("input");r.type="checkbox",r.id="tpl-cb-"+t.id,n[t.id]=r;var p=document.createElement("label");p.htmlFor=r.id,p.appendChild(r);var l=D("span");l.textContent=t.label,p.appendChild(l),a.appendChild(p);var o=D("span","tpl-val"),d=S(t),c=E(t,d);if(o.textContent=c||"(空)",o.title=c||"(空)",a.appendChild(o),e.appendChild(a),t.specialAction){i[t.id]={value:"current"};var u=D("div","tpl-special-opt"),m=document.createElement("label"),s=document.createElement("input");s.type="radio",s.name="mode_"+t.id,s.value="current",s.checked=!0,s.onchange=function(){i[t.id].value="current"},m.appendChild(s),m.appendChild(document.createTextNode(" 現在入力値を保存"));var v=document.createElement("label"),g=document.createElement("input");g.type="radio",g.name="mode_"+t.id,g.value=t.specialAction,g.onchange=function(){i[t.id].value=t.specialAction},v.appendChild(g);var f="monthButton"===t.specialAction?" 月副題ボタンで自動セット":" テンプレ適用日を自動セット";v.appendChild(document.createTextNode(f)),u.appendChild(m),u.appendChild(v),e.appendChild(u)}if("mediaList"===t.type){var h=D("div","tpl-media-detail");h.textContent=A(d.value),e.appendChild(h)}})}});var r=D("div","tpl-footer"),p=D("button","tpl-btn tpl-btn-secondary");p.textContent="キャンセル",p.onclick=function(){y="list",O()};var o=D("button","tpl-btn tpl-btn-primary");o.textContent="保存",o.onclick=function(){var e=a.value.trim();if(!e)return a.style.borderColor="%23c62828",void a.focus();var t={};c.forEach(function(e){if("import"===l&&e.importTypeOnly){var a=I().type;if(e.importTypeOnly!==a)return}var r=!(!n[e.id]||!n[e.id].checked),p=S(e),o={enabled:r};"mediaList"===e.type?o.value=p.value:(o.value=p.value,void 0!==p.name&&(o.name=p.name),void 0!==p.typeVal&&(o.typeVal=p.typeVal)),e.specialAction&&i[e.id]&&"current"!==i[e.id].value&&(o.action=i[e.id].value),t[e.id]=o});var r={name:e,createdAt:(new Date).toISOString(),fields:t};"import"===l&&(r.importType=I().type);var p=V();p.push(r),_(p),alert("テンプレ「"+e+"」を保存しました。"),y="list",O()},r.appendChild(p),r.appendChild(o),h.appendChild(r)}(i):"edit"===y?function(e){var t=V()[b];if(!t)return y="manage",void O();var a=D("div");a.textContent="テンプレ名",a.style.cssText="font-size:13px;font-weight:600;margin-bottom:6px;color:%23333",e.appendChild(a);var i=document.createElement("input");if(i.className="tpl-name-input",i.value=t.name,e.appendChild(i),"import"===l&&t.importType){var n=D("div");n.style.cssText="font-size:12px;color:%23666;margin:4px 0 0 2px",n.textContent="取込種別: "+C(t.importType),e.appendChild(n)}var r={},p={},o={};function d(){var e={};return c.forEach(function(a){if("import"===l&&a.importTypeOnly&&t.importType&&a.importTypeOnly!==t.importType)t.fields[a.id]&&(e[a.id]=t.fields[a.id]);else{var i=!(!r[a.id]||!r[a.id].checked),n=t.fields[a.id],d=x[a.id],c={enabled:i};if(a.specialAction)(o[a.id]?o[a.id].value:"current")===a.specialAction?(c.action=a.specialAction,c.value=d?d.value:"",d&&void 0!==d.name&&(c.name=d.name),d&&void 0!==d.typeVal&&(c.typeVal=d.typeVal)):(c.value=d?d.value:"",d&&void 0!==d.name&&(c.name=d.name),d&&void 0!==d.typeVal&&(c.typeVal=d.typeVal));else"current"===(p[a.id]?p[a.id].value:"saved")?"mediaList"===a.type?c.value=d?d.value:[]:(c.value=d?d.value:"",d&&void 0!==d.name&&(c.name=d.name),d&&void 0!==d.typeVal&&(c.typeVal=d.typeVal)):n?(c.value=n.value,void 0!==n.name&&(c.name=n.name),void 0!==n.typeVal&&(c.typeVal=n.typeVal)):c.value="mediaList"===a.type?[]:"";e[a.id]=c}}),e}s.forEach(function(a){var i=c.filter(function(e){if(e.group!==a)return!1;if("import"===l&&e.importTypeOnly){if(!t.importType)return!0;if(e.importTypeOnly!==t.importType)return!1}return!0});if(0!==i.length){var n=D("div","tpl-group-title");n.textContent=u[a],e.appendChild(n),i.forEach(function(a){var i=t.fields[a.id],n=x[a.id],l=D("div","tpl-field-row"),d=document.createElement("input");d.type="checkbox",d.id="tpl-ecb-"+a.id,d.checked=!(!i||!i.enabled),r[a.id]=d;var c=document.createElement("label");c.htmlFor=d.id,c.appendChild(d);var u=D("span");u.textContent=a.label,c.appendChild(u),l.appendChild(c);var m=function(e,t){if(!t)return"";if("monthButton"===t.action)return"(月副題ボタンで自動セット)";if("today"===t.action)return"(テンプレ適用日を自動セット)";if("mediaList"===e.type){return(t.value||[]).length+"行"}return E(e,t)}(a,i),s=E(a,n),v=D("span","tpl-val"),g="保存値: "+(m||"(空)")+" / 現在入力値: "+(s||"(空)");if(v.textContent=g,v.title=g,v.style.maxWidth="320px",l.appendChild(v),e.appendChild(l),a.specialAction){var f=i&&i.action===a.specialAction?a.specialAction:"current";o[a.id]={value:f};var h=D("div","tpl-special-opt"),y=document.createElement("label"),b=document.createElement("input");b.type="radio",b.name="emode_"+a.id,b.value="current",b.checked="current"===f,b.onchange=function(){o[a.id].value="current"},y.appendChild(b),y.appendChild(document.createTextNode(" 現在入力値を保存"));var C=document.createElement("label"),T=document.createElement("input");T.type="radio",T.name="emode_"+a.id,T.value=a.specialAction,T.checked=f===a.specialAction,T.onchange=function(){o[a.id].value=a.specialAction},C.appendChild(T);var I="monthButton"===a.specialAction?" 月副題ボタンで自動セット":" テンプレ適用日を自動セット";C.appendChild(document.createTextNode(I)),h.appendChild(y),h.appendChild(C),e.appendChild(h)}else{p[a.id]={value:"saved"};var S=D("div","tpl-special-opt"),k=document.createElement("label"),w=document.createElement("input");w.type="radio",w.name="src_"+a.id,w.value="saved",w.checked=!0,w.onchange=function(){p[a.id].value="saved"},k.appendChild(w),k.appendChild(document.createTextNode(" 保存値を使う"));var N=document.createElement("label"),V=document.createElement("input");V.type="radio",V.name="src_"+a.id,V.value="current",V.onchange=function(){p[a.id].value="current"},N.appendChild(V),N.appendChild(document.createTextNode(" 現在入力値で上書き")),S.appendChild(k),S.appendChild(N),e.appendChild(S)}if("mediaList"===a.type){var _=D("div","tpl-media-detail"),L=i&&i.value||[],O=n&&n.value||[],z="【保存値】\n"+A(L)+"\n\n【現在入力値】\n"+A(O);_.textContent=z,e.appendChild(_)}})}});var m=D("div","tpl-footer"),v=D("button","tpl-btn tpl-btn-secondary");v.textContent="キャンセル",v.onclick=function(){y="manage",b=-1,x=null,O()};var g=D("button","tpl-btn tpl-btn-success");g.textContent="別名で保存",g.onclick=function(){var e=i.value.trim()||t.name,a=prompt("新しいテンプレ名を入力してください:",e);if(null!==a)if(a=a.trim()){var n=d(),r=V(),p={name:a,createdAt:(new Date).toISOString(),fields:n};"import"===l&&t.importType&&(p.importType=t.importType),r.push(p),_(r),alert("テンプレ「"+a+"」を新規保存しました。"),y="manage",b=-1,x=null,O()}else alert("テンプレ名を入力してください。")};var f=D("button","tpl-btn tpl-btn-primary");f.textContent="上書き保存",f.onclick=function(){var e=i.value.trim();if(!e)return i.style.borderColor="%23c62828",void i.focus();var a=d(),n=V(),r={name:e,createdAt:t.createdAt,updatedAt:(new Date).toISOString(),fields:a};"import"===l&&t.importType&&(r.importType=t.importType),n[b]=r,_(n),alert("テンプレ「"+e+"」を上書き保存しました。"),y="manage",b=-1,x=null,O()},m.appendChild(v),m.appendChild(g),m.appendChild(f),h.appendChild(m)}(i):function(e){var t=V();if(0===t.length){var a=D("div","tpl-empty");a.textContent="テンプレがありません。",e.appendChild(a)}else t.forEach(function(a,i){var n=D("div","tpl-list-item");n.style.cursor="default";var r=D("span","tpl-list-name");if(r.textContent=a.name,n.appendChild(r),"import"===l&&a.importType){var p=D("span","tpl-import-type-badge");p.textContent=C(a.importType),n.appendChild(p)}var o=D("span","tpl-list-meta"),d=Object.keys(a.fields).filter(function(e){return a.fields[e].enabled}).length;o.textContent=d+"項目 | "+new Date(a.createdAt).toLocaleDateString("ja-JP"),n.appendChild(o);var u=D("div","tpl-list-actions"),m=D("button","tpl-icon-btn");m.textContent="✏️",m.title="参照/編集",m.onclick=function(){b=i,x={},c.forEach(function(e){x[e.id]=S(e)}),y="edit",O()};var s=D("button","tpl-icon-btn");s.textContent="🗑️",s.title="削除",s.onclick=function(){confirm("「"+a.name+"」を削除しますか?")&&(t.splice(i,1),_(t),O())},u.appendChild(m),u.appendChild(s),n.appendChild(u),e.appendChild(n)});var i=D("div","tpl-footer"),n=D("button","tpl-btn tpl-btn-secondary");n.textContent="📥 インポート",n.onclick=function(){var e=document.createElement("input");e.type="file",e.accept=".json",e.onchange=function(e){var t=e.target.files[0];if(t){var a=new FileReader;a.onload=function(e){try{var t=JSON.parse(e.target.result);if(!t||"object"!=typeof t||!t.kind||!Array.isArray(t.templates))throw new Error("ファイル形式が不正です。");if(t.kind!==l){var a="recording"===t.kind?"収録":"取込";return void alert("このファイルは"+a+"テンプレ用です。現在のモーダルでは読み込めません。")}_(V().concat(t.templates)),alert(t.templates.length+"件のテンプレをインポートしました。"),O()}catch(e){alert("インポートに失敗しました: "+e.message)}},a.readAsText(t)}},e.click()};var r=D("button","tpl-btn tpl-btn-success");r.textContent="📤 エクスポート",r.onclick=function(){var e=V(),t={kind:l,exportedAt:(new Date).toISOString(),templates:e},a=JSON.stringify(t,null,2),i=new Blob([a],{type:"application/json"}),n=document.createElement("a");n.href=URL.createObjectURL(i);var r=new Date,p=r.getFullYear()+"-"+String(r.getMonth()+1).padStart(2,"0")+"-"+String(r.getDate()).padStart(2,"0"),o=String(r.getHours()).padStart(2,"0")+String(r.getMinutes()).padStart(2,"0")+String(r.getSeconds()).padStart(2,"0");n.download="cp_templates_"+l+"_"+p+"_"+o+".json",n.click(),URL.revokeObjectURL(n.href)},i.appendChild(n),i.appendChild(r),h.appendChild(i)}(i),h.appendChild(i)}}());">
登録はこちら