[{"data":1,"prerenderedAt":723},["ShallowReactive",2],{"quirekit-doc:\u002Fen\u002Fpptx\u002Fcommands":3},{"id":4,"title":5,"body":6,"description":713,"extension":714,"keywords":715,"locale":716,"meta":717,"navigation":164,"order":132,"path":718,"section":719,"seo":720,"stem":721,"__hash__":722},"docs\u002Fpptx\u002Fcommands.en.md","Session and commands",{"type":7,"value":8,"toc":707},"minimark",[9,19,24,80,87,94,197,201,208,215,265,271,403,407,414,418,628,635,703],[10,11,12,13,18],"p",{},"Session commands take the same editing path as the interface: each call is one undoable edit and the interface updates at once. See ",[14,15,17],"a",{"href":16},"\u002Fen\u002Fpptx\u002Ffiles","Open and save"," for getting the session.",[20,21,23],"h2",{"id":22},"call-commands","Call commands",[25,26,31],"pre",{"className":27,"code":28,"language":29,"meta":30,"style":30},"language-ts shiki shiki-themes github-light github-light github-dark","const added = session.commands.addSlide({ after: 0, title: 'Second slide', body: 'Key points' })\n","ts","",[32,33,34],"code",{"__ignoreMap":30},[35,36,39,43,47,50,54,58,61,64,67,71,74,77],"span",{"class":37,"line":38},"line",1,[35,40,42],{"class":41},"sDD9d","const",[35,44,46],{"class":45},"sUNQB"," added",[35,48,49],{"class":41}," =",[35,51,53],{"class":52},"sVPnS"," session.commands.",[35,55,57],{"class":56},"sgQzM","addSlide",[35,59,60],{"class":52},"({ after: ",[35,62,63],{"class":45},"0",[35,65,66],{"class":52},", title: ",[35,68,70],{"class":69},"s-HEn","'Second slide'",[35,72,73],{"class":52},", body: ",[35,75,76],{"class":69},"'Key points'",[35,78,79],{"class":52}," })\n",[10,81,82,83,86],{},"Each command takes one options object and returns whether it applied. When it does not apply, for example because the slide or shape does not exist, it returns ",[32,84,85],{},"false"," and the deck is unchanged.",[10,88,89,90,93],{},"Combine several steps into one undo step with ",[32,91,92],{},"chain()","; if any step does not apply, none of them is kept:",[25,95,97],{"className":27,"code":96,"language":29,"meta":30,"style":30},"session.chain()\n  .addSlide({ after: 1, title: 'Third slide' })\n  .addSlide({ after: 2, title: 'Fourth slide' })\n  .run()\n\nawait session.undo()   \u002F\u002F undoes the whole chain\nawait session.redo()\n",[32,98,99,110,130,149,159,166,185],{"__ignoreMap":30},[35,100,101,104,107],{"class":37,"line":38},[35,102,103],{"class":52},"session.",[35,105,106],{"class":56},"chain",[35,108,109],{"class":52},"()\n",[35,111,113,116,118,120,123,125,128],{"class":37,"line":112},2,[35,114,115],{"class":52},"  .",[35,117,57],{"class":56},[35,119,60],{"class":52},[35,121,122],{"class":45},"1",[35,124,66],{"class":52},[35,126,127],{"class":69},"'Third slide'",[35,129,79],{"class":52},[35,131,133,135,137,139,142,144,147],{"class":37,"line":132},3,[35,134,115],{"class":52},[35,136,57],{"class":56},[35,138,60],{"class":52},[35,140,141],{"class":45},"2",[35,143,66],{"class":52},[35,145,146],{"class":69},"'Fourth slide'",[35,148,79],{"class":52},[35,150,152,154,157],{"class":37,"line":151},4,[35,153,115],{"class":52},[35,155,156],{"class":56},"run",[35,158,109],{"class":52},[35,160,162],{"class":37,"line":161},5,[35,163,165],{"emptyLinePlaceholder":164},true,"\n",[35,167,169,172,175,178,181],{"class":37,"line":168},6,[35,170,171],{"class":41},"await",[35,173,174],{"class":52}," session.",[35,176,177],{"class":56},"undo",[35,179,180],{"class":52},"()   ",[35,182,184],{"class":183},"sqmzS","\u002F\u002F undoes the whole chain\n",[35,186,188,190,192,195],{"class":37,"line":187},7,[35,189,171],{"class":41},[35,191,174],{"class":52},[35,193,194],{"class":56},"redo",[35,196,109],{"class":52},[20,198,200],{"id":199},"find-slides-and-shapes","Find slides and shapes",[10,202,203,204,207],{},"Commands address slides by part name (such as ",[32,205,206],{},"\u002Fppt\u002Fslides\u002Fslide3.xml",") and shapes by id, which stay valid when slides move.",[10,209,210,211,214],{},"The shapes the user selected come from ",[32,212,213],{},"selection()",":",[25,216,218],{"className":27,"code":217,"language":29,"meta":30,"style":30},"for (const shape of session.selection()) {\n  session.commands.setShapeFill({ slide: shape.slide, shapes: [shape.shape], color: '#2F6FED' })\n}\n",[32,219,220,244,260],{"__ignoreMap":30},[35,221,222,225,228,230,233,236,238,241],{"class":37,"line":38},[35,223,224],{"class":41},"for",[35,226,227],{"class":52}," (",[35,229,42],{"class":41},[35,231,232],{"class":45}," shape",[35,234,235],{"class":41}," of",[35,237,174],{"class":52},[35,239,240],{"class":56},"selection",[35,242,243],{"class":52},"()) {\n",[35,245,246,249,252,255,258],{"class":37,"line":112},[35,247,248],{"class":52},"  session.commands.",[35,250,251],{"class":56},"setShapeFill",[35,253,254],{"class":52},"({ slide: shape.slide, shapes: [shape.shape], color: ",[35,256,257],{"class":69},"'#2F6FED'",[35,259,79],{"class":52},[35,261,262],{"class":37,"line":132},[35,263,264],{"class":52},"}\n",[10,266,267,268,214],{},"To walk every slide, read the current content with the MIT package ",[32,269,270],{},"@quirekit\u002Foffice-kit-pptx",[25,272,274],{"className":27,"code":273,"language":29,"meta":30,"style":30},"import { getShapeId, getShapeName, getShapeText, getSlidePartName, getSlides, getSlideShapes, loadPresentation } from '@quirekit\u002Foffice-kit-pptx'\n\nconst deck = await loadPresentation(await session.snapshot())\nfor (const slide of getSlides(deck)) {\n  const part = getSlidePartName(slide)\n  for (const shape of getSlideShapes(slide)) console.log(part, getShapeId(shape), getShapeName(shape), getShapeText(shape))\n}\n",[32,275,276,290,294,322,341,357,399],{"__ignoreMap":30},[35,277,278,281,284,287],{"class":37,"line":38},[35,279,280],{"class":41},"import",[35,282,283],{"class":52}," { getShapeId, getShapeName, getShapeText, getSlidePartName, getSlides, getSlideShapes, loadPresentation } ",[35,285,286],{"class":41},"from",[35,288,289],{"class":69}," '@quirekit\u002Foffice-kit-pptx'\n",[35,291,292],{"class":37,"line":112},[35,293,165],{"emptyLinePlaceholder":164},[35,295,296,298,301,303,306,309,312,314,316,319],{"class":37,"line":132},[35,297,42],{"class":41},[35,299,300],{"class":45}," deck",[35,302,49],{"class":41},[35,304,305],{"class":41}," await",[35,307,308],{"class":56}," loadPresentation",[35,310,311],{"class":52},"(",[35,313,171],{"class":41},[35,315,174],{"class":52},[35,317,318],{"class":56},"snapshot",[35,320,321],{"class":52},"())\n",[35,323,324,326,328,330,333,335,338],{"class":37,"line":151},[35,325,224],{"class":41},[35,327,227],{"class":52},[35,329,42],{"class":41},[35,331,332],{"class":45}," slide",[35,334,235],{"class":41},[35,336,337],{"class":56}," getSlides",[35,339,340],{"class":52},"(deck)) {\n",[35,342,343,346,349,351,354],{"class":37,"line":161},[35,344,345],{"class":41},"  const",[35,347,348],{"class":45}," part",[35,350,49],{"class":41},[35,352,353],{"class":56}," getSlidePartName",[35,355,356],{"class":52},"(slide)\n",[35,358,359,362,364,366,368,370,373,376,379,382,385,388,391,393,396],{"class":37,"line":168},[35,360,361],{"class":41},"  for",[35,363,227],{"class":52},[35,365,42],{"class":41},[35,367,232],{"class":45},[35,369,235],{"class":41},[35,371,372],{"class":56}," getSlideShapes",[35,374,375],{"class":52},"(slide)) console.",[35,377,378],{"class":56},"log",[35,380,381],{"class":52},"(part, ",[35,383,384],{"class":56},"getShapeId",[35,386,387],{"class":52},"(shape), ",[35,389,390],{"class":56},"getShapeName",[35,392,387],{"class":52},[35,394,395],{"class":56},"getShapeText",[35,397,398],{"class":52},"(shape))\n",[35,400,401],{"class":37,"line":187},[35,402,264],{"class":52},[20,404,406],{"id":405},"units","Units",[10,408,409,410,413],{},"Positions and sizes are in EMU: 1 inch = 914400, 1 cm = 360000, 1 pt = 12700. A 16:9 slide is 12192000 wide and 6858000 high by default. Font sizes are in points and colors are written ",[32,411,412],{},"#RRGGBB",".",[20,415,417],{"id":416},"common-commands","Common commands",[419,420,421,434],"table",{},[422,423,424],"thead",{},[425,426,427,431],"tr",{},[428,429,430],"th",{},"Use",[428,432,433],{},"Commands",[435,436,437,469,497,528,558,580,596,618],"tbody",{},[425,438,439,443],{},[440,441,442],"td",{},"Slides",[440,444,445,447,448,447,451,447,454,447,457,447,460,447,463,447,466],{},[32,446,57],{},", ",[32,449,450],{},"duplicateSlide",[32,452,453],{},"moveSlide",[32,455,456],{},"deleteSlide",[32,458,459],{},"setSlideHidden",[32,461,462],{},"setSlideNotes",[32,464,465],{},"setSlideLayout",[32,467,468],{},"setSlideBackground",[425,470,471,474],{},[440,472,473],{},"Text",[440,475,476,447,479,447,482,447,485,447,488,447,491,447,494],{},[32,477,478],{},"setShapeText",[32,480,481],{},"replaceShapeText",[32,483,484],{},"setTextFormat",[32,486,487],{},"setTextAlignment",[32,489,490],{},"setTextAnchor",[32,492,493],{},"setParagraphBullets",[32,495,496],{},"setLineSpacing",[425,498,499,502],{},[440,500,501],{},"Insert",[440,503,504,447,507,447,510,447,513,447,516,447,519,447,522,447,525],{},[32,505,506],{},"addTextBox",[32,508,509],{},"addShape",[32,511,512],{},"addPicture",[32,514,515],{},"addTable",[32,517,518],{},"addChart",[32,520,521],{},"addMedia",[32,523,524],{},"addEquation",[32,526,527],{},"addFreeform",[425,529,530,533],{},[440,531,532],{},"Shapes",[440,534,535,447,538,447,541,447,543,447,546,447,549,447,552,447,555],{},[32,536,537],{},"setShapeBounds",[32,539,540],{},"moveShapes",[32,542,251],{},[32,544,545],{},"setShapeOutline",[32,547,548],{},"rotateShapes",[32,550,551],{},"flipShapes",[32,553,554],{},"deleteShape",[32,556,557],{},"duplicateShapes",[425,559,560,563],{},[440,561,562],{},"Arrange",[440,564,565,447,568,447,571,447,574,447,577],{},[32,566,567],{},"arrangeShapes",[32,569,570],{},"alignShapes",[32,572,573],{},"distributeShapes",[32,575,576],{},"groupShapes",[32,578,579],{},"ungroupShapes",[425,581,582,585],{},[440,583,584],{},"Tables and charts",[440,586,587,447,590,447,593],{},[32,588,589],{},"setTableCellText",[32,591,592],{},"setTableStyle",[32,594,595],{},"setChartData",[425,597,598,601],{},[440,599,600],{},"Transitions and animations",[440,602,603,447,606,447,609,447,612,447,615],{},[32,604,605],{},"setSlideTransition",[32,607,608],{},"addShapeAnimation",[32,610,611],{},"updateAnimation",[32,613,614],{},"removeAnimation",[32,616,617],{},"moveAnimation",[425,619,620,623],{},[440,621,622],{},"Links",[440,624,625],{},[32,626,627],{},"setShapeLink",[10,629,630,631,634],{},"The types list every command and its options: type ",[32,632,633],{},"session.commands."," in your editor to see them with their descriptions.",[25,636,638],{"className":27,"code":637,"language":29,"meta":30,"style":30},"session.commands.addTextBox({\n  slide: '\u002Fppt\u002Fslides\u002Fslide1.xml',\n  text: 'Q3 revenue: 210 million',\n  x: 914400, y: 4572000, width: 6096000, height: 685800,\n})\n",[32,639,640,649,660,670,698],{"__ignoreMap":30},[35,641,642,644,646],{"class":37,"line":38},[35,643,633],{"class":52},[35,645,506],{"class":56},[35,647,648],{"class":52},"({\n",[35,650,651,654,657],{"class":37,"line":112},[35,652,653],{"class":52},"  slide: ",[35,655,656],{"class":69},"'\u002Fppt\u002Fslides\u002Fslide1.xml'",[35,658,659],{"class":52},",\n",[35,661,662,665,668],{"class":37,"line":132},[35,663,664],{"class":52},"  text: ",[35,666,667],{"class":69},"'Q3 revenue: 210 million'",[35,669,659],{"class":52},[35,671,672,675,678,681,684,687,690,693,696],{"class":37,"line":151},[35,673,674],{"class":52},"  x: ",[35,676,677],{"class":45},"914400",[35,679,680],{"class":52},", y: ",[35,682,683],{"class":45},"4572000",[35,685,686],{"class":52},", width: ",[35,688,689],{"class":45},"6096000",[35,691,692],{"class":52},", height: ",[35,694,695],{"class":45},"685800",[35,697,659],{"class":52},[35,699,700],{"class":37,"line":161},[35,701,702],{"class":52},"})\n",[704,705,706],"style",{},"html pre.shiki code .sDD9d, html code.shiki .sDD9d{--shiki-default:#D73A49;--shiki-light:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sUNQB, html code.shiki .sUNQB{--shiki-default:#005CC5;--shiki-light:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVPnS, html code.shiki .sVPnS{--shiki-default:#24292E;--shiki-light:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sgQzM, html code.shiki .sgQzM{--shiki-default:#6F42C1;--shiki-light:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s-HEn, html code.shiki .s-HEn{--shiki-default:#032F62;--shiki-light:#032F62;--shiki-dark:#9ECBFF}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 .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-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);}html pre.shiki code .sqmzS, html code.shiki .sqmzS{--shiki-default:#6A737D;--shiki-light:#6A737D;--shiki-dark:#6A737D}",{"title":30,"searchDepth":112,"depth":112,"links":708},[709,710,711,712],{"id":22,"depth":112,"text":23},{"id":199,"depth":112,"text":200},{"id":405,"depth":112,"text":406},{"id":416,"depth":112,"text":417},"Read the selection and content from scripts, change slides, and keep every change in the undo history.","md",null,"en",{},"\u002Fen\u002Fpptx\u002Fcommands","PPTX Editor",{"title":5,"description":713},"pptx\u002Fcommands.en","C7w8hNJrxsKI0hjNVtwnodg_g41fndG1Kr6c2Hw9gHA",1796438336811]