More powerful selection

Ie multi cell and section selection.

Experiments

jspluginid=selectiontype=menu
export const menu = (ctx, { React, Menu }) => {
  const { filter, select, selectPosition } = lit.utils.unist;
  const rc = React.createElement;

  const secFromCell = (pos) => {
    const secs = selectPosition.selectAll("section", ctx.selectedCell, lit.ast);
    const last = secs.slice(-1)[0];
    console.log("Sections", secs, last);
    return last.position;
  };

  const selectAll = rc(
    "span",
    { onClick: () => ctx.setSelectedCell(lit.ast.position) },
    "Select All"
  );

  const selectSec = rc(
    "span",
    {
      onClick: () => {
        ctx.setSelectedCell(secFromCell(ctx.selectedCell));
      },
    },
    "Select Section"
  );

  return rc(
    Menu,
    {
      title: "Selection",
      disabled: false,
    },
    [selectAll, selectSec]
  );
};

js
const {filter, select, selectPosition} = lit.utils.unist
const is = t => node => {
  console.log(node.type)
  return node.type === t
}

// return lit.ast
// return filter.toString()
// filter(lit.ast, {cascade: false } , is('heading'))
return selectPosition
txtUpdated 59.7w ago
{ atPos: [Getter], selectAll: [Getter] }