@qwanyx/ai-editor 1.2.1 → 1.3.1
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/components/RichTextEditor.d.ts.map +1 -1
- package/dist/components/RichTextEditor.js +2 -1
- package/dist/components/RichTextViewer.d.ts.map +1 -1
- package/dist/components/RichTextViewer.js +2 -1
- package/dist/context/EditorModeContext.d.ts +12 -0
- package/dist/context/EditorModeContext.d.ts.map +1 -0
- package/dist/context/EditorModeContext.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/nodes/ImageNode.d.ts.map +1 -1
- package/dist/nodes/ImageNode.js +22 -13
- package/dist/plugins/ImageLinkPlugin.d.ts.map +1 -1
- package/dist/plugins/ImageLinkPlugin.js +20 -15
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../../src/components/RichTextEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RichTextEditor.d.ts","sourceRoot":"","sources":["../../src/components/RichTextEditor.tsx"],"names":[],"mappings":"AAkCA,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/C,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE;QACrB,QAAQ,EAAE,MAAM,CAAA;QAChB,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;QAC1C,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAqKD,wBAAgB,cAAc,CAAC,EAC7B,cAAmB,EACnB,QAAQ,EACR,WAAW,EACX,WAAqC,EACrC,SAAc,EACd,SAAmB,EACpB,EAAE,mBAAmB,2CA6IrB"}
|
|
@@ -57,6 +57,7 @@ const LexicalListPlugin_1 = require("@lexical/react/LexicalListPlugin");
|
|
|
57
57
|
const LexicalLinkPlugin_1 = require("@lexical/react/LexicalLinkPlugin");
|
|
58
58
|
const lexical_1 = require("lexical");
|
|
59
59
|
const EditorToolbar_1 = require("./EditorToolbar");
|
|
60
|
+
const EditorModeContext_1 = require("../context/EditorModeContext");
|
|
60
61
|
// Theme for Lexical editor
|
|
61
62
|
const editorTheme = {
|
|
62
63
|
paragraph: 'editor-paragraph',
|
|
@@ -285,5 +286,5 @@ function RichTextEditor({ initialContent = '', onChange, onAIRequest, placeholde
|
|
|
285
286
|
const fullscreenClasses = isFullscreen
|
|
286
287
|
? 'fixed inset-0 z-50'
|
|
287
288
|
: '';
|
|
288
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `border border-gray-200 rounded-lg bg-white flex flex-col ${fullscreenClasses} ${className}`, children: [(0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: { __html: editorStyles } }), (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, { initialConfig: getEditorConfig(initialContent), children: [(0, jsx_runtime_1.jsx)(EditorToolbar_1.EditorToolbar, { onAIAction: handleAIAction, isLoading: isLoading, isFullscreen: isFullscreen, onToggleFullscreen: toggleFullscreen }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex-1 overflow-auto", style: minHeight && !isFullscreen ? { minHeight } : {}, children: [(0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: "outline-none p-4 text-gray-900 h-full min-h-full" }), placeholder: (0, jsx_runtime_1.jsx)("div", { className: "absolute top-4 left-4 text-gray-400 pointer-events-none", children: placeholder }), ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalLinkPlugin_1.LinkPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalOnChangePlugin_1.OnChangePlugin, { onChange: handleChange }), (0, jsx_runtime_1.jsx)(InitialContentPlugin, { content: initialContent }), (0, jsx_runtime_1.jsx)(EditorRefPlugin, { editorRef: editorRef }), (0, jsx_runtime_1.jsx)(InsertObjectPlugin_1.InsertObjectPlugin, {}), (0, jsx_runtime_1.jsx)(ImageLinkPlugin_1.ImageLinkPlugin, {}), (0, jsx_runtime_1.jsx)(LinkPlugin_1.SimpleLinkPlugin, {}), isLoading && ((0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 bg-white/80 flex items-center justify-center z-10", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 text-blue-600", children: [(0, jsx_runtime_1.jsx)("span", { className: "material-icons animate-spin", children: "sync" }), (0, jsx_runtime_1.jsx)("span", { children: "L'IA travaille..." })] }) }))] })] })] }));
|
|
289
|
+
return ((0, jsx_runtime_1.jsx)(EditorModeContext_1.EditorModeProvider, { isViewer: false, children: (0, jsx_runtime_1.jsxs)("div", { className: `border border-gray-200 rounded-lg bg-white flex flex-col ${fullscreenClasses} ${className}`, children: [(0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: { __html: editorStyles } }), (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, { initialConfig: getEditorConfig(initialContent), children: [(0, jsx_runtime_1.jsx)("div", { className: "sticky top-0 z-10 bg-white border-b border-gray-200", children: (0, jsx_runtime_1.jsx)(EditorToolbar_1.EditorToolbar, { onAIAction: handleAIAction, isLoading: isLoading, isFullscreen: isFullscreen, onToggleFullscreen: toggleFullscreen }) }), (0, jsx_runtime_1.jsxs)("div", { className: "relative flex-1 overflow-auto", style: minHeight && !isFullscreen ? { minHeight } : {}, children: [(0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: "outline-none p-4 text-gray-900 h-full min-h-full" }), placeholder: (0, jsx_runtime_1.jsx)("div", { className: "absolute top-4 left-4 text-gray-400 pointer-events-none", children: placeholder }), ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalLinkPlugin_1.LinkPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalOnChangePlugin_1.OnChangePlugin, { onChange: handleChange }), (0, jsx_runtime_1.jsx)(InitialContentPlugin, { content: initialContent }), (0, jsx_runtime_1.jsx)(EditorRefPlugin, { editorRef: editorRef }), (0, jsx_runtime_1.jsx)(InsertObjectPlugin_1.InsertObjectPlugin, {}), (0, jsx_runtime_1.jsx)(ImageLinkPlugin_1.ImageLinkPlugin, {}), (0, jsx_runtime_1.jsx)(LinkPlugin_1.SimpleLinkPlugin, {}), isLoading && ((0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 bg-white/80 flex items-center justify-center z-10", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 text-blue-600", children: [(0, jsx_runtime_1.jsx)("span", { className: "material-icons animate-spin", children: "sync" }), (0, jsx_runtime_1.jsx)("span", { children: "L'IA travaille..." })] }) }))] })] })] }) }));
|
|
289
290
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextViewer.d.ts","sourceRoot":"","sources":["../../src/components/RichTextViewer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RichTextViewer.d.ts","sourceRoot":"","sources":["../../src/components/RichTextViewer.tsx"],"names":[],"mappings":"AAoBA,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AA4ID,wBAAgB,cAAc,CAAC,EAC7B,OAAY,EACZ,SAAc,EACf,EAAE,mBAAmB,kDA8BrB"}
|
|
@@ -19,6 +19,7 @@ const ImageLinkPlugin_1 = require("../plugins/ImageLinkPlugin");
|
|
|
19
19
|
const LinkPlugin_1 = require("../plugins/LinkPlugin");
|
|
20
20
|
const LexicalListPlugin_1 = require("@lexical/react/LexicalListPlugin");
|
|
21
21
|
const LexicalLinkPlugin_1 = require("@lexical/react/LexicalLinkPlugin");
|
|
22
|
+
const EditorModeContext_1 = require("../context/EditorModeContext");
|
|
22
23
|
// Theme for Lexical viewer (same as editor)
|
|
23
24
|
const viewerTheme = {
|
|
24
25
|
paragraph: 'editor-paragraph',
|
|
@@ -157,5 +158,5 @@ function RichTextViewer({ content = '', className = '' }) {
|
|
|
157
158
|
if (!content) {
|
|
158
159
|
return null;
|
|
159
160
|
}
|
|
160
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: className, children: [(0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: { __html: viewerStyles } }), (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, { initialConfig: getViewerConfig(), children: [(0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: "outline-none text-gray-900", style: { cursor: 'default' } }), placeholder: null, ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalLinkPlugin_1.LinkPlugin, {}), (0, jsx_runtime_1.jsx)(ContentLoaderPlugin, { content: content }), (0, jsx_runtime_1.jsx)(ImageLinkPlugin_1.ImageLinkPlugin, {}), (0, jsx_runtime_1.jsx)(LinkPlugin_1.SimpleLinkPlugin, {})] })] }));
|
|
161
|
+
return ((0, jsx_runtime_1.jsx)(EditorModeContext_1.EditorModeProvider, { isViewer: true, children: (0, jsx_runtime_1.jsxs)("div", { className: className, children: [(0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: { __html: viewerStyles } }), (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, { initialConfig: getViewerConfig(), children: [(0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: "outline-none text-gray-900", style: { cursor: 'default' } }), placeholder: null, ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalLinkPlugin_1.LinkPlugin, {}), (0, jsx_runtime_1.jsx)(ContentLoaderPlugin, { content: content }), (0, jsx_runtime_1.jsx)(ImageLinkPlugin_1.ImageLinkPlugin, {}), (0, jsx_runtime_1.jsx)(LinkPlugin_1.SimpleLinkPlugin, {})] })] }) }));
|
|
161
162
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface EditorModeContextValue {
|
|
3
|
+
isViewer: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const EditorModeContext: React.Context<EditorModeContextValue>;
|
|
6
|
+
export declare function useEditorMode(): EditorModeContextValue;
|
|
7
|
+
export declare function EditorModeProvider({ children, isViewer }: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
isViewer?: boolean;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=EditorModeContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorModeContext.d.ts","sourceRoot":"","sources":["../../src/context/EditorModeContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAExD,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,iBAAiB,uCAA6D,CAAA;AAE3F,wBAAgB,aAAa,2BAE5B;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,QAAgB,EACjB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,2CAMA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.EditorModeContext = void 0;
|
|
5
|
+
exports.useEditorMode = useEditorMode;
|
|
6
|
+
exports.EditorModeProvider = EditorModeProvider;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
exports.EditorModeContext = (0, react_1.createContext)({ isViewer: false });
|
|
10
|
+
function useEditorMode() {
|
|
11
|
+
return (0, react_1.useContext)(exports.EditorModeContext);
|
|
12
|
+
}
|
|
13
|
+
function EditorModeProvider({ children, isViewer = false }) {
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(exports.EditorModeContext.Provider, { value: { isViewer }, children: children }));
|
|
15
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export type { SimpleLinkPayload } from './nodes/LinkNode';
|
|
|
13
13
|
export { InsertObjectPlugin, INSERT_OBJECT_COMMAND } from './plugins/InsertObjectPlugin';
|
|
14
14
|
export { ImageLinkPlugin } from './plugins/ImageLinkPlugin';
|
|
15
15
|
export { SimpleLinkPlugin } from './plugins/LinkPlugin';
|
|
16
|
+
export { EditorModeContext, EditorModeProvider, useEditorMode } from './context/EditorModeContext';
|
|
16
17
|
export { RichTextEditor as AIEditor } from './components/RichTextEditor';
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGtE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAGpE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC7E,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAErE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACxH,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AACvH,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAGzD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAGvD,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/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kPlugin = exports.ImageLinkPlugin = exports.INSERT_OBJECT_COMMAND = exports.InsertObjectPlugin = exports.$wrapSelectionInSimpleLink = exports.$isSimpleLinkNode = exports.$createSimpleLinkNode = exports.SimpleLinkNode = exports.$wrapSelectionInImageLink = exports.$isImageLinkNode = exports.$createImageLinkNode = exports.ImageLinkNode = exports.$isImageNode = exports.$createImageNode = exports.ImageNode = exports.EditorToolbar = exports.RichTextViewer = exports.RichTextEditor = void 0;
|
|
3
|
+
exports.AIEditor = exports.useEditorMode = exports.EditorModeProvider = exports.EditorModeContext = exports.SimpleLinkPlugin = exports.ImageLinkPlugin = exports.INSERT_OBJECT_COMMAND = exports.InsertObjectPlugin = exports.$wrapSelectionInSimpleLink = exports.$isSimpleLinkNode = exports.$createSimpleLinkNode = exports.SimpleLinkNode = exports.$wrapSelectionInImageLink = exports.$isImageLinkNode = exports.$createImageLinkNode = exports.ImageLinkNode = exports.$isImageNode = exports.$createImageNode = exports.ImageNode = exports.EditorToolbar = exports.RichTextViewer = exports.RichTextEditor = void 0;
|
|
4
4
|
// Main WYSIWYG editor component
|
|
5
5
|
var RichTextEditor_1 = require("./components/RichTextEditor");
|
|
6
6
|
Object.defineProperty(exports, "RichTextEditor", { enumerable: true, get: function () { return RichTextEditor_1.RichTextEditor; } });
|
|
@@ -33,6 +33,11 @@ var ImageLinkPlugin_1 = require("./plugins/ImageLinkPlugin");
|
|
|
33
33
|
Object.defineProperty(exports, "ImageLinkPlugin", { enumerable: true, get: function () { return ImageLinkPlugin_1.ImageLinkPlugin; } });
|
|
34
34
|
var LinkPlugin_1 = require("./plugins/LinkPlugin");
|
|
35
35
|
Object.defineProperty(exports, "SimpleLinkPlugin", { enumerable: true, get: function () { return LinkPlugin_1.SimpleLinkPlugin; } });
|
|
36
|
+
// Context
|
|
37
|
+
var EditorModeContext_1 = require("./context/EditorModeContext");
|
|
38
|
+
Object.defineProperty(exports, "EditorModeContext", { enumerable: true, get: function () { return EditorModeContext_1.EditorModeContext; } });
|
|
39
|
+
Object.defineProperty(exports, "EditorModeProvider", { enumerable: true, get: function () { return EditorModeContext_1.EditorModeProvider; } });
|
|
40
|
+
Object.defineProperty(exports, "useEditorMode", { enumerable: true, get: function () { return EditorModeContext_1.useEditorMode; } });
|
|
36
41
|
// Alias for backwards compatibility
|
|
37
42
|
var RichTextEditor_2 = require("./components/RichTextEditor");
|
|
38
43
|
Object.defineProperty(exports, "AIEditor", { enumerable: true, get: function () { return RichTextEditor_2.RichTextEditor; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageNode.d.ts","sourceRoot":"","sources":["../../src/nodes/ImageNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EAEP,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAmD,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"ImageNode.d.ts","sourceRoot":"","sources":["../../src/nodes/ImageNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EAEP,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAmD,MAAM,OAAO,CAAA;AAGvE,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAEtD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,cAAc,CAAA;CACvB;AAED,MAAM,MAAM,mBAAmB,GAAG,M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K,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAKzC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAK3C,QAAQ,IAAI,MAAM,GAAG,SAAS;IAI9B,SAAS,IAAI,MAAM,GAAG,SAAS;IAI/B,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAKjD,YAAY,IAAI,MAAM,GAAG,SAAS;IAIlC,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAKvD,eAAe,IAAI,MAAM,GAAG,SAAS;IAIrC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAK7C,UAAU,IAAI,MAAM,GAAG,SAAS;IAIhC,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI;IAKjD,QAAQ,IAAI,cAAc,GAAG,SAAS;IAItC,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,mBAAmB,GAAG,SAAS;IAKjE,UAAU,IAAI,mBAAmB;IAejC,SAAS,IAAI,eAAe;IAS5B,MAAM,CAAC,SAAS,IAAI,gBAAgB,GAAG,IAAI;IAgB3C,QAAQ,IAAI,KAAK,CAAC,YAAY;CAe/B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,CAWjE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,SAAS,CAEpF"}
|
package/dist/nodes/ImageNode.js
CHANGED
|
@@ -8,11 +8,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const lexical_1 = require("lexical");
|
|
9
9
|
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
10
10
|
const react_1 = require("react");
|
|
11
|
+
const EditorModeContext_1 = require("../context/EditorModeContext");
|
|
11
12
|
function ImageComponent({ src, altText, width, height, copyright: initialCopyright, photographer: initialPhotographer, comment: initialComment, float: initialFloat, nodeKey, }) {
|
|
12
13
|
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
14
|
+
const { isViewer } = (0, EditorModeContext_1.useEditorMode)();
|
|
13
15
|
const containerRef = (0, react_1.useRef)(null);
|
|
14
16
|
const imageRef = (0, react_1.useRef)(null);
|
|
15
17
|
const [isSelected, setIsSelected] = (0, react_1.useState)(false);
|
|
18
|
+
const [isHovered, setIsHovered] = (0, react_1.useState)(false);
|
|
16
19
|
const [isResizing, setIsResizing] = (0, react_1.useState)(false);
|
|
17
20
|
const [showMetadataEditor, setShowMetadataEditor] = (0, react_1.useState)(false);
|
|
18
21
|
const [showFullscreen, setShowFullscreen] = (0, react_1.useState)(false);
|
|
@@ -31,11 +34,17 @@ function ImageComponent({ src, altText, width, height, copyright: initialCopyrig
|
|
|
31
34
|
const [editFloat, setEditFloat] = (0, react_1.useState)('none');
|
|
32
35
|
const startX = (0, react_1.useRef)(0);
|
|
33
36
|
const startWidth = (0, react_1.useRef)(0);
|
|
34
|
-
// Handle click to select
|
|
37
|
+
// Handle click to select (or open fullscreen in viewer mode)
|
|
35
38
|
const handleClick = (0, react_1.useCallback)((e) => {
|
|
36
39
|
e.stopPropagation();
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
if (isViewer) {
|
|
41
|
+
// In viewer mode, click opens fullscreen directly
|
|
42
|
+
setShowFullscreen(true);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
setIsSelected(true);
|
|
46
|
+
}
|
|
47
|
+
}, [isViewer]);
|
|
39
48
|
// Click outside to deselect
|
|
40
49
|
(0, react_1.useEffect)(() => {
|
|
41
50
|
const handleClickOutside = (e) => {
|
|
@@ -131,13 +140,13 @@ function ImageComponent({ src, altText, width, height, copyright: initialCopyrig
|
|
|
131
140
|
display: 'inline-block',
|
|
132
141
|
position: 'relative',
|
|
133
142
|
...getFloatStyles(),
|
|
134
|
-
}, onClick: handleClick, children: [(0, jsx_runtime_1.jsx)("img", { ref: imageRef, src: src, alt: altText, title: displayComment || undefined, style: {
|
|
143
|
+
}, onClick: handleClick, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), children: [(0, jsx_runtime_1.jsx)("img", { ref: imageRef, src: src, alt: altText, title: displayComment || undefined, style: {
|
|
135
144
|
maxWidth: '100%',
|
|
136
145
|
height: 'auto',
|
|
137
146
|
width: currentWidth ? `${currentWidth}px` : 'auto',
|
|
138
147
|
display: 'block',
|
|
139
148
|
borderRadius: '4px',
|
|
140
|
-
outline: isSelected ? '2px solid #3b82f6' : 'none',
|
|
149
|
+
outline: !isViewer && isSelected ? '2px solid #3b82f6' : 'none',
|
|
141
150
|
cursor: 'pointer',
|
|
142
151
|
}, draggable: false }), (displayCopyright || displayPhotographer) && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
143
152
|
position: 'absolute',
|
|
@@ -149,7 +158,7 @@ function ImageComponent({ src, altText, width, height, copyright: initialCopyrig
|
|
|
149
158
|
flexDirection: 'column',
|
|
150
159
|
gap: '2px',
|
|
151
160
|
textShadow: '0 1px 3px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.5)',
|
|
152
|
-
}, children: [displayCopyright && ((0, jsx_runtime_1.jsxs)("span", { style: { display: 'flex', alignItems: 'center', gap: '2px' }, children: [(0, jsx_runtime_1.jsx)("span", { className: "material-icons", style: { fontSize: '10px' }, children: "copyright" }), displayCopyright] })), displayPhotographer && ((0, jsx_runtime_1.jsxs)("span", { style: { display: 'flex', alignItems: 'center', gap: '2px' }, children: [(0, jsx_runtime_1.jsx)("span", { className: "material-icons", style: { fontSize: '10px' }, children: "photo_camera" }), displayPhotographer] }))] })), isSelected && ((0, jsx_runtime_1.jsx)("button", { onClick: (e) => {
|
|
161
|
+
}, children: [displayCopyright && ((0, jsx_runtime_1.jsxs)("span", { style: { display: 'flex', alignItems: 'center', gap: '2px' }, children: [(0, jsx_runtime_1.jsx)("span", { className: "material-icons", style: { fontSize: '10px' }, children: "copyright" }), displayCopyright] })), displayPhotographer && ((0, jsx_runtime_1.jsxs)("span", { style: { display: 'flex', alignItems: 'center', gap: '2px' }, children: [(0, jsx_runtime_1.jsx)("span", { className: "material-icons", style: { fontSize: '10px' }, children: "photo_camera" }), displayPhotographer] }))] })), !isViewer && isSelected && ((0, jsx_runtime_1.jsx)("button", { onClick: (e) => {
|
|
153
162
|
e.stopPropagation();
|
|
154
163
|
openMetadataEditor();
|
|
155
164
|
}, style: {
|
|
@@ -166,24 +175,24 @@ function ImageComponent({ src, altText, width, height, copyright: initialCopyrig
|
|
|
166
175
|
alignItems: 'center',
|
|
167
176
|
justifyContent: 'center',
|
|
168
177
|
boxShadow: '0 1px 3px rgba(0,0,0,0.3)',
|
|
169
|
-
}, title: "Modifier les m\u00E9tadonn\u00E9es", children: (0, jsx_runtime_1.jsx)("span", { className: "material-icons", style: { fontSize: '14px', color: 'white' }, children: "edit" }) })), isSelected && ((0, jsx_runtime_1.jsx)("button", { onClick: (e) => {
|
|
178
|
+
}, title: "Modifier les m\u00E9tadonn\u00E9es", children: (0, jsx_runtime_1.jsx)("span", { className: "material-icons", style: { fontSize: '14px', color: 'white' }, children: "edit" }) })), ((!isViewer && isSelected) || (isViewer && isHovered)) && ((0, jsx_runtime_1.jsx)("button", { onClick: (e) => {
|
|
170
179
|
e.stopPropagation();
|
|
171
180
|
setShowFullscreen(true);
|
|
172
181
|
}, style: {
|
|
173
182
|
position: 'absolute',
|
|
174
|
-
top: '-6px',
|
|
175
|
-
right: '20px',
|
|
183
|
+
top: isViewer ? '8px' : '-6px',
|
|
184
|
+
right: isViewer ? '8px' : '20px',
|
|
176
185
|
width: '24px',
|
|
177
186
|
height: '24px',
|
|
178
|
-
backgroundColor: '#3b82f6',
|
|
179
|
-
border: '2px solid white',
|
|
180
|
-
borderRadius: '4px',
|
|
187
|
+
backgroundColor: isViewer ? 'rgba(0, 0, 0, 0.6)' : '#3b82f6',
|
|
188
|
+
border: isViewer ? 'none' : '2px solid white',
|
|
189
|
+
borderRadius: isViewer ? '50%' : '4px',
|
|
181
190
|
cursor: 'pointer',
|
|
182
191
|
display: 'flex',
|
|
183
192
|
alignItems: 'center',
|
|
184
193
|
justifyContent: 'center',
|
|
185
194
|
boxShadow: '0 1px 3px rgba(0,0,0,0.3)',
|
|
186
|
-
}, title: "Voir en plein \u00E9cran", children: (0, jsx_runtime_1.jsx)("span", { className: "material-icons", style: { fontSize: '14px', color: 'white' }, children: "fullscreen" }) })), isSelected && ((0, jsx_runtime_1.jsx)("div", { onMouseDown: handleResizeStart, style: {
|
|
195
|
+
}, title: "Voir en plein \u00E9cran", children: (0, jsx_runtime_1.jsx)("span", { className: "material-icons", style: { fontSize: '14px', color: 'white' }, children: "fullscreen" }) })), !isViewer && isSelected && ((0, jsx_runtime_1.jsx)("div", { onMouseDown: handleResizeStart, style: {
|
|
187
196
|
position: 'absolute',
|
|
188
197
|
right: '-6px',
|
|
189
198
|
bottom: '-6px',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageLinkPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/ImageLinkPlugin.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImageLinkPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/ImageLinkPlugin.tsx"],"names":[],"mappings":"AAwIA,wBAAgB,eAAe,4CAiF9B"}
|
|
@@ -7,6 +7,7 @@ const react_1 = require("react");
|
|
|
7
7
|
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
8
8
|
const lexical_1 = require("lexical");
|
|
9
9
|
const ImageLinkNode_1 = require("../nodes/ImageLinkNode");
|
|
10
|
+
const EditorModeContext_1 = require("../context/EditorModeContext");
|
|
10
11
|
// Fullscreen modal component
|
|
11
12
|
function ImageLinkFullscreenModal({ url, altText, copyright, photographer, comment, onClose, }) {
|
|
12
13
|
// Close on Escape key
|
|
@@ -63,6 +64,7 @@ function ImageLinkFullscreenModal({ url, altText, copyright, photographer, comme
|
|
|
63
64
|
}
|
|
64
65
|
function ImageLinkPlugin() {
|
|
65
66
|
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
67
|
+
const { isViewer } = (0, EditorModeContext_1.useEditorMode)();
|
|
66
68
|
const [fullscreenData, setFullscreenData] = (0, react_1.useState)(null);
|
|
67
69
|
// Find ImageLinkNode at current selection
|
|
68
70
|
const getImageLinkNodeAtSelection = (0, react_1.useCallback)(() => {
|
|
@@ -87,27 +89,30 @@ function ImageLinkPlugin() {
|
|
|
87
89
|
});
|
|
88
90
|
return foundNode;
|
|
89
91
|
}, [editor]);
|
|
90
|
-
// Handle
|
|
92
|
+
// Handle click on ImageLinkNode
|
|
93
|
+
// In editor mode: Ctrl+Click opens fullscreen
|
|
94
|
+
// In viewer mode: Simple click opens fullscreen
|
|
91
95
|
(0, react_1.useEffect)(() => {
|
|
92
96
|
return editor.registerCommand(lexical_1.CLICK_COMMAND, (event) => {
|
|
93
|
-
const target = event.target;
|
|
94
|
-
// Check if we clicked on an element inside the editor that is an ImageLinkNode
|
|
95
97
|
const imageLinkNode = getImageLinkNodeAtSelection();
|
|
96
|
-
if (imageLinkNode
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
if (imageLinkNode) {
|
|
99
|
+
// In viewer mode: simple click opens fullscreen
|
|
100
|
+
// In editor mode: Ctrl+Click opens fullscreen
|
|
101
|
+
if (isViewer || event.ctrlKey) {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
setFullscreenData({
|
|
104
|
+
url: imageLinkNode.getUrl(),
|
|
105
|
+
altText: imageLinkNode.getAltText(),
|
|
106
|
+
copyright: imageLinkNode.getCopyright(),
|
|
107
|
+
photographer: imageLinkNode.getPhotographer(),
|
|
108
|
+
comment: imageLinkNode.getComment(),
|
|
109
|
+
});
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
107
112
|
}
|
|
108
113
|
return false;
|
|
109
114
|
}, lexical_1.COMMAND_PRIORITY_HIGH);
|
|
110
|
-
}, [editor, getImageLinkNodeAtSelection]);
|
|
115
|
+
}, [editor, getImageLinkNodeAtSelection, isViewer]);
|
|
111
116
|
const closeFullscreen = (0, react_1.useCallback)(() => {
|
|
112
117
|
setFullscreenData(null);
|
|
113
118
|
}, []);
|