@os-design/editor 1.0.160 → 1.0.161
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/Editor/BlockToolbar.js +4 -18
- package/dist/cjs/Editor/BlockToolbar.js.map +1 -1
- package/dist/cjs/Editor/StyleToolbar.js +6 -23
- package/dist/cjs/Editor/StyleToolbar.js.map +1 -1
- package/dist/cjs/Editor/Toolbar.js +0 -7
- package/dist/cjs/Editor/Toolbar.js.map +1 -1
- package/dist/cjs/Editor/ToolbarButton.js +2 -21
- package/dist/cjs/Editor/ToolbarButton.js.map +1 -1
- package/dist/cjs/Editor/blocks/Figure.js +0 -6
- package/dist/cjs/Editor/blocks/Figure.js.map +1 -1
- package/dist/cjs/Editor/blocks/FigureCaption.js +0 -7
- package/dist/cjs/Editor/blocks/FigureCaption.js.map +1 -1
- package/dist/cjs/Editor/blocks/imageBlock.js +12 -62
- package/dist/cjs/Editor/blocks/imageBlock.js.map +1 -1
- package/dist/cjs/Editor/blocks/videoBlock.js +4 -22
- package/dist/cjs/Editor/blocks/videoBlock.js.map +1 -1
- package/dist/cjs/Editor/decorators/linkDecorator.js +3 -9
- package/dist/cjs/Editor/decorators/linkDecorator.js.map +1 -1
- package/dist/cjs/Editor/hooks/useBlockToolbarProps.js +14 -32
- package/dist/cjs/Editor/hooks/useBlockToolbarProps.js.map +1 -1
- package/dist/cjs/Editor/hooks/usePastedTextHandler.js +0 -9
- package/dist/cjs/Editor/hooks/usePastedTextHandler.js.map +1 -1
- package/dist/cjs/Editor/hooks/useReturnHandler.js +0 -8
- package/dist/cjs/Editor/hooks/useReturnHandler.js.map +1 -1
- package/dist/cjs/Editor/hooks/useStyleToolbarProps.js +16 -29
- package/dist/cjs/Editor/hooks/useStyleToolbarProps.js.map +1 -1
- package/dist/cjs/Editor/index.js +41 -76
- package/dist/cjs/Editor/index.js.map +1 -1
- package/dist/cjs/Editor/styles/defaultDraftJsStyles.js +0 -4
- package/dist/cjs/Editor/styles/defaultDraftJsStyles.js.map +1 -1
- package/dist/cjs/Editor/styles/overrideDraftJsStyles.js +0 -6
- package/dist/cjs/Editor/styles/overrideDraftJsStyles.js.map +1 -1
- package/dist/cjs/Editor/utils/addNewBlockAt.js +0 -5
- package/dist/cjs/Editor/utils/addNewBlockAt.js.map +1 -1
- package/dist/cjs/Editor/utils/changeBlock.js +0 -3
- package/dist/cjs/Editor/utils/changeBlock.js.map +1 -1
- package/dist/cjs/Editor/utils/createContentEditorState.js +0 -5
- package/dist/cjs/Editor/utils/createContentEditorState.js.map +1 -1
- package/dist/cjs/Editor/utils/createDecorator.js +0 -5
- package/dist/cjs/Editor/utils/createDecorator.js.map +1 -1
- package/dist/cjs/Editor/utils/createEmptyEditorState.js +0 -5
- package/dist/cjs/Editor/utils/createEmptyEditorState.js.map +1 -1
- package/dist/cjs/Editor/utils/defaultStyleToolbarItems.js +0 -7
- package/dist/cjs/Editor/utils/defaultStyleToolbarItems.js.map +1 -1
- package/dist/cjs/Editor/utils/getCurrentBlock.js +0 -2
- package/dist/cjs/Editor/utils/getCurrentBlock.js.map +1 -1
- package/dist/cjs/Editor/utils/getSelectedBlockElement.js +0 -6
- package/dist/cjs/Editor/utils/getSelectedBlockElement.js.map +1 -1
- package/dist/cjs/Editor/utils/getSelectionRange.js +0 -2
- package/dist/cjs/Editor/utils/getSelectionRange.js.map +1 -1
- package/dist/cjs/Editor/utils/setLink.js +0 -6
- package/dist/cjs/Editor/utils/setLink.js.map +1 -1
- package/dist/cjs/Editor/utils/transformers.js +0 -4
- package/dist/cjs/Editor/utils/transformers.js.map +1 -1
- package/dist/cjs/Editor/utils/unsetLink.js +0 -4
- package/dist/cjs/Editor/utils/unsetLink.js.map +1 -1
- package/dist/cjs/EditorSkeleton/index.js +1 -12
- package/dist/cjs/EditorSkeleton/index.js.map +1 -1
- package/dist/cjs/index.js +0 -21
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/Editor/BlockToolbar.js +0 -2
- package/dist/esm/Editor/BlockToolbar.js.map +1 -1
- package/dist/esm/Editor/StyleToolbar.js +2 -5
- package/dist/esm/Editor/StyleToolbar.js.map +1 -1
- package/dist/esm/Editor/Toolbar.js.map +1 -1
- package/dist/esm/Editor/ToolbarButton.js +0 -5
- package/dist/esm/Editor/ToolbarButton.js.map +1 -1
- package/dist/esm/Editor/blocks/Figure.js.map +1 -1
- package/dist/esm/Editor/blocks/FigureCaption.js.map +1 -1
- package/dist/esm/Editor/blocks/imageBlock.js +9 -15
- package/dist/esm/Editor/blocks/imageBlock.js.map +1 -1
- package/dist/esm/Editor/blocks/videoBlock.js +0 -5
- 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 +0 -6
- package/dist/esm/Editor/hooks/useBlockToolbarProps.js.map +1 -1
- package/dist/esm/Editor/hooks/usePastedTextHandler.js +0 -4
- package/dist/esm/Editor/hooks/usePastedTextHandler.js.map +1 -1
- package/dist/esm/Editor/hooks/useReturnHandler.js +0 -4
- package/dist/esm/Editor/hooks/useReturnHandler.js.map +1 -1
- package/dist/esm/Editor/hooks/useStyleToolbarProps.js +5 -6
- package/dist/esm/Editor/hooks/useStyleToolbarProps.js.map +1 -1
- package/dist/esm/Editor/index.js +10 -10
- package/dist/esm/Editor/index.js.map +1 -1
- package/dist/esm/Editor/styles/defaultDraftJsStyles.js +1 -1
- package/dist/esm/Editor/styles/defaultDraftJsStyles.js.map +1 -1
- package/dist/esm/Editor/styles/overrideDraftJsStyles.js +2 -2
- package/dist/esm/Editor/styles/overrideDraftJsStyles.js.map +1 -1
- package/dist/esm/Editor/utils/addNewBlockAt.js +0 -2
- package/dist/esm/Editor/utils/addNewBlockAt.js.map +1 -1
- package/dist/esm/Editor/utils/changeBlock.js +0 -2
- package/dist/esm/Editor/utils/changeBlock.js.map +1 -1
- package/dist/esm/Editor/utils/createContentEditorState.js +0 -2
- package/dist/esm/Editor/utils/createContentEditorState.js.map +1 -1
- package/dist/esm/Editor/utils/createDecorator.js +0 -2
- package/dist/esm/Editor/utils/createDecorator.js.map +1 -1
- package/dist/esm/Editor/utils/createEmptyEditorState.js +0 -2
- package/dist/esm/Editor/utils/createEmptyEditorState.js.map +1 -1
- package/dist/esm/Editor/utils/defaultStyleToolbarItems.js.map +1 -1
- package/dist/esm/Editor/utils/getCurrentBlock.js +0 -1
- package/dist/esm/Editor/utils/getCurrentBlock.js.map +1 -1
- package/dist/esm/Editor/utils/getSelectedBlockElement.js +0 -4
- package/dist/esm/Editor/utils/getSelectedBlockElement.js.map +1 -1
- package/dist/esm/Editor/utils/getSelectionRange.js +0 -1
- package/dist/esm/Editor/utils/getSelectionRange.js.map +1 -1
- package/dist/esm/Editor/utils/setLink.js +0 -2
- 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 +0 -2
- package/dist/esm/Editor/utils/unsetLink.js.map +1 -1
- package/dist/esm/EditorSkeleton/index.js +1 -2
- package/dist/esm/EditorSkeleton/index.js.map +1 -1
- package/dist/esm/emotion.d.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -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,
|
|
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,GAAG,MAC7BF,WAAW,CAACG,WAAW,CAACF,eAAe,EAAE,CAAC;AAE5C,eAAeC,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultStyleToolbarItems.js","names":["React","styled","Bold","FontSize","OrderedList","UnorderedList","Link","LinkIcon","FontSizeSmall","defaultStyleToolbarItems","name","type","icon"],"sources":["../../../../src/Editor/utils/defaultStyleToolbarItems.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport {\n Bold,\n FontSize,\n OrderedList,\n UnorderedList,\n Link as LinkIcon,\n} from '@os-design/icons';\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,
|
|
1
|
+
{"version":3,"file":"defaultStyleToolbarItems.js","names":["React","styled","Bold","FontSize","OrderedList","UnorderedList","Link","LinkIcon","FontSizeSmall","defaultStyleToolbarItems","name","type","icon"],"sources":["../../../../src/Editor/utils/defaultStyleToolbarItems.tsx"],"sourcesContent":["import React from 'react';\nimport styled from '@emotion/styled';\nimport {\n Bold,\n FontSize,\n OrderedList,\n UnorderedList,\n Link as LinkIcon,\n} from '@os-design/icons';\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,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SACEC,IAAI,EACJC,QAAQ,EACRC,WAAW,EACXC,aAAa,EACbC,IAAI,IAAIC,QAAQ,QACX,kBAAkB;AAQzB,MAAMC,aAAa,GAAGP,MAAM,CAACE,QAAQ,CAAE;AACvC;AACA,CAAC;AAED,MAAMM,wBAA4C,GAAG,CACnD;EAAEC,IAAI,EAAE,YAAY;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAE,oBAAC,QAAQ;AAAI,CAAC,EACzD;EAAEF,IAAI,EAAE,cAAc;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAE,oBAAC,aAAa;AAAI,CAAC,EAChE;EAAEF,IAAI,EAAE,MAAM;EAAEC,IAAI,EAAE,QAAQ;EAAEC,IAAI,eAAE,oBAAC,IAAI;AAAI,CAAC,EAChD;EAAEF,IAAI,EAAE,qBAAqB;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAE,oBAAC,aAAa;AAAI,CAAC,EACvE;EAAEF,IAAI,EAAE,mBAAmB;EAAEC,IAAI,EAAE,OAAO;EAAEC,IAAI,eAAE,oBAAC,WAAW;AAAI,CAAC,EACnE;EAAEF,IAAI,EAAE,MAAM;EAAEC,IAAI,EAAE,QAAQ;EAAEC,IAAI,eAAE,oBAAC,QAAQ;AAAI,CAAC,CACrD;AAED,eAAeH,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,
|
|
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,EAAE;EACjD,MAAMC,YAAY,GAAGH,WAAW,CAACI,iBAAiB,EAAE;EACpD,OAAOD,YAAY,CAACE,cAAc,CAACJ,cAAc,CAACK,WAAW,EAAE,CAAC;AAClE,CAAC;AAED,eAAeP,eAAe"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import getSelectionRange from './getSelectionRange';
|
|
2
|
-
|
|
3
2
|
const getSelectedBlockElement = () => {
|
|
4
3
|
const selectionRange = getSelectionRange();
|
|
5
4
|
if (!selectionRange) return null;
|
|
6
5
|
let node = selectionRange.startContainer;
|
|
7
|
-
|
|
8
6
|
do {
|
|
9
7
|
if (node instanceof Element && node.getAttribute('data-block') === 'true') return node;
|
|
10
8
|
node = node.parentNode;
|
|
11
9
|
} while (node != null);
|
|
12
|
-
|
|
13
10
|
return null;
|
|
14
11
|
};
|
|
15
|
-
|
|
16
12
|
export default getSelectedBlockElement;
|
|
17
13
|
//# sourceMappingURL=getSelectedBlockElement.js.map
|
|
@@ -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,
|
|
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,GAAG,MAAsB;EACpD,MAAMC,cAAc,GAAGF,iBAAiB,EAAE;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,GAAG,MAAoB;EAC5C,MAAMC,SAAS,GAAGC,QAAQ,CAACC,
|
|
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,GAAG,MAAoB;EAC5C,MAAMC,SAAS,GAAGC,QAAQ,CAACC,YAAY,EAAE;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,5 +1,4 @@
|
|
|
1
1
|
import { EditorState, RichUtils } from 'draft-js';
|
|
2
|
-
|
|
3
2
|
const setLink = (editorState, url) => {
|
|
4
3
|
const containsLink = RichUtils.currentBlockContainsLink(editorState);
|
|
5
4
|
if (containsLink) return editorState;
|
|
@@ -13,6 +12,5 @@ const setLink = (editorState, url) => {
|
|
|
13
12
|
});
|
|
14
13
|
return RichUtils.toggleLink(nextEditorState, nextEditorState.getSelection(), entityKey);
|
|
15
14
|
};
|
|
16
|
-
|
|
17
15
|
export default setLink;
|
|
18
16
|
//# sourceMappingURL=setLink.js.map
|
|
@@ -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,
|
|
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,GAAG,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,EAAE;EACpD,MAAMC,oBAAoB,GAAGF,YAAY,CAACG,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE;IACxEN;EACF,CAAC,CAAC;EACF,MAAMO,SAAS,GAAGF,oBAAoB,CAACG,uBAAuB,EAAE;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,EAAE,EAC9BN,SAAS,CACV;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,
|
|
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,EAAE,CACnBC,gBAAgB,EAAE,CAClBC,IAAI,CAAEC,KAAK,IAAKA,KAAK,CAACC,OAAO,EAAE,KAAK,UAAU,CAAC;EAElD,OAAOL,kBAAkB,GAAGA,kBAAkB,CAACM,OAAO,EAAE,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,EAAE"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { RichUtils } from 'draft-js';
|
|
2
|
-
|
|
3
2
|
const unsetLink = editorState => {
|
|
4
3
|
const containsLink = RichUtils.currentBlockContainsLink(editorState);
|
|
5
4
|
if (!containsLink) return editorState;
|
|
6
5
|
const selectionState = editorState.getSelection();
|
|
7
6
|
return RichUtils.toggleLink(editorState, selectionState, null);
|
|
8
7
|
};
|
|
9
|
-
|
|
10
8
|
export default unsetLink;
|
|
11
9
|
//# sourceMappingURL=unsetLink.js.map
|
|
@@ -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,
|
|
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,EAAE;EACjD,OAAON,SAAS,CAACO,UAAU,CAACL,WAAW,EAAEG,cAAc,EAAE,IAAI,CAAC;AAChE,CAAC;AAED,eAAeJ,SAAS"}
|
|
@@ -1,15 +1,14 @@
|
|
|
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
|
-
|
|
3
2
|
import styled from '@emotion/styled';
|
|
4
3
|
import React, { forwardRef } from 'react';
|
|
5
4
|
import { InputSkeleton } from '@os-design/core';
|
|
6
5
|
const StyledEditorSkeleton = styled(InputSkeleton)`
|
|
7
6
|
height: ${p => p.theme.editorMinHeight}em;
|
|
8
7
|
`;
|
|
8
|
+
|
|
9
9
|
/**
|
|
10
10
|
* Provides an editor placeholder while a user waits for the content to load.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
12
|
const EditorSkeleton = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/React.createElement(StyledEditorSkeleton, _extends({}, props, {
|
|
14
13
|
ref: ref
|
|
15
14
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["styled","React","forwardRef","InputSkeleton","StyledEditorSkeleton","p","theme","editorMinHeight","EditorSkeleton","props","ref","displayName"],"sources":["../../../src/EditorSkeleton/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport React, { forwardRef } from 'react';\nimport { InputSkeleton, InputSkeletonProps } from '@os-design/core';\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":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["styled","React","forwardRef","InputSkeleton","StyledEditorSkeleton","p","theme","editorMinHeight","EditorSkeleton","props","ref","displayName"],"sources":["../../../src/EditorSkeleton/index.tsx"],"sourcesContent":["import styled from '@emotion/styled';\nimport React, { forwardRef } from 'react';\nimport { InputSkeleton, InputSkeletonProps } from '@os-design/core';\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;AACpC,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,aAAa,QAA4B,iBAAiB;AAInE,MAAMC,oBAAoB,GAAGJ,MAAM,CAACG,aAAa,CAAE;AACnD,YAAaE,CAAC,IAAKA,CAAC,CAACC,KAAK,CAACC,eAAgB;AAC3C,CAAC;;AAED;AACA;AACA;AACA,MAAMC,cAAc,gBAAGN,UAAU,CAC/B,CAACO,KAAK,EAAEC,GAAG,kBAAK,oBAAC,oBAAoB,eAAKD,KAAK;EAAE,GAAG,EAAEC;AAAI,GAAG,CAC9D;AAEDF,cAAc,CAACG,WAAW,GAAG,gBAAgB;AAE7C,eAAeH,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emotion.d.js","names":[],"sources":["../../src/emotion.d.ts"],"sourcesContent":["import '@emotion/react';\nimport { Theme as BaseTheme } from '@os-design/theming';\n\ndeclare module '@emotion/react' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface Theme extends BaseTheme {}\n}\n"],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"emotion.d.js","names":[],"sources":["../../src/emotion.d.ts"],"sourcesContent":["import '@emotion/react';\nimport { Theme as BaseTheme } from '@os-design/theming';\n\ndeclare module '@emotion/react' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface Theme extends BaseTheme {}\n}\n"],"mappings":"AAAA,OAAO,gBAAgB"}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","Editor","addNewBlockAt","changeBlock","createContentEditorState","createDecorator","createEmptyEditorState","defaultStyleToolbarItems","getCurrentBlock","imageBlock","videoBlock","EditorSkeleton"],"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,SAASA,OAAO,IAAIC,
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","Editor","addNewBlockAt","changeBlock","createContentEditorState","createDecorator","createEmptyEditorState","defaultStyleToolbarItems","getCurrentBlock","imageBlock","videoBlock","EditorSkeleton"],"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,SAASA,OAAO,IAAIC,MAAM,QAAQ,UAAU;AAC5C,SAASD,OAAO,IAAIE,aAAa,QAAQ,8BAA8B;AACvE,SAASF,OAAO,IAAIG,WAAW,QAAQ,4BAA4B;AACnE,SAASH,OAAO,IAAII,wBAAwB,QAAQ,yCAAyC;AAC7F,SAASJ,OAAO,IAAIK,eAAe,QAAQ,gCAAgC;AAC3E,SAASL,OAAO,IAAIM,sBAAsB,QAAQ,uCAAuC;AACzF,SAASN,OAAO,IAAIO,wBAAwB,QAAQ,yCAAyC;AAC7F,SAASP,OAAO,IAAIQ,eAAe,QAAQ,gCAAgC;AAC3E,SAASR,OAAO,IAAIS,UAAU,QAAQ,4BAA4B;AAClE,SAAST,OAAO,IAAIU,UAAU,QAAQ,4BAA4B;AAClE,SAASV,OAAO,IAAIW,cAAc,QAAQ,kBAAkB;AAE5D,cAAc,UAAU;AACxB,cAAc,6BAA6B;AAC3C,cAAc,uBAAuB;AACrC,cAAc,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.161",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@os-design/core": "^1.0.
|
|
32
|
+
"@os-design/core": "^1.0.157",
|
|
33
33
|
"@os-design/icons": "^1.0.41",
|
|
34
34
|
"@os-design/styles": "^1.0.39",
|
|
35
35
|
"@os-design/theming": "^1.0.37",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"react": ">=18",
|
|
50
50
|
"react-dom": ">=18"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "e884ebba49c0d56a0a6adff6eb9f0f9530a29ab5"
|
|
53
53
|
}
|