Skip to content

Conditionally load MarkNodes #2641

Answered by 6peterlu
6peterlu asked this question in Q&A
Discussion options

You must be logged in to vote

Was able to save the relevant fields of a selection to a JSON with the following format:

const SELECTION_FIELDS = {
  focus: { key: '2', offset: 56, type: 'text' },
  anchor: { key: '2', offset: 72, type: 'text' },
  isBackward: true,
  id: '0a44d86f-fec1-4628-ad2c-ff7874f16f5b',
  format: 0
};

Then create the RangeSelection object with the $createRangeSelection function:

  const rangeSelection = $createRangeSelection();
  rangeSelection.anchor.key =
    TEST_SELECTION_DATA.anchor.key;
  rangeSelection.anchor.offset =
    TEST_SELECTION_DATA.anchor.offset;
  rangeSelection.anchor.type = 'text';
  rangeSelection.focus.key = TEST_SELECTION_DATA.focus.key;
  rangeSelection.focus.offset =
  …

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by 6peterlu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant