payload-richtext-tiptap 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/TiktokEmbed.d.ts +0 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/TiktokEmbed.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/TiktokEmbed.js +0 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/TiktokEmbed.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/menus/SocialMediaMenu.js +1 -1
- package/dist/src/fields/TiptapEditor/extensions/SocialMedia/menus/SocialMediaMenu.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/TrailingNode/trailing-node.d.ts +1 -1
- package/dist/src/fields/TiptapEditor/extensions/TrailingNode/trailing-node.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/TrailingNode/trailing-node.js +5 -5
- package/dist/src/fields/TiptapEditor/extensions/TrailingNode/trailing-node.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js +2 -2
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/hooks/useTextmenuStates.js +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/hooks/useTextmenuStates.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js +2 -2
- package/dist/src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/InsideLinksEditorPanel/InsideLinksEditorPanel.js +1 -1
- package/dist/src/fields/TiptapEditor/features/panels/InsideLinksEditorPanel/InsideLinksEditorPanel.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TiktokEmbed.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/TiktokEmbed.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TiktokEmbed.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/TiktokEmbed.tsx"],"names":[],"mappings":";gCAKuB;IAAE,IAAI,EAAE;QAAE,KAAK,EAAE;YAAE,GAAG,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE;AAA5D,wBAUE"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Music } from "lucide-react";
|
|
3
3
|
import { TikTokEmbed } from "react-social-media-embed";
|
|
4
|
-
import "../socialMedia.scss";
|
|
5
4
|
import SocialMediaEmbed from "../SocialMediaEmbed.js";
|
|
6
5
|
export default ((props)=>{
|
|
7
6
|
return /*#__PURE__*/ _jsx(SocialMediaEmbed, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/TiktokEmbed.tsx"],"sourcesContent":["import { NodeViewContent, NodeViewWrapper } from \"@tiptap/react\";\nimport { Music } from \"lucide-react\";\nimport { TikTokEmbed } from \"react-social-media-embed\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/Tiktok/TiktokEmbed.tsx"],"sourcesContent":["import { NodeViewContent, NodeViewWrapper } from \"@tiptap/react\";\nimport { Music } from \"lucide-react\";\nimport { TikTokEmbed } from \"react-social-media-embed\";\nimport SocialMediaEmbed from \"../SocialMediaEmbed.js\";\n\nexport default (props: { node: { attrs: { url?: string } } }) => {\n return (\n <SocialMediaEmbed\n props={props}\n Icon={Music}\n text={\" Embed a Video from Tiktok\"}\n >\n <TikTokEmbed url={props?.node?.attrs?.url ?? \"\"} />\n </SocialMediaEmbed>\n );\n};\n"],"names":["Music","TikTokEmbed","SocialMediaEmbed","props","Icon","text","url","node","attrs"],"rangeMappings":";;;;;;;;;;;;;","mappings":";AACA,SAASA,KAAK,QAAQ,eAAe;AACrC,SAASC,WAAW,QAAQ,2BAA2B;AACvD,OAAOC,sBAAsB,yBAAyB;AAEtD,eAAe,CAAA,CAACC;IACd,qBACE,KAACD;QACCC,OAAOA;QACPC,MAAMJ;QACNK,MAAM;kBAEN,cAAA,KAACJ;YAAYK,KAAKH,OAAOI,MAAMC,OAAOF,OAAO;;;AAGnD,CAAA,EAAE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
|
-
import { SocialMediaEditorPanel } from "
|
|
4
|
+
import { SocialMediaEditorPanel } from "../../../features/panels/SocialMediaEditorPanel/SocialMediaEditorPanel.js";
|
|
5
5
|
import { supportedSocialMedia } from "./constants.js";
|
|
6
6
|
export const SocialMediaMenu = ({ editor, appendTo })=>{
|
|
7
7
|
const shouldShow = useCallback(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/menus/SocialMediaMenu.tsx"],"sourcesContent":["import { BubbleMenu as BaseBubbleMenu } from \"@tiptap/react\";\nimport { useCallback } from \"react\";\n\nimport { SocialMediaEditorPanel } from \"
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/SocialMedia/menus/SocialMediaMenu.tsx"],"sourcesContent":["import { BubbleMenu as BaseBubbleMenu } from \"@tiptap/react\";\nimport { useCallback } from \"react\";\n\nimport { SocialMediaEditorPanel } from \"../../../features/panels/SocialMediaEditorPanel/SocialMediaEditorPanel.js\";\nimport { MenuProps } from \"../../../features/menus/types.js\";\nimport { supportedSocialMedia } from \"./constants.js\";\n\nexport const SocialMediaMenu = ({ editor, appendTo }: MenuProps) => {\n const shouldShow = useCallback(() => {\n const isInSocialMedia = supportedSocialMedia?.some((socialMedia) => {\n const hasUrl = editor?.getAttributes(socialMedia)?.url;\n return !hasUrl && editor.isActive(socialMedia);\n });\n\n return isInSocialMedia;\n // const isIframe = editor.isActive('iframe')\n // return isIframe\n }, [editor]);\n\n const onHtml = useCallback(\n (url: string) => {\n const socialMedia = supportedSocialMedia?.find((socialMedia) => {\n return editor.isActive(socialMedia);\n });\n switch (socialMedia) {\n case \"facebook\":\n editor.chain().focus().insertFacebook(url).run();\n\n break;\n case \"instagram\":\n editor.chain().focus().insertInstagram(url).run();\n\n break;\n case \"youtube\":\n editor.chain().focus().insertYoutube(url).run();\n\n break;\n case \"linkedin\":\n editor.chain().focus().insertLinkedin(url).run();\n\n break;\n case \"tiktok\":\n editor.chain().focus().insertTiktok(url).run();\n\n break;\n case \"twitter\":\n editor.chain().focus().insertTwitter(url).run();\n break;\n }\n },\n [editor]\n );\n\n const generateTexts = useCallback(() => {\n const socialMedia = supportedSocialMedia?.find((socialMedia) => {\n return editor.isActive(socialMedia);\n });\n switch (socialMedia) {\n case \"facebook\":\n return {\n placeholderText: \"https://facebook.com/...\",\n buttonText: \"Embed Facebook\",\n descriptionText: \"Works with links to Facebook posts\",\n };\n\n case \"instagram\":\n return {\n placeholderText: \"https://instagram.com/...\",\n buttonText: \"Embed Instagram\",\n descriptionText: \"Works with links to Instagram posts\",\n };\n case \"youtube\":\n return {\n placeholderText: \"https://youtube.com/...\",\n buttonText: \"Embed Youtube\",\n descriptionText: \"Works with links to Youtube videos\",\n };\n case \"linkedin\":\n return {\n placeholderText: \"https://linkedin.com/...\",\n buttonText: \"Embed Linkedin\",\n descriptionText: \"Works with links to Linkedin posts\",\n };\n case \"tiktok\":\n return {\n placeholderText: \"https://tiktok.com/...\",\n buttonText: \"Embed Tiktok\",\n descriptionText: \"Works with links to tiktok videos\",\n };\n case \"twitter\":\n return {\n placeholderText: \"https://twitter.com/...\",\n buttonText: \"Embed Twitter\",\n descriptionText: \"Works with links to Tweets\",\n };\n }\n }, [editor]);\n return (\n <BaseBubbleMenu\n editor={editor}\n pluginKey={`socialMediaMenu`}\n shouldShow={shouldShow}\n tippyOptions={{\n popperOptions: { placement: \"bottom\" },\n placement: \"bottom\",\n // appendTo: () => {\n // return appendTo?.current\n // },\n }}\n updateDelay={100}\n >\n <SocialMediaEditorPanel\n onSetLink={onHtml}\n initialSrc=\"\"\n placeholderText={generateTexts()?.placeholderText ?? \"\"}\n buttonText={generateTexts()?.buttonText ?? \"\"}\n descriptionText={generateTexts()?.descriptionText ?? \"\"}\n />\n {/* <SocialMediaPopover onSetLink={onHtml} initialSrcLink={''} /> */}\n {/* \n <Toolbar.Wrapper>\n <to\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Sidebar left\"\n active={true}\n // onClick={onColumnLeft}\n >\n <SocialMediaPopover onSetLink={onHtml} initialSrcLink={''} />\n </Toolbar.Button>\n </Toolbar.Wrapper> */}\n </BaseBubbleMenu>\n );\n};\n\nexport default SocialMediaMenu;\n"],"names":["BubbleMenu","BaseBubbleMenu","useCallback","SocialMediaEditorPanel","supportedSocialMedia","SocialMediaMenu","editor","appendTo","shouldShow","isInSocialMedia","some","socialMedia","hasUrl","getAttributes","url","isActive","onHtml","find","chain","focus","insertFacebook","run","insertInstagram","insertYoutube","insertLinkedin","insertTiktok","insertTwitter","generateTexts","placeholderText","buttonText","descriptionText","pluginKey","tippyOptions","popperOptions","placement","updateDelay","onSetLink","initialSrc"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,cAAcC,cAAc,QAA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,OAAO;oBACLiB,iBAAiB;oBACjBC,YAAY;oBACZC,iBAAiB;gBACnB;YAEF,KAAK;gBACH,OAAO;oBACLF,iBAAiB;oBACjBC,YAAY;oBACZC,iBAAiB;gBACnB;YACF,KAAK;gBACH,OAAO;oBACLF,iBAAiB;oBACjBC,YAAY;oBACZC,iBAAiB;gBACnB;YACF,KAAK;gBACH,OAAO;oBACLF,iBAAiB;oBACjBC,YAAY;oBACZC,iBAAiB;gBACnB;YACF,KAAK;gBACH,OAAO;oBACLF,iBAAiB;oBACjBC,YAAY;oBACZC,iBAAiB;gBACnB;YACF,KAAK;gBACH,OAAO;oBACLF,iBAAiB;oBACjBC,YAAY;oBACZC,iBAAiB;gBACnB;QACJ;IACF,GAAG;QAACxB;KAAO;IACX,qBACE,KAACL;QACCK,QAAQA;QACRyB,WAAW,CAAC,eAAe,CAAC;QAC5BvB,YAAYA;QACZwB,cAAc;YACZC,eAAe;gBAAEC,WAAW;YAAS;YACrCA,WAAW;QAIb;QACAC,aAAa;kBAEb,cAAA,KAAChC;YACCiC,WAAWpB;YACXqB,YAAW;YACXT,iBAAiBD,iBAAiBC,mBAAmB;YACrDC,YAAYF,iBAAiBE,cAAc;YAC3CC,iBAAiBH,iBAAiBG,mBAAmB;;;AAiB7D,EAAE;AAEF,eAAezB,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trailing-node.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/TrailingNode/trailing-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"trailing-node.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/TrailingNode/trailing-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAUzC;;;;GAIG;AAEH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,YAAY,qCAmDvB,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Extension } from
|
|
2
|
-
import { Plugin, PluginKey } from
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
function nodeEqualsType({ types, node }) {
|
|
5
5
|
return Array.isArray(types) && types.includes(node.type) || node.type === types;
|
|
6
6
|
}
|
|
7
7
|
export const TrailingNode = Extension.create({
|
|
8
|
-
name:
|
|
8
|
+
name: "trailingNode",
|
|
9
9
|
addOptions () {
|
|
10
10
|
return {
|
|
11
|
-
node:
|
|
11
|
+
node: "paragraph",
|
|
12
12
|
notAfter: [
|
|
13
|
-
|
|
13
|
+
"paragraph"
|
|
14
14
|
]
|
|
15
15
|
};
|
|
16
16
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/TrailingNode/trailing-node.ts"],"sourcesContent":["import { Extension } from
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/TrailingNode/trailing-node.ts"],"sourcesContent":["import { Extension } from \"@tiptap/core\";\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\";\n\n// @ts-ignore\nfunction nodeEqualsType({ types, node }) {\n return (\n (Array.isArray(types) && types.includes(node.type)) || node.type === types\n );\n}\n\n/**\n * Extension based on:\n * - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js\n * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts\n */\n\nexport interface TrailingNodeOptions {\n node: string;\n notAfter: string[];\n}\n\nexport const TrailingNode = Extension.create<TrailingNodeOptions>({\n name: \"trailingNode\",\n\n addOptions() {\n return {\n node: \"paragraph\",\n notAfter: [\"paragraph\"],\n };\n },\n\n addProseMirrorPlugins() {\n const plugin = new PluginKey(this.name);\n const disabledNodes = Object.entries(this.editor.schema.nodes)\n .map(([, value]) => value)\n .filter((node) => this.options.notAfter.includes(node.name));\n\n return [\n new Plugin({\n key: plugin,\n appendTransaction: (_, __, state) => {\n const { doc, tr, schema } = state;\n const shouldInsertNodeAtEnd = plugin.getState(state);\n const endPosition = doc.content.size;\n const type = schema.nodes[this.options.node];\n\n if (!shouldInsertNodeAtEnd) {\n return;\n }\n\n // eslint-disable-next-line consistent-return\n return tr.insert(endPosition, type.create());\n },\n state: {\n init: (_, state) => {\n const lastNode = state.tr.doc.lastChild;\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes });\n },\n apply: (tr, value) => {\n if (!tr.docChanged) {\n return value;\n }\n\n const lastNode = tr.doc.lastChild;\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes });\n },\n },\n }),\n ];\n },\n});\n"],"names":["Extension","Plugin","PluginKey","nodeEqualsType","types","node","Array","isArray","includes","type","TrailingNode","create","name","addOptions","notAfter","addProseMirrorPlugins","plugin","disabledNodes","Object","entries","editor","schema","nodes","map","value","filter","options","key","appendTransaction","_","__","state","doc","tr","shouldInsertNodeAtEnd","getState","endPosition","content","size","insert","init","lastNode","lastChild","apply","docChanged"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,eAAe;AACzC,SAASC,MAAM,EAAEC,SAAS,QAAQ,mBAAmB;AAErD,aAAa;AACb,SAASC,eAAe,EAAEC,KAAK,EAAEC,IAAI,EAAE;IACrC,OACE,AAACC,MAAMC,OAAO,CAACH,UAAUA,MAAMI,QAAQ,CAACH,KAAKI,IAAI,KAAMJ,KAAKI,IAAI,KAAKL;AAEzE;AAaA,OAAO,MAAMM,eAAeV,UAAUW,MAAM,CAAsB;IAChEC,MA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ist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js
CHANGED
|
@@ -3,8 +3,8 @@ import { useLocale } from "@payloadcms/ui/providers/Locale";
|
|
|
3
3
|
import * as Popover from "@radix-ui/react-popover";
|
|
4
4
|
import { useAssistant } from "ai/react";
|
|
5
5
|
import { ArrowDownWideNarrow, CheckCheck, ChevronDown, Languages, RefreshCcwDot, StepForward, WrapText } from "lucide-react";
|
|
6
|
-
import { languages } from "
|
|
7
|
-
import { getPrevText } from "
|
|
6
|
+
import { languages } from "../../../../lib/constants.js";
|
|
7
|
+
import { getPrevText } from "../../../../lib/utils/index.js";
|
|
8
8
|
import { DropdownCategoryTitle } from "../../../ui/Dropdown/Dropdown.js";
|
|
9
9
|
import { Icon } from "../../../ui/Icon.js";
|
|
10
10
|
import { Surface } from "../../../ui/Surface.js";
|
package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.tsx"],"sourcesContent":["import { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport * as Popover from \"@radix-ui/react-popover\";\nimport { Editor } from \"@tiptap/react\";\nimport { useAssistant } from \"ai/react\";\nimport {\n ArrowDownWideNarrow,\n CheckCheck,\n ChevronDown,\n Languages,\n RefreshCcwDot,\n StepForward,\n WrapText,\n} from \"lucide-react\";\nimport { languages } from \"
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.tsx"],"sourcesContent":["import { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport * as Popover from \"@radix-ui/react-popover\";\nimport { Editor } from \"@tiptap/react\";\nimport { useAssistant } from \"ai/react\";\nimport {\n ArrowDownWideNarrow,\n CheckCheck,\n ChevronDown,\n Languages,\n RefreshCcwDot,\n StepForward,\n WrapText,\n} from \"lucide-react\";\nimport { languages } from \"../../../../lib/constants.js\";\nimport { getPrevText } from \"../../../../lib/utils/index.js\";\nimport { DropdownCategoryTitle } from \"../../../ui/Dropdown/Dropdown.js\";\nimport { Icon } from \"../../../ui/Icon.js\";\nimport { Surface } from \"../../../ui/Surface.js\";\nimport { Toolbar } from \"../../../ui/Toolbar.js\";\nconst options = [\n // {\n // value: 'translate',\n // label: 'Translate text',\n // icon: WrapText,\n // },\n {\n value: \"summarize\",\n label: \"Summarize text\",\n icon: WrapText,\n },\n {\n value: \"rewrite\",\n label: \"Rewrite into Axios\",\n icon: WrapText,\n },\n {\n value: \"improve\",\n label: \"Improve writing\",\n icon: RefreshCcwDot,\n },\n\n {\n value: \"fix\",\n label: \"Fix grammar\",\n icon: CheckCheck,\n },\n {\n value: \"shorter\",\n label: \"Make shorter\",\n icon: ArrowDownWideNarrow,\n },\n {\n value: \"longer\",\n label: \"Make longer\",\n icon: WrapText,\n },\n];\n\ninterface AISelectorCommandsProps {\n editor: Editor;\n onSelect: (\n value: string,\n options: { option: string; language?: string }\n ) => void;\n}\n\nconst AISelectorCommands = ({ onSelect, editor }: AISelectorCommandsProps) => {\n const { status, messages, input, submitMessage, handleInputChange } =\n useAssistant({\n api: \"/api/assistant\",\n });\n const { code } = useLocale();\n\n return (\n <>\n <DropdownCategoryTitle>Edit or review selection</DropdownCategoryTitle>\n <Popover.Root>\n <Popover.Trigger asChild>\n <Toolbar.Button\n className=\"gap-2 px-4 w-full flex justify-start \"\n type=\"button\"\n // active={!!states.currentHighlight}\n tooltip=\"Highlight text\"\n >\n <Icon icon={Languages} className=\"h-4 w-4 text-blue-500\" />\n Translate text\n <Icon icon={ChevronDown} className=\"h-4 w-4 text-blue-500\" />\n </Toolbar.Button>\n </Popover.Trigger>\n <Popover.Content side=\"right\" align=\"start\" sideOffset={8} asChild>\n <Surface className=\"flex flex-col min-w-[15rem] p-2 max-h-[20rem] overflow-auto\">\n <DropdownCategoryTitle>Languages</DropdownCategoryTitle>\n\n {languages.map((lang) => (\n <Toolbar.Button\n onClick={() => {\n const { from, to, empty } = editor.state.selection;\n const content = editor.state.doc.textBetween(from, to, \" \");\n onSelect(content, {\n option: \"translate\",\n language: lang.value,\n });\n }}\n className=\"gap-2 px-4 w-full flex justify-start \"\n key={lang.value}\n >\n {lang.label}\n </Toolbar.Button>\n ))}\n </Surface>\n </Popover.Content>\n </Popover.Root>\n\n {options.map((option) => (\n <Toolbar.Button\n // onSelect={(value) => {\n // const slice = editor.state.selection.content()\n // const text = editor.storage.markdown.serializer.serialize(slice.content)\n // onSelect(text, option.value)\n // }}\n onClick={() => {\n const { from, to, empty } = editor.state.selection;\n const content = editor.state.doc.textBetween(from, to, \" \");\n onSelect(content, { option: option.value, language: code ?? \"en\" });\n }}\n className=\" gap-2 px-4 w-full flex justify-start\"\n key={option.value}\n value={option.value}\n >\n <option.icon className=\"h-4 w-4 text-blue-500\" />\n {option.label}\n </Toolbar.Button>\n ))}\n <Toolbar.Divider horizontal />\n <DropdownCategoryTitle>Use AI to do more</DropdownCategoryTitle>\n <Toolbar.Button\n onClick={() => {\n const text = getPrevText(editor, { chars: 5000 });\n onSelect(text, { option: \"continue\", language: code ?? \"en\" });\n }}\n value=\"continue\"\n className=\"gap-2 px-4 w-full flex justify-start\"\n >\n <StepForward className=\"h-4 w-4 text-blue-500\" />\n Continue writing\n </Toolbar.Button>\n </>\n );\n};\n\nexport default AISelectorCommands;\n"],"names":["useLocale","Popover","useAssistant","ArrowDownWideNarrow","CheckCheck","ChevronDown","Languages","RefreshCcwDot","StepForward","WrapText","languages","getPrevText","DropdownCategoryTitle","Icon","Surface","Toolbar","options","value","label","icon","AISelectorCommands","onSelect","editor","status","messages","input","submitMessage","handleInputChange","api","code","Root","Trigger","asChild","Button","className","type","tooltip","Content","side","align","sideOffset","map","lang","onClick","from","to","empty","state","selection","content","doc","textBetween","option","language","Divider","horizontal","text","chars"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AOnC,KAAK;;sCAEnB,KAACmC,OAAOjC,IAAI;4BAACe,WAAU;;wBACtBkB,OAAOlC,KAAK;;mBAJRkC,OAAOnC,KAAK;0BAOrB,KAACF,QAAQuC,OAAO;gBAACC,UAAU;;0BAC3B,KAAC3C;0BAAsB;;0BACvB,MAACG,QAAQkB,MAAM;gBACbU,SAAS;oBACP,MAAMa,OAAO7C,YAAYW,QAAQ;wBAAEmC,OAAO;oBAAK;oBAC/CpC,SAASmC,MAAM;wBAAEJ,QAAQ;wBAAYC,UAAUxB,QAAQ;oBAAK;gBAC9D;gBACAZ,OAAM;gBACNiB,WAAU;;kCAEV,KAAC1B;wBAAY0B,WAAU;;oBAA0B;;;;;AAKzD;AAEA,eAAed,mBAAmB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
import { isCustomNodeSelected, isTextSelected } from "../../../../lib/utils/index.js";
|
|
3
|
-
import { supportedSocialMedia } from "
|
|
3
|
+
import { supportedSocialMedia } from "../../../../extensions/SocialMedia/menus/constants.js";
|
|
4
4
|
export const useTextmenuStates = (editor)=>{
|
|
5
5
|
const shouldShow = useCallback(({ view, from })=>{
|
|
6
6
|
const isInSocialMedia = supportedSocialMedia?.some((socialMedia)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../src/fields/TiptapEditor/features/menus/TextMenu/hooks/useTextmenuStates.ts"],"sourcesContent":["import { Editor } from \"@tiptap/react\";\nimport { useCallback, useMemo } from \"react\";\nimport { ShouldShowProps } from \"../../types.js\";\nimport {\n isCustomNodeSelected,\n isTextSelected,\n} from \"../../../../lib/utils/index.js\";\nimport { supportedSocialMedia } from \"
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/fields/TiptapEditor/features/menus/TextMenu/hooks/useTextmenuStates.ts"],"sourcesContent":["import { Editor } from \"@tiptap/react\";\nimport { useCallback, useMemo } from \"react\";\nimport { ShouldShowProps } from \"../../types.js\";\nimport {\n isCustomNodeSelected,\n isTextSelected,\n} from \"../../../../lib/utils/index.js\";\nimport { supportedSocialMedia } from \"../../../../extensions/SocialMedia/menus/constants.js\";\n\nexport const useTextmenuStates = (editor: Editor) => {\n const shouldShow = useCallback(\n ({ view, from }: ShouldShowProps) => {\n const isInSocialMedia = supportedSocialMedia?.some((socialMedia) => {\n return editor.isActive(socialMedia);\n });\n if (!view || isInSocialMedia || editor.isActive(\"insideLinks\")) {\n return false;\n }\n\n const domAtPos = view.domAtPos(from || 0).node as HTMLElement;\n const nodeDOM = view.nodeDOM(from || 0) as HTMLElement;\n const node = nodeDOM || domAtPos;\n\n if (isCustomNodeSelected(editor, node)) {\n return false;\n }\n\n return isTextSelected({ editor });\n },\n [editor]\n );\n\n return {\n isBold: editor.isActive(\"bold\"),\n isItalic: editor.isActive(\"italic\"),\n isStrike: editor.isActive(\"strike\"),\n isUnderline: editor.isActive(\"underline\"),\n isCode: editor.isActive(\"code\"),\n isSubscript: editor.isActive(\"subscript\"),\n isSuperscript: editor.isActive(\"superscript\"),\n isAlignLeft: editor.isActive({ textAlign: \"left\" }),\n isAlignCenter: editor.isActive({ textAlign: \"center\" }),\n isAlignRight: editor.isActive({ textAlign: \"right\" }),\n isAlignJustify: editor.isActive({ textAlign: \"justify\" }),\n currentColor: editor.getAttributes(\"textStyle\")?.color || undefined,\n currentHighlight: editor.getAttributes(\"highlight\")?.color || undefined,\n currentFont: editor.getAttributes(\"textStyle\")?.fontFamily || undefined,\n currentSize: editor.getAttributes(\"textStyle\")?.fontSize || undefined,\n shouldShow,\n };\n};\n"],"names":["useCallback","isCustomNodeSelected","isTextSelected","supportedSocialMedia","useTextmenuStates","editor","shouldShow","view","from","isInSocialMedia","some","socialMedia","isActive","domAtPos","node","nodeDOM","isBold","isItalic","isStrike","isUnderline","isCode","isSubscript","isSuperscript","isAlignLeft","textAlign","isAlignCenter","isAlignRight","isAlignJustify","currentColor","getAttributes","color","undefined","currentHighlight","currentFont","fontFamily","currentSize","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AAC,cAAcC,SAASC;QAC1DC,kBAAkB3B,OAAOwB,aAAa,CAAC,cAAcC,SAASC;QAC9DE,aAAa5B,OAAOwB,aAAa,CAAC,cAAcK,cAAcH;QAC9DI,aAAa9B,OAAOwB,aAAa,CAAC,cAAcO,YAAYL;QAC5DzB;IACF;AACF,EAAE"}
|
|
@@ -5,8 +5,8 @@ import { useCompletion } from "ai/react";
|
|
|
5
5
|
import { ArrowRight, Sparkles } from "lucide-react";
|
|
6
6
|
import { useCallback, useState } from "react";
|
|
7
7
|
import Markdown from "react-markdown";
|
|
8
|
-
import { getPrevText } from "
|
|
9
|
-
import { isRTL } from "
|
|
8
|
+
import { getPrevText } from "../../../lib/utils/index.js";
|
|
9
|
+
import { isRTL } from "../../../lib/utils/isRtl.js";
|
|
10
10
|
import AICompletionCommands from "../../menus/TextMenu/components/ai-completion-command.js";
|
|
11
11
|
import AISelectorCommands from "../../menus/TextMenu/components/ai-selector-commands.js";
|
|
12
12
|
import { Surface } from "../../ui/Surface.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\nimport { useCompletion } from \"ai/react\";\nimport { ArrowRight, Sparkles } from \"lucide-react\";\nimport { useCallback, useState } from \"react\";\nimport Markdown from \"react-markdown\";\nimport { getPrevText } from \"
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/AIEditorPanel/AIEditorPanel.tsx"],"sourcesContent":["\"use client\";\n\nimport { useLocale } from \"@payloadcms/ui/providers/Locale\";\nimport { Editor } from \"@tiptap/react\";\nimport { useCompletion } from \"ai/react\";\nimport { ArrowRight, Sparkles } from \"lucide-react\";\nimport { useCallback, useState } from \"react\";\nimport Markdown from \"react-markdown\";\nimport { getPrevText } from \"../../../lib/utils/index.js\";\nimport { isRTL } from \"../../../lib/utils/isRtl.js\";\nimport AICompletionCommands from \"../../menus/TextMenu/components/ai-completion-command.js\";\nimport AISelectorCommands from \"../../menus/TextMenu/components/ai-selector-commands.js\";\nimport { Surface } from \"../../ui/Surface.js\";\nimport { Toolbar } from \"../../ui/Toolbar.js\";\nimport CrazySpinner from \"../../ui/crazy-spinner.js\";\nimport { ScrollArea } from \"../../ui/scroll-area.js\";\nexport type AIEditorPanelProps = {\n editor: Editor;\n onOpenChange: (value: boolean) => void;\n};\n\nexport const AIEditorPanel = ({ editor, onOpenChange }: AIEditorPanelProps) => {\n const [inputValue, setInputValue] = useState(\"\");\n const { code } = useLocale();\n\n // const { status, messages, input, submitMessage, handleInputChange } = useAssistant({\n // // id: \"novel\",\n // api: \"/api/assistant\",\n // onResponse: (response) => {\n // if (response.status === 429) {\n // toast.error(\"You have reached your request limit for the day.\");\n // return;\n // }\n // },\n // onError: (e) => {\n // toast.error(e.message);\n // },\n // });\n\n const { completion, complete, isLoading } = useCompletion({\n // id: \"novel\",\n api: \"/api/generate\",\n onResponse: (response) => {\n if (response.status === 429) {\n console.log(\"You have reached your request limit for the day.\");\n\n return;\n }\n },\n onError: (e) => {\n console.log(\"ERROR\", e.message);\n },\n });\n\n const hasCompletion = completion.length > 0;\n const handleClick = useCallback(() => {\n if (completion)\n return complete(completion, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n const text = getPrevText(editor, { chars: 5000 });\n\n complete(text, {\n body: { option: \"zap\", command: inputValue, language: code ?? \"en\" },\n }).then(() => setInputValue(\"\"));\n }, [code]);\n return (\n <Surface className=\"p-2 min-w-[20rem]\">\n <>\n {hasCompletion && (\n <div className=\"flex max-h-[400px]\">\n <ScrollArea>\n <div\n className=\"prose p-2 px-4 prose-sm\"\n dir={isRTL(completion) ? \"rtl\" : \"ltr\"}\n >\n <Markdown>{completion}</Markdown>\n </div>\n </ScrollArea>\n </div>\n )}\n\n {isLoading && (\n <div className=\"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-blue-500\">\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 \" />\n AI is thinking\n <div className=\"ml-2 mt-1\">\n <CrazySpinner />\n </div>\n </div>\n )}\n\n {!isLoading && (\n <>\n <div className=\"flex justify-between items-center\">\n {/* <CommandInput\n value={inputValue}\n onValueChange={setInputValue}\n autoFocus\n placeholder={\n hasCompletion ? 'Tell AI what to do next' : 'Ask AI to edit or generate...'\n }\n // onFocus={() => addAIHighlight(editor)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') handleClick()\n }}\n /> */}\n <Sparkles className=\"mr-2 h-4 w-4 shrink-0 text-blue-500 \" />\n <input\n className=\"w-full p-2 text-black bg-white rounded dark:bg-black dark:text-white focus:outline-none\"\n value={inputValue}\n onChange={(e) => {\n setInputValue(e.target.value);\n }}\n placeholder={\n hasCompletion\n ? \"Tell AI what to do next\"\n : \"Ask AI to edit or generate...\"\n }\n autoFocus\n // onFocus={() => addAIHighlight(editor)}\n\n onKeyDown={(e) => {\n if (e.key === \"Enter\") handleClick();\n }}\n />\n <Toolbar.Button\n // size=\"icon\"\n\n // className=\"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-zinc-100 hover:bg-zinc-150\"\n onClick={handleClick}\n >\n <ArrowRight />\n </Toolbar.Button>\n </div>\n {hasCompletion ? (\n <AICompletionCommands\n editor={editor}\n onDiscard={() => {\n editor.chain().unsetHighlight().focus().run();\n onOpenChange(false);\n }}\n completion={completion}\n />\n ) : (\n <AISelectorCommands\n editor={editor}\n onSelect={(value, options) => {\n complete(value, { body: options });\n }}\n />\n )}\n </>\n )}\n </>\n </Surface>\n );\n};\n"],"names":["useLocale","useCompletion","ArrowRight","Sparkles","useCallback","useState","Markdown","getPrevText","isRTL","AICompletionCommands","AISelectorCommands","Surface","Toolbar","CrazySpinner","ScrollArea","AIEditorPanel","editor","onOpenChange","inputValue","setInputValue","code","completion","complete","isLoading","api","onResponse","response","status","console","log","onError","e","message","hasCompletion","length","handleClick","body","option","command","language","then","text","chars","className","div","dir","input","value","onChange","target","placeholder","autoFocus","onKeyDown","key","Button","onClick","onDiscard","chain","unsetHighlight","focus","run","onSelect","options"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAEA,SAASA,SAAS,QAAQ,kCAAkC;AAE5D,SAASC,aAAa,QAAQ,WAAW;AACzC,SAASC,UAAU,EAAEC,QAAQ,QAAQ,eAAe;AACpD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAC9C,OAAOC,cAAc,iBAAiB;AACtC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,KAAK,QAAQ,8BAA8B;AACpD,OAAOC,0BAA0B,2DAA2D;AAC5F,OAAOC,wBAAwB,0DAA0D;AACzF,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,OAAOC,kBAAkB,4BAA4B;AACrD,SAASC,UAAU,QAAQ,0BAA0B;AAMrD,OAAO,MAAMC,gBAAgB,CAAC,EAAEC,MAAM,EAAEC,YAAY,EAAsB;IACxE,MAAM,CAACC,YAAYC,cAAc,GAAGd,SAAS;IAC7C,MAAM,EAAEe,IAAI,EAAE,GAAGpB;IAEjB,uFAAuF;IACvF,oBAAoB;IACpB,2BAA2B;IAC3B,gCAAgC;IAChC,qCAAqC;IACrC,yEAAyE;IACzE,gBAAgB;IAChB,QAAQ;IACR,OAAO;IACP,sBAAsB;IACtB,8BAA8B;IAC9B,OAAO;IACP,MAAM;IAEN,MAAM,EAAEqB,UAAU,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGtB,cAAc;QACxD,eAAe;QACfuB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wCACV,IAAIA,EAAEsB,GAAG,KAAK,SAASlB;oCACzB;;8CAEF,KAACvB,QAAQ0C,MAAM;oCACb,cAAc;oCAEd,4GAA4G;oCAC5GC,SAASpB;8CAET,cAAA,KAACjC;;;;wBAGJ+B,8BACC,KAACxB;4BACCO,QAAQA;4BACRwC,WAAW;gCACTxC,OAAOyC,KAAK,GAAGC,cAAc,GAAGC,KAAK,GAAGC,GAAG;gCAC3C3C,aAAa;4BACf;4BACAI,YAAYA;2CAGd,KAACX;4BACCM,QAAQA;4BACR6C,UAAU,CAACd,OAAOe;gCAChBxC,SAASyB,OAAO;oCAAEX,MAAM0B;gCAAQ;4BAClC;;;;;;;AAQhB,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ContentRelationship } from "
|
|
2
|
+
import { ContentRelationship } from "../../../extensions/InsideLinks/InsideLink.client.js";
|
|
3
3
|
import { Surface } from "../../ui/Surface.js";
|
|
4
4
|
export const InsideLinksEditorPanel = ({ onRelationshipSelect, onCancel })=>{
|
|
5
5
|
return /*#__PURE__*/ _jsx(Surface, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/InsideLinksEditorPanel/InsideLinksEditorPanel.tsx"],"sourcesContent":["import { ContentRelationship } from \"
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/features/panels/InsideLinksEditorPanel/InsideLinksEditorPanel.tsx"],"sourcesContent":["import { ContentRelationship } from \"../../../extensions/InsideLinks/InsideLink.client.js\";\nimport { Surface } from \"../../ui/Surface.js\";\n\nexport type InsideLinksEditorPanelProps = {\n onRelationshipSelect: ({\n thumbnail,\n title,\n id,\n type,\n url,\n }: {\n id: string;\n type: string;\n thumbnail: string;\n title: string;\n url: string;\n }) => void;\n onCancel: () => void;\n};\n\nexport const InsideLinksEditorPanel = ({\n onRelationshipSelect,\n onCancel,\n}: // initialOpenInNewTab,\nInsideLinksEditorPanelProps) => {\n return (\n <Surface className=\"p-2\">\n <div className=\"flex flex-col items-center gap-2 p-1\">\n <ContentRelationship\n setRelationship={({ id, thumbnail, title, type, url }) => {\n onRelationshipSelect({ id, thumbnail, title, type, url });\n }}\n cancelSelection={() => {\n onCancel();\n }}\n />\n <span className=\"mt-1 mb-0 text-sm\">Add Internal Link to Contents</span>\n </div>\n </Surface>\n );\n};\n"],"names":["ContentRelationship","Surface","InsideLinksEditorPanel","onRelationshipSelect","onCancel","className","div","setRelationship","id","thumbnail","title","type","url","cancelSelection","span"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,mBAAmB,QAAQ,uDAAuD;AAC3F,SAASC,OAAO,QAAQ,sBAAsB;AAmB9C,OAAO,MAAMC,yBAAyB,CAAC,EACrCC,oBAAoB,EACpBC,QAAQ,EAEiB;IACzB,qBACE,KAACH;QAAQI,WAAU;kBACjB,cAAA,MAACC;YAAID,WAAU;;8BACb,KAACL;oBACCO,iBAAiB,CAAC,EAAEC,EAAE,EAAEC,SAAS,EAAEC,KAAK,EAAEC,IAAI,EAAEC,GAAG,EAAE;wBACnDT,qBAAqB;4BAAEK;4BAAIC;4BAAWC;4BAAOC;4BAAMC;wBAAI;oBACzD;oBACAC,iBAAiB;wBACfT;oBACF;;8BAEF,KAACU;oBAAKT,WAAU;8BAAoB;;;;;AAI5C,EAAE"}
|