@tiptap/extension-text-align
Advanced tools
Comparing version 1.0.0-alpha.2 to 2.0.0-alpha.1
@@ -6,2 +6,10 @@ # Change Log | ||
# [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@1.0.0-alpha.2...@tiptap/extension-text-align@2.0.0-alpha.1) (2020-11-18) | ||
**Note:** Version bump only for package @tiptap/extension-text-align | ||
# [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-text-align@1.0.0-alpha.1...@tiptap/extension-text-align@1.0.0-alpha.2) (2020-11-16) | ||
@@ -8,0 +16,0 @@ |
@@ -9,5 +9,9 @@ import { Command, Extension } from '@tiptap/core'; | ||
/** | ||
* Update the text align attribute | ||
* Set the text align attribute | ||
*/ | ||
textAlign: (alignment: string) => Command; | ||
setTextAlign: (alignment: string) => Command; | ||
/** | ||
* Unset the text align attribute | ||
*/ | ||
unsetTextAlign: () => Command; | ||
}>; | ||
@@ -14,0 +18,0 @@ export default TextAlign; |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@tiptap/core")):"function"==typeof define&&define.amd?define(["@tiptap/core"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["@tiptap/extension-text-align"]=e(t["@tiptap/core"])}(this,(function(t){"use strict";return t.Extension.create({defaultOptions:{types:["heading","paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,renderHTML:t=>({style:"text-align: "+t.textAlign}),parseHTML:t=>({textAlign:t.style.textAlign||this.options.defaultAlignment})}}}]},addCommands(){return{textAlign:t=>({commands:e})=>!!this.options.alignments.includes(t)&&e.updateNodeAttributes({textAlign:t})}},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitBlock({withAttributes:!0}),"Ctrl-Shift-l":()=>this.editor.commands.textAlign("left"),"Ctrl-Shift-e":()=>this.editor.commands.textAlign("center"),"Ctrl-Shift-r":()=>this.editor.commands.textAlign("right"),"Ctrl-Shift-j":()=>this.editor.commands.textAlign("justify")}}})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@tiptap/core")):"function"==typeof define&&define.amd?define(["@tiptap/core"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["@tiptap/extension-text-align"]=e(t["@tiptap/core"])}(this,(function(t){"use strict";return t.Extension.create({defaultOptions:{types:["heading","paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,renderHTML:t=>({style:"text-align: "+t.textAlign}),parseHTML:t=>({textAlign:t.style.textAlign||this.options.defaultAlignment})}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>!!this.options.alignments.includes(t)&&this.options.types.every((i=>e.updateNodeAttributes(i,{textAlign:t}))),unsetTextAlign:()=>({commands:t})=>this.options.types.every((e=>t.resetNodeAttributes(e,"textAlign")))}},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitBlock({withAttributes:!0}),"Ctrl-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Ctrl-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Ctrl-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Ctrl-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}})})); | ||
//# sourceMappingURL=tiptap-extension-text-align.bundle.umd.min.js.map |
@@ -32,10 +32,16 @@ 'use strict'; | ||
/** | ||
* Update the text align attribute | ||
* Set the text align attribute | ||
*/ | ||
textAlign: (alignment) => ({ commands }) => { | ||
setTextAlign: (alignment) => ({ commands }) => { | ||
if (!this.options.alignments.includes(alignment)) { | ||
return false; | ||
} | ||
return commands.updateNodeAttributes({ textAlign: alignment }); | ||
return this.options.types.every(type => commands.updateNodeAttributes(type, { textAlign: alignment })); | ||
}, | ||
/** | ||
* Unset the text align attribute | ||
*/ | ||
unsetTextAlign: () => ({ commands }) => { | ||
return this.options.types.every(type => commands.resetNodeAttributes(type, 'textAlign')); | ||
}, | ||
}; | ||
@@ -51,6 +57,6 @@ }, | ||
}), | ||
'Ctrl-Shift-l': () => this.editor.commands.textAlign('left'), | ||
'Ctrl-Shift-e': () => this.editor.commands.textAlign('center'), | ||
'Ctrl-Shift-r': () => this.editor.commands.textAlign('right'), | ||
'Ctrl-Shift-j': () => this.editor.commands.textAlign('justify'), | ||
'Ctrl-Shift-l': () => this.editor.commands.setTextAlign('left'), | ||
'Ctrl-Shift-e': () => this.editor.commands.setTextAlign('center'), | ||
'Ctrl-Shift-r': () => this.editor.commands.setTextAlign('right'), | ||
'Ctrl-Shift-j': () => this.editor.commands.setTextAlign('justify'), | ||
}; | ||
@@ -57,0 +63,0 @@ }, |
@@ -30,10 +30,16 @@ import { Extension } from '@tiptap/core'; | ||
/** | ||
* Update the text align attribute | ||
* Set the text align attribute | ||
*/ | ||
textAlign: (alignment) => ({ commands }) => { | ||
setTextAlign: (alignment) => ({ commands }) => { | ||
if (!this.options.alignments.includes(alignment)) { | ||
return false; | ||
} | ||
return commands.updateNodeAttributes({ textAlign: alignment }); | ||
return this.options.types.every(type => commands.updateNodeAttributes(type, { textAlign: alignment })); | ||
}, | ||
/** | ||
* Unset the text align attribute | ||
*/ | ||
unsetTextAlign: () => ({ commands }) => { | ||
return this.options.types.every(type => commands.resetNodeAttributes(type, 'textAlign')); | ||
}, | ||
}; | ||
@@ -49,6 +55,6 @@ }, | ||
}), | ||
'Ctrl-Shift-l': () => this.editor.commands.textAlign('left'), | ||
'Ctrl-Shift-e': () => this.editor.commands.textAlign('center'), | ||
'Ctrl-Shift-r': () => this.editor.commands.textAlign('right'), | ||
'Ctrl-Shift-j': () => this.editor.commands.textAlign('justify'), | ||
'Ctrl-Shift-l': () => this.editor.commands.setTextAlign('left'), | ||
'Ctrl-Shift-e': () => this.editor.commands.setTextAlign('center'), | ||
'Ctrl-Shift-r': () => this.editor.commands.setTextAlign('right'), | ||
'Ctrl-Shift-j': () => this.editor.commands.setTextAlign('justify'), | ||
}; | ||
@@ -55,0 +61,0 @@ }, |
@@ -34,10 +34,16 @@ (function (global, factory) { | ||
/** | ||
* Update the text align attribute | ||
* Set the text align attribute | ||
*/ | ||
textAlign: (alignment) => ({ commands }) => { | ||
setTextAlign: (alignment) => ({ commands }) => { | ||
if (!this.options.alignments.includes(alignment)) { | ||
return false; | ||
} | ||
return commands.updateNodeAttributes({ textAlign: alignment }); | ||
return this.options.types.every(type => commands.updateNodeAttributes(type, { textAlign: alignment })); | ||
}, | ||
/** | ||
* Unset the text align attribute | ||
*/ | ||
unsetTextAlign: () => ({ commands }) => { | ||
return this.options.types.every(type => commands.resetNodeAttributes(type, 'textAlign')); | ||
}, | ||
}; | ||
@@ -53,6 +59,6 @@ }, | ||
}), | ||
'Ctrl-Shift-l': () => this.editor.commands.textAlign('left'), | ||
'Ctrl-Shift-e': () => this.editor.commands.textAlign('center'), | ||
'Ctrl-Shift-r': () => this.editor.commands.textAlign('right'), | ||
'Ctrl-Shift-j': () => this.editor.commands.textAlign('justify'), | ||
'Ctrl-Shift-l': () => this.editor.commands.setTextAlign('left'), | ||
'Ctrl-Shift-e': () => this.editor.commands.setTextAlign('center'), | ||
'Ctrl-Shift-r': () => this.editor.commands.setTextAlign('right'), | ||
'Ctrl-Shift-j': () => this.editor.commands.setTextAlign('justify'), | ||
}; | ||
@@ -59,0 +65,0 @@ }, |
{ | ||
"name": "@tiptap/extension-text-align", | ||
"version": "1.0.0-alpha.2", | ||
"version": "2.0.0-alpha.1", | ||
"homepage": "https://tiptap.dev", | ||
@@ -24,5 +24,5 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@tiptap/core": "2.0.0-alpha.3" | ||
"@tiptap/core": "^2.0.0-alpha.0" | ||
}, | ||
"gitHead": "a8a578edb78db7763e2eda83960c25b02e8488c5" | ||
"gitHead": "276118e48eef313fb435088dee3dc58b91363109" | ||
} |
@@ -8,3 +8,3 @@ # @tiptap/extension-text-align | ||
## Introduction | ||
tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich-text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*. | ||
tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*. | ||
@@ -11,0 +11,0 @@ ## Offical Documentation |
@@ -38,5 +38,5 @@ import { Command, Extension } from '@tiptap/core' | ||
/** | ||
* Update the text align attribute | ||
* Set the text align attribute | ||
*/ | ||
textAlign: (alignment: string): Command => ({ commands }) => { | ||
setTextAlign: (alignment: string): Command => ({ commands }) => { | ||
if (!this.options.alignments.includes(alignment)) { | ||
@@ -46,4 +46,10 @@ return false | ||
return commands.updateNodeAttributes({ textAlign: alignment }) | ||
return this.options.types.every(type => commands.updateNodeAttributes(type, { textAlign: alignment })) | ||
}, | ||
/** | ||
* Unset the text align attribute | ||
*/ | ||
unsetTextAlign: (): Command => ({ commands }) => { | ||
return this.options.types.every(type => commands.resetNodeAttributes(type, 'textAlign')) | ||
}, | ||
} | ||
@@ -60,6 +66,6 @@ }, | ||
}), | ||
'Ctrl-Shift-l': () => this.editor.commands.textAlign('left'), | ||
'Ctrl-Shift-e': () => this.editor.commands.textAlign('center'), | ||
'Ctrl-Shift-r': () => this.editor.commands.textAlign('right'), | ||
'Ctrl-Shift-j': () => this.editor.commands.textAlign('justify'), | ||
'Ctrl-Shift-l': () => this.editor.commands.setTextAlign('left'), | ||
'Ctrl-Shift-e': () => this.editor.commands.setTextAlign('center'), | ||
'Ctrl-Shift-r': () => this.editor.commands.setTextAlign('right'), | ||
'Ctrl-Shift-j': () => this.editor.commands.setTextAlign('justify'), | ||
} | ||
@@ -66,0 +72,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
31056
288