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 / blocks / article-summary / src / edit.js

edit.js in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.5, at react-src/gutenberg/blocks/article-summary/src/edit.js

105 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from "@wordpress/i18n";
2 import { useBlockProps } from "@wordpress/block-editor";
3 import { useEffect } from "@wordpress/element";
4
5 import Inspector from "./inspector";
6 import Style from "./style";
7
8 const Edit = (props) => {
9 const { attributes, setAttributes, clientId } = props;
10 const {
11 blockId,
12 customTitle,
13 showTitle,
14 iconSize,
15 } = attributes;
16
17 // Set unique block ID
18 useEffect(() => {
19 if (!blockId) {
20 setAttributes({ blockId: `betterdocs-article-summary-${clientId}` });
21 }
22 }, [clientId, blockId, setAttributes]);
23
24 const blockProps = useBlockProps({
25 className: `betterdocs-article-summary ${blockId || ''}`,
26 });
27
28 // Determine title text
29 const titleText = customTitle || __("Doc Summary", "betterdocs");
30
31 return (
32 <>
33 <Inspector {...props} />
34 <Style attributes={attributes} setAttributes={setAttributes} clientId={clientId} />
35
36 <div {...blockProps} id="betterdocs-article-summary" data-post-id="1" data-post-type="docs" className={`${blockProps.className} betterdocs-editor-mode`}>
37 {showTitle && (
38 <div className="betterdocs-summary-header" id="betterdocs-summary-toggle">
39 <span className="betterdocs-summary-title">
40 <img
41 src="/wp-content/plugins/betterdocs/assets/images/ai-summary-icon.svg"
42 alt={__("AI Article Summary", "betterdocs")}
43 />
44 {titleText}
45 <span className="betterdocs-summary-arrow">
46 <svg
47 className="angle-icon angle-right"
48 width="12"
49 height="12"
50 viewBox="0 0 24 24"
51 fill="none"
52 xmlns="http://www.w3.org/2000/svg"
53 style={{ display: "none" }}
54 >
55 <path d="M6 9L12 15L18 9" stroke="#98A2B3" strokeWidth="4" strokeLinecap="round" strokeLinejoin="round"/>
56 </svg>
57 <svg
58 className="angle-icon angle-down"
59 width="12"
60 height="12"
61 viewBox="0 0 24 24"
62 fill="none"
63 xmlns="http://www.w3.org/2000/svg"
64 >
65 <path d="M18 15L12 9L6 15" stroke="#98A2B3" strokeWidth="4" strokeLinecap="round" strokeLinejoin="round"/>
66 </svg>
67 </span>
68 </span>
69 </div>
70 )}
71
72 <div className="betterdocs-summary-content" id="betterdocs-summary-content" style={{ display: "block" }}>
73 <div className="betterdocs-summary-loading" id="betterdocs-summary-loading" style={{ display: "none" }}>
74 <img
75 src="../../../../../assets/static/images/thinking-icon.svg"
76 alt={__("Doc Summarizer Thinking", "betterdocs")}
77 />
78 <span className="betterdocs-thinking-text">
79 {__("Thinking", "betterdocs")}<span className="betterdocs-thinking-dots"></span>
80 </span>
81 </div>
82 <div className="betterdocs-summary-text" id="betterdocs-summary-text">
83 <div className="betterdocs-summary-preview">
84 <p>
85 {__(
86 "This is a preview of the Doc Summarizer block. The actual AI-generated summary will appear here when viewed on the frontend.",
87 "betterdocs"
88 )}
89 </p>
90 <p>
91 {__(
92 "The summary will be automatically generated based on the article content using OpenAI technology.",
93 "betterdocs"
94 )}
95 </p>
96 </div>
97 </div>
98 </div>
99 </div>
100 </>
101 );
102 };
103
104 export default Edit;
105