@remirror/core-utils
Advanced tools
Comparing version 0.0.0-pr1713.12 to 0.0.0-pr1801.1
@@ -455,3 +455,6 @@ import { RemirrorIdentifier } from '@remirror/core-constants'; | ||
/** | ||
* Retrieves the document and throws an error in a non-browser environment. | ||
* Retrieves the document from global scope and throws an error in a non-browser | ||
* environment. | ||
* | ||
* @internal | ||
*/ | ||
@@ -458,0 +461,0 @@ export declare function getDocument(): Document; |
@@ -130,2 +130,4 @@ import type { AttributesProps, EditorSchema, EditorState, EditorView, Fragment, KeyBindingCommandFunction, KeyBindings, Mark, MarkTypesProps, NodeTypeProps, NodeTypesProps, OptionalMarkProps, OptionalProsemirrorNodeProps, PosProps, ProsemirrorAttributes, ProsemirrorKeyBindings, ProsemirrorNode, ProsemirrorNodeProps, ResolvedPos, Selection, SelectionProps, Transaction, TransactionProps } from '@remirror/core-types'; | ||
* @param selection - the prosemirror selection | ||
* | ||
* @deprecated This util is hard to use and not that useful | ||
*/ | ||
@@ -143,2 +145,4 @@ export declare function findPositionOfNodeBefore(value: Selection | ResolvedPos | EditorState | Transaction): FindProsemirrorNodeResult | undefined; | ||
* @param tr | ||
* | ||
* @deprecated This util is hard to use and not that useful | ||
*/ | ||
@@ -198,2 +202,4 @@ export declare function removeNodeBefore(tr: Transaction): Transaction; | ||
* @param selection - the prosemirror selection | ||
* | ||
* @deprecated This util is hard to use and not that useful | ||
*/ | ||
@@ -209,2 +215,4 @@ export declare function findPositionOfNodeAfter(value: Selection | ResolvedPos | EditorState): FindProsemirrorNodeResult | undefined; | ||
* @param tr | ||
* | ||
* @deprecated This util is hard to use and not that useful | ||
*/ | ||
@@ -211,0 +219,0 @@ export declare function removeNodeAfter(tr: Transaction): Transaction; |
@@ -0,1 +1,9 @@ | ||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { | ||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b] | ||
}) : x)(function(x) { | ||
if (typeof require !== "undefined") | ||
return require.apply(this, arguments); | ||
throw new Error('Dynamic require of "' + x + '" is not supported'); | ||
}); | ||
// packages/remirror__core-utils/src/command-utils.ts | ||
@@ -868,3 +876,3 @@ import { ErrorConstant as ErrorConstant3 } from "@remirror/core-constants"; | ||
let { from, to } = state.selection; | ||
const getChar = (start, end) => getTextContentFromSlice(TextSelection.create(state.doc, start, end).content()); | ||
const getChar = (start, end) => getTextContentFromSlice(TextSelection.between(state.doc.resolve(start), state.doc.resolve(end)).content()); | ||
for (let char = getChar(from - 1, from); char && !exclude.test(char); from--, char = getChar(from - 1, from)) { | ||
@@ -945,7 +953,7 @@ } | ||
const head2 = clampToDocument(pos.head); | ||
return TextSelection.create(doc, anchor2, head2); | ||
return TextSelection.between(doc.resolve(anchor2), doc.resolve(head2)); | ||
} | ||
const anchor = clampToDocument(pos.from); | ||
const head = clampToDocument(pos.to); | ||
return TextSelection.create(doc, anchor, head); | ||
return TextSelection.between(doc.resolve(anchor), doc.resolve(head)); | ||
} | ||
@@ -997,3 +1005,16 @@ var MAX_ATTEMPTS = 3; | ||
} | ||
throw new Error("Unable to retrieve the document from the global scope. Maybe you are running Remirror in a non-browser environment? If you are using Node.js, you can install JSDOM or similar to create a fake document and pass that document to Remirror."); | ||
try { | ||
const { JSDOM } = __require("jsdom"); | ||
return new JSDOM().window.document; | ||
} catch { | ||
} | ||
try { | ||
return __require("domino").createDocument(); | ||
} catch { | ||
} | ||
try { | ||
return __require("min-document"); | ||
} catch { | ||
} | ||
throw new Error("Unable to retrieve the document from the global scope. Maybe you are running Remirror in a non-browser environment? If you are using Node.js, you can install JSDOM or similar to create a fake document and pass it to Remirror."); | ||
} | ||
@@ -1183,3 +1204,3 @@ function prosemirrorNodeToDom(node, document2 = getDocument()) { | ||
const { type, attrs = object2(), appendText, range } = props; | ||
const selection = range ? TextSelection2.create(tr.doc, range.from, range.to) : tr.selection; | ||
const selection = range ? TextSelection2.between(tr.doc.resolve(range.from), tr.doc.resolve(range.to)) : tr.selection; | ||
const { $from, from, to } = selection; | ||
@@ -1303,5 +1324,5 @@ let applicable = $from.depth === 0 ? tr.doc.type.allowsMarkType(type) : false; | ||
if (empty) { | ||
tr.setSelection(TextSelection2.create(tr.doc, head)); | ||
tr.setSelection(TextSelection2.near(tr.doc.resolve(head))); | ||
} else { | ||
tr.setSelection(TextSelection2.create(tr.doc, anchor, head)); | ||
tr.setSelection(TextSelection2.between(tr.doc.resolve(anchor), tr.doc.resolve(head))); | ||
} | ||
@@ -1308,0 +1329,0 @@ } |
{ | ||
"name": "@remirror/core-utils", | ||
"version": "0.0.0-pr1713.12", | ||
"version": "0.0.0-pr1801.1", | ||
"description": "Core utilities for dealing with the dom and prosemirror within remirror", | ||
@@ -34,6 +34,6 @@ "homepage": "https://github.com/remirror/remirror/tree/HEAD/packages/remirror__core-utils", | ||
"@babel/runtime": "^7.13.10", | ||
"@remirror/core-constants": "0.0.0-pr1713.12", | ||
"@remirror/core-helpers": "0.0.0-pr1713.12", | ||
"@remirror/core-types": "0.0.0-pr1713.12", | ||
"@remirror/messages": "0.0.0-pr1713.12", | ||
"@remirror/core-constants": "0.0.0-pr1801.1", | ||
"@remirror/core-helpers": "0.0.0-pr1801.1", | ||
"@remirror/core-types": "0.0.0-pr1801.1", | ||
"@remirror/messages": "0.0.0-pr1801.1", | ||
"@types/min-document": "^2.19.0", | ||
@@ -45,3 +45,3 @@ "css-in-js-utils": "^3.1.0", | ||
"devDependencies": { | ||
"@remirror/pm": "0.0.0-pr1713.12", | ||
"@remirror/pm": "0.0.0-pr1801.1", | ||
"@types/jsdom": "^16.2.13", | ||
@@ -53,3 +53,3 @@ "@types/node": "^16.3.3", | ||
"peerDependencies": { | ||
"@remirror/pm": "0.0.0-pr1713.12", | ||
"@remirror/pm": "0.0.0-pr1801.1", | ||
"@types/node": "*", | ||
@@ -56,0 +56,0 @@ "domino": "*", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
342403
3537
6
+ Added@remirror/core-constants@0.0.0-pr1801.1(transitive)
+ Added@remirror/core-helpers@0.0.0-pr1801.1(transitive)
+ Added@remirror/core-types@0.0.0-pr1801.1(transitive)
+ Added@remirror/messages@0.0.0-pr1801.1(transitive)
+ Added@remirror/pm@0.0.0-pr1801.1(transitive)
+ Added@remirror/types@0.0.0-pr1801.1(transitive)
+ Addedprosemirror-paste-rules@0.0.0-pr1801.1(transitive)
+ Addedprosemirror-suggest@0.0.0-pr1801.1(transitive)
+ Addedprosemirror-trailing-node@0.0.0-pr1801.1(transitive)
- Removed@remirror/core-constants@0.0.0-pr1713.12(transitive)
- Removed@remirror/core-helpers@0.0.0-pr1713.12(transitive)
- Removed@remirror/core-types@0.0.0-pr1713.12(transitive)
- Removed@remirror/messages@0.0.0-pr1713.12(transitive)
- Removed@remirror/pm@0.0.0-pr1713.12(transitive)
- Removed@remirror/types@0.0.0-pr1713.12(transitive)
- Removedprosemirror-paste-rules@0.0.0-pr1713.12(transitive)
- Removedprosemirror-suggest@0.0.0-pr1713.12(transitive)
- Removedprosemirror-trailing-node@0.0.0-pr1713.12(transitive)