@webiny/lexical-editor 0.0.0-unstable.06b2ede40f
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/LICENSE +21 -0
- package/README.md +17 -0
- package/commands/image.d.ts +6 -0
- package/commands/image.js +4 -0
- package/commands/image.js.map +1 -0
- package/commands/index.d.ts +5 -0
- package/commands/index.js +7 -0
- package/commands/index.js.map +1 -0
- package/commands/list.d.ts +7 -0
- package/commands/list.js +6 -0
- package/commands/list.js.map +1 -0
- package/commands/quote.d.ts +5 -0
- package/commands/quote.js +4 -0
- package/commands/quote.js.map +1 -0
- package/commands/toolbar.d.ts +1 -0
- package/commands/toolbar.js +4 -0
- package/commands/toolbar.js.map +1 -0
- package/commands/typography.d.ts +8 -0
- package/commands/typography.js +4 -0
- package/commands/typography.js.map +1 -0
- package/components/Editor/EnsureHeadingTagPlugin.d.ts +6 -0
- package/components/Editor/EnsureHeadingTagPlugin.js +20 -0
- package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -0
- package/components/Editor/HeadingEditor.d.ts +7 -0
- package/components/Editor/HeadingEditor.js +22 -0
- package/components/Editor/HeadingEditor.js.map +1 -0
- package/components/Editor/ParagraphEditor.d.ts +7 -0
- package/components/Editor/ParagraphEditor.js +22 -0
- package/components/Editor/ParagraphEditor.js.map +1 -0
- package/components/Editor/RichTextEditor.d.ts +49 -0
- package/components/Editor/RichTextEditor.js +133 -0
- package/components/Editor/RichTextEditor.js.map +1 -0
- package/components/Editor/normalizeInputValue.d.ts +6 -0
- package/components/Editor/normalizeInputValue.js +16 -0
- package/components/Editor/normalizeInputValue.js.map +1 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +20 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +63 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
- package/components/LexicalEditorConfig/components/Node.d.ts +14 -0
- package/components/LexicalEditorConfig/components/Node.js +30 -0
- package/components/LexicalEditorConfig/components/Node.js.map +1 -0
- package/components/LexicalEditorConfig/components/Plugin.d.ts +13 -0
- package/components/LexicalEditorConfig/components/Plugin.js +30 -0
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.d.ts +13 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.js +30 -0
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -0
- package/components/LexicalHtmlRenderer.d.ts +14 -0
- package/components/LexicalHtmlRenderer.js +55 -0
- package/components/LexicalHtmlRenderer.js.map +1 -0
- package/components/Toolbar/StaticToolbar.css +260 -0
- package/components/Toolbar/StaticToolbar.d.ts +5 -0
- package/components/Toolbar/StaticToolbar.js +22 -0
- package/components/Toolbar/StaticToolbar.js.map +1 -0
- package/components/Toolbar/Toolbar.css +643 -0
- package/components/Toolbar/Toolbar.d.ts +6 -0
- package/components/Toolbar/Toolbar.js +148 -0
- package/components/Toolbar/Toolbar.js.map +1 -0
- package/components/ToolbarActions/BoldAction.d.ts +2 -0
- package/components/ToolbarActions/BoldAction.js +25 -0
- package/components/ToolbarActions/BoldAction.js.map +1 -0
- package/components/ToolbarActions/BulletListAction.d.ts +2 -0
- package/components/ToolbarActions/BulletListAction.js +40 -0
- package/components/ToolbarActions/BulletListAction.js.map +1 -0
- package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -0
- package/components/ToolbarActions/CodeHighlightAction.js +25 -0
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -0
- package/components/ToolbarActions/FontColorAction.d.ts +29 -0
- package/components/ToolbarActions/FontColorAction.js +50 -0
- package/components/ToolbarActions/FontColorAction.js.map +1 -0
- package/components/ToolbarActions/FontSizeAction.d.ts +14 -0
- package/components/ToolbarActions/FontSizeAction.js +91 -0
- package/components/ToolbarActions/FontSizeAction.js.map +1 -0
- package/components/ToolbarActions/ImageAction.d.ts +2 -0
- package/components/ToolbarActions/ImageAction.js +37 -0
- package/components/ToolbarActions/ImageAction.js.map +1 -0
- package/components/ToolbarActions/ItalicAction.d.ts +2 -0
- package/components/ToolbarActions/ItalicAction.js +25 -0
- package/components/ToolbarActions/ItalicAction.js.map +1 -0
- package/components/ToolbarActions/LinkAction.d.ts +2 -0
- package/components/ToolbarActions/LinkAction.js +37 -0
- package/components/ToolbarActions/LinkAction.js.map +1 -0
- package/components/ToolbarActions/NumberedListAction.d.ts +2 -0
- package/components/ToolbarActions/NumberedListAction.js +48 -0
- package/components/ToolbarActions/NumberedListAction.js.map +1 -0
- package/components/ToolbarActions/QuoteAction.d.ts +2 -0
- package/components/ToolbarActions/QuoteAction.js +33 -0
- package/components/ToolbarActions/QuoteAction.js.map +1 -0
- package/components/ToolbarActions/TextAlignmentAction.d.ts +29 -0
- package/components/ToolbarActions/TextAlignmentAction.js +61 -0
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
- package/components/ToolbarActions/TypographyAction.d.ts +29 -0
- package/components/ToolbarActions/TypographyAction.js +108 -0
- package/components/ToolbarActions/TypographyAction.js.map +1 -0
- package/components/ToolbarActions/UnderlineAction.d.ts +2 -0
- package/components/ToolbarActions/UnderlineAction.js +24 -0
- package/components/ToolbarActions/UnderlineAction.js.map +1 -0
- package/context/FontColorActionContext.d.ts +6 -0
- package/context/FontColorActionContext.js +4 -0
- package/context/FontColorActionContext.js.map +1 -0
- package/context/RichTextEditorContext.d.ts +19 -0
- package/context/RichTextEditorContext.js +21 -0
- package/context/RichTextEditorContext.js.map +1 -0
- package/context/SharedHistoryContext.d.ts +10 -0
- package/context/SharedHistoryContext.js +19 -0
- package/context/SharedHistoryContext.js.map +1 -0
- package/context/TextAlignmentActionContextProps.d.ts +9 -0
- package/context/TextAlignmentActionContextProps.js +4 -0
- package/context/TextAlignmentActionContextProps.js.map +1 -0
- package/context/TypographyActionContext.d.ts +8 -0
- package/context/TypographyActionContext.js +4 -0
- package/context/TypographyActionContext.js.map +1 -0
- package/hooks/index.d.ts +8 -0
- package/hooks/index.js +10 -0
- package/hooks/index.js.map +1 -0
- package/hooks/useCurrentElement.d.ts +7 -0
- package/hooks/useCurrentElement.js +27 -0
- package/hooks/useCurrentElement.js.map +1 -0
- package/hooks/useCurrentSelection.d.ts +13 -0
- package/hooks/useCurrentSelection.js +57 -0
- package/hooks/useCurrentSelection.js.map +1 -0
- package/hooks/useFontColorPicker.d.ts +2 -0
- package/hooks/useFontColorPicker.js +11 -0
- package/hooks/useFontColorPicker.js.map +1 -0
- package/hooks/useIsMounted.d.ts +1 -0
- package/hooks/useIsMounted.js +12 -0
- package/hooks/useIsMounted.js.map +1 -0
- package/hooks/useList.d.ts +2 -0
- package/hooks/useList.js +50 -0
- package/hooks/useList.js.map +1 -0
- package/hooks/useQuote.d.ts +2 -0
- package/hooks/useQuote.js +17 -0
- package/hooks/useQuote.js.map +1 -0
- package/hooks/useRichTextEditor.d.ts +2 -0
- package/hooks/useRichTextEditor.js +11 -0
- package/hooks/useRichTextEditor.js.map +1 -0
- package/hooks/useTextAlignmentAction.d.ts +1 -0
- package/hooks/useTextAlignmentAction.js +11 -0
- package/hooks/useTextAlignmentAction.js.map +1 -0
- package/hooks/useTypographyAction.d.ts +1 -0
- package/hooks/useTypographyAction.js +11 -0
- package/hooks/useTypographyAction.js.map +1 -0
- package/images/icons/LICENSE.md +5 -0
- package/images/icons/chat-square-quote.svg +1 -0
- package/images/icons/chevron-down.svg +1 -0
- package/images/icons/code.svg +1 -0
- package/images/icons/font-color.svg +1 -0
- package/images/icons/indent.svg +3 -0
- package/images/icons/insert-image.svg +4 -0
- package/images/icons/justify.svg +3 -0
- package/images/icons/link.svg +1 -0
- package/images/icons/list-ol.svg +1 -0
- package/images/icons/list-ul.svg +1 -0
- package/images/icons/outdent.svg +3 -0
- package/images/icons/pencil-fill.svg +1 -0
- package/images/icons/text-center.svg +1 -0
- package/images/icons/text-left.svg +1 -0
- package/images/icons/text-paragraph.svg +1 -0
- package/images/icons/text-right.svg +1 -0
- package/images/icons/type-bold.svg +1 -0
- package/images/icons/type-h1.svg +1 -0
- package/images/icons/type-h2.svg +1 -0
- package/images/icons/type-h3.svg +1 -0
- package/images/icons/type-h4.svg +1 -0
- package/images/icons/type-h5.svg +1 -0
- package/images/icons/type-h6.svg +1 -0
- package/images/icons/type-italic.svg +1 -0
- package/images/icons/type-strikethrough.svg +1 -0
- package/images/icons/type-underline.svg +1 -0
- package/images/icons/unlink_icon.svg +1 -0
- package/index.d.ts +37 -0
- package/index.js +50 -0
- package/index.js.map +1 -0
- package/package.json +40 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +20 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +14 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
- package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/index.js +3 -0
- package/plugins/CodeHighlightPlugin/index.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +176 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +14 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +8 -0
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +104 -0
- package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +9 -0
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +34 -0
- package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.js +3 -0
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.d.ts +1 -0
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +12 -0
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.d.ts +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js +27 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
- package/plugins/FontColorPlugin/applyColorToNode.d.ts +3 -0
- package/plugins/FontColorPlugin/applyColorToNode.js +8 -0
- package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -0
- package/plugins/FontColorPlugin/applyColorToSelection.d.ts +3 -0
- package/plugins/FontColorPlugin/applyColorToSelection.js +66 -0
- package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -0
- package/plugins/ImagesPlugin/ImagesPlugin.d.ts +12 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js +151 -0
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -0
- package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
- package/plugins/LinkPlugin/LinkPlugin.js +59 -0
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
- package/plugins/ListPLugin/ListPlugin.d.ts +1 -0
- package/plugins/ListPLugin/ListPlugin.js +17 -0
- package/plugins/ListPLugin/ListPlugin.js.map +1 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.d.ts +1 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -0
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -0
- package/plugins/StateHandlingPlugin.d.ts +8 -0
- package/plugins/StateHandlingPlugin.js +75 -0
- package/plugins/StateHandlingPlugin.js.map +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.d.ts +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js +27 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
- package/types.d.ts +12 -0
- package/types.js +9 -0
- package/types.js.map +1 -0
- package/ui/ContentEditable.css +22 -0
- package/ui/ContentEditable.d.ts +12 -0
- package/ui/ContentEditable.js +19 -0
- package/ui/ContentEditable.js.map +1 -0
- package/ui/Divider.d.ts +2 -0
- package/ui/Divider.js +8 -0
- package/ui/Divider.js.map +1 -0
- package/ui/DropDown.d.ts +25 -0
- package/ui/DropDown.js +182 -0
- package/ui/DropDown.js.map +1 -0
- package/ui/ImageResizer.d.ts +24 -0
- package/ui/ImageResizer.js +211 -0
- package/ui/ImageResizer.js.map +1 -0
- package/ui/Input.css +32 -0
- package/ui/LinkPreview.css +69 -0
- package/ui/LinkPreview.d.ts +12 -0
- package/ui/LinkPreview.js +97 -0
- package/ui/LinkPreview.js.map +1 -0
- package/ui/Placeholder.css +20 -0
- package/ui/Placeholder.d.ts +15 -0
- package/ui/Placeholder.js +24 -0
- package/ui/Placeholder.js.map +1 -0
- package/ui/TextInput.d.ts +18 -0
- package/ui/TextInput.js +34 -0
- package/ui/TextInput.js.map +1 -0
- package/ui/ToolbarActionDialog.d.ts +11 -0
- package/ui/ToolbarActionDialog.js +77 -0
- package/ui/ToolbarActionDialog.js.map +1 -0
- package/utils/canUseDOM.d.ts +1 -0
- package/utils/canUseDOM.js +3 -0
- package/utils/canUseDOM.js.map +1 -0
- package/utils/files.d.ts +11 -0
- package/utils/files.js +21 -0
- package/utils/files.js.map +1 -0
- package/utils/getDOMRangeRect.d.ts +8 -0
- package/utils/getDOMRangeRect.js +23 -0
- package/utils/getDOMRangeRect.js.map +1 -0
- package/utils/getSelectedNode.d.ts +2 -0
- package/utils/getSelectedNode.js +25 -0
- package/utils/getSelectedNode.js.map +1 -0
- package/utils/getTransparentImage.d.ts +1 -0
- package/utils/getTransparentImage.js +5 -0
- package/utils/getTransparentImage.js.map +1 -0
- package/utils/insertImage.d.ts +2 -0
- package/utils/insertImage.js +16 -0
- package/utils/insertImage.js.map +1 -0
- package/utils/isAnchorLink.d.ts +1 -0
- package/utils/isAnchorLink.js +5 -0
- package/utils/isAnchorLink.js.map +1 -0
- package/utils/isChildOfFloatingToolbar.d.ts +1 -0
- package/utils/isChildOfFloatingToolbar.js +12 -0
- package/utils/isChildOfFloatingToolbar.js.map +1 -0
- package/utils/isHTMLElement.d.ts +8 -0
- package/utils/isHTMLElement.js +12 -0
- package/utils/isHTMLElement.js.map +1 -0
- package/utils/isValidJSON.d.ts +1 -0
- package/utils/isValidJSON.js +13 -0
- package/utils/isValidJSON.js.map +1 -0
- package/utils/isValidLexicalData.d.ts +4 -0
- package/utils/isValidLexicalData.js +24 -0
- package/utils/isValidLexicalData.js.map +1 -0
- package/utils/point.d.ts +21 -0
- package/utils/point.js +49 -0
- package/utils/point.js.map +1 -0
- package/utils/rect.d.ts +45 -0
- package/utils/rect.js +130 -0
- package/utils/rect.js.map +1 -0
- package/utils/sanitizeUrl.d.ts +1 -0
- package/utils/sanitizeUrl.js +25 -0
- package/utils/sanitizeUrl.js.map +1 -0
- package/utils/setFloatingElemPosition.d.ts +1 -0
- package/utils/setFloatingElemPosition.js +30 -0
- package/utils/setFloatingElemPosition.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isPoint","Rect","constructor","left","top","right","bottom","physicTop","physicBottom","physicLeft","physicRight","_top","_right","_left","_bottom","width","Math","abs","height","equals","contains","target","x","y","isOnTopSide","isOnBottomSide","isOnLeftSide","isOnRightSide","result","reason","intersectsWith","rect","x1","y1","w1","h1","x2","y2","w2","h2","maxX","maxY","minX","minY","generateNewRect","fromLTRB","fromLWTH","fromPoints","startPoint","endPoint","fromDOM","dom","getBoundingClientRect"],"sources":["rect.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport type { Point } from \"./point\";\nimport { isPoint } from \"./point\";\n\ntype ContainsPointReturn = {\n result: boolean;\n reason: {\n isOnTopSide: boolean;\n isOnBottomSide: boolean;\n isOnLeftSide: boolean;\n isOnRightSide: boolean;\n };\n};\n\nexport class Rect {\n private readonly _left: number;\n private readonly _top: number;\n private readonly _right: number;\n private readonly _bottom: number;\n\n constructor(left: number, top: number, right: number, bottom: number) {\n const [physicTop, physicBottom] = top <= bottom ? [top, bottom] : [bottom, top];\n\n const [physicLeft, physicRight] = left <= right ? [left, right] : [right, left];\n\n this._top = physicTop;\n this._right = physicRight;\n this._left = physicLeft;\n this._bottom = physicBottom;\n }\n\n get top(): number {\n return this._top;\n }\n\n get right(): number {\n return this._right;\n }\n\n get bottom(): number {\n return this._bottom;\n }\n\n get left(): number {\n return this._left;\n }\n\n get width(): number {\n return Math.abs(this._left - this._right);\n }\n\n get height(): number {\n return Math.abs(this._bottom - this._top);\n }\n\n public equals({ top, left, bottom, right }: Rect): boolean {\n return (\n top === this._top &&\n bottom === this._bottom &&\n left === this._left &&\n right === this._right\n );\n }\n\n public contains({ x, y }: Point): ContainsPointReturn;\n public contains({ top, left, bottom, right }: Rect): boolean;\n public contains(target: Point | Rect): boolean | ContainsPointReturn {\n if (isPoint(target)) {\n const { x, y } = target;\n\n const isOnTopSide = y < this._top;\n const isOnBottomSide = y > this._bottom;\n const isOnLeftSide = x < this._left;\n const isOnRightSide = x > this._right;\n\n const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide;\n\n return {\n reason: {\n isOnBottomSide,\n isOnLeftSide,\n isOnRightSide,\n isOnTopSide\n },\n result\n };\n } else {\n const { top, left, bottom, right } = target;\n\n return (\n top >= this._top &&\n top <= this._bottom &&\n bottom >= this._top &&\n bottom <= this._bottom &&\n left >= this._left &&\n left <= this._right &&\n right >= this._left &&\n right <= this._right\n );\n }\n }\n\n public intersectsWith(rect: Rect): boolean {\n const { left: x1, top: y1, width: w1, height: h1 } = rect;\n const { left: x2, top: y2, width: w2, height: h2 } = this;\n const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2;\n const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2;\n const minX = x1 <= x2 ? x1 : x2;\n const minY = y1 <= y2 ? y1 : y2;\n return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2;\n }\n\n public generateNewRect({\n left = this.left,\n top = this.top,\n right = this.right,\n bottom = this.bottom\n }): Rect {\n return new Rect(left, top, right, bottom);\n }\n\n static fromLTRB(left: number, top: number, right: number, bottom: number): Rect {\n return new Rect(left, top, right, bottom);\n }\n\n static fromLWTH(left: number, width: number, top: number, height: number): Rect {\n return new Rect(left, top, left + width, top + height);\n }\n\n static fromPoints(startPoint: Point, endPoint: Point): Rect {\n const { y: top, x: left } = startPoint;\n const { y: bottom, x: right } = endPoint;\n return Rect.fromLTRB(left, top, right, bottom);\n }\n\n static fromDOM(dom: HTMLElement): Rect {\n const { top, width, left, height } = dom.getBoundingClientRect();\n return Rect.fromLWTH(left, width, top, height);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO;AAYhB,OAAO,MAAMC,IAAI,CAAC;EAMdC,WAAWA,CAACC,IAAY,EAAEC,GAAW,EAAEC,KAAa,EAAEC,MAAc,EAAE;IAClE,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGJ,GAAG,IAAIE,MAAM,GAAG,CAACF,GAAG,EAAEE,MAAM,CAAC,GAAG,C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EAAEnB;IAAK,CAAC,GAAG6C,UAAU;IACtC,MAAM;MAAEzB,CAAC,EAAEjB,MAAM;MAAEgB,CAAC,EAAEjB;IAAM,CAAC,GAAG4C,QAAQ;IACxC,OAAOhD,IAAI,CAAC4C,QAAQ,CAAC1C,IAAI,EAAEC,GAAG,EAAEC,KAAK,EAAEC,MAAM,CAAC;EAClD;EAEA,OAAO4C,OAAOA,CAACC,GAAgB,EAAQ;IACnC,MAAM;MAAE/C,GAAG;MAAEW,KAAK;MAAEZ,IAAI;MAAEe;IAAO,CAAC,GAAGiC,GAAG,CAACC,qBAAqB,CAAC,CAAC;IAChE,OAAOnD,IAAI,CAAC6C,QAAQ,CAAC3C,IAAI,EAAEY,KAAK,EAAEX,GAAG,EAAEc,MAAM,CAAC;EAClD;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sanitizeUrl: (url: string) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { isAnchorLink } from "./isAnchorLink";
|
|
9
|
+
export const sanitizeUrl = url => {
|
|
10
|
+
/** A pattern that matches safe URLs. */
|
|
11
|
+
const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi;
|
|
12
|
+
|
|
13
|
+
/** A pattern that matches safe data URLs. */
|
|
14
|
+
const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
|
|
15
|
+
url = String(url).trim();
|
|
16
|
+
if (isAnchorLink(url)) {
|
|
17
|
+
return url;
|
|
18
|
+
}
|
|
19
|
+
if (url.match(SAFE_URL_PATTERN) || url.match(DATA_URL_PATTERN)) {
|
|
20
|
+
return url;
|
|
21
|
+
}
|
|
22
|
+
return `https://`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=sanitizeUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isAnchorLink","sanitizeUrl","url","SAFE_URL_PATTERN","DATA_URL_PATTERN","String","trim","match"],"sources":["sanitizeUrl.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nimport { isAnchorLink } from \"~/utils/isAnchorLink\";\n\nexport const sanitizeUrl = (url: string): string => {\n /** A pattern that matches safe URLs. */\n const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi;\n\n /** A pattern that matches safe data URLs. */\n const DATA_URL_PATTERN =\n /^data:(?:image\\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\\/(?:mpeg|mp4|ogg|webm)|audio\\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;\n\n url = String(url).trim();\n\n if (isAnchorLink(url)) {\n return url;\n }\n\n if (url.match(SAFE_URL_PATTERN) || url.match(DATA_URL_PATTERN)) {\n return url;\n }\n\n return `https://`;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,YAAY;AAErB,OAAO,MAAMC,WAAW,GAAIC,GAAW,IAAa;EAChD;EACA,MAAMC,gBAAgB,GAAG,iEAAiE;;EAE1F;EACA,MAAMC,gBAAgB,GAClB,qIAAqI;EAEzIF,GAAG,GAAGG,MAAM,CAACH,GAAG,CAAC,CAACI,IAAI,CAAC,CAAC;EAExB,IAAIN,YAAY,CAACE,GAAG,CAAC,EAAE;IACnB,OAAOA,GAAG;EACd;EAEA,IAAIA,GAAG,CAACK,KAAK,CAACJ,gBAAgB,CAAC,IAAID,GAAG,CAACK,KAAK,CAACH,gBAAgB,CAAC,EAAE;IAC5D,OAAOF,GAAG;EACd;EAEA,OAAO,UAAU;AACrB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setFloatingElemPosition(basePosition: ClientRect | null, elementToPosition: HTMLElement, anchorElem: HTMLElement, verticalGap?: number, horizontalOffset?: number): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const VERTICAL_GAP = 10;
|
|
2
|
+
const HORIZONTAL_OFFSET = 5;
|
|
3
|
+
export function setFloatingElemPosition(basePosition, elementToPosition, anchorElem, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET) {
|
|
4
|
+
// A small timeout gives enough time for DOM to update and provides us with correct bounding rect values.
|
|
5
|
+
setTimeout(() => {
|
|
6
|
+
const scrollerElem = anchorElem.parentElement;
|
|
7
|
+
if (basePosition === null || !scrollerElem) {
|
|
8
|
+
elementToPosition.style.opacity = "0";
|
|
9
|
+
elementToPosition.style.transform = "translate(-10000px, -10000px)";
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const rectToPosition = elementToPosition.getBoundingClientRect();
|
|
13
|
+
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
14
|
+
const editorScrollerRect = scrollerElem.getBoundingClientRect();
|
|
15
|
+
let top = basePosition.top - rectToPosition.height - verticalGap;
|
|
16
|
+
let left = basePosition.left - horizontalOffset;
|
|
17
|
+
if (top < editorScrollerRect.top) {
|
|
18
|
+
top += rectToPosition.height + basePosition.height + verticalGap * 2;
|
|
19
|
+
}
|
|
20
|
+
if (left + rectToPosition.width > editorScrollerRect.right) {
|
|
21
|
+
left = editorScrollerRect.right - rectToPosition.width - horizontalOffset;
|
|
22
|
+
}
|
|
23
|
+
top -= anchorElementRect.top;
|
|
24
|
+
left -= anchorElementRect.left;
|
|
25
|
+
elementToPosition.style.opacity = "1";
|
|
26
|
+
elementToPosition.style.transform = `translate(${left}px, ${top}px)`;
|
|
27
|
+
}, 10);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=setFloatingElemPosition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["VERTICAL_GAP","HORIZONTAL_OFFSET","setFloatingElemPosition","basePosition","elementToPosition","anchorElem","verticalGap","horizontalOffset","setTimeout","scrollerElem","parentElement","style","opacity","transform","rectToPosition","getBoundingClientRect","anchorElementRect","editorScrollerRect","top","height","left","width","right"],"sources":["setFloatingElemPosition.ts"],"sourcesContent":["const VERTICAL_GAP = 10;\nconst HORIZONTAL_OFFSET = 5;\n\nexport function setFloatingElemPosition(\n basePosition: ClientRect | null,\n elementToPosition: HTMLElement,\n anchorElem: HTMLElement,\n verticalGap: number = VERTICAL_GAP,\n horizontalOffset: number = HORIZONTAL_OFFSET\n): void {\n // A small timeout gives enough time for DOM to update and provides us with correct bounding rect values.\n setTimeout(() => {\n const scrollerElem = anchorElem.parentElement;\n\n if (basePosition === null || !scrollerElem) {\n elementToPosition.style.opacity = \"0\";\n elementToPosition.style.transform = \"translate(-10000px, -10000px)\";\n return;\n }\n\n const rectToPosition = elementToPosition.getBoundingClientRect();\n const anchorElementRect = anchorElem.getBoundingClientRect();\n const editorScrollerRect = scrollerElem.getBoundingClientRect();\n\n let top = basePosition.top - rectToPosition.height - verticalGap;\n let left = basePosition.left - horizontalOffset;\n\n if (top < editorScrollerRect.top) {\n top += rectToPosition.height + basePosition.height + verticalGap * 2;\n }\n\n if (left + rectToPosition.width > editorScrollerRect.right) {\n left = editorScrollerRect.right - rectToPosition.width - horizontalOffset;\n }\n\n top -= anchorElementRect.top;\n left -= anchorElementRect.left;\n\n elementToPosition.style.opacity = \"1\";\n elementToPosition.style.transform = `translate(${left}px, ${top}px)`;\n }, 10);\n}\n"],"mappings":"AAAA,MAAMA,YAAY,GAAG,EAAE;AACvB,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