@bwthomas/outline-numbering 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tiptap.js ADDED
@@ -0,0 +1,145 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { PluginKey, Plugin } from 'prosemirror-state';
3
+ import { DecorationSet, Decoration } from 'prosemirror-view';
4
+
5
+ // src/tiptap.ts
6
+
7
+ // src/strategies.ts
8
+ function toRoman(n) {
9
+ const pairs = [
10
+ [1e3, "M"],
11
+ [900, "CM"],
12
+ [500, "D"],
13
+ [400, "CD"],
14
+ [100, "C"],
15
+ [90, "XC"],
16
+ [50, "L"],
17
+ [40, "XL"],
18
+ [10, "X"],
19
+ [9, "IX"],
20
+ [5, "V"],
21
+ [4, "IV"],
22
+ [1, "I"]
23
+ ];
24
+ let result = "";
25
+ for (const [value, symbol] of pairs) {
26
+ while (n >= value) {
27
+ result += symbol;
28
+ n -= value;
29
+ }
30
+ }
31
+ return result;
32
+ }
33
+ function toLetter(n, uppercase) {
34
+ let result = "";
35
+ while (n > 0) {
36
+ n--;
37
+ const base = uppercase ? 65 : 97;
38
+ result = String.fromCharCode(base + n % 26) + result;
39
+ n = Math.floor(n / 26);
40
+ }
41
+ return result;
42
+ }
43
+ var alphanumericStrategy = {
44
+ name: "alphanumeric",
45
+ format(counter, depth) {
46
+ const phase = depth % 4;
47
+ switch (phase) {
48
+ case 0:
49
+ return toRoman(counter) + ".";
50
+ case 1:
51
+ return toLetter(counter, true) + ".";
52
+ case 2:
53
+ return counter.toString() + ".";
54
+ case 3:
55
+ return toLetter(counter, false) + ".";
56
+ default:
57
+ return counter.toString() + ".";
58
+ }
59
+ }
60
+ };
61
+
62
+ // src/plugin.ts
63
+ var OUTLINE_NUMBERING_KEY = new PluginKey("outlineNumbering");
64
+ function outlineNumberingPlugin(options = {}) {
65
+ const strategy = options.strategy ?? alphanumericStrategy;
66
+ const descendThroughContainers = options.descendThroughContainers ?? true;
67
+ return new Plugin({
68
+ key: OUTLINE_NUMBERING_KEY,
69
+ state: {
70
+ init(_, { doc }) {
71
+ return computeDecorations(doc, strategy, descendThroughContainers);
72
+ },
73
+ apply(tr, decorationSet) {
74
+ if (tr.docChanged) {
75
+ return computeDecorations(tr.doc, strategy, descendThroughContainers);
76
+ }
77
+ return decorationSet.map(tr.mapping, tr.doc);
78
+ }
79
+ },
80
+ props: {
81
+ decorations(state) {
82
+ return this.getState(state);
83
+ }
84
+ }
85
+ });
86
+ }
87
+ function computeDecorations(doc, strategy, descendThroughContainers = true) {
88
+ const decorations = [];
89
+ function walk(node, pos, depth, insideListItem) {
90
+ if (node.type.name === "orderedList") {
91
+ walkOrderedList(node, pos, depth);
92
+ return;
93
+ }
94
+ if (insideListItem && !descendThroughContainers) return;
95
+ if (!node.isBlock || node.isLeaf) return;
96
+ const offset = pos + (node.type.name === "doc" ? 0 : 1);
97
+ let childOffset = 0;
98
+ node.forEach((child) => {
99
+ walk(child, offset + childOffset, depth, insideListItem);
100
+ childOffset += child.nodeSize;
101
+ });
102
+ }
103
+ function walkOrderedList(node, pos, depth) {
104
+ const offset = pos + 1;
105
+ let counter = 0;
106
+ let childOffset = 0;
107
+ node.forEach((child) => {
108
+ if (child.type.name !== "listItem") {
109
+ childOffset += child.nodeSize;
110
+ return;
111
+ }
112
+ counter++;
113
+ const itemPos = offset + childOffset;
114
+ decorations.push(
115
+ Decoration.node(itemPos, itemPos + child.nodeSize, {
116
+ "data-outline-depth": String(depth),
117
+ "data-outline-marker": strategy.format(counter, depth)
118
+ })
119
+ );
120
+ let grandOffset = itemPos + 1;
121
+ child.forEach((grandchild) => {
122
+ walk(grandchild, grandOffset, depth + 1, true);
123
+ grandOffset += grandchild.nodeSize;
124
+ });
125
+ childOffset += child.nodeSize;
126
+ });
127
+ }
128
+ walk(doc, 0, 0, false);
129
+ return DecorationSet.create(doc, decorations);
130
+ }
131
+
132
+ // src/tiptap.ts
133
+ var OutlineNumbering = Extension.create({
134
+ name: "outlineNumbering",
135
+ addOptions() {
136
+ return {};
137
+ },
138
+ addProseMirrorPlugins() {
139
+ return [outlineNumberingPlugin(this.options)];
140
+ }
141
+ });
142
+
143
+ export { OutlineNumbering };
144
+ //# sourceMappingURL=tiptap.js.map
145
+ //# sourceMappingURL=tiptap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/strategies.ts","../src/plugin.ts","../src/tiptap.ts"],"names":[],"mappings":";;;;;;;AASO,SAAS,QAAQ,CAAA,EAAmB;AACzC,EAAA,MAAM,KAAA,GAAkD;AAAA,IACtD,CAAC,KAAM,GAAG,CAAA;AAAA,IAAG,CAAC,KAAK,IAAI,CAAA;AAAA,IAAG,CAAC,KAAK,GAAG,CAAA;AAAA,IAAG,CAAC,KAAK,IAAI,CAAA;AAAA,IAChD,CAAC,KAAK,GAAG,CAAA;AAAA,IAAG,CAAC,IAAI,IAAI,CAAA;AAAA,IAAG,CAAC,IAAI,GAAG,CAAA;AAAA,IAAG,CAAC,IAAI,IAAI,CAAA;AAAA,IAC5C,CAAC,IAAI,GAAG,CAAA;AAAA,IAAG,CAAC,GAAG,IAAI,CAAA;AAAA,IAAG,CAAC,GAAG,GAAG,CAAA;AAAA,IAAG,CAAC,GAAG,IAAI,CAAA;AAAA,IAAG,CAAC,GAAG,GAAG;AAAA,GACpD;AACA,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,KAAA,MAAW,CAAC,KAAA,EAAO,MAAM,CAAA,IAAK,KAAA,EAAO;AACnC,IAAA,OAAO,KAAK,KAAA,EAAO;AACjB,MAAA,MAAA,IAAU,MAAA;AACV,MAAA,CAAA,IAAK,KAAA;AAAA,IACP;AAAA,EACF;AACA,EAAA,OAAO,MAAA;AACT;AAEO,SAAS,QAAA,CAAS,GAAW,SAAA,EAA4B;AAC9D,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,OAAO,IAAI,CAAA,EAAG;AACZ,IAAA,CAAA,EAAA;AACA,IAAA,MAAM,IA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IAAM,gBAAA,GAAmB,UAAU,MAAA,CAAgC;AAAA,EACxE,IAAA,EAAM,kBAAA;AAAA,EAEN,UAAA,GAAa;AACX,IAAA,OAAO,EAAC;AAAA,EACV,CAAA;AAAA,EAEA,qBAAA,GAAwB;AACtB,IAAA,OAAO,CAAC,sBAAA,CAAuB,IAAA,CAAK,OAAO,CAAC,CAAA;AAAA,EAC9C;AACF,CAAC","file":"tiptap.js","sourcesContent":["/**\n * Built-in numbering strategies.\n *\n * Each strategy is a pure function of (counter, depth) → string. Consumers can\n * use these directly or implement their own (emoji markers, CJK ordinals,\n * custom cycles, etc.).\n */\nimport type { OutlineNumberingStrategy } from './plugin';\n\nexport function toRoman(n: number): string {\n const pairs: ReadonlyArray<readonly [number, string]> = [\n [1000, 'M'], [900, 'CM'], [500, 'D'], [400, 'CD'],\n [100, 'C'], [90, 'XC'], [50, 'L'], [40, 'XL'],\n [10, 'X'], [9, 'IX'], [5, 'V'], [4, 'IV'], [1, 'I'],\n ];\n let result = '';\n for (const [value, symbol] of pairs) {\n while (n >= value) {\n result += symbol;\n n -= value;\n }\n }\n return result;\n}\n\nexport function toLetter(n: number, uppercase: boolean): string {\n let result = '';\n while (n > 0) {\n n--;\n const base = uppercase ? 65 : 97;\n result = String.fromCharCode(base + (n % 26)) + result;\n n = Math.floor(n / 26);\n }\n return result;\n}\n\n/**\n * Alphanumeric outline (also known as \"Harvard outline\").\n * depth 0 → Roman (I, II, III)\n * depth 1 → uppercase letter (A, B, C)\n * depth 2 → Arabic (1, 2, 3)\n * depth 3 → lowercase letter (a, b, c)\n * depth 4+ → cycles back to depth 0\n *\n * Canonical form documented by Purdue OWL, MLA, and most US writing style\n * guides.\n */\nexport const alphanumericStrategy: OutlineNumberingStrategy = {\n name: 'alphanumeric',\n format(counter, depth) {\n const phase = depth % 4;\n switch (phase) {\n case 0: return toRoman(counter) + '.';\n case 1: return toLetter(counter, true) + '.';\n case 2: return counter.toString() + '.';\n case 3: return toLetter(counter, false) + '.';\n default: return counter.toString() + '.';\n }\n },\n};\n\n/**\n * Alias for `alphanumericStrategy`. \"Harvard outline\" is a common informal\n * name, though \"Harvard\" in academic/British contexts more commonly denotes\n * citation style — if that ambiguity bothers you, prefer\n * `alphanumericStrategy`.\n */\nexport const harvardStrategy = alphanumericStrategy;\n\n/**\n * Alias for `alphanumericStrategy`. Purdue OWL (Online Writing Lab) is the\n * most widely cited documentation of this scheme and the first reference a\n * lot of writers encounter it through.\n */\nexport const purdueOwlStrategy = alphanumericStrategy;\n\n/**\n * Decimal outline (ISO 2145, IETF).\n * depth 0 → 1., 2., 3.\n * depth 1 → 1.1., 1.2., 2.1.\n * depth 2 → 1.1.1., 1.1.2.\n * ... and so on, indefinitely.\n *\n * Used in technical documentation, engineering reports, software\n * specifications, and European academic writing.\n *\n * Note: the strategy interface does not see the full ancestor chain — the\n * plugin calls `format(counter, depth)` with only the item's own counter.\n * Proper decimal numbering (e.g. \"1.2.3\") requires ancestor context, so this\n * strategy emits a trailing-level marker only (\"3.\" at depth 2). If you need\n * full decimal prefixes, wire them through a custom CSS pseudo-element using\n * `counter-reset` / `counters(ol, \".\")` instead.\n */\nexport const decimalStrategy: OutlineNumberingStrategy = {\n name: 'decimal',\n format(counter) {\n return counter.toString() + '.';\n },\n};\n\n/**\n * Legal / extended alphanumeric outline.\n * depth 0 → I., II., III.\n * depth 1 → A., B., C.\n * depth 2 → 1., 2., 3.\n * depth 3 → a., b., c.\n * depth 4 → (1), (2), (3)\n * depth 5 → (a), (b), (c)\n * depth 6 → (i), (ii), (iii)\n * depth 7+ → cycles back to depth 0\n *\n * Common in US legal writing (briefs, bylaws, statutes) and full-depth\n * academic outlines.\n */\nexport const legalStrategy: OutlineNumberingStrategy = {\n name: 'legal',\n format(counter, depth) {\n const phase = depth % 7;\n switch (phase) {\n case 0: return toRoman(counter) + '.';\n case 1: return toLetter(counter, true) + '.';\n case 2: return counter.toString() + '.';\n case 3: return toLetter(counter, false) + '.';\n case 4: return '(' + counter.toString() + ')';\n case 5: return '(' + toLetter(counter, false) + ')';\n case 6: return '(' + toRoman(counter).toLowerCase() + ')';\n default: return counter.toString() + '.';\n }\n },\n};\n\n/**\n * Flat Arabic numerals at every depth: 1., 2., 3. — no depth awareness.\n * Useful for simple numbered lists or as a building block for custom\n * strategies.\n */\nexport const arabicStrategy: OutlineNumberingStrategy = {\n name: 'arabic',\n format(counter) {\n return counter.toString() + '.';\n },\n};\n\n/**\n * Flat lowercase Roman numerals at every depth: i., ii., iii. — no depth\n * awareness. Matches CSS `list-style-type: lower-roman`. Rare as a root\n * outline style; useful for prefaces, appendices, or as a building block.\n */\nexport const lowerRomanStrategy: OutlineNumberingStrategy = {\n name: 'lower-roman',\n format(counter) {\n return toRoman(counter).toLowerCase() + '.';\n },\n};\n","/**\n * Framework-agnostic ProseMirror plugin for nested ordered-list numbering.\n *\n * The plugin walks the document, counts items per nesting level, and attaches\n * `data-outline-depth` + `data-outline-marker` decorations to each list item.\n * The marker string itself is produced by the caller-supplied strategy, so\n * consumers can render Harvard (I/A/1/a), decimal (1.1.1), legal, emoji, CJK,\n * or any other custom numbering scheme.\n *\n * Consumers turn the attributes into visible markers in CSS, typically via\n * `content: attr(data-outline-marker)` on a `::before` pseudo-element.\n */\nimport { Plugin, PluginKey } from 'prosemirror-state';\nimport { Decoration, DecorationSet } from 'prosemirror-view';\nimport { alphanumericStrategy } from './strategies';\n\n/**\n * Produces the marker string for a given 1-based `counter` at a given nesting\n * `depth`. Implementations must be pure (same inputs → same output); the\n * plugin invokes the strategy once per list item during a walk.\n */\nexport interface OutlineNumberingStrategy {\n name: string;\n format(counter: number, depth: number): string;\n}\n\nexport interface OutlineNumberingPluginOptions {\n /** Numbering scheme. Defaults to `alphanumericStrategy` (Harvard I/A/1/a). */\n strategy: OutlineNumberingStrategy;\n /**\n * When true (default), nested orderedLists inside non-orderedList containers\n * (bulletList, blockquote, custom blocks) within a listItem are discovered\n * and numbered at one level deeper. When false, only orderedLists that are\n * direct children of a listItem are numbered.\n */\n descendThroughContainers: boolean;\n}\n\n/**\n * Stable plugin key — exposed so other plugins can read the current\n * DecorationSet via `OUTLINE_NUMBERING_KEY.getState(editorState)`.\n */\nexport const OUTLINE_NUMBERING_KEY = new PluginKey<DecorationSet>('outlineNumbering');\n\nexport function outlineNumberingPlugin(\n options: Partial<OutlineNumberingPluginOptions> = {},\n): Plugin<DecorationSet> {\n const strategy = options.strategy ?? alphanumericStrategy;\n const descendThroughContainers = options.descendThroughContainers ?? true;\n\n return new Plugin<DecorationSet>({\n key: OUTLINE_NUMBERING_KEY,\n state: {\n init(_, { doc }) {\n return computeDecorations(doc, strategy, descendThroughContainers);\n },\n apply(tr, decorationSet) {\n if (tr.docChanged) {\n return computeDecorations(tr.doc, strategy, descendThroughContainers);\n }\n return decorationSet.map(tr.mapping, tr.doc);\n },\n },\n props: {\n decorations(state) {\n return this.getState(state);\n },\n },\n });\n}\n\n/**\n * Computes the DecorationSet for a document given a strategy. Exported for\n * programmatic use (tests, custom plugin composition); the plugin itself\n * calls this internally.\n */\nexport function computeDecorations(\n doc: any,\n strategy: OutlineNumberingStrategy,\n descendThroughContainers: boolean = true,\n): DecorationSet {\n const decorations: Decoration[] = [];\n\n function walk(node: any, pos: number, depth: number, insideListItem: boolean) {\n if (node.type.name === 'orderedList') {\n walkOrderedList(node, pos, depth);\n return;\n }\n if (insideListItem && !descendThroughContainers) return;\n if (!node.isBlock || node.isLeaf) return;\n const offset = pos + (node.type.name === 'doc' ? 0 : 1);\n let childOffset = 0;\n node.forEach((child: any) => {\n walk(child, offset + childOffset, depth, insideListItem);\n childOffset += child.nodeSize;\n });\n }\n\n function walkOrderedList(node: any, pos: number, depth: number) {\n const offset = pos + 1;\n let counter = 0;\n let childOffset = 0;\n node.forEach((child: any) => {\n if (child.type.name !== 'listItem') {\n childOffset += child.nodeSize;\n return;\n }\n counter++;\n const itemPos = offset + childOffset;\n decorations.push(\n Decoration.node(itemPos, itemPos + child.nodeSize, {\n 'data-outline-depth': String(depth),\n 'data-outline-marker': strategy.format(counter, depth),\n }),\n );\n\n let grandOffset = itemPos + 1;\n child.forEach((grandchild: any) => {\n walk(grandchild, grandOffset, depth + 1, true);\n grandOffset += grandchild.nodeSize;\n });\n childOffset += child.nodeSize;\n });\n }\n\n walk(doc, 0, 0, false);\n return DecorationSet.create(doc, decorations);\n}\n","/**\n * Tiptap wrapper around the framework-agnostic ProseMirror plugin.\n *\n * This module is published under the `/tiptap` subpath. Tiptap consumers:\n *\n * import { OutlineNumbering } from '@bwthomas/outline-numbering/tiptap';\n * import { decimalStrategy } from '@bwthomas/outline-numbering';\n * new Editor({ extensions: [OutlineNumbering.configure({ strategy: decimalStrategy })] });\n *\n * Raw ProseMirror users do not need to load this file — import\n * `outlineNumberingPlugin` from the package root instead.\n */\nimport { Extension } from '@tiptap/core';\nimport {\n OutlineNumberingPluginOptions,\n outlineNumberingPlugin,\n} from './plugin';\n\nexport type OutlineNumberingOptions = Partial<OutlineNumberingPluginOptions>;\n\nexport const OutlineNumbering = Extension.create<OutlineNumberingOptions>({\n name: 'outlineNumbering',\n\n addOptions() {\n return {};\n },\n\n addProseMirrorPlugins() {\n return [outlineNumberingPlugin(this.options)];\n },\n});\n"]}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@bwthomas/outline-numbering",
3
+ "version": "0.1.0",
4
+ "description": "Framework-agnostic ProseMirror plugin (with Tiptap wrapper) for nested ordered-list numbering with pluggable strategies: alphanumeric (Harvard / Purdue OWL I/A/1/a), decimal, legal, arabic, lower-roman, or custom.",
5
+ "license": "MIT",
6
+ "author": "Blake Thomas <bwthomas@users.noreply.github.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/bwthomas/outline-numbering.git"
10
+ },
11
+ "homepage": "https://github.com/bwthomas/outline-numbering#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/bwthomas/outline-numbering/issues"
14
+ },
15
+ "keywords": [
16
+ "prosemirror",
17
+ "prosemirror-plugin",
18
+ "tiptap",
19
+ "tiptap-extension",
20
+ "outline",
21
+ "numbering",
22
+ "ordered-list",
23
+ "alphanumeric",
24
+ "decimal"
25
+ ],
26
+ "type": "module",
27
+ "main": "./dist/index.cjs",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.cjs"
35
+ },
36
+ "./tiptap": {
37
+ "types": "./dist/tiptap.d.ts",
38
+ "import": "./dist/tiptap.js",
39
+ "require": "./dist/tiptap.cjs"
40
+ }
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "README.md",
45
+ "LICENSE"
46
+ ],
47
+ "scripts": {
48
+ "build": "tsup",
49
+ "test": "vitest run",
50
+ "test:watch": "vitest",
51
+ "typecheck": "tsc --noEmit",
52
+ "ci": "npm run typecheck && npm run test && npm run build",
53
+ "prepare": "npm run build"
54
+ },
55
+ "peerDependencies": {
56
+ "@tiptap/core": "^3.0.0",
57
+ "prosemirror-state": "^1.0.0",
58
+ "prosemirror-view": "^1.0.0"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "@tiptap/core": { "optional": true }
62
+ },
63
+ "devDependencies": {
64
+ "@tiptap/core": "^3.22.3",
65
+ "prosemirror-model": "^1.25.0",
66
+ "prosemirror-state": "^1.4.0",
67
+ "prosemirror-view": "^1.40.0",
68
+ "tsup": "^8.5.0",
69
+ "typescript": "^5.9.0",
70
+ "vitest": "^3.2.0"
71
+ }
72
+ }