@tiptap/extension-focus 2.0.0-beta.22 → 2.0.0-beta.220

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.
@@ -3,26 +3,28 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@tiptap/core');
6
- var prosemirrorState = require('prosemirror-state');
7
- var prosemirrorView = require('prosemirror-view');
6
+ var state = require('@tiptap/pm/state');
7
+ var view = require('@tiptap/pm/view');
8
8
 
9
9
  const FocusClasses = core.Extension.create({
10
10
  name: 'focus',
11
- defaultOptions: {
12
- className: 'has-focus',
13
- mode: 'all',
11
+ addOptions() {
12
+ return {
13
+ className: 'has-focus',
14
+ mode: 'all',
15
+ };
14
16
  },
15
17
  addProseMirrorPlugins() {
16
18
  return [
17
- new prosemirrorState.Plugin({
18
- key: new prosemirrorState.PluginKey('focus'),
19
+ new state.Plugin({
20
+ key: new state.PluginKey('focus'),
19
21
  props: {
20
22
  decorations: ({ doc, selection }) => {
21
23
  const { isEditable, isFocused } = this.editor;
22
24
  const { anchor } = selection;
23
25
  const decorations = [];
24
26
  if (!isEditable || !isFocused) {
25
- return prosemirrorView.DecorationSet.create(doc, []);
27
+ return view.DecorationSet.create(doc, []);
26
28
  }
27
29
  // Maximum Levels
28
30
  let maxLevels = 0;
@@ -31,7 +33,7 @@ const FocusClasses = core.Extension.create({
31
33
  if (node.isText) {
32
34
  return;
33
35
  }
34
- const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1);
36
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
35
37
  if (!isCurrent) {
36
38
  return false;
37
39
  }
@@ -44,7 +46,7 @@ const FocusClasses = core.Extension.create({
44
46
  if (node.isText) {
45
47
  return false;
46
48
  }
47
- const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1);
49
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
48
50
  if (!isCurrent) {
49
51
  return false;
50
52
  }
@@ -54,11 +56,11 @@ const FocusClasses = core.Extension.create({
54
56
  if (outOfScope) {
55
57
  return this.options.mode === 'deepest';
56
58
  }
57
- decorations.push(prosemirrorView.Decoration.node(pos, pos + node.nodeSize, {
59
+ decorations.push(view.Decoration.node(pos, pos + node.nodeSize, {
58
60
  class: this.options.className,
59
61
  }));
60
62
  });
61
- return prosemirrorView.DecorationSet.create(doc, decorations);
63
+ return view.DecorationSet.create(doc, decorations);
62
64
  },
63
65
  },
64
66
  }),
@@ -67,5 +69,5 @@ const FocusClasses = core.Extension.create({
67
69
  });
68
70
 
69
71
  exports.FocusClasses = FocusClasses;
70
- exports.default = FocusClasses;
71
- //# sourceMappingURL=tiptap-extension-focus.cjs.js.map
72
+ exports["default"] = FocusClasses;
73
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/focus.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nexport interface FocusOptions {\n className: string\n mode: 'all' | 'deepest' | 'shallowest'\n}\n\nexport const FocusClasses = Extension.create<FocusOptions>({\n name: 'focus',\n\n addOptions() {\n return {\n className: 'has-focus',\n mode: 'all',\n }\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('focus'),\n props: {\n decorations: ({ doc, selection }) => {\n const { isEditable, isFocused } = this.editor\n const { anchor } = selection\n const decorations: Decoration[] = []\n\n if (!isEditable || !isFocused) {\n return DecorationSet.create(doc, [])\n }\n\n // Maximum Levels\n let maxLevels = 0\n\n if (this.options.mode === 'deepest') {\n doc.descendants((node, pos) => {\n if (node.isText) {\n return\n }\n\n const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1\n\n if (!isCurrent) {\n return false\n }\n\n maxLevels += 1\n })\n }\n\n // Loop through current\n let currentLevel = 0\n\n doc.descendants((node, pos) => {\n if (node.isText) {\n return false\n }\n\n const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1\n\n if (!isCurrent) {\n return false\n }\n\n currentLevel += 1\n\n const outOfScope = (this.options.mode === 'deepest' && maxLevels - currentLevel > 0)\n || (this.options.mode === 'shallowest' && currentLevel > 1)\n\n if (outOfScope) {\n return this.options.mode === 'deepest'\n }\n\n decorations.push(\n Decoration.node(pos, pos + node.nodeSize, {\n class: this.options.className,\n }),\n )\n })\n\n return DecorationSet.create(doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"names":["Extension","Plugin","PluginKey","DecorationSet","Decoration"],"mappings":";;;;;;;;AASa,MAAA,YAAY,GAAGA,cAAS,CAAC,MAAM,CAAe;AACzD,IAAA,IAAI,EAAE,OAAO;IAEb,UAAU,GAAA;QACR,OAAO;AACL,YAAA,SAAS,EAAE,WAAW;AACtB,YAAA,IAAI,EAAE,KAAK;SACZ,CAAA;KACF;IAED,qBAAqB,GAAA;QACnB,OAAO;AACL,YAAA,IAAIC,YAAM,CAAC;AACT,gBAAA,GAAG,EAAE,IAAIC,eAAS,CAAC,OAAO,CAAC;AAC3B,gBAAA,KAAK,EAAE;oBACL,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAI;wBAClC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;AAC7C,wBAAA,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;wBAC5B,MAAM,WAAW,GAAiB,EAAE,CAAA;AAEpC,wBAAA,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,EAAE;4BAC7B,OAAOC,kBAAa,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACrC,yBAAA;;wBAGD,IAAI,SAAS,GAAG,CAAC,CAAA;AAEjB,wBAAA,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;4BACnC,GAAG,CAAC,WAAW,CAAC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,SAAS;AAC9B,6BAAA,CAAC,CACH,CAAA;AACH,yBAAC,CAAC,CAAA;wBAEF,OAAOD,kBAAa,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;qBAC9C;AACF,iBAAA;aACF,CAAC;SACH,CAAA;KACF;AACF,CAAA;;;;;"}
@@ -1,12 +1,14 @@
1
1
  import { Extension } from '@tiptap/core';
2
- import { Plugin, PluginKey } from 'prosemirror-state';
3
- import { DecorationSet, Decoration } from 'prosemirror-view';
2
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
3
+ import { DecorationSet, Decoration } from '@tiptap/pm/view';
4
4
 
5
5
  const FocusClasses = Extension.create({
6
6
  name: 'focus',
7
- defaultOptions: {
8
- className: 'has-focus',
9
- mode: 'all',
7
+ addOptions() {
8
+ return {
9
+ className: 'has-focus',
10
+ mode: 'all',
11
+ };
10
12
  },
11
13
  addProseMirrorPlugins() {
12
14
  return [
@@ -27,7 +29,7 @@ const FocusClasses = Extension.create({
27
29
  if (node.isText) {
28
30
  return;
29
31
  }
30
- const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1);
32
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
31
33
  if (!isCurrent) {
32
34
  return false;
33
35
  }
@@ -40,7 +42,7 @@ const FocusClasses = Extension.create({
40
42
  if (node.isText) {
41
43
  return false;
42
44
  }
43
- const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1);
45
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
44
46
  if (!isCurrent) {
45
47
  return false;
46
48
  }
@@ -62,6 +64,5 @@ const FocusClasses = Extension.create({
62
64
  },
63
65
  });
64
66
 
65
- export default FocusClasses;
66
- export { FocusClasses };
67
- //# sourceMappingURL=tiptap-extension-focus.esm.js.map
67
+ export { FocusClasses, FocusClasses as default };
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/focus.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nexport interface FocusOptions {\n className: string\n mode: 'all' | 'deepest' | 'shallowest'\n}\n\nexport const FocusClasses = Extension.create<FocusOptions>({\n name: 'focus',\n\n addOptions() {\n return {\n className: 'has-focus',\n mode: 'all',\n }\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('focus'),\n props: {\n decorations: ({ doc, selection }) => {\n const { isEditable, isFocused } = this.editor\n const { anchor } = selection\n const decorations: Decoration[] = []\n\n if (!isEditable || !isFocused) {\n return DecorationSet.create(doc, [])\n }\n\n // Maximum Levels\n let maxLevels = 0\n\n if (this.options.mode === 'deepest') {\n doc.descendants((node, pos) => {\n if (node.isText) {\n return\n }\n\n const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1\n\n if (!isCurrent) {\n return false\n }\n\n maxLevels += 1\n })\n }\n\n // Loop through current\n let currentLevel = 0\n\n doc.descendants((node, pos) => {\n if (node.isText) {\n return false\n }\n\n const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1\n\n if (!isCurrent) {\n return false\n }\n\n currentLevel += 1\n\n const outOfScope = (this.options.mode === 'deepest' && maxLevels - currentLevel > 0)\n || (this.options.mode === 'shallowest' && currentLevel > 1)\n\n if (outOfScope) {\n return this.options.mode === 'deepest'\n }\n\n decorations.push(\n Decoration.node(pos, pos + node.nodeSize, {\n class: this.options.className,\n }),\n )\n })\n\n return DecorationSet.create(doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"names":[],"mappings":";;;;AASa,MAAA,YAAY,GAAG,SAAS,CAAC,MAAM,CAAe;AACzD,IAAA,IAAI,EAAE,OAAO;IAEb,UAAU,GAAA;QACR,OAAO;AACL,YAAA,SAAS,EAAE,WAAW;AACtB,YAAA,IAAI,EAAE,KAAK;SACZ,CAAA;KACF;IAED,qBAAqB,GAAA;QACnB,OAAO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,CAAC,QAAQ,GAAG,CAAC,CAAA;4BAEpE,IAAI,CAAC,SAAS,EAAE;AACd,gCAAA,OAAO,KAAK,CAAA;AACb,6BAAA;4BAED,YAAY,IAAI,CAAC,CAAA;AAEjB,4BAAA,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,GAAG,YAAY,GAAG,CAAC;AAC9E,oCAAC,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,IAAI,YAAY,GAAG,CAAC,CAAC,CAAA;AAE7D,4BAAA,IAAI,UAAU,EAAE;AACd,gCAAA,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAA;AACvC,6BAAA;AAED,4BAAA,WAAW,CAAC,IAAI,CACd,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE;AACxC,gCAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;AAC9B,6BAAA,CAAC,CACH,CAAA;AACH,yBAAC,CAAC,CAAA;wBAEF,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;qBAC9C;AACF,iBAAA;aACF,CAAC;SACH,CAAA;KACF;AACF,CAAA;;;;"}
@@ -1,26 +1,28 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('prosemirror-state'), require('prosemirror-view')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'prosemirror-state', 'prosemirror-view'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@tiptap/extension-focus'] = {}, global.core, global.prosemirrorState, global.prosemirrorView));
5
- }(this, (function (exports, core, prosemirrorState, prosemirrorView) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/pm/state'), require('@tiptap/pm/view')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/pm/state', '@tiptap/pm/view'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-focus"] = {}, global.core, global.state, global.view));
5
+ })(this, (function (exports, core, state, view) { 'use strict';
6
6
 
7
7
  const FocusClasses = core.Extension.create({
8
8
  name: 'focus',
9
- defaultOptions: {
10
- className: 'has-focus',
11
- mode: 'all',
9
+ addOptions() {
10
+ return {
11
+ className: 'has-focus',
12
+ mode: 'all',
13
+ };
12
14
  },
13
15
  addProseMirrorPlugins() {
14
16
  return [
15
- new prosemirrorState.Plugin({
16
- key: new prosemirrorState.PluginKey('focus'),
17
+ new state.Plugin({
18
+ key: new state.PluginKey('focus'),
17
19
  props: {
18
20
  decorations: ({ doc, selection }) => {
19
21
  const { isEditable, isFocused } = this.editor;
20
22
  const { anchor } = selection;
21
23
  const decorations = [];
22
24
  if (!isEditable || !isFocused) {
23
- return prosemirrorView.DecorationSet.create(doc, []);
25
+ return view.DecorationSet.create(doc, []);
24
26
  }
25
27
  // Maximum Levels
26
28
  let maxLevels = 0;
@@ -29,7 +31,7 @@
29
31
  if (node.isText) {
30
32
  return;
31
33
  }
32
- const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1);
34
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
33
35
  if (!isCurrent) {
34
36
  return false;
35
37
  }
@@ -42,7 +44,7 @@
42
44
  if (node.isText) {
43
45
  return false;
44
46
  }
45
- const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1);
47
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1;
46
48
  if (!isCurrent) {
47
49
  return false;
48
50
  }
@@ -52,11 +54,11 @@
52
54
  if (outOfScope) {
53
55
  return this.options.mode === 'deepest';
54
56
  }
55
- decorations.push(prosemirrorView.Decoration.node(pos, pos + node.nodeSize, {
57
+ decorations.push(view.Decoration.node(pos, pos + node.nodeSize, {
56
58
  class: this.options.className,
57
59
  }));
58
60
  });
59
- return prosemirrorView.DecorationSet.create(doc, decorations);
61
+ return view.DecorationSet.create(doc, decorations);
60
62
  },
61
63
  },
62
64
  }),
@@ -65,9 +67,9 @@
65
67
  });
66
68
 
67
69
  exports.FocusClasses = FocusClasses;
68
- exports.default = FocusClasses;
70
+ exports["default"] = FocusClasses;
69
71
 
70
72
  Object.defineProperty(exports, '__esModule', { value: true });
71
73
 
72
- })));
73
- //# sourceMappingURL=tiptap-extension-focus.umd.js.map
74
+ }));
75
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/focus.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nexport interface FocusOptions {\n className: string\n mode: 'all' | 'deepest' | 'shallowest'\n}\n\nexport const FocusClasses = Extension.create<FocusOptions>({\n name: 'focus',\n\n addOptions() {\n return {\n className: 'has-focus',\n mode: 'all',\n }\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('focus'),\n props: {\n decorations: ({ doc, selection }) => {\n const { isEditable, isFocused } = this.editor\n const { anchor } = selection\n const decorations: Decoration[] = []\n\n if (!isEditable || !isFocused) {\n return DecorationSet.create(doc, [])\n }\n\n // Maximum Levels\n let maxLevels = 0\n\n if (this.options.mode === 'deepest') {\n doc.descendants((node, pos) => {\n if (node.isText) {\n return\n }\n\n const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1\n\n if (!isCurrent) {\n return false\n }\n\n maxLevels += 1\n })\n }\n\n // Loop through current\n let currentLevel = 0\n\n doc.descendants((node, pos) => {\n if (node.isText) {\n return false\n }\n\n const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1\n\n if (!isCurrent) {\n return false\n }\n\n currentLevel += 1\n\n const outOfScope = (this.options.mode === 'deepest' && maxLevels - currentLevel > 0)\n || (this.options.mode === 'shallowest' && currentLevel > 1)\n\n if (outOfScope) {\n return this.options.mode === 'deepest'\n }\n\n decorations.push(\n Decoration.node(pos, pos + node.nodeSize, {\n class: this.options.className,\n }),\n )\n })\n\n return DecorationSet.create(doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"names":["Extension","Plugin","PluginKey","DecorationSet","Decoration"],"mappings":";;;;;;AASa,QAAA,YAAY,GAAGA,cAAS,CAAC,MAAM,CAAe;EACzD,IAAA,IAAI,EAAE,OAAO;MAEb,UAAU,GAAA;UACR,OAAO;EACL,YAAA,SAAS,EAAE,WAAW;EACtB,YAAA,IAAI,EAAE,KAAK;WACZ,CAAA;OACF;MAED,qBAAqB,GAAA;UACnB,OAAO;EACL,YAAA,IAAIC,YAAM,CAAC;EACT,gBAAA,GAAG,EAAE,IAAIC,eAAS,CAAC,OAAO,CAAC;EAC3B,gBAAA,KAAK,EAAE;sBACL,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAI;0BAClC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;EAC7C,wBAAA,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;0BAC5B,MAAM,WAAW,GAAiB,EAAE,CAAA;EAEpC,wBAAA,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,EAAE;8BAC7B,OAAOC,kBAAa,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;EACrC,yBAAA;;0BAGD,IAAI,SAAS,GAAG,CAAC,CAAA;EAEjB,wBAAA,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;8BACnC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,GAAG,KAAI;kCAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;sCACf,OAAM;EACP,iCAAA;EAED,gCAAA,MAAM,SAAS,GAAG,MAAM,IAAI,G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9C;EACF,iBAAA;eACF,CAAC;WACH,CAAA;OACF;EACF,CAAA;;;;;;;;;;;"}
@@ -3,4 +3,4 @@ export interface FocusOptions {
3
3
  className: string;
4
4
  mode: 'all' | 'deepest' | 'shallowest';
5
5
  }
6
- export declare const FocusClasses: Extension<FocusOptions>;
6
+ export declare const FocusClasses: Extension<FocusOptions, any>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-focus",
3
3
  "description": "focus extension for tiptap",
4
- "version": "2.0.0-beta.22",
4
+ "version": "2.0.0-beta.220",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -12,25 +12,37 @@
12
12
  "type": "github",
13
13
  "url": "https://github.com/sponsors/ueberdosis"
14
14
  },
15
- "main": "dist/tiptap-extension-focus.cjs.js",
16
- "umd": "dist/tiptap-extension-focus.umd.js",
17
- "module": "dist/tiptap-extension-focus.esm.js",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/packages/extension-focus/src/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs"
21
+ }
22
+ },
23
+ "main": "dist/index.cjs",
24
+ "module": "dist/index.js",
25
+ "umd": "dist/index.umd.js",
18
26
  "types": "dist/packages/extension-focus/src/index.d.ts",
19
27
  "files": [
20
28
  "src",
21
29
  "dist"
22
30
  ],
23
31
  "peerDependencies": {
24
- "@tiptap/core": "^2.0.0-beta.1"
32
+ "@tiptap/core": "^2.0.0-beta.209",
33
+ "@tiptap/pm": "^2.0.0-beta.209"
25
34
  },
26
- "dependencies": {
27
- "prosemirror-state": "^1.3.4",
28
- "prosemirror-view": "^1.18.11"
35
+ "devDependencies": {
36
+ "@tiptap/core": "^2.0.0-beta.220",
37
+ "@tiptap/pm": "^2.0.0-beta.220"
29
38
  },
30
39
  "repository": {
31
40
  "type": "git",
32
41
  "url": "https://github.com/ueberdosis/tiptap",
33
42
  "directory": "packages/extension-focus"
34
43
  },
35
- "gitHead": "345ea8cf8abba6422dabc6e548594fb8e2c30409"
44
+ "scripts": {
45
+ "clean": "rm -rf dist",
46
+ "build": "npm run clean && rollup -c"
47
+ }
36
48
  }
package/src/focus.ts CHANGED
@@ -1,18 +1,20 @@
1
1
  import { Extension } from '@tiptap/core'
2
- import { Plugin, PluginKey } from 'prosemirror-state'
3
- import { DecorationSet, Decoration } from 'prosemirror-view'
2
+ import { Plugin, PluginKey } from '@tiptap/pm/state'
3
+ import { Decoration, DecorationSet } from '@tiptap/pm/view'
4
4
 
5
5
  export interface FocusOptions {
6
- className: string,
7
- mode: 'all' | 'deepest' | 'shallowest',
6
+ className: string
7
+ mode: 'all' | 'deepest' | 'shallowest'
8
8
  }
9
9
 
10
10
  export const FocusClasses = Extension.create<FocusOptions>({
11
11
  name: 'focus',
12
12
 
13
- defaultOptions: {
14
- className: 'has-focus',
15
- mode: 'all',
13
+ addOptions() {
14
+ return {
15
+ className: 'has-focus',
16
+ mode: 'all',
17
+ }
16
18
  },
17
19
 
18
20
  addProseMirrorPlugins() {
@@ -38,7 +40,7 @@ export const FocusClasses = Extension.create<FocusOptions>({
38
40
  return
39
41
  }
40
42
 
41
- const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)
43
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1
42
44
 
43
45
  if (!isCurrent) {
44
46
  return false
@@ -56,7 +58,7 @@ export const FocusClasses = Extension.create<FocusOptions>({
56
58
  return false
57
59
  }
58
60
 
59
- const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)
61
+ const isCurrent = anchor >= pos && anchor <= pos + node.nodeSize - 1
60
62
 
61
63
  if (!isCurrent) {
62
64
  return false
@@ -71,9 +73,11 @@ export const FocusClasses = Extension.create<FocusOptions>({
71
73
  return this.options.mode === 'deepest'
72
74
  }
73
75
 
74
- decorations.push(Decoration.node(pos, pos + node.nodeSize, {
75
- class: this.options.className,
76
- }))
76
+ decorations.push(
77
+ Decoration.node(pos, pos + node.nodeSize, {
78
+ class: this.options.className,
79
+ }),
80
+ )
77
81
  })
78
82
 
79
83
  return DecorationSet.create(doc, decorations)
package/CHANGELOG.md DELETED
@@ -1,300 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [2.0.0-beta.22](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.21...@tiptap/extension-focus@2.0.0-beta.22) (2021-07-26)
7
-
8
- **Note:** Version bump only for package @tiptap/extension-focus
9
-
10
-
11
-
12
-
13
-
14
- # [2.0.0-beta.21](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.20...@tiptap/extension-focus@2.0.0-beta.21) (2021-06-23)
15
-
16
- **Note:** Version bump only for package @tiptap/extension-focus
17
-
18
-
19
-
20
-
21
-
22
- # [2.0.0-beta.20](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.19...@tiptap/extension-focus@2.0.0-beta.20) (2021-05-27)
23
-
24
- **Note:** Version bump only for package @tiptap/extension-focus
25
-
26
-
27
-
28
-
29
-
30
- # [2.0.0-beta.19](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.18...@tiptap/extension-focus@2.0.0-beta.19) (2021-05-18)
31
-
32
- **Note:** Version bump only for package @tiptap/extension-focus
33
-
34
-
35
-
36
-
37
-
38
- # [2.0.0-beta.18](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.17...@tiptap/extension-focus@2.0.0-beta.18) (2021-05-17)
39
-
40
- **Note:** Version bump only for package @tiptap/extension-focus
41
-
42
-
43
-
44
-
45
-
46
- # [2.0.0-beta.17](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.16...@tiptap/extension-focus@2.0.0-beta.17) (2021-05-13)
47
-
48
- **Note:** Version bump only for package @tiptap/extension-focus
49
-
50
-
51
-
52
-
53
-
54
- # [2.0.0-beta.16](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.15...@tiptap/extension-focus@2.0.0-beta.16) (2021-05-07)
55
-
56
-
57
- ### Bug Fixes
58
-
59
- * revert adding exports ([bc320d0](https://github.com/ueberdosis/tiptap/commit/bc320d0b4b80b0e37a7e47a56e0f6daec6e65d98))
60
-
61
-
62
-
63
-
64
-
65
- # [2.0.0-beta.15](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.14...@tiptap/extension-focus@2.0.0-beta.15) (2021-05-06)
66
-
67
-
68
- ### Bug Fixes
69
-
70
- * revert adding type: module ([f8d6475](https://github.com/ueberdosis/tiptap/commit/f8d6475e2151faea6f96baecdd6bd75880d50d2c))
71
-
72
-
73
-
74
-
75
-
76
- # [2.0.0-beta.14](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.13...@tiptap/extension-focus@2.0.0-beta.14) (2021-05-06)
77
-
78
-
79
- ### Bug Fixes
80
-
81
- * add exports to package.json ([1277fa4](https://github.com/ueberdosis/tiptap/commit/1277fa47151e9c039508cdb219bdd0ffe647f4ee))
82
-
83
-
84
-
85
-
86
-
87
- # [2.0.0-beta.13](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.12...@tiptap/extension-focus@2.0.0-beta.13) (2021-05-06)
88
-
89
- **Note:** Version bump only for package @tiptap/extension-focus
90
-
91
-
92
-
93
-
94
-
95
- # [2.0.0-beta.12](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.11...@tiptap/extension-focus@2.0.0-beta.12) (2021-05-05)
96
-
97
- **Note:** Version bump only for package @tiptap/extension-focus
98
-
99
-
100
-
101
-
102
-
103
- # [2.0.0-beta.11](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.10...@tiptap/extension-focus@2.0.0-beta.11) (2021-05-04)
104
-
105
- **Note:** Version bump only for package @tiptap/extension-focus
106
-
107
-
108
-
109
-
110
-
111
- # [2.0.0-beta.10](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.9...@tiptap/extension-focus@2.0.0-beta.10) (2021-04-23)
112
-
113
- **Note:** Version bump only for package @tiptap/extension-focus
114
-
115
-
116
-
117
-
118
-
119
- # [2.0.0-beta.9](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.8...@tiptap/extension-focus@2.0.0-beta.9) (2021-04-22)
120
-
121
- **Note:** Version bump only for package @tiptap/extension-focus
122
-
123
-
124
-
125
-
126
-
127
- # [2.0.0-beta.8](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.7...@tiptap/extension-focus@2.0.0-beta.8) (2021-04-16)
128
-
129
- **Note:** Version bump only for package @tiptap/extension-focus
130
-
131
-
132
-
133
-
134
-
135
- # [2.0.0-beta.7](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.6...@tiptap/extension-focus@2.0.0-beta.7) (2021-04-15)
136
-
137
- **Note:** Version bump only for package @tiptap/extension-focus
138
-
139
-
140
-
141
-
142
-
143
- # [2.0.0-beta.6](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.5...@tiptap/extension-focus@2.0.0-beta.6) (2021-03-31)
144
-
145
- **Note:** Version bump only for package @tiptap/extension-focus
146
-
147
-
148
-
149
-
150
-
151
- # [2.0.0-beta.5](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.4...@tiptap/extension-focus@2.0.0-beta.5) (2021-03-28)
152
-
153
- **Note:** Version bump only for package @tiptap/extension-focus
154
-
155
-
156
-
157
-
158
-
159
- # [2.0.0-beta.4](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.3...@tiptap/extension-focus@2.0.0-beta.4) (2021-03-25)
160
-
161
- **Note:** Version bump only for package @tiptap/extension-focus
162
-
163
-
164
-
165
-
166
-
167
- # [2.0.0-beta.3](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.2...@tiptap/extension-focus@2.0.0-beta.3) (2021-03-24)
168
-
169
- **Note:** Version bump only for package @tiptap/extension-focus
170
-
171
-
172
-
173
-
174
-
175
- # [2.0.0-beta.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-beta.1...@tiptap/extension-focus@2.0.0-beta.2) (2021-03-18)
176
-
177
- **Note:** Version bump only for package @tiptap/extension-focus
178
-
179
-
180
-
181
-
182
-
183
- # [2.0.0-beta.1](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.12...@tiptap/extension-focus@2.0.0-beta.1) (2021-03-05)
184
-
185
- **Note:** Version bump only for package @tiptap/extension-focus
186
-
187
-
188
-
189
-
190
-
191
- # [2.0.0-alpha.12](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.11...@tiptap/extension-focus@2.0.0-alpha.12) (2021-02-26)
192
-
193
- **Note:** Version bump only for package @tiptap/extension-focus
194
-
195
-
196
-
197
-
198
-
199
- # [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.10...@tiptap/extension-focus@2.0.0-alpha.11) (2021-02-16)
200
-
201
- **Note:** Version bump only for package @tiptap/extension-focus
202
-
203
-
204
-
205
-
206
-
207
- # [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.9...@tiptap/extension-focus@2.0.0-alpha.10) (2021-02-07)
208
-
209
- **Note:** Version bump only for package @tiptap/extension-focus
210
-
211
-
212
-
213
-
214
-
215
- # [2.0.0-alpha.9](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.8...@tiptap/extension-focus@2.0.0-alpha.9) (2021-02-05)
216
-
217
- **Note:** Version bump only for package @tiptap/extension-focus
218
-
219
-
220
-
221
-
222
-
223
- # [2.0.0-alpha.8](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.7...@tiptap/extension-focus@2.0.0-alpha.8) (2021-01-29)
224
-
225
- **Note:** Version bump only for package @tiptap/extension-focus
226
-
227
-
228
-
229
-
230
-
231
- # [2.0.0-alpha.7](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.6...@tiptap/extension-focus@2.0.0-alpha.7) (2021-01-29)
232
-
233
- **Note:** Version bump only for package @tiptap/extension-focus
234
-
235
-
236
-
237
-
238
-
239
- # [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.5...@tiptap/extension-focus@2.0.0-alpha.6) (2021-01-28)
240
-
241
- **Note:** Version bump only for package @tiptap/extension-focus
242
-
243
-
244
-
245
-
246
-
247
- # [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.4...@tiptap/extension-focus@2.0.0-alpha.5) (2020-12-18)
248
-
249
- **Note:** Version bump only for package @tiptap/extension-focus
250
-
251
-
252
-
253
-
254
-
255
- # [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.3...@tiptap/extension-focus@2.0.0-alpha.4) (2020-12-02)
256
-
257
- **Note:** Version bump only for package @tiptap/extension-focus
258
-
259
-
260
-
261
-
262
-
263
- # [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.2...@tiptap/extension-focus@2.0.0-alpha.3) (2020-11-19)
264
-
265
- **Note:** Version bump only for package @tiptap/extension-focus
266
-
267
-
268
-
269
-
270
-
271
- # [2.0.0-alpha.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@2.0.0-alpha.1...@tiptap/extension-focus@2.0.0-alpha.2) (2020-11-19)
272
-
273
- **Note:** Version bump only for package @tiptap/extension-focus
274
-
275
-
276
-
277
-
278
-
279
- # [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@1.0.0-alpha.2...@tiptap/extension-focus@2.0.0-alpha.1) (2020-11-18)
280
-
281
- **Note:** Version bump only for package @tiptap/extension-focus
282
-
283
-
284
-
285
-
286
-
287
- # [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap/compare/@tiptap/extension-focus@1.0.0-alpha.1...@tiptap/extension-focus@1.0.0-alpha.2) (2020-11-16)
288
-
289
- **Note:** Version bump only for package @tiptap/extension-focus
290
-
291
-
292
-
293
-
294
-
295
- # 1.0.0-alpha.1 (2020-11-16)
296
-
297
-
298
- ### Reverts
299
-
300
- * Revert "use global namespace" ([0c9ce26](https://github.com/ueberdosis/tiptap/commit/0c9ce26c02c07d88a757c01b0a9d7f9e2b0b7502))
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021, überdosis GbR
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-focus.cjs.js","sources":["../src/focus.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from 'prosemirror-state'\nimport { DecorationSet, Decoration } from 'prosemirror-view'\n\nexport interface FocusOptions {\n className: string,\n mode: 'all' | 'deepest' | 'shallowest',\n}\n\nexport const FocusClasses = Extension.create<FocusOptions>({\n name: 'focus',\n\n defaultOptions: {\n className: 'has-focus',\n mode: 'all',\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('focus'),\n props: {\n decorations: ({ doc, selection }) => {\n const { isEditable, isFocused } = this.editor\n const { anchor } = selection\n const decorations: Decoration[] = []\n\n if (!isEditable || !isFocused) {\n return DecorationSet.create(doc, [])\n }\n\n // Maximum Levels\n let maxLevels = 0\n\n if (this.options.mode === 'deepest') {\n doc.descendants((node, pos) => {\n if (node.isText) {\n return\n }\n\n const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)\n\n if (!isCurrent) {\n return false\n }\n\n maxLevels += 1\n })\n }\n\n // Loop through current\n let currentLevel = 0\n\n doc.descendants((node, pos) => {\n if (node.isText) {\n return false\n }\n\n const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)\n\n if (!isCurrent) {\n return false\n }\n\n currentLevel += 1\n\n const outOfScope = (this.options.mode === 'deepest' && maxLevels - currentLevel > 0)\n || (this.options.mode === 'shallowest' && currentLevel > 1)\n\n if (outOfScope) {\n return this.options.mode === 'deepest'\n }\n\n decorations.push(Decoration.node(pos, pos + node.nodeSize, {\n class: this.options.className,\n }))\n })\n\n return DecorationSet.create(doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"names":["Extension","Plugin","PluginKey","DecorationSet","Decoration"],"mappings":";;;;;;;;MASa,YAAY,GAAGA,cAAS,CAAC,MAAM,CAAe;IACzD,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,SAAS,EAA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AEtE,IAAI,CAAC,SAAS,EAAE;gCACd,OAAO,KAAK,CAAA;6BACb;4BAED,YAAY,IAAI,CAAC,CAAA;4BAEjB,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,GAAG,YAAY,GAAG,CAAC;oCAC7E,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,IAAI,YAAY,GAAG,CAAC,CAAC,CAAA;4BAE7D,IAAI,UAAU,EAAE;gCACd,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAA;6BACvC;4BAED,WAAW,CAAC,IAAI,CAACC,0BAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE;gCACzD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;6BAC9B,CAAC,CAAC,CAAA;yBACJ,CAAC,CAAA;wBAEF,OAAOD,6BAAa,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;qBAC9C;iBACF;aACF,CAAC;SACH,CAAA;KACF;CACF;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-focus.esm.js","sources":["../src/focus.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from 'prosemirror-state'\nimport { DecorationSet, Decoration } from 'prosemirror-view'\n\nexport interface FocusOptions {\n className: string,\n mode: 'all' | 'deepest' | 'shallowest',\n}\n\nexport const FocusClasses = Extension.create<FocusOptions>({\n name: 'focus',\n\n defaultOptions: {\n className: 'has-focus',\n mode: 'all',\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('focus'),\n props: {\n decorations: ({ doc, selection }) => {\n const { isEditable, isFocused } = this.editor\n const { anchor } = selection\n const decorations: Decoration[] = []\n\n if (!isEditable || !isFocused) {\n return DecorationSet.create(doc, [])\n }\n\n // Maximum Levels\n let maxLevels = 0\n\n if (this.options.mode === 'deepest') {\n doc.descendants((node, pos) => {\n if (node.isText) {\n return\n }\n\n const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)\n\n if (!isCurrent) {\n return false\n }\n\n maxLevels += 1\n })\n }\n\n // Loop through current\n let currentLevel = 0\n\n doc.descendants((node, pos) => {\n if (node.isText) {\n return false\n }\n\n const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)\n\n if (!isCurrent) {\n return false\n }\n\n currentLevel += 1\n\n const outOfScope = (this.options.mode === 'deepest' && maxLevels - currentLevel > 0)\n || (this.options.mode === 'shallowest' && currentLevel > 1)\n\n if (outOfScope) {\n return this.options.mode === 'deepest'\n }\n\n decorations.push(Decoration.node(pos, pos + node.nodeSize, {\n class: this.options.className,\n }))\n })\n\n return DecorationSet.create(doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"names":[],"mappings":";;;;MASa,YAAY,GAAG,SAAS,CAAC,MAAM,CAAe;IACzD,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,SAAS,EAAE,WAAW;QACtB,IAAI,EAAE,KAAK;KACZ;IAED,qBAAqB;QACnB,OAAO;YACL,IAAI,MAAM,CAAC;gBACT,GAAG,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC;gBAC3B,KAAK,EAAE;oBACL,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE;wBAC9B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;wBAC7C,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;wBAC5B,MAAM,WAAW,GAAiB,EAAE,CAAA;wBAEpC,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,EAAE;4BAC7B,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;yBACrC;;wBAGD,IAAI,SAAS,GAAG,CAAC,CAAA;wBAEjB,IAAI,IAAI,CAAC,OAAO,CAAC,IAA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AAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;qBAC9C;iBACF;aACF,CAAC;SACH,CAAA;KACF;CACF;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-focus.umd.js","sources":["../src/focus.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from 'prosemirror-state'\nimport { DecorationSet, Decoration } from 'prosemirror-view'\n\nexport interface FocusOptions {\n className: string,\n mode: 'all' | 'deepest' | 'shallowest',\n}\n\nexport const FocusClasses = Extension.create<FocusOptions>({\n name: 'focus',\n\n defaultOptions: {\n className: 'has-focus',\n mode: 'all',\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('focus'),\n props: {\n decorations: ({ doc, selection }) => {\n const { isEditable, isFocused } = this.editor\n const { anchor } = selection\n const decorations: Decoration[] = []\n\n if (!isEditable || !isFocused) {\n return DecorationSet.create(doc, [])\n }\n\n // Maximum Levels\n let maxLevels = 0\n\n if (this.options.mode === 'deepest') {\n doc.descendants((node, pos) => {\n if (node.isText) {\n return\n }\n\n const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)\n\n if (!isCurrent) {\n return false\n }\n\n maxLevels += 1\n })\n }\n\n // Loop through current\n let currentLevel = 0\n\n doc.descendants((node, pos) => {\n if (node.isText) {\n return false\n }\n\n const isCurrent = anchor >= pos && anchor <= (pos + node.nodeSize - 1)\n\n if (!isCurrent) {\n return false\n }\n\n currentLevel += 1\n\n const outOfScope = (this.options.mode === 'deepest' && maxLevels - currentLevel > 0)\n || (this.options.mode === 'shallowest' && currentLevel > 1)\n\n if (outOfScope) {\n return this.options.mode === 'deepest'\n }\n\n decorations.push(Decoration.node(pos, pos + node.nodeSize, {\n class: this.options.className,\n }))\n })\n\n return DecorationSet.create(doc, decorations)\n },\n },\n }),\n ]\n },\n})\n"],"names":["Extension","Plugin","PluginKey","DecorationSet","Decoration"],"mappings":";;;;;;QASa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