@tiptap/extension-focus 2.0.0-beta.39 → 2.0.0-beta.43

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.
@@ -1 +1 @@
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 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(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"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,CAAA;6BACb;4BAED,MAAM,SAAS,GAAG,MAAM,IAAI,GAAG,IAAI,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAA;4BAEtE,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
+ {"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 { Decoration, DecorationSet } 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 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(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":";;;;;;;;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,uBAAM,CAAC;AACT,gBAAA,GAAG,EAAE,IAAIC,0BAAS,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;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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,CAACC,0BAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE;AACzD,gCAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;AAC9B,6BAAA,CAAC,CAAC,CAAA;AACL,yBAAC,CAAC,CAAA;wBAEF,OAAOD,6BAAa,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;qBAC9C;AACF,iBAAA;aACF,CAAC;SACH,CAAA;KACF;AACF,CAAA;;;;;"}
@@ -1 +1 @@
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 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(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,UAAU;QACR,OAAO;YACL,SAAS,EAAE,WAAW;YACtB,IAAI,EAAE,KAAK;SACZ,CAAA;KACF;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,IAAI,KAAK,SAAS,EAAE;4BACnC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,GAAG;gCACxB,IAAI,IAAI,CAAC,MAAM,EAAE;oCACf,OAAM;iCACP;gCAED,MAAM,SAAS,GAAG,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/focus.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from 'prosemirror-state'\nimport { Decoration, DecorationSet } 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 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(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":";;;;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;QACn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G,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAA;4BAEtE,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,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE;AACzD,gCAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;AAC9B,6BAAA,CAAC,CAAC,CAAA;AACL,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 +1 @@
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 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(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,YAAY,GAAGA,cAAS,CAAC,MAAM,CAAe;MACzD,IAAI,EAAE,OAAO;MAEb,UAAU;UACR,OAAO;cACL,SAAS,EAAE,WAAW;cACtB,IAAI,EAAE,KAAK;WACZ,CAAA;OACF;MAED,qBAAqB;UACnB,OAAO;cACL,IAAIC,uBAAM,CAAC;kBACT,GAAG,EAAE,IAAIC,0BAAS,CAAC,OAAO,CAAC;kBAC3B,KAAK,EAAE;sBACL,WAAW,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE;0BAC9B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;0BAC7C,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;0BAC5B,MAAM,WAAW,GAAiB,EAAE,CAAA;0BAEpC,IAAI,CAAC,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IAAI,CAACC,0BAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE;kCACzD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;+BAC9B,CAAC,CAAC,CAAA;2BACJ,CAAC,CAAA;0BAEF,OAAOD,6BAAa,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;uBAC9C;mBACF;eACF,CAAC;WACH,CAAA;OACF;GACF;;;;;;;;;;;"}
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 { Decoration, DecorationSet } 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 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(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":";;;;;;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,uBAAM,CAAC;EACT,gBAAA,GAAG,EAAE,IAAIC,0BAAS,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,6BAAa,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,GAAG,IAAI,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,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;;;;;;"}
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.39",
4
+ "version": "2.0.0-beta.43",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -25,12 +25,12 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "prosemirror-state": "^1.3.4",
28
- "prosemirror-view": "^1.23.5"
28
+ "prosemirror-view": "^1.23.6"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",
32
32
  "url": "https://github.com/ueberdosis/tiptap",
33
33
  "directory": "packages/extension-focus"
34
34
  },
35
- "gitHead": "e550d3c69e06a1fb153c3faf17ab78c3081ae61b"
35
+ "gitHead": "591c0807a2ab5c34b4b7fe12c12511fe4f493ebd"
36
36
  }
package/src/focus.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Extension } from '@tiptap/core'
2
2
  import { Plugin, PluginKey } from 'prosemirror-state'
3
- import { DecorationSet, Decoration } from 'prosemirror-view'
3
+ import { Decoration, DecorationSet } from 'prosemirror-view'
4
4
 
5
5
  export interface FocusOptions {
6
6
  className: string,