* @param rpos
(rpos: Y.RelativePosition | Object)
| 52 | * @param rpos |
| 53 | */ |
| 54 | fromYPos(rpos: Y.RelativePosition | Object) { |
| 55 | if (!this.ytext.doc) throw new Error('Document not attached') |
| 56 | const pos = Y.createAbsolutePositionFromRelativePosition( |
| 57 | Y.createRelativePositionFromJSON(rpos), |
| 58 | this.ytext.doc, |
| 59 | ) |
| 60 | if (pos == null || pos.type !== this.ytext) { |
| 61 | throw new Error( |
| 62 | '[yCodeblockPlugins]] The position you want to retrieve was created by a different document', |
| 63 | ) |
| 64 | } |
| 65 | return { |
| 66 | pos: pos.index, |
| 67 | assoc: pos.assoc, |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * @param range |