@os-design/editor 1.0.197 → 1.0.199
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReturnHandler.js","names":["useReturnHandler","onChange","handler","useCallback","e","editorState","currentBlock","getCurrentBlock","currentBlockType","getType","startsWith","nextEditorState","addNewBlockAt","getKey"],"sources":["../../../../src/Editor/hooks/useReturnHandler.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { EditorProps as DraftEditorProps, EditorState } from 'draft-js';\nimport getCurrentBlock from '../utils/getCurrentBlock';\nimport addNewBlockAt from '../utils/addNewBlockAt';\n\ntype UseReturnHandlerRes =
|
|
1
|
+
{"version":3,"file":"useReturnHandler.js","names":["useReturnHandler","onChange","handler","useCallback","e","editorState","currentBlock","getCurrentBlock","currentBlockType","getType","startsWith","nextEditorState","addNewBlockAt","getKey"],"sources":["../../../../src/Editor/hooks/useReturnHandler.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { EditorProps as DraftEditorProps, EditorState } from 'draft-js';\nimport getCurrentBlock from '../utils/getCurrentBlock';\nimport addNewBlockAt from '../utils/addNewBlockAt';\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":";;;;;;AAAA;AAEA;AACA;AAAmD;AAInD;AACA;AACA;AACA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAgB,CACpBC,QAAsC,EACtCC,OAA4B;EAAA,OAE5B,IAAAC,kBAAW,EACT,UAACC,CAAC,EAAEC,WAAW,EAAK;IAClB,IAAMC,YAAY,GAAG,IAAAC,2BAAe,EAACF,WAAW,CAAC;IACjD,IAAMG,gBAAgB,GAAGF,YAAY,CAACG,OAAO,EAAE;IAE/C,IACED,gBAAgB,CAACE,UAAU,CAAC,QAAQ,CAAC,IACrCF,gBAAgB,CAACE,UAAU,CAAC,QAAQ,CAAC,EACrC;MACA,IAAMC,eAAe,GAAG,IAAAC,yBAAa,EACnCP,WAAW,EACXC,YAAY,CAACO,MAAM,EAAE,CACtB;MACDZ,QAAQ,CAACU,eAAe,CAAC;MACzB,OAAO,SAAS;IAClB;IAEA,OAAOT,OAAO,CAACE,CAAC,EAAEC,WAAW,CAAC;EAChC,CAAC,EACD,CAACJ,QAAQ,EAAEC,OAAO,CAAC,CACpB;AAAA;AAAC,eAEWF,gBAAgB;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReturnHandler.js","names":["useCallback","getCurrentBlock","addNewBlockAt","useReturnHandler","onChange","handler","e","editorState","currentBlock","currentBlockType","getType","startsWith","nextEditorState","getKey"],"sources":["../../../../src/Editor/hooks/useReturnHandler.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { EditorProps as DraftEditorProps, EditorState } from 'draft-js';\nimport getCurrentBlock from '../utils/getCurrentBlock';\nimport addNewBlockAt from '../utils/addNewBlockAt';\n\ntype UseReturnHandlerRes =
|
|
1
|
+
{"version":3,"file":"useReturnHandler.js","names":["useCallback","getCurrentBlock","addNewBlockAt","useReturnHandler","onChange","handler","e","editorState","currentBlock","currentBlockType","getType","startsWith","nextEditorState","getKey"],"sources":["../../../../src/Editor/hooks/useReturnHandler.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { EditorProps as DraftEditorProps, EditorState } from 'draft-js';\nimport getCurrentBlock from '../utils/getCurrentBlock';\nimport addNewBlockAt from '../utils/addNewBlockAt';\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":"AAAA,SAASA,WAAW,QAAQ,OAAO;AAEnC,OAAOC,eAAe,MAAM,0BAA0B;AACtD,OAAOC,aAAa,MAAM,wBAAwB;AAIlD;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,CACvBC,QAAsC,EACtCC,OAA4B,KAE5BL,WAAW,CACT,CAACM,CAAC,EAAEC,WAAW,KAAK;EAClB,MAAMC,YAAY,GAAGP,eAAe,CAACM,WAAW,CAAC;EACjD,MAAME,gBAAgB,GAAGD,YAAY,CAACE,OAAO,EAAE;EAE/C,IACED,gBAAgB,CAACE,UAAU,CAAC,QAAQ,CAAC,IACrCF,gBAAgB,CAACE,UAAU,CAAC,QAAQ,CAAC,EACrC;IACA,MAAMC,eAAe,GAAGV,aAAa,CACnCK,WAAW,EACXC,YAAY,CAACK,MAAM,EAAE,CACtB;IACDT,QAAQ,CAACQ,eAAe,CAAC;IACzB,OAAO,SAAS;EAClB;EAEA,OAAOP,OAAO,CAACC,CAAC,EAAEC,WAAW,CAAC;AAChC,CAAC,EACD,CAACH,QAAQ,EAAEC,OAAO,CAAC,CACpB;AAEH,eAAeF,gBAAgB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditorProps as DraftEditorProps, EditorState } from 'draft-js';
|
|
2
|
-
type UseReturnHandlerRes =
|
|
2
|
+
type UseReturnHandlerRes = NonNullable<DraftEditorProps['handleReturn']>;
|
|
3
3
|
declare const useReturnHandler: (onChange: (value: EditorState) => void, handler: UseReturnHandlerRes) => UseReturnHandlerRes;
|
|
4
4
|
export default useReturnHandler;
|
|
5
5
|
//# sourceMappingURL=useReturnHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReturnHandler.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/useReturnHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIxE,KAAK,mBAAmB,GAAG,
|
|
1
|
+
{"version":3,"file":"useReturnHandler.d.ts","sourceRoot":"","sources":["../../../../src/Editor/hooks/useReturnHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIxE,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.199",
|
|
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.194",
|
|
33
33
|
"@os-design/icons": "^1.0.46",
|
|
34
34
|
"@os-design/styles": "^1.0.43",
|
|
35
35
|
"@os-design/theming": "^1.0.41",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"react": ">=18",
|
|
50
50
|
"react-dom": ">=18"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "873d6653d3784b53dca629e44d71d68ded6acb74"
|
|
53
53
|
}
|