@os-design/editor 1.0.200 → 1.0.202
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/cjs/@types/emotion.d.js.map +1 -1
- package/dist/cjs/Editor/BlockToolbar.js.map +1 -1
- package/dist/cjs/Editor/StyleToolbar.js +3 -3
- package/dist/cjs/Editor/StyleToolbar.js.map +1 -1
- package/dist/cjs/Editor/Toolbar.js.map +1 -1
- package/dist/cjs/Editor/ToolbarButton.js +5 -5
- package/dist/cjs/Editor/ToolbarButton.js.map +1 -1
- package/dist/cjs/Editor/blocks/Figure.js.map +1 -1
- package/dist/cjs/Editor/blocks/FigureCaption.js.map +1 -1
- package/dist/cjs/Editor/blocks/imageBlock.js +66 -68
- package/dist/cjs/Editor/blocks/imageBlock.js.map +1 -1
- package/dist/cjs/Editor/blocks/types.js +0 -4
- package/dist/cjs/Editor/blocks/types.js.map +1 -1
- package/dist/cjs/Editor/blocks/videoBlock.js +9 -20
- package/dist/cjs/Editor/blocks/videoBlock.js.map +1 -1
- package/dist/cjs/Editor/decorators/linkDecorator.js.map +1 -1
- package/dist/cjs/Editor/hooks/useBlockToolbarProps.js +2 -2
- package/dist/cjs/Editor/hooks/useBlockToolbarProps.js.map +1 -1
- package/dist/cjs/Editor/hooks/usePastedTextHandler.js +1 -1
- package/dist/cjs/Editor/hooks/usePastedTextHandler.js.map +1 -1
- package/dist/cjs/Editor/hooks/useReturnHandler.js +1 -1
- package/dist/cjs/Editor/hooks/useReturnHandler.js.map +1 -1
- package/dist/cjs/Editor/hooks/useStyleToolbarProps.js +3 -3
- package/dist/cjs/Editor/hooks/useStyleToolbarProps.js.map +1 -1
- package/dist/cjs/Editor/index.js +23 -23
- package/dist/cjs/Editor/index.js.map +1 -1
- package/dist/cjs/Editor/styles/defaultDraftJsStyles.js.map +1 -1
- package/dist/cjs/Editor/styles/overrideDraftJsStyles.js.map +1 -1
- package/dist/cjs/Editor/utils/addNewBlockAt.js +1 -1
- package/dist/cjs/Editor/utils/addNewBlockAt.js.map +1 -1
- package/dist/cjs/Editor/utils/changeBlock.js.map +1 -1
- package/dist/cjs/Editor/utils/createContentEditorState.js.map +1 -1
- package/dist/cjs/Editor/utils/createDecorator.js.map +1 -1
- package/dist/cjs/Editor/utils/createEmptyEditorState.js.map +1 -1
- package/dist/cjs/Editor/utils/defaultStyleToolbarItems.js +1 -1
- package/dist/cjs/Editor/utils/defaultStyleToolbarItems.js.map +1 -1
- package/dist/cjs/Editor/utils/getCurrentBlock.js.map +1 -1
- package/dist/cjs/Editor/utils/getSelectedBlockElement.js.map +1 -1
- package/dist/cjs/Editor/utils/getSelectionRange.js.map +1 -1
- package/dist/cjs/Editor/utils/setLink.js.map +1 -1
- package/dist/cjs/Editor/utils/transformers.js.map +1 -1
- package/dist/cjs/Editor/utils/unsetLink.js.map +1 -1
- package/dist/cjs/EditorSkeleton/index.js +1 -1
- package/dist/cjs/EditorSkeleton/index.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/Editor/BlockToolbar.js.map +1 -1
- package/dist/esm/Editor/StyleToolbar.js +3 -3
- package/dist/esm/Editor/StyleToolbar.js.map +1 -1
- package/dist/esm/Editor/ToolbarButton.js +2 -2
- package/dist/esm/Editor/ToolbarButton.js.map +1 -1
- package/dist/esm/Editor/blocks/imageBlock.js +5 -5
- package/dist/esm/Editor/blocks/imageBlock.js.map +1 -1
- package/dist/esm/Editor/blocks/types.js.map +1 -1
- package/dist/esm/Editor/blocks/videoBlock.js +3 -3
- package/dist/esm/Editor/blocks/videoBlock.js.map +1 -1
- package/dist/esm/Editor/decorators/linkDecorator.js.map +1 -1
- package/dist/esm/Editor/hooks/useBlockToolbarProps.js.map +1 -1
- package/dist/esm/Editor/hooks/usePastedTextHandler.js +1 -1
- package/dist/esm/Editor/hooks/usePastedTextHandler.js.map +1 -1
- package/dist/esm/Editor/hooks/useReturnHandler.js +1 -1
- package/dist/esm/Editor/hooks/useReturnHandler.js.map +1 -1
- package/dist/esm/Editor/hooks/useStyleToolbarProps.js +1 -1
- package/dist/esm/Editor/hooks/useStyleToolbarProps.js.map +1 -1
- package/dist/esm/Editor/index.js +11 -11
- package/dist/esm/Editor/index.js.map +1 -1
- package/dist/esm/Editor/utils/addNewBlockAt.js +1 -1
- package/dist/esm/Editor/utils/addNewBlockAt.js.map +1 -1
- package/dist/esm/Editor/utils/changeBlock.js.map +1 -1
- package/dist/esm/Editor/utils/createContentEditorState.js.map +1 -1
- package/dist/esm/Editor/utils/createDecorator.js.map +1 -1
- package/dist/esm/Editor/utils/createEmptyEditorState.js.map +1 -1
- package/dist/esm/Editor/utils/defaultStyleToolbarItems.js +2 -2
- package/dist/esm/Editor/utils/defaultStyleToolbarItems.js.map +1 -1
- package/dist/esm/Editor/utils/getCurrentBlock.js.map +1 -1
- package/dist/esm/Editor/utils/getSelectedBlockElement.js.map +1 -1
- package/dist/esm/Editor/utils/getSelectionRange.js.map +1 -1
- package/dist/esm/Editor/utils/setLink.js.map +1 -1
- package/dist/esm/Editor/utils/transformers.js.map +1 -1
- package/dist/esm/Editor/utils/unsetLink.js.map +1 -1
- package/dist/esm/EditorSkeleton/index.js +1 -1
- package/dist/esm/EditorSkeleton/index.js.map +1 -1
- package/dist/types/Editor/BlockToolbar.d.ts +2 -2
- package/dist/types/Editor/BlockToolbar.d.ts.map +1 -1
- package/dist/types/Editor/StyleToolbar.d.ts +2 -2
- package/dist/types/Editor/StyleToolbar.d.ts.map +1 -1
- package/dist/types/Editor/ToolbarButton.d.ts.map +1 -1
- package/dist/types/Editor/blocks/imageBlock.d.ts.map +1 -1
- package/dist/types/Editor/blocks/types.d.ts +1 -1
- package/dist/types/Editor/blocks/types.d.ts.map +1 -1
- package/dist/types/Editor/blocks/videoBlock.d.ts.map +1 -1
- package/dist/types/Editor/decorators/linkDecorator.d.ts.map +1 -1
- package/dist/types/Editor/hooks/useBlockToolbarProps.d.ts.map +1 -1
- package/dist/types/Editor/hooks/usePastedTextHandler.d.ts.map +1 -1
- package/dist/types/Editor/hooks/useReturnHandler.d.ts.map +1 -1
- package/dist/types/Editor/hooks/useStyleToolbarProps.d.ts.map +1 -1
- package/dist/types/Editor/index.d.ts +3 -3
- package/dist/types/Editor/index.d.ts.map +1 -1
- package/dist/types/Editor/utils/addNewBlockAt.d.ts.map +1 -1
- package/dist/types/Editor/utils/defaultStyleToolbarItems.d.ts.map +1 -1
- package/dist/types/EditorSkeleton/index.d.ts +1 -1
- package/dist/types/EditorSkeleton/index.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
7
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
9
8
|
var _icons = require("@os-design/icons");
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _templateObject;
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
12
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultStyleToolbarItems.js","names":["FontSizeSmall","styled","FontSize","defaultStyleToolbarItems","name","type","icon"],"sources":["../../../../src/Editor/utils/defaultStyleToolbarItems.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"defaultStyleToolbarItems.js","names":["_styled","_interopRequireDefault","require","_icons","_react","_templateObject","obj","__esModule","_taggedTemplateLiteral","strings","raw","slice","Object","freeze","defineProperties","value","FontSizeSmall","styled","FontSize","defaultStyleToolbarItems","name","type","icon","createElement","Bold","UnorderedList","OrderedList","Link","_default","exports"],"sources":["../../../../src/Editor/utils/defaultStyleToolbarItems.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport {\n Bold,\n FontSize,\n Link as LinkIcon,\n OrderedList,\n UnorderedList,\n} from '@os-design/icons';\nimport React from 'react';\n\nexport interface StyleToolbarItem {\n name: string;\n type: 'block' | 'inline';\n icon: React.ReactNode;\n}\n\nconst FontSizeSmall = styled(FontSize)`\n transform: scale(0.7);\n`;\n\nconst defaultStyleToolbarItems: StyleToolbarItem[] = [\n { name: 'header-two', type: 'block', icon: <FontSize /> },\n { name: 'header-three', type: 'block', icon: <FontSizeSmall /> },\n { name: 'BOLD', type: 'inline', icon: <Bold /> },\n { name: 'unordered-list-item', type: 'block', icon: <UnorderedList /> },\n { name: 'ordered-list-item', type: 'block', icon: <OrderedList /> },\n { name: 'LINK', type: 'inline', icon: <LinkIcon /> },\n];\n\nexport default defaultStyleToolbarItems;\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA0B,IAAAG,eAAA;AAAA,SAAAJ,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,uBAAAC,OAAA,EAAAC,GAAA,SAAAA,GAAA,IAAAA,GAAA,GAAAD,OAAA,CAAAE,KAAA,cAAAC,MAAA,CAAAC,MAAA,CAAAD,MAAA,CAAAE,gBAAA,CAAAL,OAAA,IAAAC,GAAA,IAAAK,KAAA,EAAAH,MAAA,CAAAC,MAAA,CAAAH,GAAA;AAQ1B,IAAMM,aAAa,GAAG,IAAAC,kBAAM,EAACC,eAAQ,CAAC,CAAAb,eAAA,KAAAA,eAAA,GAAAG,sBAAA,oCAErC;AAED,IAAMW,wBAA4C,GAAG,CACnD;EAAEC,IAAI,EAAE,YAAY;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAElB,MAAA,YAAAmB,aAAA,CAACpB,MAAA,CAAAe,QAAQ,MAAE;AAAE,CAAC,EACzD;EAAEE,IAAI,EAAE,cAAc;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAElB,MAAA,YAAAmB,aAAA,CAACP,aAAa,MAAE;AAAE,CAAC,EAChE;EAAEI,IAAI,EAAE,MAAM;EAAEC,IAAI,EAAE,QAAQ;EAAEC,IAAI,eAAElB,MAAA,YAAAmB,aAAA,CAACpB,MAAA,CAAAqB,IAAI,MAAE;AAAE,CAAC,EAChD;EAAEJ,IAAI,EAAE,qBAAqB;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAElB,MAAA,YAAAmB,aAAA,CAACpB,MAAA,CAAAsB,aAAa,MAAE;AAAE,CAAC,EACvE;EAAEL,IAAI,EAAE,mBAAmB;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAElB,MAAA,YAAAmB,aAAA,CAACpB,MAAA,CAAAuB,WAAW,MAAE;AAAE,CAAC,EACnE;EAAEN,IAAI,EAAE,MAAM;EAAEC,IAAI,EAAE,QAAQ;EAAEC,IAAI,eAAElB,MAAA,YAAAmB,aAAA,CAACpB,MAAA,CAAAwB,IAAQ,MAAE;AAAE,CAAC,CACrD;AAAC,IAAAC,QAAA,GAEaT,wBAAwB;AAAAU,OAAA,cAAAD,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCurrentBlock.js","names":["getCurrentBlock","editorState","selectionState","getSelection","contentState","getCurrentContent","getBlockForKey","getStartKey"],"sources":["../../../../src/Editor/utils/getCurrentBlock.ts"],"sourcesContent":["import { ContentBlock, EditorState } from 'draft-js';\n\nconst getCurrentBlock = (editorState: EditorState): ContentBlock => {\n const selectionState = editorState.getSelection();\n const contentState = editorState.getCurrentContent();\n return contentState.getBlockForKey(selectionState.getStartKey());\n};\n\nexport default getCurrentBlock;\n"],"mappings":";;;;;;AAEA,IAAMA,eAAe,GAAG,SAAlBA,
|
|
1
|
+
{"version":3,"file":"getCurrentBlock.js","names":["getCurrentBlock","editorState","selectionState","getSelection","contentState","getCurrentContent","getBlockForKey","getStartKey","_default","exports"],"sources":["../../../../src/Editor/utils/getCurrentBlock.ts"],"sourcesContent":["import { ContentBlock, EditorState } from 'draft-js';\n\nconst getCurrentBlock = (editorState: EditorState): ContentBlock => {\n const selectionState = editorState.getSelection();\n const contentState = editorState.getCurrentContent();\n return contentState.getBlockForKey(selectionState.getStartKey());\n};\n\nexport default getCurrentBlock;\n"],"mappings":";;;;;;AAEA,IAAMA,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,WAAwB,EAAmB;EAClE,IAAMC,cAAc,GAAGD,WAAW,CAACE,YAAY,CAAC,CAAC;EACjD,IAAMC,YAAY,GAAGH,WAAW,CAACI,iBAAiB,CAAC,CAAC;EACpD,OAAOD,YAAY,CAACE,cAAc,CAACJ,cAAc,CAACK,WAAW,CAAC,CAAC,CAAC;AAClE,CAAC;AAAC,IAAAC,QAAA,GAEaR,eAAe;AAAAS,OAAA,cAAAD,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelectedBlockElement.js","names":["getSelectedBlockElement","selectionRange","getSelectionRange","node","startContainer","Element","getAttribute","parentNode"],"sources":["../../../../src/Editor/utils/getSelectedBlockElement.ts"],"sourcesContent":["import getSelectionRange from './getSelectionRange';\n\nconst getSelectedBlockElement = (): Element | null => {\n const selectionRange = getSelectionRange();\n if (!selectionRange) return null;\n\n let node: Node | null = selectionRange.startContainer;\n\n do {\n if (node instanceof Element && node.getAttribute('data-block') === 'true')\n return node;\n node = node.parentNode;\n } while (node != null);\n return null;\n};\n\nexport default getSelectedBlockElement;\n"],"mappings":";;;;;;AAAA;AAAoD;AAEpD,
|
|
1
|
+
{"version":3,"file":"getSelectedBlockElement.js","names":["_getSelectionRange","_interopRequireDefault","require","obj","__esModule","getSelectedBlockElement","selectionRange","getSelectionRange","node","startContainer","Element","getAttribute","parentNode","_default","exports"],"sources":["../../../../src/Editor/utils/getSelectedBlockElement.ts"],"sourcesContent":["import getSelectionRange from './getSelectionRange';\n\nconst getSelectedBlockElement = (): Element | null => {\n const selectionRange = getSelectionRange();\n if (!selectionRange) return null;\n\n let node: Node | null = selectionRange.startContainer;\n\n do {\n if (node instanceof Element && node.getAttribute('data-block') === 'true')\n return node;\n node = node.parentNode;\n } while (node != null);\n return null;\n};\n\nexport default getSelectedBlockElement;\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoD,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAEpD,IAAME,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAAA,EAAyB;EACpD,IAAMC,cAAc,GAAG,IAAAC,6BAAiB,EAAC,CAAC;EAC1C,IAAI,CAACD,cAAc,EAAE,OAAO,IAAI;EAEhC,IAAIE,IAAiB,GAAGF,cAAc,CAACG,cAAc;EAErD,GAAG;IACD,IAAID,IAAI,YAAYE,OAAO,IAAIF,IAAI,CAACG,YAAY,CAAC,YAAY,CAAC,KAAK,MAAM,EACvE,OAAOH,IAAI;IACbA,IAAI,GAAGA,IAAI,CAACI,UAAU;EACxB,CAAC,QAAQJ,IAAI,IAAI,IAAI;EACrB,OAAO,IAAI;AACb,CAAC;AAAC,IAAAK,QAAA,GAEaR,uBAAuB;AAAAS,OAAA,cAAAD,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelectionRange.js","names":["getSelectionRange","selection","document","getSelection","rangeCount","getRangeAt"],"sources":["../../../../src/Editor/utils/getSelectionRange.ts"],"sourcesContent":["const getSelectionRange = (): Range | null => {\n const selection = document.getSelection();\n if (!selection || selection.rangeCount === 0) return null;\n return selection.getRangeAt(0);\n};\n\nexport default getSelectionRange;\n"],"mappings":";;;;;;AAAA,IAAMA,iBAAiB,GAAG,SAApBA,
|
|
1
|
+
{"version":3,"file":"getSelectionRange.js","names":["getSelectionRange","selection","document","getSelection","rangeCount","getRangeAt","_default","exports"],"sources":["../../../../src/Editor/utils/getSelectionRange.ts"],"sourcesContent":["const getSelectionRange = (): Range | null => {\n const selection = document.getSelection();\n if (!selection || selection.rangeCount === 0) return null;\n return selection.getRangeAt(0);\n};\n\nexport default getSelectionRange;\n"],"mappings":";;;;;;AAAA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAA,EAAuB;EAC5C,IAAMC,SAAS,GAAGC,QAAQ,CAACC,YAAY,CAAC,CAAC;EACzC,IAAI,CAACF,SAAS,IAAIA,SAAS,CAACG,UAAU,KAAK,CAAC,EAAE,OAAO,IAAI;EACzD,OAAOH,SAAS,CAACI,UAAU,CAAC,CAAC,CAAC;AAChC,CAAC;AAAC,IAAAC,QAAA,GAEaN,iBAAiB;AAAAO,OAAA,cAAAD,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setLink.js","names":["setLink","editorState","url","containsLink","RichUtils","currentBlockContainsLink","contentState","getCurrentContent","contentStateWithLink","createEntity","entityKey","getLastCreatedEntityKey","nextEditorState","EditorState","set","currentContent","toggleLink","getSelection"],"sources":["../../../../src/Editor/utils/setLink.ts"],"sourcesContent":["import { EditorState, RichUtils } from 'draft-js';\n\nconst setLink = (editorState: EditorState, url: string): EditorState => {\n const containsLink = RichUtils.currentBlockContainsLink(editorState);\n if (containsLink) return editorState;\n\n const contentState = editorState.getCurrentContent();\n const contentStateWithLink = contentState.createEntity('LINK', 'MUTABLE', {\n url,\n });\n const entityKey = contentStateWithLink.getLastCreatedEntityKey();\n const nextEditorState = EditorState.set(editorState, {\n currentContent: contentStateWithLink,\n });\n return RichUtils.toggleLink(\n nextEditorState,\n nextEditorState.getSelection(),\n entityKey\n );\n};\n\nexport default setLink;\n"],"mappings":";;;;;;AAAA;AAEA,
|
|
1
|
+
{"version":3,"file":"setLink.js","names":["_draftJs","require","setLink","editorState","url","containsLink","RichUtils","currentBlockContainsLink","contentState","getCurrentContent","contentStateWithLink","createEntity","entityKey","getLastCreatedEntityKey","nextEditorState","EditorState","set","currentContent","toggleLink","getSelection","_default","exports"],"sources":["../../../../src/Editor/utils/setLink.ts"],"sourcesContent":["import { EditorState, RichUtils } from 'draft-js';\n\nconst setLink = (editorState: EditorState, url: string): EditorState => {\n const containsLink = RichUtils.currentBlockContainsLink(editorState);\n if (containsLink) return editorState;\n\n const contentState = editorState.getCurrentContent();\n const contentStateWithLink = contentState.createEntity('LINK', 'MUTABLE', {\n url,\n });\n const entityKey = contentStateWithLink.getLastCreatedEntityKey();\n const nextEditorState = EditorState.set(editorState, {\n currentContent: contentStateWithLink,\n });\n return RichUtils.toggleLink(\n nextEditorState,\n nextEditorState.getSelection(),\n entityKey\n );\n};\n\nexport default setLink;\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAMC,OAAO,GAAG,SAAVA,OAAOA,CAAIC,WAAwB,EAAEC,GAAW,EAAkB;EACtE,IAAMC,YAAY,GAAGC,kBAAS,CAACC,wBAAwB,CAACJ,WAAW,CAAC;EACpE,IAAIE,YAAY,EAAE,OAAOF,WAAW;EAEpC,IAAMK,YAAY,GAAGL,WAAW,CAACM,iBAAiB,CAAC,CAAC;EACpD,IAAMC,oBAAoB,GAAGF,YAAY,CAACG,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE;IACxEP,GAAG,EAAHA;EACF,CAAC,CAAC;EACF,IAAMQ,SAAS,GAAGF,oBAAoB,CAACG,uBAAuB,CAAC,CAAC;EAChE,IAAMC,eAAe,GAAGC,oBAAW,CAACC,GAAG,CAACb,WAAW,EAAE;IACnDc,cAAc,EAAEP;EAClB,CAAC,CAAC;EACF,OAAOJ,kBAAS,CAACY,UAAU,CACzBJ,eAAe,EACfA,eAAe,CAACK,YAAY,CAAC,CAAC,EAC9BP,SACF,CAAC;AACH,CAAC;AAAC,IAAAQ,QAAA,GAEalB,OAAO;AAAAmB,OAAA,cAAAD,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.js","names":["editorStateToFirstParagraph","editorState","firstUnstyledBlock","getCurrentContent","getBlocksAsArray","find","block","getType","getText","editorStateToMetaDescription","slice","replace","trim"],"sources":["../../../../src/Editor/utils/transformers.ts"],"sourcesContent":["import { EditorState } from 'draft-js';\n\nexport const editorStateToFirstParagraph = (\n editorState: EditorState\n): string => {\n const firstUnstyledBlock = editorState\n .getCurrentContent()\n .getBlocksAsArray()\n .find((block) => block.getType() === 'unstyled');\n\n return firstUnstyledBlock ? firstUnstyledBlock.getText() : '';\n};\n\nexport const editorStateToMetaDescription = (\n editorState: EditorState\n): string =>\n editorStateToFirstParagraph(editorState)\n .slice(0, 200)\n .replace(/^(.*[.?!])(.*)/, '$1')\n .trim();\n"],"mappings":";;;;;;AAEO,IAAMA,2BAA2B,GAAG,SAA9BA,
|
|
1
|
+
{"version":3,"file":"transformers.js","names":["editorStateToFirstParagraph","editorState","firstUnstyledBlock","getCurrentContent","getBlocksAsArray","find","block","getType","getText","exports","editorStateToMetaDescription","slice","replace","trim"],"sources":["../../../../src/Editor/utils/transformers.ts"],"sourcesContent":["import { EditorState } from 'draft-js';\n\nexport const editorStateToFirstParagraph = (\n editorState: EditorState\n): string => {\n const firstUnstyledBlock = editorState\n .getCurrentContent()\n .getBlocksAsArray()\n .find((block) => block.getType() === 'unstyled');\n\n return firstUnstyledBlock ? firstUnstyledBlock.getText() : '';\n};\n\nexport const editorStateToMetaDescription = (\n editorState: EditorState\n): string =>\n editorStateToFirstParagraph(editorState)\n .slice(0, 200)\n .replace(/^(.*[.?!])(.*)/, '$1')\n .trim();\n"],"mappings":";;;;;;AAEO,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA2BA,CACtCC,WAAwB,EACb;EACX,IAAMC,kBAAkB,GAAGD,WAAW,CACnCE,iBAAiB,CAAC,CAAC,CACnBC,gBAAgB,CAAC,CAAC,CAClBC,IAAI,CAAC,UAACC,KAAK;IAAA,OAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,KAAK,UAAU;EAAA,EAAC;EAElD,OAAOL,kBAAkB,GAAGA,kBAAkB,CAACM,OAAO,CAAC,CAAC,GAAG,EAAE;AAC/D,CAAC;AAACC,OAAA,CAAAT,2BAAA,GAAAA,2BAAA;AAEK,IAAMU,4BAA4B,GAAG,SAA/BA,4BAA4BA,CACvCT,WAAwB;EAAA,OAExBD,2BAA2B,CAACC,WAAW,CAAC,CACrCU,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CACbC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAC/BC,IAAI,CAAC,CAAC;AAAA;AAACJ,OAAA,CAAAC,4BAAA,GAAAA,4BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsetLink.js","names":["unsetLink","editorState","containsLink","RichUtils","currentBlockContainsLink","selectionState","getSelection","toggleLink"],"sources":["../../../../src/Editor/utils/unsetLink.ts"],"sourcesContent":["import { EditorState, RichUtils } from 'draft-js';\n\nconst unsetLink = (editorState: EditorState): EditorState => {\n const containsLink = RichUtils.currentBlockContainsLink(editorState);\n if (!containsLink) return editorState;\n\n const selectionState = editorState.getSelection();\n return RichUtils.toggleLink(editorState, selectionState, null);\n};\n\nexport default unsetLink;\n"],"mappings":";;;;;;AAAA;AAEA,
|
|
1
|
+
{"version":3,"file":"unsetLink.js","names":["_draftJs","require","unsetLink","editorState","containsLink","RichUtils","currentBlockContainsLink","selectionState","getSelection","toggleLink","_default","exports"],"sources":["../../../../src/Editor/utils/unsetLink.ts"],"sourcesContent":["import { EditorState, RichUtils } from 'draft-js';\n\nconst unsetLink = (editorState: EditorState): EditorState => {\n const containsLink = RichUtils.currentBlockContainsLink(editorState);\n if (!containsLink) return editorState;\n\n const selectionState = editorState.getSelection();\n return RichUtils.toggleLink(editorState, selectionState, null);\n};\n\nexport default unsetLink;\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAIC,WAAwB,EAAkB;EAC3D,IAAMC,YAAY,GAAGC,kBAAS,CAACC,wBAAwB,CAACH,WAAW,CAAC;EACpE,IAAI,CAACC,YAAY,EAAE,OAAOD,WAAW;EAErC,IAAMI,cAAc,GAAGJ,WAAW,CAACK,YAAY,CAAC,CAAC;EACjD,OAAOH,kBAAS,CAACI,UAAU,CAACN,WAAW,EAAEI,cAAc,EAAE,IAAI,CAAC;AAChE,CAAC;AAAC,IAAAG,QAAA,GAEaR,SAAS;AAAAS,OAAA,cAAAD,QAAA"}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
9
|
var _core = require("@os-design/core");
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _templateObject;
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["StyledEditorSkeleton","styled","InputSkeleton","p","theme","editorMinHeight","EditorSkeleton","forwardRef","props","ref","displayName"],"sources":["../../../src/EditorSkeleton/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport
|
|
1
|
+
{"version":3,"file":"index.js","names":["_styled","_interopRequireDefault","require","_core","_react","_interopRequireWildcard","_templateObject","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","_taggedTemplateLiteral","strings","raw","slice","freeze","defineProperties","value","StyledEditorSkeleton","styled","InputSkeleton","p","theme","editorMinHeight","EditorSkeleton","forwardRef","props","ref","createElement","displayName","_default","exports"],"sources":["../../../src/EditorSkeleton/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\n\nimport { InputSkeleton, InputSkeletonProps } from '@os-design/core';\nimport React, { forwardRef } from 'react';\n\nexport type EditorSkeletonProps = InputSkeletonProps;\n\nconst StyledEditorSkeleton = styled(InputSkeleton)`\n height: ${(p) => p.theme.editorMinHeight}em;\n`;\n\n/**\n * Provides an editor placeholder while a user waits for the content to load.\n */\nconst EditorSkeleton = forwardRef<HTMLDivElement, EditorSkeletonProps>(\n (props, ref) => <StyledEditorSkeleton {...props} ref={ref} />\n);\n\nEditorSkeleton.displayName = 'EditorSkeleton';\n\nexport default EditorSkeleton;\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAA0C,IAAAI,eAAA;AAAA,SAAAC,yBAAAC,WAAA,eA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AAC,IAAA,eAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,GAAAF,SAAA,CAAAD,CAAA,YAAAV,GAAA,IAAAa,MAAA,QAAAhB,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAU,MAAA,EAAAb,GAAA,KAAAS,MAAA,CAAAT,GAAA,IAAAa,MAAA,CAAAb,GAAA,gBAAAS,MAAA,YAAAH,QAAA,CAAAQ,KAAA,OAAAH,SAAA;AAAA,SAAAI,uBAAAC,OAAA,EAAAC,GAAA,SAAAA,GAAA,IAAAA,GAAA,GAAAD,OAAA,CAAAE,KAAA,cAAArB,MAAA,CAAAsB,MAAA,CAAAtB,MAAA,CAAAuB,gBAAA,CAAAJ,OAAA,IAAAC,GAAA,IAAAI,KAAA,EAAAxB,MAAA,CAAAsB,MAAA,CAAAF,GAAA;AAI1C,IAAMK,oBAAoB,GAAG,IAAAC,kBAAM,EAACC,mBAAa,CAAC,CAAAzC,eAAA,KAAAA,eAAA,GAAAgC,sBAAA,8BACtC,UAACU,CAAC;EAAA,OAAKA,CAAC,CAACC,KAAK,CAACC,eAAe;AAAA,EACzC;;AAED;AACA;AACA;AACA,IAAMC,cAAc,gBAAG,IAAAC,iBAAU,EAC/B,UAACC,KAAK,EAAEC,GAAG;EAAA,oBAAKlD,MAAA,YAAAmD,aAAA,CAACV,oBAAoB,EAAAhB,QAAA,KAAKwB,KAAK;IAAEC,GAAG,EAAEA;EAAI,EAAE,CAAC;AAAA,CAC/D,CAAC;AAEDH,cAAc,CAACK,WAAW,GAAG,gBAAgB;AAAC,IAAAC,QAAA,GAE/BN,cAAc;AAAAO,OAAA,cAAAD,QAAA"}
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export { default as Editor } from './Editor';\nexport { default as addNewBlockAt } from './Editor/utils/addNewBlockAt';\nexport { default as changeBlock } from './Editor/utils/changeBlock';\nexport { default as createContentEditorState } from './Editor/utils/createContentEditorState';\nexport { default as createDecorator } from './Editor/utils/createDecorator';\nexport { default as createEmptyEditorState } from './Editor/utils/createEmptyEditorState';\nexport { default as defaultStyleToolbarItems } from './Editor/utils/defaultStyleToolbarItems';\nexport { default as getCurrentBlock } from './Editor/utils/getCurrentBlock';\nexport { default as imageBlock } from './Editor/blocks/imageBlock';\nexport { default as videoBlock } from './Editor/blocks/videoBlock';\nexport { default as EditorSkeleton } from './EditorSkeleton';\n\nexport * from './Editor';\nexport * from './Editor/utils/transformers';\nexport * from './Editor/blocks/types';\nexport * from './EditorSkeleton';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Editor","_interopRequireWildcard","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_addNewBlockAt","_interopRequireDefault","_changeBlock","_createContentEditorState","_createDecorator","_createEmptyEditorState","_defaultStyleToolbarItems","_getCurrentBlock","_imageBlock","_videoBlock","_EditorSkeleton","_transformers","_types","obj","__esModule","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","_typeof","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as Editor } from './Editor';\nexport { default as addNewBlockAt } from './Editor/utils/addNewBlockAt';\nexport { default as changeBlock } from './Editor/utils/changeBlock';\nexport { default as createContentEditorState } from './Editor/utils/createContentEditorState';\nexport { default as createDecorator } from './Editor/utils/createDecorator';\nexport { default as createEmptyEditorState } from './Editor/utils/createEmptyEditorState';\nexport { default as defaultStyleToolbarItems } from './Editor/utils/defaultStyleToolbarItems';\nexport { default as getCurrentBlock } from './Editor/utils/getCurrentBlock';\nexport { default as imageBlock } from './Editor/blocks/imageBlock';\nexport { default as videoBlock } from './Editor/blocks/videoBlock';\nexport { default as EditorSkeleton } from './EditorSkeleton';\n\nexport * from './Editor';\nexport * from './Editor/utils/transformers';\nexport * from './Editor/blocks/types';\nexport * from './EditorSkeleton';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAYAC,MAAA,CAAAC,IAAA,CAAAJ,OAAA,EAAAK,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAN,OAAA,CAAAM,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAd,OAAA,CAAAM,GAAA;IAAA;EAAA;AAAA;AAXA,IAAAS,cAAA,GAAAC,sBAAA,CAAAd,OAAA;AACA,IAAAe,YAAA,GAAAD,sBAAA,CAAAd,OAAA;AACA,IAAAgB,yBAAA,GAAAF,sBAAA,CAAAd,OAAA;AACA,IAAAiB,gBAAA,GAAAH,sBAAA,CAAAd,OAAA;AACA,IAAAkB,uBAAA,GAAAJ,sBAAA,CAAAd,OAAA;AACA,IAAAmB,yBAAA,GAAAL,sBAAA,CAAAd,OAAA;AACA,IAAAoB,gBAAA,GAAAN,sBAAA,CAAAd,OAAA;AACA,IAAAqB,WAAA,GAAAP,sBAAA,CAAAd,OAAA;AACA,IAAAsB,WAAA,GAAAR,sBAAA,CAAAd,OAAA;AACA,IAAAuB,eAAA,GAAAx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AAA,MAAAQ,KAAA,IAAAA,KAAA,CAAAM,GAAA,CAAAd,GAAA,EAAAU,MAAA,YAAAA,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockToolbar.js","names":["React","useCallback","Toolbar","ToolbarButton","getCurrentBlock","BlockToolbar","items","value","onChange","setReadOnly","rest","clickHandler","onClick","currentBlock","getType","getLength","map","item","type","icon"],"sources":["../../../src/Editor/BlockToolbar.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"BlockToolbar.js","names":["React","useCallback","Toolbar","ToolbarButton","getCurrentBlock","BlockToolbar","items","value","onChange","setReadOnly","rest","clickHandler","onClick","currentBlock","getType","getLength","createElement","map","item","key","type","icon"],"sources":["../../../src/Editor/BlockToolbar.tsx"],"sourcesContent":["import { PopoverProps } from '@os-design/core';\nimport { EditorState } from 'draft-js';\nimport React, { useCallback } from 'react';\n\nimport Toolbar from './Toolbar';\nimport ToolbarButton from './ToolbarButton';\nimport { BlockToolbarItem } from './blocks/types';\nimport getCurrentBlock from './utils/getCurrentBlock';\n\ninterface BlockToolbarProps extends Omit<PopoverProps, 'onChange'> {\n items: BlockToolbarItem[];\n value: EditorState;\n onChange: (value: EditorState) => void;\n setReadOnly: (readOnly: boolean) => void;\n}\n\nconst BlockToolbar: React.FC<BlockToolbarProps> = ({\n items,\n value,\n onChange,\n setReadOnly,\n ...rest\n}) => {\n const clickHandler = useCallback<(item: BlockToolbarItem) => void>(\n ({ onClick }) => {\n const currentBlock = getCurrentBlock(value);\n if (currentBlock.getType() !== 'unstyled' || currentBlock.getLength() > 0)\n return;\n onClick({\n value,\n onChange,\n setReadOnly,\n });\n },\n [value, onChange, setReadOnly]\n );\n\n return (\n <Toolbar {...rest}>\n {items.map((item) => (\n <ToolbarButton key={item.type} onClick={() => clickHandler(item)}>\n {item.icon}\n </ToolbarButton>\n ))}\n </Toolbar>\n );\n};\n\nexport default BlockToolbar;\n"],"mappings":"AAEA,OAAOA,KAAK,IAAIC,WAAW,QAAQ,OAAO;AAE1C,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,aAAa,MAAM,iBAAiB;AAE3C,OAAOC,eAAe,MAAM,yBAAyB;AASrD,MAAMC,YAAyC,GAAGA,CAAC;EACjDC,KAAK;EACLC,KAAK;EACLC,QAAQ;EACRC,WAAW;EACX,GAAGC;AACL,CAAC,KAAK;EACJ,MAAMC,YAAY,GAAGV,WAAW,CAC9B,CAAC;IAAEW;EAAQ,CAAC,KAAK;IACf,MAAMC,YAAY,GAAGT,eAAe,CAACG,KAAK,CAAC;IAC3C,IAAIM,YAAY,CAACC,OAAO,CAAC,CAAC,KAAK,UAAU,IAAID,YAAY,CAACE,SAAS,CAAC,CAAC,GAAG,CAAC,EACvE;IACFH,OAAO,CAAC;MACNL,KAAK;MACLC,QAAQ;MACRC;IACF,CAAC,CAAC;EACJ,CAAC,EACD,CAACF,KAAK,EAAEC,QAAQ,EAAEC,WAAW,CAC/B,CAAC;EAED,oBACET,KAAA,CAAAgB,aAAA,CAACd,OAAO,EAAKQ,IAAI,EACdJ,KAAK,CAACW,GAAG,CAAEC,IAAI,iBACdlB,KAAA,CAAAgB,aAAA,CAACb,aAAa;IAACgB,GAAG,EAAED,IAAI,CAACE,IAAK;IAACR,OAAO,EAAEA,CAAA,KAAMD,YAAY,CAACO,IAAI;EAAE,GAC9DA,IAAI,CAACG,IACO,CAChB,CACM,CAAC;AAEd,CAAC;AAED,eAAehB,YAAY"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { useCallback, useMemo } from 'react';
|
|
2
1
|
import { RichUtils } from 'draft-js';
|
|
3
|
-
import
|
|
4
|
-
import unsetLink from './utils/unsetLink';
|
|
2
|
+
import React, { useCallback, useMemo } from 'react';
|
|
5
3
|
import Toolbar from './Toolbar';
|
|
6
4
|
import ToolbarButton from './ToolbarButton';
|
|
5
|
+
import setLink from './utils/setLink';
|
|
6
|
+
import unsetLink from './utils/unsetLink';
|
|
7
7
|
const StyleToolbar = ({
|
|
8
8
|
items,
|
|
9
9
|
value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyleToolbar.js","names":["React","useCallback","useMemo","
|
|
1
|
+
{"version":3,"file":"StyleToolbar.js","names":["RichUtils","React","useCallback","useMemo","Toolbar","ToolbarButton","setLink","unsetLink","StyleToolbar","items","value","onChange","rest","currentBlockType","getCurrentBlockType","currentBlockContainsLink","toggleLink","url","prompt","clickHandler","item","type","toggleInlineStyle","name","toggleBlockType","length","createElement","map","isLink","active","getCurrentInlineStyle","has","onClick","key","icon","displayName"],"sources":["../../../src/Editor/StyleToolbar.tsx"],"sourcesContent":["import { PopoverProps } from '@os-design/core';\nimport { EditorState, RichUtils } from 'draft-js';\n\nimport React, { useCallback, useMemo } from 'react';\nimport Toolbar from './Toolbar';\nimport ToolbarButton from './ToolbarButton';\n\nimport { StyleToolbarItem } from './utils/defaultStyleToolbarItems';\nimport setLink from './utils/setLink';\nimport unsetLink from './utils/unsetLink';\n\ninterface StyleToolbarProps extends Omit<PopoverProps, 'onChange'> {\n items: StyleToolbarItem[];\n value: EditorState;\n onChange: (value: EditorState) => void;\n}\n\nconst StyleToolbar: React.FC<StyleToolbarProps> = ({\n items,\n value,\n onChange = () => {},\n ...rest\n}) => {\n const currentBlockType = useMemo(\n () => RichUtils.getCurrentBlockType(value),\n [value]\n );\n const currentBlockContainsLink = useMemo(\n () => RichUtils.currentBlockContainsLink(value),\n [value]\n );\n\n const toggleLink = useCallback(() => {\n if (currentBlockContainsLink) {\n onChange(unsetLink(value));\n return;\n }\n // eslint-disable-next-line no-alert\n const url = prompt('Paste or type a link');\n if (!url) return;\n onChange(setLink(value, url));\n }, [currentBlockContainsLink, value, onChange]);\n\n const clickHandler = useCallback<(item: StyleToolbarItem) => void>(\n (item) => {\n if (item.type === 'inline') {\n onChange(RichUtils.toggleInlineStyle(value, item.name));\n } else if (item.type === 'block') {\n onChange(RichUtils.toggleBlockType(value, item.name));\n }\n },\n [value, onChange]\n );\n\n if (items.length === 0) return null;\n\n return (\n <Toolbar {...rest}>\n {items.map((item) => {\n const isLink = item.name === 'LINK' && item.type === 'inline';\n\n const active = isLink\n ? currentBlockContainsLink\n : value.getCurrentInlineStyle().has(item.name) ||\n currentBlockType === item.name;\n const onClick = isLink ? toggleLink : () => clickHandler(item);\n\n return (\n <ToolbarButton key={item.name} active={active} onClick={onClick}>\n {item.icon}\n </ToolbarButton>\n );\n })}\n </Toolbar>\n );\n};\n\nStyleToolbar.displayName = 'StyleToolbar';\n\nexport default StyleToolbar;\n"],"mappings":"AACA,SAAsBA,SAAS,QAAQ,UAAU;AAEjD,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,aAAa,MAAM,iBAAiB;AAG3C,OAAOC,OAAO,MAAM,iBAAiB;AACrC,OAAOC,SAAS,MAAM,mBAAmB;AAQzC,MAAMC,YAAyC,GAAGA,CAAC;EACjDC,KAAK;EACLC,KAAK;EACLC,QAAQ,GAAGA,CAAA,KAAM,CAAC,CAAC;EACnB,GAAGC;AACL,CAAC,KAAK;EACJ,MAAMC,gBAAgB,GAAGV,OAAO,CAC9B,MAAMH,SAAS,CAACc,mBAAmB,CAACJ,KAAK,CAAC,EAC1C,CAACA,KAAK,CACR,CAAC;EACD,MAAMK,wBAAwB,GAAGZ,OAAO,CACtC,MAAMH,SAAS,CAACe,wBAAwB,CAACL,KAAK,CAAC,EAC/C,CAACA,KAAK,CACR,CAAC;EAED,MAAMM,UAAU,GAAGd,WAAW,CAAC,MAAM;IACnC,IAAIa,wBAAwB,EAAE;MAC5BJ,QAAQ,CAACJ,SAAS,CAACG,KAAK,CAAC,CAAC;MAC1B;IACF;IACA;IACA,MAAMO,GAAG,GAAGC,MAAM,CAAC,sBAAsB,CAAC;IAC1C,IAAI,CAACD,GAAG,EAAE;IACVN,QAAQ,CAACL,OAAO,CAACI,KAAK,EAAEO,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CAAC;AAED1B,YAAY,CAAC2B,WAAW,GAAG,cAAc;AAEzC,eAAe3B,YAAY"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import { css } from '@emotion/react';
|
|
4
|
-
import { clr } from '@os-design/theming';
|
|
5
3
|
import styled from '@emotion/styled';
|
|
6
4
|
import { resetButtonStyles, transitionStyles } from '@os-design/styles';
|
|
5
|
+
import { clr } from '@os-design/theming';
|
|
7
6
|
import { omitEmotionProps } from '@os-design/utils';
|
|
7
|
+
import React from 'react';
|
|
8
8
|
const activeStyles = p => p.active && css`
|
|
9
9
|
background-color: ${clr(p.theme.editorToolbarButtonColorBgActive)};
|
|
10
10
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarButton.js","names":["
|
|
1
|
+
{"version":3,"file":"ToolbarButton.js","names":["css","styled","resetButtonStyles","transitionStyles","clr","omitEmotionProps","React","activeStyles","p","active","theme","editorToolbarButtonColorBgActive","StyledToolbarButton","editorToolbarButtonSize","editorToolbarButtonColorBg","editorToolbarButtonColorText","editorToolbarButtonColorBgHover","ToolbarButton","onMouseDown","rest","createElement","_extends","e","preventDefault","displayName"],"sources":["../../../src/Editor/ToolbarButton.tsx"],"sourcesContent":["import { css } from '@emotion/react';\n\nimport styled from '@emotion/styled';\nimport { resetButtonStyles, transitionStyles } from '@os-design/styles';\nimport { clr } from '@os-design/theming';\n\nimport { omitEmotionProps } from '@os-design/utils';\nimport React from 'react';\n\ntype JsxButtonProps = JSX.IntrinsicElements['button'];\ninterface ToolbarButtonProps extends JsxButtonProps {\n active?: boolean;\n}\n\nconst activeStyles = (p) =>\n p.active &&\n css`\n background-color: ${clr(p.theme.editorToolbarButtonColorBgActive)};\n `;\n\ntype StyledToolbarButtonProps = Pick<ToolbarButtonProps, 'active'>;\nconst StyledToolbarButton = styled(\n 'button',\n omitEmotionProps('active')\n)<StyledToolbarButtonProps>`\n ${resetButtonStyles};\n cursor: pointer;\n font-size: 1.3em;\n\n display: flex;\n justify-content: center;\n align-items: center;\n\n width: ${(p) => p.theme.editorToolbarButtonSize}em;\n height: ${(p) => p.theme.editorToolbarButtonSize}em;\n background-color: ${(p) => clr(p.theme.editorToolbarButtonColorBg)};\n color: ${(p) => clr(p.theme.editorToolbarButtonColorText)};\n\n @media (hover: hover) {\n &:hover,\n &:focus {\n background-color: ${(p) => clr(p.theme.editorToolbarButtonColorBgHover)};\n }\n }\n\n ${activeStyles};\n ${transitionStyles('background-color')};\n`;\n\nconst ToolbarButton: React.FC<ToolbarButtonProps> = ({\n onMouseDown = () => {},\n ...rest\n}) => (\n <StyledToolbarButton\n onMouseDown={(e) => {\n onMouseDown(e);\n e.preventDefault();\n }}\n {...rest}\n />\n);\n\nToolbarButton.displayName = 'ToolbarButton';\n\nexport default ToolbarButton;\n"],"mappings":";AAAA,SAASA,GAAG,QAAQ,gBAAgB;AAEpC,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,mBAAmB;AACvE,SAASC,GAAG,QAAQ,oBAAoB;AAExC,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,OAAOC,KAAK,MAAM,OAAO;AAOzB,MAAMC,YAAY,GAAIC,CAAC,IACrBA,CAAC,CAACC,MAAM,IACRT,GAAI;AACN,wBAAwBI,GAAG,CAACI,CAAC,CAACE,KAAK,CAACC,gCAAgC,CAAE;AACtE,GAAG;AAGH,MAAMC,mBAAmB,GAAGX,MAAM,CAChC,QAAQ,EACRI,gBAAgB,CAAC,QAAQ,CAC3B,CAA4B;AAC5B,IAAIH,iBAAkB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYM,CAAC,IAAKA,CAAC,CAACE,KAAK,CAACG,uBAAwB;AAClD,YAAaL,CAAC,IAAKA,CAAC,CAACE,KAAK,CAACG,uBAAwB;AACnD,sBAAuBL,CAAC,IAAKJ,GAAG,CAACI,CAAC,CAACE,KAAK,CAACI,0BAA0B,CAAE;AACrE,WAAYN,CAAC,IAAKJ,GAAG,CAACI,CAAC,CAACE,KAAK,CAACK,4BAA4B,CAAE;AAC5D;AACA;AACA;AACA;AACA,0BAA2BP,CAAC,IAAKJ,GAAG,CAACI,CAAC,CAACE,KAAK,CAACM,+BAA+B,CAAE;AAC9E;AACA;AACA;AACA,IAAIT,YAAa;AACjB,IAAIJ,gBAAgB,CAAC,kBAAkB,CAAE;AACzC,CAAC;AAED,MAAMc,aAA2C,GAAGA,CAAC;EACnDC,WAAW,GAAGA,CAAA,KAAM,CAAC,CAAC;EACtB,GAAGC;AACL,CAAC,kBACCb,KAAA,CAAAc,aAAA,CAACR,mBAAmB,EAAAS,QAAA;EAClBH,WAAW,EAAGI,CAAC,IAAK;IAClBJ,WAAW,CAACI,CAAC,CAAC;IACdA,CAAC,CAACC,cAAc,CAAC,CAAC;EACpB;AAAE,GACEJ,IAAI,CACT,CACF;AAEDF,aAAa,CAACO,WAAW,GAAG,eAAe;AAE3C,eAAeP,aAAa"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
2
|
import styled from '@emotion/styled';
|
|
3
|
-
import { EditorBlock } from 'draft-js';
|
|
4
|
-
import { Loading, Picture } from '@os-design/icons';
|
|
5
3
|
import { message } from '@os-design/core';
|
|
4
|
+
import { Loading, Picture } from '@os-design/icons';
|
|
6
5
|
import { omitEmotionProps, useEvent } from '@os-design/utils';
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
6
|
+
import { EditorBlock } from 'draft-js';
|
|
7
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
9
8
|
import changeBlock from '../utils/changeBlock';
|
|
10
9
|
import getCurrentBlock from '../utils/getCurrentBlock';
|
|
11
10
|
import Figure from './Figure';
|
|
11
|
+
import FigureCaption from './FigureCaption';
|
|
12
12
|
const widthStyles = p => p.width && css`
|
|
13
13
|
width: ${p.width}px;
|
|
14
14
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageBlock.js","names":["
|
|
1
|
+
{"version":3,"file":"imageBlock.js","names":["css","styled","message","Loading","Picture","omitEmotionProps","useEvent","EditorBlock","React","useCallback","useRef","useState","changeBlock","getCurrentBlock","Figure","FigureCaption","widthStyles","p","width","ImageFigure","Mask","div","theme","editorBlockImageMaskOpacity","LoadingIcon","editorBlockImageLoadingFontSize","Image","img","editorBlockImageMaxHeight","ImageBlock","props","block","data","getData","src","get","loading","imageRef","setWidth","updateWidth","current","window","undefined","createElement","startsWith","alt","getText","onLoad","ref","IMAGE_BLOCK","imageBlock","onImageUpload","type","component","icon","onClick","value","onChange","setReadOnly","Error","input","document","accept","onchange","e","target","files","file","URL","createObjectURL","currentBlock","nextEditorState","err","error","click"],"sources":["../../../../src/Editor/blocks/imageBlock.tsx"],"sourcesContent":["import { css } from '@emotion/react';\n\nimport styled from '@emotion/styled';\nimport { message } from '@os-design/core';\n\nimport { Loading, Picture } from '@os-design/icons';\n\nimport { omitEmotionProps, useEvent } from '@os-design/utils';\nimport { EditorBlock } from 'draft-js';\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport changeBlock from '../utils/changeBlock';\nimport getCurrentBlock from '../utils/getCurrentBlock';\nimport Figure from './Figure';\nimport FigureCaption from './FigureCaption';\n\nimport { BlockProps, BlockToolbarItem } from './types';\n\nconst widthStyles = (p) =>\n p.width &&\n css`\n width: ${p.width}px;\n `;\n\ninterface ImageFigureProps {\n width: number;\n}\nconst ImageFigure = styled(Figure, omitEmotionProps('width'))<ImageFigureProps>`\n position: relative;\n display: inline-block;\n max-width: 100%;\n ${widthStyles};\n`;\n\nconst Mask = styled.div`\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n display: flex;\n justify-content: center;\n align-items: center;\n\n background-color: hsla(\n 0,\n 0%,\n 0%,\n ${(p) => p.theme.editorBlockImageMaskOpacity}\n );\n color: hsl(0, 0%, 100%);\n`;\n\nconst LoadingIcon = styled(Loading)`\n font-size: ${(p) => p.theme.editorBlockImageLoadingFontSize}em;\n`;\n\nconst Image = styled.img`\n max-width: 100%;\n max-height: ${(p) => p.theme.editorBlockImageMaxHeight}em;\n vertical-align: bottom;\n`;\n\nconst ImageBlock: React.FC<BlockProps> = (props) => {\n const { block } = props;\n const data = block.getData();\n const src = data.get('src') as string;\n const loading = data.get('loading') as boolean;\n\n // Update the width of the image\n const imageRef = useRef<HTMLImageElement>(null);\n const [width, setWidth] = useState(0);\n const updateWidth = useCallback(() => {\n if (!imageRef.current) return;\n setWidth(imageRef.current.width);\n }, []);\n useEvent(\n (typeof window !== 'undefined' ? window : undefined) as EventTarget,\n 'resize',\n updateWidth\n );\n\n if (!src) return null;\n\n return (\n <ImageFigure width={width}>\n {loading && (\n <Mask>\n <LoadingIcon />\n </Mask>\n )}\n <Image\n src={src.startsWith('blob:') ? src : `${src}-1024`}\n alt={block.getText()}\n onLoad={updateWidth}\n ref={imageRef}\n />\n {!loading && (\n <FigureCaption>\n <EditorBlock {...props} />\n </FigureCaption>\n )}\n </ImageFigure>\n );\n};\n\nexport const IMAGE_BLOCK = 'atomic:image';\n\nconst imageBlock = (\n onImageUpload: (file: File) => Promise<string>\n): BlockToolbarItem => ({\n type: IMAGE_BLOCK,\n component: ImageBlock,\n icon: <Picture />,\n onClick: ({ value, onChange, setReadOnly }) => {\n if (!onImageUpload) throw new Error('Specify the onImageUpload method');\n\n // Not working in mobile Safari.\n // The input must be actually appended to the DOM.\n const input = document.createElement('input');\n input.type = 'file';\n input.accept = 'image/jpeg,image/png,image/webp';\n input.onchange = async (e) => {\n const target = e.target as HTMLInputElement | null;\n if (!target) return;\n const { files } = target;\n if (!files) return;\n\n setReadOnly(true);\n const file = files[0];\n let src = URL.createObjectURL(file);\n\n // Add the local image\n const currentBlock = getCurrentBlock(value);\n let nextEditorState = changeBlock(value, currentBlock, IMAGE_BLOCK, {\n src,\n loading: true,\n });\n onChange(nextEditorState);\n\n // Replace the local image with the remote one\n try {\n src = await onImageUpload(file);\n nextEditorState = changeBlock(value, currentBlock, IMAGE_BLOCK, {\n src,\n });\n } catch (err) {\n if (err instanceof Error) {\n message.error(err.message);\n }\n nextEditorState = changeBlock(value, currentBlock, 'unstyled');\n }\n\n setReadOnly(false);\n onChange(nextEditorState);\n };\n input.click();\n },\n});\n\nexport default imageBlock;\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AAEpC,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,OAAO,QAAQ,iBAAiB;AAEzC,SAASC,OAAO,EAAEC,OAAO,QAAQ,kBAAkB;AAEnD,SAASC,gBAAgB,EAAEC,QAAQ,QAAQ,kBAAkB;AAC7D,SAASC,WAAW,QAAQ,UAAU;AACtC,OAAOC,KAAK,IAAIC,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAE5D,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,eAAe,MAAM,0BAA0B;AACtD,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,aAAa,MAAM,iBAAiB;AAI3C,MAAMC,WAAW,GAAIC,CAAC,IACpBA,CAAC,CAACC,KAAK,IACPlB,GAAI;AACN,aAAaiB,CAAC,CAACC,KAAM;AACrB,GAAG;AAKH,MAAMC,WAAW,GAAGlB,MAAM,CAACa,MAAM,EAAET,gBAAgB,CAAC,OAAO,CAAC,CAAoB;AAChF;AACA;AACA;AACA,IAAIW,WAAY;AAChB,CAAC;AAED,MAAMI,IAAI,GAAGnB,MAAM,CAACoB,GAAI;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAOJ,CAAC,IAAKA,CAA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,IAAI,CAAC;;MAEnC;MACA,MAAMG,YAAY,GAAGzD,eAAe,CAAC2C,KAAK,CAAC;MAC3C,IAAIe,eAAe,GAAG3D,WAAW,CAAC4C,KAAK,EAAEc,YAAY,EAAErB,WAAW,EAAE;QAClEf,GAAG;QACHE,OAAO,EAAE;MACX,CAAC,CAAC;MACFqB,QAAQ,CAACc,eAAe,CAAC;;MAEzB;MACA,IAAI;QACFrC,GAAG,GAAG,MAAMiB,aAAa,CAACgB,IAAI,CAAC;QAC/BI,eAAe,GAAG3D,WAAW,CAAC4C,KAAK,EAAEc,YAAY,EAAErB,WAAW,EAAE;UAC9Df;QACF,CAAC,CAAC;MACJ,CAAC,CAAC,OAAOsC,GAAG,EAAE;QACZ,IAAIA,GAAG,YAAYb,KAAK,EAAE;UACxBzD,OAAO,CAACuE,KAAK,CAACD,GAAG,CAACtE,OAAO,CAAC;QAC5B;QACAqE,eAAe,GAAG3D,WAAW,CAAC4C,KAAK,EAAEc,YAAY,EAAE,UAAU,CAAC;MAChE;MAEAZ,WAAW,CAAC,KAAK,CAAC;MAClBD,QAAQ,CAACc,eAAe,CAAC;IAC3B,CAAC;IACDX,KAAK,CAACc,KAAK,CAAC,CAAC;EACf;AACF,CAAC,CAAC;AAEF,eAAexB,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/Editor/blocks/types.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/Editor/blocks/types.ts"],"sourcesContent":["import { ContentBlock, EditorState } from 'draft-js';\nimport React from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface BlockProps extends Record<string, any> {\n block: ContentBlock;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface BlockToolbarItemOnClickProps extends Record<string, any> {\n value: EditorState;\n onChange: (value: EditorState) => void;\n setReadOnly: (readOnly: boolean) => void;\n}\n\nexport interface BlockToolbarItem {\n type: string;\n component: React.FC<BlockProps>;\n icon: React.ReactElement;\n onClick: (props: BlockToolbarItemOnClickProps) => void;\n}\n"],"mappings":""}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { EditorBlock } from 'draft-js';
|
|
3
1
|
import { Video } from '@os-design/core';
|
|
4
2
|
import { Video as VideoIcon } from '@os-design/icons';
|
|
5
|
-
import
|
|
3
|
+
import { EditorBlock } from 'draft-js';
|
|
4
|
+
import React from 'react';
|
|
6
5
|
import changeBlock from '../utils/changeBlock';
|
|
7
6
|
import getCurrentBlock from '../utils/getCurrentBlock';
|
|
8
7
|
import Figure from './Figure';
|
|
8
|
+
import FigureCaption from './FigureCaption';
|
|
9
9
|
const VideoBlock = props => {
|
|
10
10
|
const {
|
|
11
11
|
block
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoBlock.js","names":["
|
|
1
|
+
{"version":3,"file":"videoBlock.js","names":["Video","VideoIcon","EditorBlock","React","changeBlock","getCurrentBlock","Figure","FigureCaption","VideoBlock","props","block","data","getData","src","get","createElement","title","getText","videoTypes","re","getUrl","id","detectVideo","url","groups","match","VIDEO_BLOCK","videoBlock","type","component","icon","onClick","value","onChange","prompt","currentBlock","nextEditorState"],"sources":["../../../../src/Editor/blocks/videoBlock.tsx"],"sourcesContent":["import { Video } from '@os-design/core';\nimport { Video as VideoIcon } from '@os-design/icons';\nimport { EditorBlock } from 'draft-js';\nimport React from 'react';\n\nimport changeBlock from '../utils/changeBlock';\nimport getCurrentBlock from '../utils/getCurrentBlock';\nimport Figure from './Figure';\nimport FigureCaption from './FigureCaption';\nimport { BlockProps, BlockToolbarItem } from './types';\n\nconst VideoBlock: React.FC<BlockProps> = (props) => {\n const { block } = props;\n const data = block.getData();\n const src = data.get('src');\n\n if (!src) return null;\n\n return (\n <Figure>\n <Video src={src} title={block.getText()} />\n <FigureCaption>\n <EditorBlock {...props} />\n </FigureCaption>\n </Figure>\n );\n};\n\nconst videoTypes = [\n /**\n * YouTube. Supported formats:\n * https://www.youtube.com/watch?v=FJIhWbUt600&ab_channel=IlyaOrdin\n * https://www.youtube.com/embed/FJIhWbUt600\n * https://youtu.be/FJIhWbUt600\n */\n {\n re: /^https:\\/\\/(?:www\\.youtube\\.com\\/(?:watch\\?v=|embed\\/)|youtu\\.be\\/)([A-z0-9-_]*).*$/,\n getUrl: (id: string) => `https://www.youtube.com/embed/${id}`,\n },\n /**\n * RuTube. Supported formats:\n * https://rutube.ru/video/d00526135b2b96d272f6d89b486036c1/\n * https://rutube.ru/play/embed/d00526135b2b96d272f6d89b486036c1\n */\n {\n re: /^https:\\/\\/rutube\\.ru\\/(?:video|play\\/embed)\\/([a-z0-9]*)\\/?$/,\n getUrl: (id: string) => `https://rutube.ru/play/embed/${id}`,\n },\n];\n\nconst detectVideo = (url: string) => {\n // eslint-disable-next-line no-restricted-syntax\n for (const { re, getUrl } of videoTypes) {\n const groups = url.match(re);\n if (groups && groups[1]) return getUrl(groups[1]);\n }\n return null;\n};\n\nexport const VIDEO_BLOCK = 'atomic:video';\n\nconst videoBlock: BlockToolbarItem = {\n type: VIDEO_BLOCK,\n component: VideoBlock,\n icon: <VideoIcon />,\n onClick: ({ value, onChange }) => {\n // eslint-disable-next-line no-alert\n const url = prompt('Insert a link to YouTube or RuTube');\n if (!url) return;\n\n const src = detectVideo(url);\n if (!src) return;\n\n const currentBlock = getCurrentBlock(value);\n const nextEditorState = changeBlock(value, currentBlock, VIDEO_BLOCK, {\n src,\n });\n\n onChange(nextEditorState);\n },\n};\n\nexport default videoBlock;\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,iBAAiB;AACvC,SAASA,KAAK,IAAIC,SAAS,QAAQ,kBAAkB;AACrD,SAASC,WAAW,QAAQ,UAAU;AACtC,OAAOC,KAAK,MAAM,OAAO;AAEzB,OAAOC,WAAW,MAAM,sBAAsB;AAC9C,OAAOC,eAAe,MAAM,0BAA0B;AACtD,OAAOC,MAA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,GAAG;EACnCC,IAAI,EAAEF,WAAW;EACjBG,SAAS,EAAErB,UAAU;EACrBsB,IAAI,eAAE3B,KAAA,CAAAY,aAAA,CAACd,SAAS,MAAE,CAAC;EACnB8B,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAAS,CAAC,KAAK;IAChC;IACA,MAAMV,GAAG,GAAGW,MAAM,CAAC,oCAAoC,CAAC;IACxD,IAAI,CAACX,GAAG,EAAE;IAEV,MAAMV,GAAG,GAAGS,WAAW,CAACC,GAAG,CAAC;IAC5B,IAAI,CAACV,GAAG,EAAE;IAEV,MAAMsB,YAAY,GAAG9B,eAAe,CAAC2B,KAAK,CAAC;IAC3C,MAAMI,eAAe,GAAGhC,WAAW,CAAC4B,KAAK,EAAEG,YAAY,EAAET,WAAW,EAAE;MACpEb;IACF,CAAC,CAAC;IAEFoB,QAAQ,CAACG,eAAe,CAAC;EAC3B;AACF,CAAC;AAED,eAAeT,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkDecorator.js","names":["Link","React","linkDecorator","strategy","contentBlock","callback","contentState","findEntityRanges","character","entityKey","getEntity","getType","component","children","url","getData"],"sources":["../../../../src/Editor/decorators/linkDecorator.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"linkDecorator.js","names":["Link","React","linkDecorator","strategy","contentBlock","callback","contentState","findEntityRanges","character","entityKey","getEntity","getType","component","children","url","getData","createElement","href"],"sources":["../../../../src/Editor/decorators/linkDecorator.tsx"],"sourcesContent":["import { Link } from '@os-design/core';\n\nimport { DraftDecorator } from 'draft-js';\n\nimport React from 'react';\n\nconst linkDecorator: DraftDecorator = {\n strategy: (contentBlock, callback, contentState) =>\n contentBlock.findEntityRanges((character) => {\n const entityKey = character.getEntity();\n return (\n entityKey !== null &&\n contentState.getEntity(entityKey).getType() === 'LINK'\n );\n }, callback),\n\n component: ({ contentState, entityKey, children }) => {\n const { url } = contentState.getEntity(entityKey).getData();\n return <Link href={url}>{children}</Link>;\n },\n};\n\nexport default linkDecorator;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,iBAAiB;AAItC,OAAOC,KAAK,MAAM,OAAO;AAEzB,MAAMC,aAA6B,GAAG;EACpCC,QAAQ,EAAEA,CAACC,YAAY,EAAEC,QAAQ,EAAEC,YAAY,KAC7CF,YAAY,CAACG,gBAAgB,CAAEC,SAAS,IAAK;IAC3C,MAAMC,SAAS,GAAGD,SAAS,CAACE,SAAS,CAAC,CAAC;IACvC,OACED,SAAS,KAAK,IAAI,IAClBH,YAAY,CAACI,SAAS,CAACD,SAAS,CAAC,CAACE,OAAO,CAAC,CAAC,KAAK,MAAM;EAE1D,CAAC,EAAEN,QAAQ,CAAC;EAEdO,SAAS,EAAEA,CAAC;IAAEN,YAAY;IAAEG,SAAS;IAAEI;EAAS,CAAC,KAAK;IACpD,MAAM;MAAEC;IAAI,CAAC,GAAGR,YAAY,CAACI,SAAS,CAACD,SAAS,CAAC,CAACM,OAAO,CAAC,CAAC;IAC3D,oBAAOd,KAAA,CAAAe,aAAA,CAAChB,IAAI;MAACiB,IAAI,EAAEH;IAAI,GAAED,QAAe,CAAC;EAC3C;AACF,CAAC;AAED,eAAeX,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBlockToolbarProps.js","names":["useEffect","useState","getSelectedBlockElement","useBlockToolbarProps","value","show","trigger","setTrigger","top","left","width","height","visible","setVisible","selectedBlockElement","selectionState","getSelection","currentBlockKey","getStartKey","contentState","getCurrentContent","currentBlock","getBlockForKey","lineNumber","getBlockMap","keySeq","findIndex","k","getType","getLength","getBoundingClientRect"],"sources":["../../../../src/Editor/hooks/useBlockToolbarProps.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useBlockToolbarProps.js","names":["useEffect","useState","getSelectedBlockElement","useBlockToolbarProps","value","show","trigger","setTrigger","top","left","width","height","visible","setVisible","selectedBlockElement","selectionState","getSelection","currentBlockKey","getStartKey","contentState","getCurrentContent","currentBlock","getBlockForKey","lineNumber","getBlockMap","keySeq","findIndex","k","getType","getLength","getBoundingClientRect"],"sources":["../../../../src/Editor/hooks/useBlockToolbarProps.ts"],"sourcesContent":["import { EditorState } from 'draft-js';\nimport { useEffect, useState } from 'react';\nimport getSelectedBlockElement from '../utils/getSelectedBlockElement';\n\ninterface Rect {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\ninterface UseBlockToolbarPropsRes {\n trigger: Rect;\n visible: boolean;\n}\n\n/**\n * Updates the visibility of the block toolbar.\n */\nconst useBlockToolbarProps = (\n value: EditorState,\n show: boolean\n): UseBlockToolbarPropsRes => {\n const [trigger, setTrigger] = useState({\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n });\n const [visible, setVisible] = useState(false);\n\n useEffect(() => {\n if (!show || !value) return;\n\n const selectedBlockElement = getSelectedBlockElement();\n if (!selectedBlockElement) {\n setVisible(false);\n return;\n }\n\n const selectionState = value.getSelection();\n const currentBlockKey = selectionState.getStartKey();\n const contentState = value.getCurrentContent();\n const currentBlock = contentState.getBlockForKey(currentBlockKey);\n const lineNumber = contentState\n .getBlockMap()\n .keySeq()\n .findIndex((k) => k === currentBlockKey);\n\n if (\n currentBlock.getType() !== 'unstyled' ||\n currentBlock.getLength() > 0 ||\n lineNumber === 0\n ) {\n setVisible(false);\n return;\n }\n\n const { top, left, height } = selectedBlockElement.getBoundingClientRect();\n setTrigger({\n top,\n left,\n width: 0,\n height,\n });\n setVisible(true);\n }, [show, value]);\n\n return { trigger, visible };\n};\n\nexport default useBlockToolbarProps;\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,OAAOC,uBAAuB,MAAM,kCAAkC;AActE;AACA;AACA;AACA,MAAMC,oBAAoB,GAAGA,CAC3BC,KAAkB,EAClBC,IAAa,KACe;EAC5B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGN,QAAQ,CAAC;IACrCO,GAAG,EAAE,CAAC;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,CAAC;AAC7B,CAAC;AAED,eAAeT,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePastedTextHandler.js","names":["
|
|
1
|
+
{"version":3,"file":"usePastedTextHandler.js","names":["EditorState","Modifier","RichUtils","useCallback","usePastedTextHandler","onChange","handler","text","html","editorState","currentBlockType","getCurrentBlockType","startsWith","contentState","getCurrentContent","nextContentState","insertText","getSelection","nextEditorState","push"],"sources":["../../../../src/Editor/hooks/usePastedTextHandler.ts"],"sourcesContent":["import {\n EditorProps as DraftEditorProps,\n DraftHandleValue,\n EditorState,\n Modifier,\n RichUtils,\n} from 'draft-js';\nimport { useCallback } from 'react';\n\ntype UsePastedTextHandlerRes = Exclude<\n DraftEditorProps['handlePastedText'],\n undefined\n>;\n\n/**\n * Pastes only text if the current block is atomic.\n */\nconst usePastedTextHandler = (\n onChange: (value: EditorState) => void,\n handler: UsePastedTextHandlerRes\n): UsePastedTextHandlerRes =>\n useCallback<UsePastedTextHandlerRes>(\n (text, html, editorState): DraftHandleValue => {\n const currentBlockType = RichUtils.getCurrentBlockType(editorState);\n\n if (currentBlockType.startsWith('atomic')) {\n const contentState = editorState.getCurrentContent();\n const nextContentState = Modifier.insertText(\n contentState,\n editorState.getSelection(),\n text\n );\n const nextEditorState = EditorState.push(\n editorState,\n nextContentState,\n 'insert-characters'\n );\n onChange(nextEditorState);\n return 'handled';\n }\n\n return handler(text, html, editorState);\n },\n [onChange, handler]\n );\n\nexport default usePastedTextHandler;\n"],"mappings":"AAAA,SAGEA,WAAW,EACXC,QAAQ,EACRC,SAAS,QACJ,UAAU;AACjB,SAASC,WAAW,QAAQ,OAAO;AAOnC;AACA;AACA;AACA,MAAMC,oBAAoB,GAAGA,CAC3BC,QAAsC,EACtCC,OAAgC,KAEhCH,WAAW,CACT,CAACI,IAAI,EAAEC,IAAI,EAAEC,WAAW,KAAuB;EAC7C,MAAMC,gBAAgB,GAAGR,SAAS,CAACS,mBAAmB,CAACF,WAAW,CAAC;EAEnE,IAAIC,gBAAgB,CAACE,UAAU,CAAC,QAAQ,CAAC,EAAE;IACzC,MAAMC,YAAY,GAAGJ,WAAW,CAACK,iBAAiB,CAAC,CAAC;IACpD,MAAMC,gBAAgB,GAAGd,QAAQ,CAACe,UAAU,CAC1CH,YAAY,EACZJ,WAAW,CAACQ,YAAY,CAAC,CAAC,EAC1BV,IACF,CAAC;IACD,MAAMW,eAAe,GAAGlB,WAAW,CAACmB,IAAI,CACtCV,WAAW,EACXM,gBAAgB,EAChB,mBACF,CAAC;IACDV,QAAQ,CAACa,eAAe,CAAC;IACzB,OAAO,SAAS;EAClB;EAEA,OAAOZ,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,WAAW,CAAC;AACzC,CAAC,EACD,CAACJ,QAAQ,EAAEC,OAAO,CACpB,CAAC;AAEH,eAAeF,oBAAoB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import getCurrentBlock from '../utils/getCurrentBlock';
|
|
3
2
|
import addNewBlockAt from '../utils/addNewBlockAt';
|
|
3
|
+
import getCurrentBlock from '../utils/getCurrentBlock';
|
|
4
4
|
/**
|
|
5
5
|
* Adds a new unstyled block if the user presses the return key.
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReturnHandler.js","names":["useCallback","
|
|
1
|
+
{"version":3,"file":"useReturnHandler.js","names":["useCallback","addNewBlockAt","getCurrentBlock","useReturnHandler","onChange","handler","e","editorState","currentBlock","currentBlockType","getType","startsWith","nextEditorState","getKey"],"sources":["../../../../src/Editor/hooks/useReturnHandler.ts"],"sourcesContent":["import { EditorProps as DraftEditorProps, EditorState } from 'draft-js';\nimport { useCallback } from 'react';\nimport addNewBlockAt from '../utils/addNewBlockAt';\nimport getCurrentBlock from '../utils/getCurrentBlock';\n\ntype UseReturnHandlerRes = NonNullable<DraftEditorProps['handleReturn']>;\n\n/**\n * Adds a new unstyled block if the user presses the return key.\n */\nconst useReturnHandler = (\n onChange: (value: EditorState) => void,\n handler: UseReturnHandlerRes\n): UseReturnHandlerRes =>\n useCallback<UseReturnHandlerRes>(\n (e, editorState) => {\n const currentBlock = getCurrentBlock(editorState);\n const currentBlockType = currentBlock.getType();\n\n if (\n currentBlockType.startsWith('atomic') ||\n currentBlockType.startsWith('header')\n ) {\n const nextEditorState = addNewBlockAt(\n editorState,\n currentBlock.getKey()\n );\n onChange(nextEditorState);\n return 'handled';\n }\n\n return handler(e, editorState);\n },\n [onChange, handler]\n );\n\nexport default useReturnHandler;\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,OAAO;AACnC,OAAOC,aAAa,MAAM,wBAAwB;AAClD,OAAOC,eAAe,MAAM,0BAA0B;AAItD;AACA;AACA;AACA,MAAMC,gBAAgB,GAAGA,CACvBC,QAAsC,EACtCC,OAA4B,KAE5BL,WAAW,CACT,CAACM,CAAC,EAAEC,WAAW,KAAK;EAClB,MAAMC,YAAY,GAAGN,eAAe,CAACK,WAAW,CAAC;EACjD,MAAME,gBAAgB,GAAGD,YAAY,CAACE,OAAO,CAAC,CAAC;EAE/C,IACED,gBAAgB,CAACE,UAAU,CAAC,QAAQ,CAAC,IACrCF,gBAAgB,CAACE,UAAU,CAAC,QAAQ,CAAC,EACrC;IACA,MAAMC,eAAe,GAAGX,aAAa,CACnCM,WAAW,EACXC,YAAY,CAACK,MAAM,CAAC,CACtB,CAAC;IACDT,QAAQ,CAACQ,eAAe,CAAC;IACzB,OAAO,SAAS;EAClB;EAEA,OAAOP,OAAO,CAACC,CAAC,EAAEC,WAAW,CAAC;AAChC,CAAC,EACD,CAACH,QAAQ,EAAEC,OAAO,CACpB,CAAC;AAEH,eAAeF,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStyleToolbarProps.js","names":["
|
|
1
|
+
{"version":3,"file":"useStyleToolbarProps.js","names":["RichUtils","useEffect","useState","getSelectionRange","useStyleToolbarProps","value","trigger","setTrigger","top","left","width","height","visible","setVisible","selectionRange","getSelection","isCollapsed","getCurrentBlockType","startsWith","getBoundingClientRect"],"sources":["../../../../src/Editor/hooks/useStyleToolbarProps.ts"],"sourcesContent":["import { EditorState, RichUtils } from 'draft-js';\nimport { useEffect, useState } from 'react';\nimport getSelectionRange from '../utils/getSelectionRange';\n\ninterface Rect {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\ninterface UseStyleToolbarPropsRes {\n trigger: Rect;\n visible: boolean;\n}\n\n/**\n * Updates the visibility of the style toolbar\n */\nconst useStyleToolbarProps = (value: EditorState): UseStyleToolbarPropsRes => {\n const [trigger, setTrigger] = useState({\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n });\n const [visible, setVisible] = useState(false);\n\n useEffect(() => {\n if (!value) return;\n const selectionRange = getSelectionRange();\n\n // Do not show the panel if either there is no selected text,\n // or the selection range is collapsed,\n // or the selected text is in an atomic block.\n if (\n !selectionRange ||\n value.getSelection().isCollapsed() ||\n RichUtils.getCurrentBlockType(value).startsWith('atomic')\n ) {\n setVisible(false);\n return;\n }\n\n // Otherwise, set the rect of the selection range\n setTrigger(selectionRange.getBoundingClientRect());\n setVisible(true);\n }, [value]);\n\n return { trigger, visible };\n};\n\nexport default useStyleToolbarProps;\n"],"mappings":"AAAA,SAAsBA,SAAS,QAAQ,UAAU;AACjD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,OAAOC,iBAAiB,MAAM,4BAA4B;AAc1D;AACA;AACA;AACA,MAAMC,oBAAoB,GAAIC,KAAkB,IAA8B;EAC5E,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGL,QAAQ,CAAC;IACrCM,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACV,CAAC,CAAC;EACF,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGX,QAAQ,CAAC,KAAK,CAAC;EAE7CD,SAAS,CAAC,MAAM;IACd,IAAI,CAACI,KAAK,EAAE;IACZ,MAAMS,cAAc,GAAGX,iBAAiB,CAAC,CAAC;;IAE1C;IACA;IACA;IACA,IACE,CAACW,cAAc,IACfT,KAAK,CAACU,YAAY,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,IAClChB,SAAS,CAACiB,mBAAmB,CAACZ,KAAK,CAAC,CAACa,UAAU,CAAC,QAAQ,CAAC,EACzD;MACAL,UAAU,CAAC,KAAK,CAAC;MACjB;IACF;;IAEA;IACAN,UAAU,CAACO,cAAc,CAACK,qBAAqB,CAAC,CAAC,CAAC;IAClDN,UAAU,CAAC,IAAI,CAAC;EAClB,CAAC,EAAE,CAACR,KAAK,CAAC,CAAC;EAEX,OAAO;IAAEC,OAAO;IAAEM;EAAQ,CAAC;AAC7B,CAAC;AAED,eAAeR,oBAAoB"}
|
package/dist/esm/Editor/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import
|
|
3
|
-
import { Editor as DraftEditor, EditorState } from 'draft-js';
|
|
4
|
-
import { InputContainer } from '@os-design/core';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
5
3
|
import styled from '@emotion/styled';
|
|
4
|
+
import { InputContainer } from '@os-design/core';
|
|
6
5
|
import { useForwardedRef, useForwardedState } from '@os-design/utils';
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import defaultDraftJsStyles from './styles/defaultDraftJsStyles';
|
|
10
|
-
import overrideDraftJsStyles from './styles/overrideDraftJsStyles';
|
|
11
|
-
import defaultStyleToolbarItems from './utils/defaultStyleToolbarItems';
|
|
12
|
-
import StyleToolbar from './StyleToolbar';
|
|
6
|
+
import { Editor as DraftEditor, EditorState } from 'draft-js';
|
|
7
|
+
import React, { forwardRef, useCallback, useState } from 'react';
|
|
13
8
|
import BlockToolbar from './BlockToolbar';
|
|
14
|
-
import
|
|
9
|
+
import StyleToolbar from './StyleToolbar';
|
|
15
10
|
import useBlockToolbarProps from './hooks/useBlockToolbarProps';
|
|
16
|
-
import useReturnHandler from './hooks/useReturnHandler';
|
|
17
11
|
import usePastedTextHandler from './hooks/usePastedTextHandler';
|
|
12
|
+
import useReturnHandler from './hooks/useReturnHandler';
|
|
13
|
+
import useStyleToolbarProps from './hooks/useStyleToolbarProps';
|
|
14
|
+
import defaultDraftJsStyles from './styles/defaultDraftJsStyles';
|
|
15
|
+
import overrideDraftJsStyles from './styles/overrideDraftJsStyles';
|
|
16
|
+
import createEmptyEditorState from './utils/createEmptyEditorState';
|
|
17
|
+
import defaultStyleToolbarItems from './utils/defaultStyleToolbarItems';
|
|
18
18
|
const disabledStyles = p => p.disabled && css`
|
|
19
19
|
cursor: not-allowed;
|
|
20
20
|
`;
|