public string NewItem(NotebookItemType type, string name = null, string data = null) { var existingNames = Notebook.UserData.Items.Select(x => x.Name.ToLowerInvariant()).ToHashSet(); if (name == null) { int i; for (i = 1; existingNames.Contains($"{type.ToString().ToLowerInvariant()}{i}"); i++) { } name = $"{type}{i}"; } else if (existingNames.Contains(name.ToLowerInvariant())) { throw new Exception($"There is already a notebook item named \"{name}\"."); } switch (type) { case NotebookItemType.Page: Notebook.UserData.Items.Add(new PageNotebookItemRecord { Name = name, Blocks = new(), }); break;
public NotebookItem(NotebookItemType type, string name, bool isVirtualTable = false) { Type = type; Name = name; IsVirtualTable = isVirtualTable; }
private static int GetOrder(NotebookItemType t) => t switch {