PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.5
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 All 203 releases
betterdocs / react-src / gutenberg / util / add-export-icon.js

add-export-icon.js in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.5, at react-src/gutenberg/util/add-export-icon.js

51 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import injectEBLogo from "./injectEBLogo";
2
3 const { apiFetch } = wp;
4 const { parse } = wp.blocks;
5
6 window.onload = function () {
7 injectEBLogo();
8
9 document
10 .querySelector("#eb-export-icon")
11 .addEventListener("click", function (e) {
12 e.preventDefault();
13
14 const title = wp.data
15 .select("core/editor")
16 .getEditedPostAttribute("title");
17 const content = wp.data.select("core/editor").getEditedPostContent();
18 const id = wp.data.select("core/editor").getCurrentPostId();
19 const type = wp.data.select("core/editor").getCurrentPostType();
20 const isEditedPostEmpty = wp.data
21 .select("core/editor")
22 .isEditedPostEmpty();
23 const { insertBlocks } = wp.data.dispatch("core/block-editor");
24
25 const data = { title: title, content: content };
26
27 if (!isEditedPostEmpty) {
28 // Store in database then send data in cloud
29 // wp.data.dispatch("core/editor").savePost();
30
31 // test item for insert block
32 const item =
33 '<!-- wp:paragraph {"eb":{"id":"112165356402"}} -->\r\n<p>TEST world</p>\r\n<!-- /wp:paragraph -->\r\n\r\n<!-- wp:essential-blocks/block-notice {"noticeId":"a9f00","eb":{"id":"21110354946"}} -->\r\n<div class="wp-block-essential-blocks-block-notice eb-notice-wrapper" style="background:#3074ff;padding:65px 60px;box-shadow:0px 0px 0px 0px #000000;border-radius:5px" data-id="a9f00" data-show-again="false"><div class="eb-notice-title-wrapper" style="display:flex;justify-content:space-between"><div class="eb-notice-title" style="font-size:32px;color:#fff">Save 20%</div><span class="eb-notice-dismiss" style="color:#fff;display:none;justify-content:center;width:24px;height:24px;cursor:pointer;align-items:center"></span></div><div><div class="eb-notice-text" style="font-size:18px;color:#edf1f7">Free shipping on all orders</div></div></div>\r\n<!-- /wp:essential-blocks/block-notice -->';
34 insertBlocks(parse(item));
35 return;
36
37 apiFetch({
38 path: `/wp/v2/${type}s/${id}`,
39 method: "POST",
40 // data: data
41 data: { title: title, content: item },
42 }).then((res) => {
43 const postData = {
44 __file: "wp_block",
45 ...data,
46 };
47 });
48 }
49 });
50 };
51