@onjmin/dtm 0.1.32 → 0.1.33

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/index.d.mts CHANGED
@@ -1219,6 +1219,13 @@ type MmlPlayerOptions = {
1219
1219
  embedUrl?: string;
1220
1220
  /** 利用規約への同意画面の表示をスキップするかどうか */
1221
1221
  skipConsent?: boolean;
1222
+ /**
1223
+ * 「MMLを表示」「MMLコピー」押下時に呼ばれる MML 取得コールバック。
1224
+ * 省略時は mountMmlPlayer に渡した mml をそのまま使う。
1225
+ * DAW と連携する場合は `() => daw.getMML().full` を渡すと
1226
+ * 常に最新の full フォーマット(メタ行・#end; 込み)を返せる。
1227
+ */
1228
+ getMml?: () => string;
1222
1229
  };
1223
1230
  type MmlPlayerInstance = {
1224
1231
  play: () => void;
package/dist/index.d.ts CHANGED
@@ -1219,6 +1219,13 @@ type MmlPlayerOptions = {
1219
1219
  embedUrl?: string;
1220
1220
  /** 利用規約への同意画面の表示をスキップするかどうか */
1221
1221
  skipConsent?: boolean;
1222
+ /**
1223
+ * 「MMLを表示」「MMLコピー」押下時に呼ばれる MML 取得コールバック。
1224
+ * 省略時は mountMmlPlayer に渡した mml をそのまま使う。
1225
+ * DAW と連携する場合は `() => daw.getMML().full` を渡すと
1226
+ * 常に最新の full フォーマット(メタ行・#end; 込み)を返せる。
1227
+ */
1228
+ getMml?: () => string;
1222
1229
  };
1223
1230
  type MmlPlayerInstance = {
1224
1231
  play: () => void;
package/dist/index.js CHANGED
@@ -6703,13 +6703,27 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6703
6703
  showMmlItem.addEventListener("click", (e) => {
6704
6704
  e.stopPropagation();
6705
6705
  toggleMenu(false);
6706
- const modalBody = openInfoModal("MML");
6706
+ const modalBody = openInfoModal("MML\u3092\u8868\u793A");
6707
+ const desc = doc.createElement("p");
6708
+ desc.textContent = "\u3053\u306EMML\u3092\u30B3\u30D4\u30FC\u3057\u3066\u3001\u4ED6\u306E\u30D7\u30EC\u30A4\u30E4\u30FC\u3084\u5171\u6709URL\u306B\u8CBC\u308A\u4ED8\u3051\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002";
6709
+ desc.style.marginBottom = "8px";
6710
+ modalBody.appendChild(desc);
6711
+ const sourceMml = options.getMml?.() ?? mml;
6712
+ const displayMml = sourceMml.split(";").map((s) => s.trim()).filter((s) => s.length > 0).join(";\n");
6707
6713
  const pre = doc.createElement("pre");
6708
- pre.textContent = mml;
6714
+ pre.textContent = displayMml;
6709
6715
  pre.style.whiteSpace = "pre-wrap";
6710
6716
  pre.style.wordBreak = "break-all";
6717
+ pre.style.cursor = "text";
6718
+ pre.addEventListener("click", () => {
6719
+ const range = doc.createRange();
6720
+ range.selectNodeContents(pre);
6721
+ const sel = doc.defaultView?.getSelection();
6722
+ sel?.removeAllRanges();
6723
+ sel?.addRange(range);
6724
+ });
6711
6725
  modalBody.appendChild(pre);
6712
- appendCopyButton(modalBody, mml);
6726
+ appendCopyButton(modalBody, sourceMml);
6713
6727
  });
6714
6728
  mmlInfoItem.addEventListener("click", (e) => {
6715
6729
  e.stopPropagation();
@@ -6747,7 +6761,7 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6747
6761
  });
6748
6762
  copyMmlItem.addEventListener("click", async (e) => {
6749
6763
  e.stopPropagation();
6750
- const success = await copyToClipboard(doc, mml);
6764
+ const success = await copyToClipboard(doc, options.getMml?.() ?? mml);
6751
6765
  if (success) {
6752
6766
  copyMmlItem.textContent = "\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F\uFF01";
6753
6767
  } else {
package/dist/index.mjs CHANGED
@@ -6592,13 +6592,27 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6592
6592
  showMmlItem.addEventListener("click", (e) => {
6593
6593
  e.stopPropagation();
6594
6594
  toggleMenu(false);
6595
- const modalBody = openInfoModal("MML");
6595
+ const modalBody = openInfoModal("MML\u3092\u8868\u793A");
6596
+ const desc = doc.createElement("p");
6597
+ desc.textContent = "\u3053\u306EMML\u3092\u30B3\u30D4\u30FC\u3057\u3066\u3001\u4ED6\u306E\u30D7\u30EC\u30A4\u30E4\u30FC\u3084\u5171\u6709URL\u306B\u8CBC\u308A\u4ED8\u3051\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002";
6598
+ desc.style.marginBottom = "8px";
6599
+ modalBody.appendChild(desc);
6600
+ const sourceMml = options.getMml?.() ?? mml;
6601
+ const displayMml = sourceMml.split(";").map((s) => s.trim()).filter((s) => s.length > 0).join(";\n");
6596
6602
  const pre = doc.createElement("pre");
6597
- pre.textContent = mml;
6603
+ pre.textContent = displayMml;
6598
6604
  pre.style.whiteSpace = "pre-wrap";
6599
6605
  pre.style.wordBreak = "break-all";
6606
+ pre.style.cursor = "text";
6607
+ pre.addEventListener("click", () => {
6608
+ const range = doc.createRange();
6609
+ range.selectNodeContents(pre);
6610
+ const sel = doc.defaultView?.getSelection();
6611
+ sel?.removeAllRanges();
6612
+ sel?.addRange(range);
6613
+ });
6600
6614
  modalBody.appendChild(pre);
6601
- appendCopyButton(modalBody, mml);
6615
+ appendCopyButton(modalBody, sourceMml);
6602
6616
  });
6603
6617
  mmlInfoItem.addEventListener("click", (e) => {
6604
6618
  e.stopPropagation();
@@ -6636,7 +6650,7 @@ var mountMmlPlayer = (target, mml, options = {}) => {
6636
6650
  });
6637
6651
  copyMmlItem.addEventListener("click", async (e) => {
6638
6652
  e.stopPropagation();
6639
- const success = await copyToClipboard(doc, mml);
6653
+ const success = await copyToClipboard(doc, options.getMml?.() ?? mml);
6640
6654
  if (success) {
6641
6655
  copyMmlItem.textContent = "\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F\uFF01";
6642
6656
  } else {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "onjmin",
3
3
  "license": "MIT",
4
4
  "name": "@onjmin/dtm",
5
- "version": "0.1.32",
5
+ "version": "0.1.33",
6
6
  "description": "MMLを中間言語に用いた、モバイルファーストなDAW / ピアノロール打ち込みコンポーネント",
7
7
  "homepage": "https://onjmin.github.io/dtm",
8
8
  "repository": {