@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
8 lines (7 loc) • 1.76 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/store/local-autosave.js"],
"sourcesContent": ["/**\n * Function returning a sessionStorage key to set or retrieve a given post's\n * automatic session backup.\n *\n * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's\n * `loggedout` handler can clear sessionStorage of any user-private content.\n *\n * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103\n *\n * @param {string} postId Post ID.\n * @param {boolean} isPostNew Whether post new.\n *\n * @return {string} sessionStorage key\n */\nfunction postKey( postId, isPostNew ) {\n\treturn `wp-autosave-block-editor-post-${\n\t\tisPostNew ? 'auto-draft' : postId\n\t}`;\n}\n\nexport function localAutosaveGet( postId, isPostNew ) {\n\treturn window.sessionStorage.getItem( postKey( postId, isPostNew ) );\n}\n\nexport function localAutosaveSet( postId, isPostNew, title, content, excerpt ) {\n\twindow.sessionStorage.setItem(\n\t\tpostKey( postId, isPostNew ),\n\t\tJSON.stringify( {\n\t\t\tpost_title: title,\n\t\t\tcontent,\n\t\t\texcerpt,\n\t\t} )\n\t);\n}\n\nexport function localAutosaveClear( postId, isPostNew ) {\n\twindow.sessionStorage.removeItem( postKey( postId, isPostNew ) );\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,SAAS,QAAS,QAAQ,WAAY;AACrC,SAAO,iCACN,YAAY,eAAe,MAC5B;AACD;AAEO,SAAS,iBAAkB,QAAQ,WAAY;AACrD,SAAO,OAAO,eAAe,QAAS,QAAS,QAAQ,SAAU,CAAE;AACpE;AAEO,SAAS,iBAAkB,QAAQ,WAAW,OAAO,SAAS,SAAU;AAC9E,SAAO,eAAe;AAAA,IACrB,QAAS,QAAQ,SAAU;AAAA,IAC3B,KAAK,UAAW;AAAA,MACf,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,IACD,CAAE;AAAA,EACH;AACD;AAEO,SAAS,mBAAoB,QAAQ,WAAY;AACvD,SAAO,eAAe,WAAY,QAAS,QAAQ,SAAU,CAAE;AAChE;",
"names": []
}