[{"data":1,"prerenderedAt":906},["ShallowReactive",2],{"site-content":3,"download-modal-content":87,"use-case-navigation":124,"blog-post-\u002Fblog\u002Fraycast-clipboard-api-preserve-formatting":145},{"id":4,"extension":5,"footer":6,"meta":74,"nav":75,"stem":85,"__hash__":86},"site\u002Fdata\u002Fsite.yml","yml",{"description":7,"columns":8,"socials":55,"builtBy":72},"Pastea saves every screenshot, snippet, link, and code block you copy, then lets you search, pin, and paste it back in seconds. Your clipboard, with a memory.",[9,21,25,43],{"title":10,"links":11},"Product",[12,15,18],{"label":13,"to":14},"Features","\u002F#features",{"label":16,"to":17},"Pricing","\u002F#pricing",{"label":19,"to":20},"Updates","\u002Fchangelog",{"title":22,"source":23,"links":24},"Use cases","useCasePages",[],{"title":26,"links":27},"Navigation",[28,31,34,37,40],{"label":29,"to":30},"Home","\u002F",{"label":32,"to":33},"FAQs","\u002F#faq",{"label":35,"to":36},"Blog","\u002Fblog",{"label":38,"to":39},"Help","\u002Fhelp",{"label":41,"to":42},"Contact","\u002Fcontact",{"title":44,"links":45},"Company",[46,49,52],{"label":47,"to":48},"About","\u002Fabout",{"label":50,"to":51},"Privacy","\u002Fprivacy",{"label":53,"to":54},"Terms","\u002Fterms",[56,60,64,68],{"icon":57,"label":58,"href":59},"youtube","YouTube","https:\u002F\u002Fwww.youtube.com\u002F@PasteaApp",{"icon":61,"label":62,"href":63},"linkedin","LinkedIn","https:\u002F\u002Fwww.linkedin.com\u002Fcompany\u002Fpastea",{"icon":65,"label":66,"href":67},"x","X","https:\u002F\u002Fx.com\u002Fpasteaapp",{"icon":69,"label":70,"href":71},"instagram","Instagram","https:\u002F\u002Fwww.instagram.com\u002Fpasteaapp\u002F",{"label":73,"href":48},"Nexo Labs",{},{"links":76,"cta":82},[77,78,80,81],{"label":13,"to":14},{"label":22,"to":79,"source":23},"\u002F#use-cases",{"label":16,"to":17},{"label":35,"to":36},{"label":83,"to":84},"Download","\u002Fdownload","data\u002Fsite","ACmqL95diXEt9h8Qbnt3yG0J3VbAq2RNuZuPmH-jS50",{"id":88,"title":89,"automaticText":90,"closeLabel":91,"extension":5,"followLabel":92,"manualLabel":93,"meta":94,"socials":95,"stem":100,"steps":101,"__hash__":123},"downloadModal\u002Fdata\u002Fdownload-modal.yml","Set up Pastea in 4 quick steps","Your download should start automatically. If it doesn’t,","Close","Follow us","download Pastea manually.",{},[96,97,98,99],{"icon":69,"label":70,"href":71},{"icon":61,"label":62,"href":63},{"icon":65,"label":66,"href":67},{"icon":57,"label":58,"href":59},"data\u002Fdownload-modal",[102,108,113,118],{"label":103,"title":104,"text":105,"image":106,"imageAlt":107},"Step 1","Open the installer","Open Pastea.dmg from your Downloads folder","\u002Fimg\u002Fdl-step-1.webp","",{"label":109,"title":110,"text":111,"image":112,"imageAlt":107},"Step 2","Install Pastea","Drag Pastea app into your Applications folder.","\u002Fimg\u002Fdl-step-2.webp",{"label":114,"title":115,"text":116,"image":117,"imageAlt":107},"Step 3","Find Pastea","Open your Applications folder and search for Pastea.","\u002Fimg\u002Fdl-step-3.webp",{"label":119,"title":120,"text":121,"image":122,"imageAlt":107},"Step 4","Open Pastea","Click the Pastea icon in your Mac’s menu bar to open the app.","\u002Fimg\u002Fdl-step-4.webp","Q1sHsBaPULfPDxaBsUNumg5sz4ttjqh5HTXAxBrY0M8",[125,130,135,140],{"path":126,"order":127,"navLabel":128,"navDescription":129},"\u002Ffor-developers","1","For Developers","Snippets, commands, and API responses on tap",{"path":131,"order":132,"navLabel":133,"navDescription":134},"\u002Ffor-designers","2","For Designers","Colors, references, and assets in reach",{"path":136,"order":137,"navLabel":138,"navDescription":139},"\u002Ffor-researchers","3","For Researchers","Quotes, sources, and notes, searchable",{"path":141,"order":142,"navLabel":143,"navDescription":144},"\u002Ffor-marketers","4","For Marketers","Campaign copy, links, and UTMs ready to go",{"id":146,"title":147,"author":148,"body":149,"category":894,"date":895,"description":896,"extension":897,"image":898,"imageQuality":899,"meta":900,"navigation":304,"path":901,"seo":902,"sitemap":903,"stem":904,"__hash__":905},"blog\u002Fblog\u002Fraycast-clipboard-api-preserve-formatting.md","Raycast Clipboard API: Read Text Without Losing HTML","Pastea Team",{"type":150,"value":151,"toc":886},"minimark",[152,156,173,176,181,184,236,239,242,246,265,268,704,713,716,720,729,732,735,754,757,761,764,767,775,779,790,793,801,805,808,862,865,874,882],[153,154,155],"p",{},"If your Raycast extension reads a rich copy as text and writes that string back, the result is a text copy. The original styling does not travel with the string.",[153,157,158,159,166,167,172],{},"Use ",[160,161,162],"strong",{},[163,164,165],"code",{},"Clipboard.read()"," when you need to inspect the available HTML as well as text. Use ",[160,168,169],{},[163,170,171],{},"Clipboard.readText()"," when plain text is the intended input. Preserving HTML can preserve some rich content, but neither operation is a universal clone of every format on the Mac pasteboard.",[153,174,175],{},"Here is how to make that distinction explicit in an extension.",[177,178,180],"h2",{"id":179},"choose-what-your-command-promises-to-preserve","Choose what your command promises to preserve",[153,182,183],{},"“Keep the formatting” can mean several things:",[185,186,187,200],"table",{},[188,189,190],"thead",{},[191,192,193,197],"tr",{},[194,195,196],"th",{},"Intended result",[194,198,199],{},"Design choice",[201,202,203,212,220,228],"tbody",{},[191,204,205,209],{},[206,207,208],"td",{},"Process a command, identifier, or URL",[206,210,211],{},"Read and write plain text deliberately",[191,213,214,217],{},[206,215,216],{},"Forward rich text when HTML is available",[206,218,219],{},"Read HTML and retain a text fallback",[191,221,222,225],{},[206,223,224],{},"Preserve arbitrary app-specific clipboard data",[206,226,227],{},"Do not assume an HTML\u002Ftext round trip can do it",[191,229,230,233],{},[206,231,232],{},"Convert content into Markdown",[206,234,235],{},"Treat it as a conversion with different output",[153,237,238],{},"For example, a command that normalizes a ticket number has no reason to keep a webpage's font. A command that forwards a styled support reply may have a reason to retain its links and emphasis.",[153,240,241],{},"Define that behavior before choosing the API. Otherwise a convenient string operation becomes an accidental format conversion.",[177,243,245],{"id":244},"read-the-available-content-once","Read the available content once",[153,247,248,249,256,257,260,261,264],{},"Raycast's ",[250,251,255],"a",{"href":252,"rel":253},"https:\u002F\u002Fdevelopers.raycast.com\u002Fapi-reference\u002Fclipboard",[254],"nofollow","Clipboard API reference"," documents ",[163,258,259],{},"read",", ",[163,262,263],{},"readText",", and copying HTML with an optional text representation. Read a snapshot, inspect the fields, and decide which output you can support.",[153,266,267],{},"This illustrative no-view command retains supplied HTML when available and falls back to supplied text. It reports a fixed error instead of logging clipboard contents:",[269,270,274],"pre",{"className":271,"code":272,"language":273,"meta":107,"style":107},"language-typescript shiki shiki-themes github-light github-dark","import { Clipboard, showToast, Toast } from \"@raycast\u002Fapi\";\n\nexport default async function Command() {\n  try {\n    const copied = await Clipboard.read();\n    const html = \"html\" in copied ? copied.html : undefined;\n    const text = \"text\" in copied ? copied.text : undefined;\n\n    if (typeof html === \"string\" && html.length > 0) {\n      await Clipboard.copy({\n        html,\n        ...(typeof text === \"string\" ? { text } : {}),\n      });\n    } else if (typeof text === \"string\") {\n      await Clipboard.copy(text);\n    } else {\n      await showToast({\n        style: Toast.Style.Failure,\n        title: \"This command supports text and HTML only\",\n      });\n      return;\n    }\n\n    await showToast({\n      style: Toast.Style.Success,\n      title: \"Supported content copied\",\n    });\n  } catch {\n    await showToast({\n      style: Toast.Style.Failure,\n      title: \"Could not copy supported content\",\n    });\n  }\n}\n","typescript",[163,275,276,299,306,328,337,361,394,422,427,466,480,486,515,521,545,557,566,576,582,594,599,607,613,618,628,634,645,651,662,671,677,687,692,698],{"__ignoreMap":107},[277,278,281,285,289,292,296],"span",{"class":279,"line":280},"line",1,[277,282,284],{"class":283},"szBVR","import",[277,286,288],{"class":287},"sVt8B"," { Clipboard, showToast, Toast } ",[277,290,291],{"class":283},"from",[277,293,295],{"class":294},"sZZnC"," \"@raycast\u002Fapi\"",[277,297,298],{"class":287},";\n",[277,300,302],{"class":279,"line":301},2,[277,303,305],{"emptyLinePlaceholder":304},true,"\n",[277,307,309,312,315,318,321,325],{"class":279,"line":308},3,[277,310,311],{"class":283},"export",[277,313,314],{"class":283}," default",[277,316,317],{"class":283}," async",[277,319,320],{"class":283}," function",[277,322,324],{"class":323},"sScJk"," Command",[277,326,327],{"class":287},"() {\n",[277,329,331,334],{"class":279,"line":330},4,[277,332,333],{"class":283},"  try",[277,335,336],{"class":287}," {\n",[277,338,340,343,347,350,353,356,358],{"class":279,"line":339},5,[277,341,342],{"class":283},"    const",[277,344,346],{"class":345},"sj4cs"," copied",[277,348,349],{"class":283}," =",[277,351,352],{"class":283}," await",[277,354,355],{"class":287}," Clipboard.",[277,357,259],{"class":323},[277,359,360],{"class":287},"();\n",[277,362,364,366,369,371,374,377,380,383,386,389,392],{"class":279,"line":363},6,[277,365,342],{"class":283},[277,367,368],{"class":345}," html",[277,370,349],{"class":283},[277,372,373],{"class":294}," \"html\"",[277,375,376],{"class":283}," in",[277,378,379],{"class":287}," copied ",[277,381,382],{"class":283},"?",[277,384,385],{"class":287}," copied.html ",[277,387,388],{"class":283},":",[277,390,391],{"class":345}," undefined",[277,393,298],{"class":287},[277,395,397,399,402,404,407,409,411,413,416,418,420],{"class":279,"line":396},7,[277,398,342],{"class":283},[277,400,401],{"class":345}," text",[277,403,349],{"class":283},[277,405,406],{"class":294}," \"text\"",[277,408,376],{"class":283},[277,410,379],{"class":287},[277,412,382],{"class":283},[277,414,415],{"class":287}," copied.text ",[277,417,388],{"class":283},[277,419,391],{"class":345},[277,421,298],{"class":287},[277,423,425],{"class":279,"line":424},8,[277,426,305],{"emptyLinePlaceholder":304},[277,428,430,433,436,439,442,445,448,451,454,457,460,463],{"class":279,"line":429},9,[277,431,432],{"class":283},"    if",[277,434,435],{"class":287}," (",[277,437,438],{"class":283},"typeof",[277,440,441],{"class":287}," html ",[277,443,444],{"class":283},"===",[277,446,447],{"class":294}," \"string\"",[277,449,450],{"class":283}," &&",[277,452,453],{"class":287}," html.",[277,455,456],{"class":345},"length",[277,458,459],{"class":283}," >",[277,461,462],{"class":345}," 0",[277,464,465],{"class":287},") {\n",[277,467,469,472,474,477],{"class":279,"line":468},10,[277,470,471],{"class":283},"      await",[277,473,355],{"class":287},[277,475,476],{"class":323},"copy",[277,478,479],{"class":287},"({\n",[277,481,483],{"class":279,"line":482},11,[277,484,485],{"class":287},"        html,\n",[277,487,489,492,495,497,500,502,504,507,510,512],{"class":279,"line":488},12,[277,490,491],{"class":283},"        ...",[277,493,494],{"class":287},"(",[277,496,438],{"class":283},[277,498,499],{"class":287}," text ",[277,501,444],{"class":283},[277,503,447],{"class":294},[277,505,506],{"class":283}," ?",[277,508,509],{"class":287}," { text } ",[277,511,388],{"class":283},[277,513,514],{"class":287}," {}),\n",[277,516,518],{"class":279,"line":517},13,[277,519,520],{"class":287},"      });\n",[277,522,524,527,530,533,535,537,539,541,543],{"class":279,"line":523},14,[277,525,526],{"class":287},"    } ",[277,528,529],{"class":283},"else",[277,531,532],{"class":283}," if",[277,534,435],{"class":287},[277,536,438],{"class":283},[277,538,499],{"class":287},[277,540,444],{"class":283},[277,542,447],{"class":294},[277,544,465],{"class":287},[277,546,548,550,552,554],{"class":279,"line":547},15,[277,549,471],{"class":283},[277,551,355],{"class":287},[277,553,476],{"class":323},[277,555,556],{"class":287},"(text);\n",[277,558,560,562,564],{"class":279,"line":559},16,[277,561,526],{"class":287},[277,563,529],{"class":283},[277,565,336],{"class":287},[277,567,569,571,574],{"class":279,"line":568},17,[277,570,471],{"class":283},[277,572,573],{"class":323}," showToast",[277,575,479],{"class":287},[277,577,579],{"class":279,"line":578},18,[277,580,581],{"class":287},"        style: Toast.Style.Failure,\n",[277,583,585,588,591],{"class":279,"line":584},19,[277,586,587],{"class":287},"        title: ",[277,589,590],{"class":294},"\"This command supports text and HTML only\"",[277,592,593],{"class":287},",\n",[277,595,597],{"class":279,"line":596},20,[277,598,520],{"class":287},[277,600,602,605],{"class":279,"line":601},21,[277,603,604],{"class":283},"      return",[277,606,298],{"class":287},[277,608,610],{"class":279,"line":609},22,[277,611,612],{"class":287},"    }\n",[277,614,616],{"class":279,"line":615},23,[277,617,305],{"emptyLinePlaceholder":304},[277,619,621,624,626],{"class":279,"line":620},24,[277,622,623],{"class":283},"    await",[277,625,573],{"class":323},[277,627,479],{"class":287},[277,629,631],{"class":279,"line":630},25,[277,632,633],{"class":287},"      style: Toast.Style.Success,\n",[277,635,637,640,643],{"class":279,"line":636},26,[277,638,639],{"class":287},"      title: ",[277,641,642],{"class":294},"\"Supported content copied\"",[277,644,593],{"class":287},[277,646,648],{"class":279,"line":647},27,[277,649,650],{"class":287},"    });\n",[277,652,654,657,660],{"class":279,"line":653},28,[277,655,656],{"class":287},"  } ",[277,658,659],{"class":283},"catch",[277,661,336],{"class":287},[277,663,665,667,669],{"class":279,"line":664},29,[277,666,623],{"class":283},[277,668,573],{"class":323},[277,670,479],{"class":287},[277,672,674],{"class":279,"line":673},30,[277,675,676],{"class":287},"      style: Toast.Style.Failure,\n",[277,678,680,682,685],{"class":279,"line":679},31,[277,681,639],{"class":287},[277,683,684],{"class":294},"\"Could not copy supported content\"",[277,686,593],{"class":287},[277,688,690],{"class":279,"line":689},32,[277,691,650],{"class":287},[277,693,695],{"class":279,"line":694},33,[277,696,697],{"class":287},"  }\n",[277,699,701],{"class":279,"line":700},34,[277,702,703],{"class":287},"}\n",[153,705,706,707,712],{},"The command copies its result back to the clipboard. It does not paste into another application. That separation makes it easier to inspect the result before inserting it somewhere important. Raycast documents toast behavior separately in its ",[250,708,711],{"href":709,"rel":710},"https:\u002F\u002Fdevelopers.raycast.com\u002Fapi-reference\u002Ffeedback\u002Ftoast",[254],"feedback API",".",[153,714,715],{},"The guards also make the unsupported case visible. This example does not claim to handle images or file copies.",[177,717,719],{"id":718},"why-reading-text-can-appear-to-lose-formatting","Why reading text can appear to “lose” formatting",[153,721,722,723,728],{},"A clipboard entry can offer several representations of the same selection. A receiving application chooses a representation it understands. Apple's ",[250,724,727],{"href":725,"rel":726},"https:\u002F\u002Fdeveloper.apple.com\u002Fdocumentation\u002Fappkit\u002Fnspasteboard",[254],"pasteboard documentation"," describes this exchange between applications.",[153,730,731],{},"Consider a copied link whose visible text is “Read the setup guide.” The text representation may contain those words. The HTML representation may also contain the destination URL and emphasis. Writing only the visible words cannot retain a link destination that was never included in your output.",[153,733,734],{},"The loss can happen at several points:",[736,737,738,742,745,748,751],"ol",{},[739,740,741],"li",{},"The source supplies only plain text.",[739,743,744],{},"Your command reads only text.",[739,746,747],{},"Your transformation discards rich content.",[739,749,750],{},"Your copy operation writes only a string.",[739,752,753],{},"The destination chooses plain text or strips unsupported styling.",[153,755,756],{},"Check each boundary. More complicated copying code cannot invent formatting the source did not provide.",[177,758,760],{"id":759},"html-is-not-an-exact-pasteboard-backup","HTML is not an exact pasteboard backup",[153,762,763],{},"An application may use RTF, image data, multiple items, or its own private representation. Retaining HTML does not establish that those other representations survived.",[153,765,766],{},"Even valid HTML may render differently in two editors. A destination can reinterpret paragraph spacing, reject styles, replace fonts, or accept only text. If exact visual appearance matters, a document or image may be a better transfer format than an editable text paste.",[153,768,769,770,774],{},"There is also a difference between the built-in Raycast history command and an extension's public API. A history feature supporting original formats does not mean every representation is exposed through the extension method you called. Our ",[250,771,773],{"href":772},"\u002Fblog\u002Fhow-to-use-raycast-clipboard-history","Raycast history guide"," covers the user-facing workflow.",[177,776,778],{"id":777},"keep-recent-history-access-bounded","Keep recent-history access bounded",[153,780,781,782,785,786,789],{},"The API reference documents an ",[163,783,784],{},"offset"," from ",[160,787,788],{},"0 through 5"," for reading recent history. That is a bounded access mechanism, not a documented full-history search API.",[153,791,792],{},"Do not build a loop that assumes arbitrary offsets will enumerate everything a user has saved. If your feature needs “the last few copies,” that limit may fit. If it needs semantic search across months of clips, design for a source that explicitly supports that task.",[153,794,795,796,800],{},"For a different integration model, Pastea exposes approved clipboard access to compatible coding tools through MCP. Our ",[250,797,799],{"href":798},"\u002Fblog\u002Fconnect-clipboard-to-ai-tools-with-mcp","clipboard-to-AI guide"," explains that workflow and its access controls. It does not extend Raycast's API or make these methods interchangeable.",[177,802,804],{"id":803},"verify-the-destination-not-just-the-returned-fields","Verify the destination, not just the returned fields",[153,806,807],{},"Before shipping a format-sensitive command, try this small matrix with harmless sample content:",[185,809,810,820],{},[188,811,812],{},[191,813,814,817],{},[194,815,816],{},"Input",[194,818,819],{},"What to inspect",[201,821,822,830,838,846,854],{},[191,823,824,827],{},[206,825,826],{},"Plain paragraph",[206,828,829],{},"Characters and line breaks survive",[191,831,832,835],{},[206,833,834],{},"Bold text with a hyperlink",[206,836,837],{},"Emphasis and the actual link destination survive where supported",[191,839,840,843],{},[206,841,842],{},"Table copied from a document",[206,844,845],{},"Cells remain useful, or the unsupported behavior is explained",[191,847,848,851],{},[206,849,850],{},"Image or Finder file",[206,852,853],{},"The command reports its text\u002FHTML limitation",[191,855,856,859],{},[206,857,858],{},"Rich copy pasted into a plain-text editor",[206,860,861],{},"Text remains usable without promising styling",[153,863,864],{},"These are validation cases, not measured compatibility results. Test the actual source, destination, Raycast version, and operating system you support.",[153,866,867,868,873],{},"An ",[250,869,872],{"href":870,"rel":871},"https:\u002F\u002Fgithub.com\u002Fraycast\u002Fextensions\u002Fissues\u002F31348",[254],"open report in Raycast's repository"," describes missing HTML in a Windows clipboard round trip. It is a platform-specific report, not evidence that the same bug affects Mac. It is a useful reason to verify behavior instead of treating a type signature as a compatibility test.",[153,875,876,877,881],{},"For ordinary Mac use, see ",[250,878,880],{"href":879},"\u002Fblog\u002Fpaste-with-formatting-mac","how to paste with formatting",". For extension authors, the rule is more specific: preserve the representations your command supports, describe the rest honestly, and never log a user's copied material just to find out what format it had.",[883,884,885],"style",{},"html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":107,"searchDepth":301,"depth":301,"links":887},[888,889,890,891,892,893],{"id":179,"depth":301,"text":180},{"id":244,"depth":301,"text":245},{"id":718,"depth":301,"text":719},{"id":759,"depth":301,"text":760},{"id":777,"depth":301,"text":778},{"id":803,"depth":301,"text":804},"Guides","2026-10-18","Use Raycast Clipboard.read to retain HTML alongside text, handle missing formats, and understand why the API cannot clone every clipboard representation.","md","\u002Fimg\u002Fraycast-clipboard-api-preserve-formatting-watercolor-2400x1264.webp","77",{},"\u002Fblog\u002Fraycast-clipboard-api-preserve-formatting",{"title":147,"description":896},{"loc":901},"blog\u002Fraycast-clipboard-api-preserve-formatting","5iJeTO-SsSv3uWVQM34nJlz5ZIvKti8587U8DOJbtU4",1792291033460]