diff options
| author | srichman333 <sarah_n_richman@brown.edu> | 2024-03-31 13:24:39 -0400 | 
|---|---|---|
| committer | srichman333 <sarah_n_richman@brown.edu> | 2024-03-31 13:24:39 -0400 | 
| commit | c254b38690e27b32d3ac6316af9bb37d6d3e86aa (patch) | |
| tree | 0f94869895530d5f8b16631aa164bbcf4cd3e9d4 /src/client/views/nodes/formattedText/RichTextMenu.tsx | |
| parent | 4c4ab22252aba8f08d8a384e2bd0c6696db9b43b (diff) | |
| parent | 1e37adacfe5b44a71ed7d7dfd785c6c2d0808eae (diff) | |
Merge branch 'master' into dataviz-ai-sarah
Diffstat (limited to 'src/client/views/nodes/formattedText/RichTextMenu.tsx')
| -rw-r--r-- | src/client/views/nodes/formattedText/RichTextMenu.tsx | 17 | 
1 files changed, 17 insertions, 0 deletions
diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx index dc2c06701..b5d0f28d8 100644 --- a/src/client/views/nodes/formattedText/RichTextMenu.tsx +++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx @@ -318,6 +318,23 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {          });      } +    elideSelection = (txstate: EditorState | undefined = undefined, visibility = false) => { +        const state = txstate ?? this.view?.state; +        if (!state || state.selection.empty) return false; +        const mark = state.schema.marks.summarize.create(); +        const tr = state.tr.addMark(state.tr.selection.from, state.selection.to, mark); +        const text = tr.selection.content(); +        const elideNode = state.schema.nodes.summary.create({ visibility, text, textslice: text.toJSON() }); +        const summary = tr.replaceSelectionWith(elideNode).removeMark(tr.selection.from - 1, tr.selection.from, mark); +        const expanded = () => { +            const endOfElidableText = summary.selection.to + text.content.size; +            const res = summary.insert(summary.selection.to, text.content).insert(endOfElidableText, state.schema.nodes.paragraph.create({})); +            return res.setSelection(new TextSelection(res.doc.resolve(endOfElidableText + 1))); +        }; +        this.view?.dispatch?.(visibility ? expanded() : summary); +        return true; +    }; +      toggleNoAutoLinkAnchor = () => {          if (this.view) {              const mark = this.view.state.schema.mark(this.view.state.schema.marks.noAutoLinkAnchor);  | 
