@automerge/automerge
Advanced tools
Comparing version 2.1.9 to 2.1.10-alpha.1
@@ -182,2 +182,40 @@ /** | ||
/** | ||
* Update the value of a string | ||
* | ||
* @typeParam T - The type of the value contained in the document | ||
* @param doc - The document to modify | ||
* @param path - The path to the string to modify | ||
* @param newText - The new text to update the value to | ||
* | ||
* @remarks | ||
* This will calculate a diff between the current value and the new value and | ||
* then convert that diff into calls to {@link splice}. This will produce results | ||
* which don't merge as well as directly capturing the user input actions, but | ||
* sometimes it's not possible to capture user input and this is the best you | ||
* can do. | ||
* | ||
* This is an experimental API and may change in the future. | ||
* | ||
* @beta | ||
*/ | ||
export function updateText(doc, path, newText) { | ||
if (!_is_proxy(doc)) { | ||
throw new RangeError("object cannot be modified outside of a change block"); | ||
} | ||
const state = _state(doc, false); | ||
const objectId = _obj(doc); | ||
if (!objectId) { | ||
throw new RangeError("invalid object for updateText"); | ||
} | ||
_clear_cache(doc); | ||
path.unshift(objectId); | ||
const value = path.join("/"); | ||
try { | ||
return state.handle.updateText(value, newText); | ||
} | ||
catch (e) { | ||
throw new RangeError(`Cannot updateText: ${e}`); | ||
} | ||
} | ||
/** | ||
* Returns a cursor for the given position in a string. | ||
@@ -184,0 +222,0 @@ * |
@@ -146,2 +146,22 @@ /** | ||
/** | ||
* Update the value of a string | ||
* | ||
* @typeParam T - The type of the value contained in the document | ||
* @param doc - The document to modify | ||
* @param path - The path to the string to modify | ||
* @param newText - The new text to update the value to | ||
* | ||
* @remarks | ||
* This will calculate a diff between the current value and the new value and | ||
* then convert that diff into calls to {@link splice}. This will produce results | ||
* which don't merge as well as directly capturing the user input actions, but | ||
* sometimes it's not possible to capture user input and this is the best you | ||
* can do. | ||
* | ||
* This is an experimental API and may change in the future. | ||
* | ||
* @beta | ||
*/ | ||
export declare function updateText(doc: Doc<unknown>, path: stable.Prop[], newText: string): void; | ||
/** | ||
* Returns a cursor for the given position in a string. | ||
@@ -148,0 +168,0 @@ * |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "2.1.9", | ||
"version": "2.1.10-alpha.1", | ||
"description": "Javascript implementation of automerge, backed by @automerge/automerge-wasm", | ||
@@ -74,5 +74,5 @@ "homepage": "https://github.com/automerge/automerge/tree/main/javascript", | ||
"dependencies": { | ||
"@automerge/automerge-wasm": "0.7.0", | ||
"@automerge/automerge-wasm": "0.8.0", | ||
"uuid": "^9.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
425159
13563
1
+ Added@automerge/automerge-wasm@0.8.0(transitive)
- Removed@automerge/automerge-wasm@0.7.0(transitive)