@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","forwardRef","useCallback","useState","Editor","DraftEditor","EditorState","InputContainer","styled","useForwardedRef","useForwardedState","css","createEmptyEditorState","defaultDraftJsStyles","overrideDraftJsStyles","defaultStyleToolbarItems","StyleToolbar","BlockToolbar","useStyleToolbarProps","useBlockToolbarProps","useReturnHandler","usePastedTextHandler","disabledStyles","p","disabled","Container","theme","editorPaddingVertical","inputPaddingHorizontal","editorMinHeight","styleToolbarItems","blockToolbarItems","value","defaultValue","onChange","size","readOnly","handleReturn","handlePastedText","rest","ref","editorRef","mergedEditorRef","forwardedValue","setForwardedValue","innerReadOnly","setInnerReadOnly","styleToolbarProps","blockToolbarProps","length","setEditorState","editorState","getSelection","getHasFocus","moveSelectionToEnd","blockRenderer","block","blockConfig","find","item","type","getType","component","returnHandler","pastedTextHandler","undefined","current","focus","displayName"],"sources":["../../../src/Editor/index.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useState } from 'react';\nimport {\n Editor as DraftEditor,\n EditorState,\n EditorProps as DraftEditorProps,\n} from 'draft-js';\nimport { InputContainer } from '@os-design/core';\nimport styled from '@emotion/styled';\nimport { WithSize } from '@os-design/styles';\nimport { useForwardedRef, useForwardedState } from '@os-design/utils';\nimport { css } from '@emotion/react';\nimport createEmptyEditorState from './utils/createEmptyEditorState';\nimport defaultDraftJsStyles from './styles/defaultDraftJsStyles';\nimport overrideDraftJsStyles from './styles/overrideDraftJsStyles';\nimport defaultStyleToolbarItems, {\n StyleToolbarItem,\n} from './utils/defaultStyleToolbarItems';\nimport StyleToolbar from './StyleToolbar';\nimport BlockToolbar from './BlockToolbar';\nimport useStyleToolbarProps from './hooks/useStyleToolbarProps';\nimport useBlockToolbarProps from './hooks/useBlockToolbarProps';\nimport useReturnHandler from './hooks/useReturnHandler';\nimport usePastedTextHandler from './hooks/usePastedTextHandler';\nimport { BlockToolbarItem } from './blocks/types';\n\nexport interface EditorProps\n extends Omit<DraftEditorProps, 'editorState' | 'onChange'>,\n WithSize {\n /**\n * Whether the editor is disabled.\n * @default false\n */\n disabled?: boolean;\n /**\n * Available styles in the toolbar.\n * @default undefined\n */\n styleToolbarItems?: StyleToolbarItem[];\n /**\n * Available blocks in the toolbar.\n * @default undefined\n */\n blockToolbarItems?: BlockToolbarItem[];\n /**\n * The editor state.\n * @default undefined\n */\n value?: EditorState;\n /**\n * The default value.\n * @default undefined\n */\n defaultValue?: EditorState;\n /**\n * The change event handler.\n * @default undefined\n */\n onChange?: (value: EditorState) => void;\n}\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n cursor: not-allowed;\n `;\n\nconst Container = styled(InputContainer)`\n height: unset;\n cursor: text;\n\n padding: ${(p) => p.theme.editorPaddingVertical}em\n ${(p) => p.theme.inputPaddingHorizontal}em;\n min-height: ${(p) => p.theme.editorMinHeight}em;\n\n ${defaultDraftJsStyles};\n ${overrideDraftJsStyles};\n ${disabledStyles};\n`;\n\n/**\n * Rich text editor based on the Draft.js.\n */\nconst Editor = forwardRef<DraftEditor, EditorProps>(\n (\n {\n disabled = false,\n styleToolbarItems = defaultStyleToolbarItems,\n blockToolbarItems = [],\n value,\n defaultValue = createEmptyEditorState(),\n onChange,\n size,\n readOnly,\n handleReturn = () => 'not-handled',\n handlePastedText = () => 'not-handled',\n ...rest\n },\n ref\n ) => {\n const [editorRef, mergedEditorRef] = useForwardedRef(ref);\n const [forwardedValue, setForwardedValue] = useForwardedState({\n value,\n defaultValue,\n onChange,\n });\n\n // Used by ImageBlock to make the editor read-only\n // while an image is being uploaded\n const [innerReadOnly, setInnerReadOnly] = useState(false);\n\n // Get the trigger and visible props for the toolbars\n const styleToolbarProps = useStyleToolbarProps(\n forwardedValue || defaultValue\n );\n const blockToolbarProps = useBlockToolbarProps(\n forwardedValue || defaultValue,\n (blockToolbarItems || []).length > 0\n );\n\n // Move the caret to the end of the content when the focus event was fired\n const setEditorState = useCallback(\n (editorState: EditorState) => {\n if (!editorState.getSelection().getHasFocus()) {\n setForwardedValue(EditorState.moveSelectionToEnd(editorState));\n return;\n }\n setForwardedValue(editorState);\n },\n [setForwardedValue]\n );\n\n const blockRenderer = useCallback(\n (block) => {\n const blockConfig = blockToolbarItems.find(\n (item) => item.type === block.getType()\n );\n if (!blockConfig) return null;\n return { component: blockConfig.component };\n },\n [blockToolbarItems]\n );\n\n // Custom handlers\n const returnHandler = useReturnHandler(setForwardedValue, handleReturn);\n const pastedTextHandler = usePastedTextHandler(\n setForwardedValue,\n handlePastedText\n );\n\n return (\n <>\n <Container\n disabled={disabled}\n size={size}\n tabIndex={!disabled ? 0 : -1}\n role={!disabled ? 'textbox' : undefined}\n onFocus={() => {\n if (disabled || !editorRef.current) return;\n editorRef.current.focus();\n }}\n >\n <DraftEditor\n onChange={setEditorState}\n blockRendererFn={blockRenderer}\n handleReturn={returnHandler}\n handlePastedText={pastedTextHandler}\n readOnly={readOnly || innerReadOnly || disabled}\n stripPastedStyles\n {...rest}\n editorState={forwardedValue || defaultValue}\n ref={mergedEditorRef}\n />\n </Container>\n\n <StyleToolbar\n {...styleToolbarProps}\n size={size}\n items={styleToolbarItems}\n value={forwardedValue || defaultValue}\n onChange={setForwardedValue}\n />\n\n <BlockToolbar\n {...blockToolbarProps}\n placement='right'\n gap={2.5}\n size={size}\n items={blockToolbarItems}\n value={forwardedValue || defaultValue}\n onChange={setForwardedValue}\n setReadOnly={setInnerReadOnly}\n />\n </>\n );\n }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;IACtC,QAAQ,EAAEW,iBAAkB;IAC5B,WAAW,EAAEE;EAAiB,GAC9B,CACD;AAEP,CAAC,CACF;AAED1C,MAAM,CAACgE,WAAW,GAAG,QAAQ;AAE7B,eAAehE,MAAM"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["css","styled","InputContainer","useForwardedRef","useForwardedState","Editor","DraftEditor","EditorState","React","forwardRef","useCallback","useState","BlockToolbar","StyleToolbar","useBlockToolbarProps","usePastedTextHandler","useReturnHandler","useStyleToolbarProps","defaultDraftJsStyles","overrideDraftJsStyles","createEmptyEditorState","defaultStyleToolbarItems","disabledStyles","p","disabled","Container","theme","editorPaddingVertical","inputPaddingHorizontal","editorMinHeight","styleToolbarItems","blockToolbarItems","value","defaultValue","onChange","size","readOnly","handleReturn","handlePastedText","rest","ref","editorRef","mergedEditorRef","forwardedValue","setForwardedValue","innerReadOnly","setInnerReadOnly","styleToolbarProps","blockToolbarProps","length","setEditorState","editorState","getSelection","getHasFocus","moveSelectionToEnd","blockRenderer","block","blockConfig","find","item","type","getType","component","returnHandler","pastedTextHandler","createElement","Fragment","tabIndex","role","undefined","onFocus","current","focus","_extends","blockRendererFn","stripPastedStyles","items","placement","gap","setReadOnly","displayName"],"sources":["../../../src/Editor/index.tsx"],"sourcesContent":["import { css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { InputContainer } from '@os-design/core';\nimport { WithSize } from '@os-design/styles';\nimport { useForwardedRef, useForwardedState } from '@os-design/utils';\n\nimport {\n Editor as DraftEditor,\n EditorProps as DraftEditorProps,\n EditorState,\n} from 'draft-js';\nimport React, { forwardRef, useCallback, useState } from 'react';\nimport BlockToolbar from './BlockToolbar';\nimport StyleToolbar from './StyleToolbar';\nimport { BlockToolbarItem } from './blocks/types';\nimport useBlockToolbarProps from './hooks/useBlockToolbarProps';\nimport usePastedTextHandler from './hooks/usePastedTextHandler';\nimport useReturnHandler from './hooks/useReturnHandler';\nimport useStyleToolbarProps from './hooks/useStyleToolbarProps';\n\nimport defaultDraftJsStyles from './styles/defaultDraftJsStyles';\nimport overrideDraftJsStyles from './styles/overrideDraftJsStyles';\nimport createEmptyEditorState from './utils/createEmptyEditorState';\n\nimport defaultStyleToolbarItems, {\n StyleToolbarItem,\n} from './utils/defaultStyleToolbarItems';\n\nexport interface EditorProps\n extends Omit<DraftEditorProps, 'editorState' | 'onChange'>,\n WithSize {\n /**\n * Whether the editor is disabled.\n * @default false\n */\n disabled?: boolean;\n /**\n * Available styles in the toolbar.\n * @default undefined\n */\n styleToolbarItems?: StyleToolbarItem[];\n /**\n * Available blocks in the toolbar.\n * @default undefined\n */\n blockToolbarItems?: BlockToolbarItem[];\n /**\n * The editor state.\n * @default undefined\n */\n value?: EditorState;\n /**\n * The default value.\n * @default undefined\n */\n defaultValue?: EditorState;\n /**\n * The change event handler.\n * @default undefined\n */\n onChange?: (value: EditorState) => void;\n}\n\nconst disabledStyles = (p) =>\n p.disabled &&\n css`\n cursor: not-allowed;\n `;\n\nconst Container = styled(InputContainer)`\n height: unset;\n cursor: text;\n\n padding: ${(p) => p.theme.editorPaddingVertical}em\n ${(p) => p.theme.inputPaddingHorizontal}em;\n min-height: ${(p) => p.theme.editorMinHeight}em;\n\n ${defaultDraftJsStyles};\n ${overrideDraftJsStyles};\n ${disabledStyles};\n`;\n\n/**\n * Rich text editor based on the Draft.js.\n */\nconst Editor = forwardRef<DraftEditor, EditorProps>(\n (\n {\n disabled = false,\n styleToolbarItems = defaultStyleToolbarItems,\n blockToolbarItems = [],\n value,\n defaultValue = createEmptyEditorState(),\n onChange,\n size,\n readOnly,\n handleReturn = () => 'not-handled',\n handlePastedText = () => 'not-handled',\n ...rest\n },\n ref\n ) => {\n const [editorRef, mergedEditorRef] = useForwardedRef(ref);\n const [forwardedValue, setForwardedValue] = useForwardedState({\n value,\n defaultValue,\n onChange,\n });\n\n // Used by ImageBlock to make the editor read-only\n // while an image is being uploaded\n const [innerReadOnly, setInnerReadOnly] = useState(false);\n\n // Get the trigger and visible props for the toolbars\n const styleToolbarProps = useStyleToolbarProps(\n forwardedValue || defaultValue\n );\n const blockToolbarProps = useBlockToolbarProps(\n forwardedValue || defaultValue,\n (blockToolbarItems || []).length > 0\n );\n\n // Move the caret to the end of the content when the focus event was fired\n const setEditorState = useCallback(\n (editorState: EditorState) => {\n if (!editorState.getSelection().getHasFocus()) {\n setForwardedValue(EditorState.moveSelectionToEnd(editorState));\n return;\n }\n setForwardedValue(editorState);\n },\n [setForwardedValue]\n );\n\n const blockRenderer = useCallback(\n (block) => {\n const blockConfig = blockToolbarItems.find(\n (item) => item.type === block.getType()\n );\n if (!blockConfig) return null;\n return { component: blockConfig.component };\n },\n [blockToolbarItems]\n );\n\n // Custom handlers\n const returnHandler = useReturnHandler(setForwardedValue, handleReturn);\n const pastedTextHandler = usePastedTextHandler(\n setForwardedValue,\n handlePastedText\n );\n\n return (\n <>\n <Container\n disabled={disabled}\n size={size}\n tabIndex={!disabled ? 0 : -1}\n role={!disabled ? 'textbox' : undefined}\n onFocus={() => {\n if (disabled || !editorRef.current) return;\n editorRef.current.focus();\n }}\n >\n <DraftEditor\n onChange={setEditorState}\n blockRendererFn={blockRenderer}\n handleReturn={returnHandler}\n handlePastedText={pastedTextHandler}\n readOnly={readOnly || innerReadOnly || disabled}\n stripPastedStyles\n {...rest}\n editorState={forwardedValue || defaultValue}\n ref={mergedEditorRef}\n />\n </Container>\n\n <StyleToolbar\n {...styleToolbarProps}\n size={size}\n items={styleToolbarItems}\n value={forwardedValue || defaultValue}\n onChange={setForwardedValue}\n />\n\n <BlockToolbar\n {...blockToolbarProps}\n placement='right'\n gap={2.5}\n size={size}\n items={blockToolbarItems}\n value={forwardedValue || defaultValue}\n onChange={setForwardedValue}\n setReadOnly={setInnerReadOnly}\n />\n </>\n );\n }\n);\n\nEditor.displayName = 'Editor';\n\nexport default Editor;\n"],"mappings":";AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,cAAc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A,KACPzB,iBAAiB;IACrB6B,SAAS,EAAC,OAAO;IACjBC,GAAG,EAAE,GAAI;IACT3C,IAAI,EAAEA,IAAK;IACXyC,KAAK,EAAE7C,iBAAkB;IACzBC,KAAK,EAAEW,cAAc,IAAIV,YAAa;IACtCC,QAAQ,EAAEU,iBAAkB;IAC5BmC,WAAW,EAAEjC;EAAiB,EAC/B,CACD,CAAC;AAEP,CACF,CAAC;AAEDzC,MAAM,CAAC2E,WAAW,GAAG,QAAQ;AAE7B,eAAe3E,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Immutable from 'immutable';
|
|
2
1
|
import { ContentBlock, EditorState, genKey } from 'draft-js';
|
|
2
|
+
import Immutable from 'immutable';
|
|
3
3
|
const addNewBlockAt = (editorState, pivotBlockKey, type = 'unstyled', data = {} // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
4
4
|
) => {
|
|
5
5
|
const contentState = editorState.getCurrentContent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNewBlockAt.js","names":["
|
|
1
|
+
{"version":3,"file":"addNewBlockAt.js","names":["ContentBlock","EditorState","genKey","Immutable","addNewBlockAt","editorState","pivotBlockKey","type","data","contentState","getCurrentContent","blockMap","getBlockMap","pivotBlock","get","Error","blocksBefore","toSeq","takeUntil","v","blocksAfter","skipUntil","rest","key","block","text","characterList","List","depth","Map","selectionState","getSelection","nextBlockMap","concat","toOrderedMap","nextContentState","merge","selectionBefore","selectionAfter","anchorKey","anchorOffset","focusKey","focusOffset","isBackward","push"],"sources":["../../../../src/Editor/utils/addNewBlockAt.ts"],"sourcesContent":["import { ContentBlock, ContentState, EditorState, genKey } from 'draft-js';\nimport Immutable from 'immutable';\n\nconst addNewBlockAt = (\n editorState: EditorState,\n pivotBlockKey: string,\n type = 'unstyled',\n data: Record<string, any> = {} // eslint-disable-line @typescript-eslint/no-explicit-any\n): EditorState => {\n const contentState = editorState.getCurrentContent();\n const blockMap = contentState.getBlockMap();\n const pivotBlock = blockMap.get(pivotBlockKey);\n if (!pivotBlock)\n throw new Error(\n `The pivot key - ${pivotBlockKey} is not present in blockMap`\n );\n const blocksBefore = blockMap.toSeq().takeUntil((v) => v === pivotBlock);\n const blocksAfter = blockMap\n .toSeq()\n .skipUntil((v) => v === pivotBlock)\n .rest();\n const key = genKey();\n\n const block = new ContentBlock({\n key,\n type,\n text: '',\n characterList: Immutable.List(),\n depth: 0,\n data: Immutable.Map(data),\n });\n\n const selectionState = editorState.getSelection();\n const nextBlockMap = blocksBefore\n .concat(\n [\n [pivotBlockKey, pivotBlock],\n [key, block],\n ],\n blocksAfter\n )\n .toOrderedMap();\n\n const nextContentState = contentState.merge({\n blockMap: nextBlockMap,\n selectionBefore: selectionState,\n selectionAfter: selectionState.merge({\n anchorKey: key,\n anchorOffset: 0,\n focusKey: key,\n focusOffset: 0,\n isBackward: false,\n }),\n }) as ContentState;\n\n return EditorState.push(editorState, nextContentState, 'split-block');\n};\n\nexport default addNewBlockAt;\n"],"mappings":"AAAA,SAASA,YAAY,EAAgBC,WAAW,EAAEC,MAAM,QAAQ,UAAU;AAC1E,OAAOC,SAAS,MAAM,WAAW;AAEjC,MAAMC,aAAa,GAAGA,CACpBC,WAAwB,EACxBC,aAAqB,EACrBC,IAAI,GAAG,UAAU,EACjBC,IAAyB,GAAG,CAAC,CAAC,CAAC;AAAA,KACf;EAChB,MAAMC,YAAY,GAAGJ,WAAW,CAACK,iBAAiB,CAAC,CAAC;EACpD,MAAMC,QAAQ,GAAGF,YAAY,CAACG,WAAW,CAAC,CAAC;EAC3C,MAAMC,UAAU,GAAGF,QAAQ,CAACG,GAAG,CAACR,aAAa,CAAC;EAC9C,IAAI,CAACO,UAAU,EACb,MAAM,IAAIE,KAAK,CACZ,mBAAkBT,aAAc,6BACnC,CAAC;EACH,MAAMU,YAAY,GAAGL,QAAQ,CAACM,KAAK,CAAC,CAAC,CAACC,SAAS,CAAEC,CAAC,IAAKA,CAAC,KAAKN,UAAU,CAAC;EACxE,MAAMO,WAAW,GAAGT,QAAQ,CACzBM,KAAK,CAAC,CAAC,CACPI,SAAS,CAAEF,CAAC,IAAKA,CAAC,KAAKN,UAAU,CAAC,CAClCS,IAAI,CAAC,CAAC;EACT,MAAMC,GAAG,GAAGrB,MAAM,CAAC,CAAC;EAEpB,MAAMsB,KAAK,GAAG,IAAIxB,YAAY,CAAC;IAC7BuB,GAAG;IACHhB,IAAI;IACJkB,IAAI,EAAE,EAAE;IACRC,aAAa,EAAEvB,SAAS,CAACwB,IAAI,CAAC,CAAC;IAC/BC,KAAK,EAAE,CAAC;IACRpB,IAAI,EAAEL,SAAS,CAAC0B,GAAG,CAACrB,IAAI;EAC1B,CAAC,CAAC;EAEF,MAAMsB,cAAc,GAAGzB,WAAW,CAAC0B,YAAY,CAAC,CAAC;EACjD,MAAMC,YAAY,GAAGhB,YAAY,CAC9BiB,MAAM,CACL,CACE,CAAC3B,aAAa,EAAEO,UAAU,CAAC,EAC3B,CAACU,GAAG,EAAEC,KAAK,CAAC,CACb,EACDJ,WACF,CAAC,CACAc,YAAY,CAAC,CAAC;EAEjB,MAAMC,gBAAgB,GAAG1B,YAAY,CAAC2B,KAAK,CAAC;IAC1CzB,QAAQ,EAAEqB,YAAY;IACtBK,eAAe,EAAEP,cAAc;IAC/BQ,cAAc,EAAER,cAAc,CAACM,KAAK,CAAC;MACnCG,SAAS,EAAEhB,GAAG;MACdiB,YAAY,EAAE,CAAC;MACfC,QAAQ,EAAElB,GAAG;MACbmB,WAAW,EAAE,CAAC;MACdC,UAAU,EAAE;IACd,CAAC;EACH,CAAC,CAAiB;EAElB,OAAO1C,WAAW,CAAC2C,IAAI,CAACvC,WAAW,EAAE8B,gBAAgB,EAAE,aAAa,CAAC;AACvE,CAAC;AAED,eAAe/B,aAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeBlock.js","names":["EditorState","changeBlock","editorState","block","type","data","contentState","getCurrentContent","nextCurrentBlock","merge","nextContentState","blockMap","getBlockMap","set","getKey","selectionAfter","getSelection","push"],"sources":["../../../../src/Editor/utils/changeBlock.ts"],"sourcesContent":["import { ContentBlock, ContentState, EditorState } from 'draft-js';\n\nconst changeBlock = (\n editorState: EditorState,\n block: ContentBlock,\n type: string,\n data: Record<string, any> = {} // eslint-disable-line @typescript-eslint/no-explicit-any\n): EditorState => {\n const contentState = editorState.getCurrentContent();\n\n const nextCurrentBlock = block.merge({ type, data }) as ContentBlock;\n const nextContentState = contentState.merge({\n blockMap: contentState.getBlockMap().set(block.getKey(), nextCurrentBlock),\n selectionAfter: editorState.getSelection(),\n }) as ContentState;\n\n return EditorState.push(editorState, nextContentState, 'change-block-type');\n};\n\nexport default changeBlock;\n"],"mappings":"AAAA,SAAqCA,WAAW,QAAQ,UAAU;AAElE,MAAMC,WAAW,
|
|
1
|
+
{"version":3,"file":"changeBlock.js","names":["EditorState","changeBlock","editorState","block","type","data","contentState","getCurrentContent","nextCurrentBlock","merge","nextContentState","blockMap","getBlockMap","set","getKey","selectionAfter","getSelection","push"],"sources":["../../../../src/Editor/utils/changeBlock.ts"],"sourcesContent":["import { ContentBlock, ContentState, EditorState } from 'draft-js';\n\nconst changeBlock = (\n editorState: EditorState,\n block: ContentBlock,\n type: string,\n data: Record<string, any> = {} // eslint-disable-line @typescript-eslint/no-explicit-any\n): EditorState => {\n const contentState = editorState.getCurrentContent();\n\n const nextCurrentBlock = block.merge({ type, data }) as ContentBlock;\n const nextContentState = contentState.merge({\n blockMap: contentState.getBlockMap().set(block.getKey(), nextCurrentBlock),\n selectionAfter: editorState.getSelection(),\n }) as ContentState;\n\n return EditorState.push(editorState, nextContentState, 'change-block-type');\n};\n\nexport default changeBlock;\n"],"mappings":"AAAA,SAAqCA,WAAW,QAAQ,UAAU;AAElE,MAAMC,WAAW,GAAGA,CAClBC,WAAwB,EACxBC,KAAmB,EACnBC,IAAY,EACZC,IAAyB,GAAG,CAAC,CAAC,CAAC;AAAA,KACf;EAChB,MAAMC,YAAY,GAAGJ,WAAW,CAACK,iBAAiB,CAAC,CAAC;EAEpD,MAAMC,gBAAgB,GAAGL,KAAK,CAACM,KAAK,CAAC;IAAEL,IAAI;IAAEC;EAAK,CAAC,CAAiB;EACpE,MAAMK,gBAAgB,GAAGJ,YAAY,CAACG,KAAK,CAAC;IAC1CE,QAAQ,EAAEL,YAAY,CAACM,WAAW,CAAC,CAAC,CAACC,GAAG,CAACV,KAAK,CAACW,MAAM,CAAC,CAAC,EAAEN,gBAAgB,CAAC;IAC1EO,cAAc,EAAEb,WAAW,CAACc,YAAY,CAAC;EAC3C,CAAC,CAAiB;EAElB,OAAOhB,WAAW,CAACiB,IAAI,CAACf,WAAW,EAAEQ,gBAAgB,EAAE,mBAAmB,CAAC;AAC7E,CAAC;AAED,eAAeT,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createContentEditorState.js","names":["EditorState","createDecorator","createContentEditorState","contentState","createWithContent"],"sources":["../../../../src/Editor/utils/createContentEditorState.ts"],"sourcesContent":["import { ContentState, EditorState } from 'draft-js';\nimport createDecorator from './createDecorator';\n\nconst createContentEditorState = (contentState: ContentState): EditorState =>\n EditorState.createWithContent(contentState, createDecorator());\n\nexport default createContentEditorState;\n"],"mappings":"AAAA,SAAuBA,WAAW,QAAQ,UAAU;AACpD,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,MAAMC,wBAAwB,GAAIC,YAA0B,IAC1DH,WAAW,CAACI,iBAAiB,CAACD,YAAY,EAAEF,eAAe,
|
|
1
|
+
{"version":3,"file":"createContentEditorState.js","names":["EditorState","createDecorator","createContentEditorState","contentState","createWithContent"],"sources":["../../../../src/Editor/utils/createContentEditorState.ts"],"sourcesContent":["import { ContentState, EditorState } from 'draft-js';\nimport createDecorator from './createDecorator';\n\nconst createContentEditorState = (contentState: ContentState): EditorState =>\n EditorState.createWithContent(contentState, createDecorator());\n\nexport default createContentEditorState;\n"],"mappings":"AAAA,SAAuBA,WAAW,QAAQ,UAAU;AACpD,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,MAAMC,wBAAwB,GAAIC,YAA0B,IAC1DH,WAAW,CAACI,iBAAiB,CAACD,YAAY,EAAEF,eAAe,CAAC,CAAC,CAAC;AAEhE,eAAeC,wBAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDecorator.js","names":["CompositeDecorator","linkDecorator","createDecorator"],"sources":["../../../../src/Editor/utils/createDecorator.ts"],"sourcesContent":["import { CompositeDecorator } from 'draft-js';\nimport linkDecorator from '../decorators/linkDecorator';\n\nconst createDecorator = (): CompositeDecorator =>\n new CompositeDecorator([linkDecorator]);\n\nexport default createDecorator;\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,UAAU;AAC7C,OAAOC,aAAa,MAAM,6BAA6B;AAEvD,MAAMC,eAAe,
|
|
1
|
+
{"version":3,"file":"createDecorator.js","names":["CompositeDecorator","linkDecorator","createDecorator"],"sources":["../../../../src/Editor/utils/createDecorator.ts"],"sourcesContent":["import { CompositeDecorator } from 'draft-js';\nimport linkDecorator from '../decorators/linkDecorator';\n\nconst createDecorator = (): CompositeDecorator =>\n new CompositeDecorator([linkDecorator]);\n\nexport default createDecorator;\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,UAAU;AAC7C,OAAOC,aAAa,MAAM,6BAA6B;AAEvD,MAAMC,eAAe,GAAGA,CAAA,KACtB,IAAIF,kBAAkB,CAAC,CAACC,aAAa,CAAC,CAAC;AAEzC,eAAeC,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEmptyEditorState.js","names":["EditorState","createDecorator","createEmptyEditorState","createEmpty"],"sources":["../../../../src/Editor/utils/createEmptyEditorState.ts"],"sourcesContent":["import { EditorState } from 'draft-js';\nimport createDecorator from './createDecorator';\n\nconst createEmptyEditorState = (): EditorState =>\n EditorState.createEmpty(createDecorator());\n\nexport default createEmptyEditorState;\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,UAAU;AACtC,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,MAAMC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"createEmptyEditorState.js","names":["EditorState","createDecorator","createEmptyEditorState","createEmpty"],"sources":["../../../../src/Editor/utils/createEmptyEditorState.ts"],"sourcesContent":["import { EditorState } from 'draft-js';\nimport createDecorator from './createDecorator';\n\nconst createEmptyEditorState = (): EditorState =>\n EditorState.createEmpty(createDecorator());\n\nexport default createEmptyEditorState;\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,UAAU;AACtC,OAAOC,eAAe,MAAM,mBAAmB;AAE/C,MAAMC,sBAAsB,GAAGA,CAAA,KAC7BF,WAAW,CAACG,WAAW,CAACF,eAAe,CAAC,CAAC,CAAC;AAE5C,eAAeC,sBAAsB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import styled from '@emotion/styled';
|
|
3
|
-
import { Bold, FontSize,
|
|
2
|
+
import { Bold, FontSize, Link as LinkIcon, OrderedList, UnorderedList } from '@os-design/icons';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
const FontSizeSmall = styled(FontSize)`
|
|
5
5
|
transform: scale(0.7);
|
|
6
6
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultStyleToolbarItems.js","names":["
|
|
1
|
+
{"version":3,"file":"defaultStyleToolbarItems.js","names":["styled","Bold","FontSize","Link","LinkIcon","OrderedList","UnorderedList","React","FontSizeSmall","defaultStyleToolbarItems","name","type","icon","createElement"],"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,OAAOA,MAAM,MAAM,iBAAiB;AACpC,SACEC,IAAI,EACJC,QAAQ,EACRC,IAAI,IAAIC,QAAQ,EAChBC,WAAW,EACXC,aAAa,QACR,kBAAkB;AACzB,OAAOC,KAAK,MAAM,OAAO;AAQzB,MAAMC,aAAa,GAAGR,MAAM,CAACE,QAAQ,CAAE;AACvC;AACA,CAAC;AAED,MAAMO,wBAA4C,GAAG,CACnD;EAAEC,IAAI,EAAE,YAAY;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAEL,KAAA,CAAAM,aAAA,CAACX,QAAQ,MAAE;AAAE,CAAC,EACzD;EAAEQ,IAAI,EAAE,cAAc;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAEL,KAAA,CAAAM,aAAA,CAACL,aAAa,MAAE;AAAE,CAAC,EAChE;EAAEE,IAAI,EAAE,MAAM;EAAEC,IAAI,EAAE,QAAQ;EAAEC,IAAI,eAAEL,KAAA,CAAAM,aAAA,CAACZ,IAAI,MAAE;AAAE,CAAC,EAChD;EAAES,IAAI,EAAE,qBAAqB;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAEL,KAAA,CAAAM,aAAA,CAACP,aAAa,MAAE;AAAE,CAAC,EACvE;EAAEI,IAAI,EAAE,mBAAmB;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAEL,KAAA,CAAAM,aAAA,CAACR,WAAW,MAAE;AAAE,CAAC,EACnE;EAAEK,IAAI,EAAE,MAAM;EAAEC,IAAI,EAAE,QAAQ;EAAEC,IAAI,eAAEL,KAAA,CAAAM,aAAA,CAACT,QAAQ,MAAE;AAAE,CAAC,CACrD;AAED,eAAeK,wBAAwB"}
|
|
@@ -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,MAAMA,eAAe,GAAIC,WAAwB,IAAmB;EAClE,MAAMC,cAAc,GAAGD,WAAW,CAACE,YAAY,
|
|
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,MAAMA,eAAe,GAAIC,WAAwB,IAAmB;EAClE,MAAMC,cAAc,GAAGD,WAAW,CAACE,YAAY,CAAC,CAAC;EACjD,MAAMC,YAAY,GAAGH,WAAW,CAACI,iBAAiB,CAAC,CAAC;EACpD,OAAOD,YAAY,CAACE,cAAc,CAACJ,cAAc,CAACK,WAAW,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,eAAeP,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelectedBlockElement.js","names":["getSelectionRange","getSelectedBlockElement","selectionRange","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,OAAOA,iBAAiB,MAAM,qBAAqB;AAEnD,MAAMC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"getSelectedBlockElement.js","names":["getSelectionRange","getSelectedBlockElement","selectionRange","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,OAAOA,iBAAiB,MAAM,qBAAqB;AAEnD,MAAMC,uBAAuB,GAAGA,CAAA,KAAsB;EACpD,MAAMC,cAAc,GAAGF,iBAAiB,CAAC,CAAC;EAC1C,IAAI,CAACE,cAAc,EAAE,OAAO,IAAI;EAEhC,IAAIC,IAAiB,GAAGD,cAAc,CAACE,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;AAED,eAAeF,uBAAuB"}
|
|
@@ -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,MAAMA,iBAAiB,
|
|
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,MAAMA,iBAAiB,GAAGA,CAAA,KAAoB;EAC5C,MAAMC,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;AAED,eAAeL,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setLink.js","names":["EditorState","RichUtils","setLink","editorState","url","containsLink","currentBlockContainsLink","contentState","getCurrentContent","contentStateWithLink","createEntity","entityKey","getLastCreatedEntityKey","nextEditorState","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,SAASA,WAAW,EAAEC,SAAS,QAAQ,UAAU;AAEjD,MAAMC,OAAO,
|
|
1
|
+
{"version":3,"file":"setLink.js","names":["EditorState","RichUtils","setLink","editorState","url","containsLink","currentBlockContainsLink","contentState","getCurrentContent","contentStateWithLink","createEntity","entityKey","getLastCreatedEntityKey","nextEditorState","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,SAASA,WAAW,EAAEC,SAAS,QAAQ,UAAU;AAEjD,MAAMC,OAAO,GAAGA,CAACC,WAAwB,EAAEC,GAAW,KAAkB;EACtE,MAAMC,YAAY,GAAGJ,SAAS,CAACK,wBAAwB,CAACH,WAAW,CAAC;EACpE,IAAIE,YAAY,EAAE,OAAOF,WAAW;EAEpC,MAAMI,YAAY,GAAGJ,WAAW,CAACK,iBAAiB,CAAC,CAAC;EACpD,MAAMC,oBAAoB,GAAGF,YAAY,CAACG,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE;IACxEN;EACF,CAAC,CAAC;EACF,MAAMO,SAAS,GAAGF,oBAAoB,CAACG,uBAAuB,CAAC,CAAC;EAChE,MAAMC,eAAe,GAAGb,WAAW,CAACc,GAAG,CAACX,WAAW,EAAE;IACnDY,cAAc,EAAEN;EAClB,CAAC,CAAC;EACF,OAAOR,SAAS,CAACe,UAAU,CACzBH,eAAe,EACfA,eAAe,CAACI,YAAY,CAAC,CAAC,EAC9BN,SACF,CAAC;AACH,CAAC;AAED,eAAeT,OAAO"}
|
|
@@ -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":"AAEA,OAAO,MAAMA,2BAA2B,GACtCC,WAAwB,IACb;EACX,MAAMC,kBAAkB,GAAGD,WAAW,CACnCE,iBAAiB,
|
|
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":"AAEA,OAAO,MAAMA,2BAA2B,GACtCC,WAAwB,IACb;EACX,MAAMC,kBAAkB,GAAGD,WAAW,CACnCE,iBAAiB,CAAC,CAAC,CACnBC,gBAAgB,CAAC,CAAC,CAClBC,IAAI,CAAEC,KAAK,IAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,KAAK,UAAU,CAAC;EAElD,OAAOL,kBAAkB,GAAGA,kBAAkB,CAACM,OAAO,CAAC,CAAC,GAAG,EAAE;AAC/D,CAAC;AAED,OAAO,MAAMC,4BAA4B,GACvCR,WAAwB,IAExBD,2BAA2B,CAACC,WAAW,CAAC,CACrCS,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CACbC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAC/BC,IAAI,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsetLink.js","names":["RichUtils","unsetLink","editorState","containsLink","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,SAAsBA,SAAS,QAAQ,UAAU;AAEjD,MAAMC,SAAS,GAAIC,WAAwB,IAAkB;EAC3D,MAAMC,YAAY,GAAGH,SAAS,CAACI,wBAAwB,CAACF,WAAW,CAAC;EACpE,IAAI,CAACC,YAAY,EAAE,OAAOD,WAAW;EAErC,MAAMG,cAAc,GAAGH,WAAW,CAACI,YAAY,
|
|
1
|
+
{"version":3,"file":"unsetLink.js","names":["RichUtils","unsetLink","editorState","containsLink","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,SAAsBA,SAAS,QAAQ,UAAU;AAEjD,MAAMC,SAAS,GAAIC,WAAwB,IAAkB;EAC3D,MAAMC,YAAY,GAAGH,SAAS,CAACI,wBAAwB,CAACF,WAAW,CAAC;EACpE,IAAI,CAACC,YAAY,EAAE,OAAOD,WAAW;EAErC,MAAMG,cAAc,GAAGH,WAAW,CAACI,YAAY,CAAC,CAAC;EACjD,OAAON,SAAS,CAACO,UAAU,CAACL,WAAW,EAAEG,cAAc,EAAE,IAAI,CAAC;AAChE,CAAC;AAED,eAAeJ,SAAS"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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
2
|
import styled from '@emotion/styled';
|
|
3
|
-
import React, { forwardRef } from 'react';
|
|
4
3
|
import { InputSkeleton } from '@os-design/core';
|
|
4
|
+
import React, { forwardRef } from 'react';
|
|
5
5
|
const StyledEditorSkeleton = styled(InputSkeleton)`
|
|
6
6
|
height: ${p => p.theme.editorMinHeight}em;
|
|
7
7
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["styled","
|
|
1
|
+
{"version":3,"file":"index.js","names":["styled","InputSkeleton","React","forwardRef","StyledEditorSkeleton","p","theme","editorMinHeight","EditorSkeleton","props","ref","createElement","_extends","displayName"],"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,OAAOA,MAAM,MAAM,iBAAiB;AAEpC,SAASC,aAAa,QAA4B,iBAAiB;AACnE,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;AAIzC,MAAMC,oBAAoB,GAAGJ,MAAM,CAACC,aAAa,CAAE;AACnD,YAAaI,CAAC,IAAKA,CAAC,CAACC,KAAK,CAACC,eAAgB;AAC3C,CAAC;;AAED;AACA;AACA;AACA,MAAMC,cAAc,gBAAGL,UAAU,CAC/B,CAACM,KAAK,EAAEC,GAAG,kBAAKR,KAAA,CAAAS,aAAA,CAACP,oBAAoB,EAAAQ,QAAA,KAAKH,KAAK;EAAEC,GAAG,EAAEA;AAAI,EAAE,CAC9D,CAAC;AAEDF,cAAc,CAACK,WAAW,GAAG,gBAAgB;AAE7C,eAAeL,cAAc"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { EditorState } from 'draft-js';
|
|
3
1
|
import { PopoverProps } from '@os-design/core';
|
|
2
|
+
import { EditorState } from 'draft-js';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import { BlockToolbarItem } from './blocks/types';
|
|
5
5
|
interface BlockToolbarProps extends Omit<PopoverProps, 'onChange'> {
|
|
6
6
|
items: BlockToolbarItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockToolbar.d.ts","sourceRoot":"","sources":["../../../src/Editor/BlockToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"BlockToolbar.d.ts","sourceRoot":"","sources":["../../../src/Editor/BlockToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAsB,MAAM,OAAO,CAAC;AAI3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,UAAU,iBAAkB,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;IAChE,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8B7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { EditorState } from 'draft-js';
|
|
3
1
|
import { PopoverProps } from '@os-design/core';
|
|
2
|
+
import { EditorState } from 'draft-js';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import { StyleToolbarItem } from './utils/defaultStyleToolbarItems';
|
|
5
5
|
interface StyleToolbarProps extends Omit<PopoverProps, 'onChange'> {
|
|
6
6
|
items: StyleToolbarItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyleToolbar.d.ts","sourceRoot":"","sources":["../../../src/Editor/StyleToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"StyleToolbar.d.ts","sourceRoot":"","sources":["../../../src/Editor/StyleToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAa,MAAM,UAAU,CAAC;AAElD,OAAO,KAA+B,MAAM,OAAO,CAAC;AAIpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAIpE,UAAU,iBAAkB,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;IAChE,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA0D7C,CAAC;AAIF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../../src/Editor/ToolbarButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../../src/Editor/ToolbarButton.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,KAAK,cAAc,GAAG,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AACtD,UAAU,kBAAmB,SAAQ,cAAc;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAqCD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAW/C,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageBlock.d.ts","sourceRoot":"","sources":["../../../../src/Editor/blocks/imageBlock.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"imageBlock.d.ts","sourceRoot":"","sources":["../../../../src/Editor/blocks/imageBlock.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAc,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA2FvD,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAE1C,QAAA,MAAM,UAAU,yBACQ,IAAI,KAAK,QAAQ,MAAM,CAAC,KAC7C,gBAgDD,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/Editor/blocks/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/Editor/blocks/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACrD,KAAK,EAAE,YAAY,CAAC;CACrB;AAGD,MAAM,WAAW,4BAA6B,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACvE,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;IAChC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;IACzB,OAAO,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,IAAI,CAAC;CACxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoBlock.d.ts","sourceRoot":"","sources":["../../../../src/Editor/blocks/videoBlock.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"videoBlock.d.ts","sourceRoot":"","sources":["../../../../src/Editor/blocks/videoBlock.tsx"],"names":[],"mappings":"AASA,OAAO,EAAc,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAkDvD,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAE1C,QAAA,MAAM,UAAU,EAAE,gBAmBjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkDecorator.d.ts","sourceRoot":"","sources":["../../../../src/Editor/decorators/linkDecorator.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linkDecorator.d.ts","sourceRoot":"","sources":["../../../../src/Editor/decorators/linkDecorator.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI1C,QAAA,MAAM,aAAa,EAAE,cAcpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBlockToolbarProps.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/useBlockToolbarProps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBlockToolbarProps.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/useBlockToolbarProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC,UAAU,IAAI;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,uBAAuB;IAC/B,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAKD,QAAA,MAAM,oBAAoB,UACjB,WAAW,QACZ,OAAO,KACZ,uBA+CF,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePastedTextHandler.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/usePastedTextHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePastedTextHandler.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/usePastedTextHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,IAAI,gBAAgB,EAE/B,WAAW,EAGZ,MAAM,UAAU,CAAC;AAGlB,KAAK,uBAAuB,GAAG,OAAO,CACpC,gBAAgB,CAAC,kBAAkB,CAAC,EACpC,SAAS,CACV,CAAC;AAKF,QAAA,MAAM,oBAAoB,qBACN,WAAW,KAAK,IAAI,WAC7B,uBAAuB,KAC/B,uBAwBA,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReturnHandler.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/useReturnHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useReturnHandler.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/useReturnHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKxE,KAAK,mBAAmB,GAAG,WAAW,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;AAKzE,QAAA,MAAM,gBAAgB,qBACF,WAAW,KAAK,IAAI,WAC7B,mBAAmB,KAC3B,mBAqBA,CAAC;AAEJ,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStyleToolbarProps.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/useStyleToolbarProps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useStyleToolbarProps.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/useStyleToolbarProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,UAAU,CAAC;AAIlD,UAAU,IAAI;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,uBAAuB;IAC/B,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAKD,QAAA,MAAM,oBAAoB,UAAW,WAAW,KAAG,uBA+BlD,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Editor as DraftEditor, EditorState, EditorProps as DraftEditorProps } from 'draft-js';
|
|
3
1
|
import { WithSize } from '@os-design/styles';
|
|
4
|
-
import {
|
|
2
|
+
import { Editor as DraftEditor, EditorProps as DraftEditorProps, EditorState } from 'draft-js';
|
|
3
|
+
import React from 'react';
|
|
5
4
|
import { BlockToolbarItem } from './blocks/types';
|
|
5
|
+
import { StyleToolbarItem } from './utils/defaultStyleToolbarItems';
|
|
6
6
|
export interface EditorProps extends Omit<DraftEditorProps, 'editorState' | 'onChange'>, WithSize {
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
styleToolbarItems?: StyleToolbarItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Editor/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Editor/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,WAAW,IAAI,gBAAgB,EAC/B,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAA4C,MAAM,OAAO,CAAC;AAGjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAUlD,OAAiC,EAC/B,gBAAgB,EACjB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,aAAa,GAAG,UAAU,CAAC,EACxD,QAAQ;IAKV,QAAQ,CAAC,EAAE,OAAO,CAAC;IAKnB,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAKvC,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAKvC,KAAK,CAAC,EAAE,WAAW,CAAC;IAKpB,YAAY,CAAC,EAAE,WAAW,CAAC;IAK3B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACzC;AAwBD,QAAA,MAAM,MAAM,iFAiHX,CAAC;AAIF,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNewBlockAt.d.ts","sourceRoot":"","sources":["../../../../src/Editor/utils/addNewBlockAt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"addNewBlockAt.d.ts","sourceRoot":"","sources":["../../../../src/Editor/utils/addNewBlockAt.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAU,MAAM,UAAU,CAAC;AAG3E,QAAA,MAAM,aAAa,gBACJ,WAAW,iBACT,MAAM,wBAEf,OAAO,MAAM,EAAE,GAAG,CAAC,KACxB,WAgDF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultStyleToolbarItems.d.ts","sourceRoot":"","sources":["../../../../src/Editor/utils/defaultStyleToolbarItems.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defaultStyleToolbarItems.d.ts","sourceRoot":"","sources":["../../../../src/Editor/utils/defaultStyleToolbarItems.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;CACvB;AAMD,QAAA,MAAM,wBAAwB,EAAE,gBAAgB,EAO/C,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { InputSkeletonProps } from '@os-design/core';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
export type EditorSkeletonProps = InputSkeletonProps;
|
|
4
4
|
declare const EditorSkeleton: React.ForwardRefExoticComponent<Omit<import("@os-design/core").SkeletonProps, "width"> & import("@os-design/styles").WithSize & React.RefAttributes<HTMLDivElement>>;
|
|
5
5
|
export default EditorSkeleton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/EditorSkeleton/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/EditorSkeleton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AASrD,QAAA,MAAM,cAAc,sKAEnB,CAAC;AAIF,eAAe,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.202",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@os-design/core": "^1.0.
|
|
33
|
-
"@os-design/icons": "^1.0.
|
|
34
|
-
"@os-design/styles": "^1.0.
|
|
35
|
-
"@os-design/theming": "^1.0.
|
|
36
|
-
"@os-design/utils": "^1.0.
|
|
32
|
+
"@os-design/core": "^1.0.197",
|
|
33
|
+
"@os-design/icons": "^1.0.47",
|
|
34
|
+
"@os-design/styles": "^1.0.44",
|
|
35
|
+
"@os-design/theming": "^1.0.42",
|
|
36
|
+
"@os-design/utils": "^1.0.60",
|
|
37
37
|
"draft-js": "^0.11.7"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"react": ">=18",
|
|
50
50
|
"react-dom": ">=18"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "0e88d3afc41e36cee61222a039ef1aa4d08115b5"
|
|
53
53
|
}
|