Skip to content

Commit

Permalink
Various stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
muratcakir committed Nov 22, 2024
1 parent 03659e2 commit f0acc6a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 54 deletions.
15 changes: 9 additions & 6 deletions src/styles/sm/summernote-sm.html → examples/summernote-sm.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
}
</script>

<!-- include Summernote -->
<script type="module" src="/src/styles/sm/summernote-sm.js"></script>

<style type="text/css">
h1, h3 {
font-family: Perpetua;
Expand Down Expand Up @@ -116,11 +119,11 @@ <h4>Tabelle</h4>
<div class="card-body">
<h5 class="card-title">Other styles</h5>
<div class="btn-group" role="group" aria-label="Styles">
<% _.forEach(htmlWebpackPlugin.options.styles, function(style) { %>
<a href="summernote-<%- style.id %>.html" class="btn btn-sm btn-light">
<%- style.name %>
</a>
<% }); %>
<a href="summernote-bs3.html" class="btn btn-sm btn-light">bs3</a>
<a href="summernote-bs4.html" class="btn btn-sm btn-light">bs4</a>
<a href="summernote-bs5.html" class="btn btn-sm btn-light">bs5</a>
<a href="summernote-sm.html" class="btn btn-sm btn-light">sm</a>
<a href="/" class="btn btn-sm btn-light">lite</a>
</div>
<hr>
<p><a href="/examples.html">Visit examples page ⮕</a></p>
Expand All @@ -129,7 +132,7 @@ <h5 class="card-title">Other styles</h5>
</div>

<!-- initialize Summernote -->
<script type="text/javascript">
<script>
$(document).ready(function() {
$('.summernote').summernote({
height: 500,
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h1>Summernote</h1>
<a href="/examples/summernote-bs3.html">bs3</a>
<a href="/examples/summernote-bs4.html">bs4</a>
<a href="/examples/summernote-bs5.html">bs5</a>
<a href="/examples/summernote-sm.html">sm</a>
<a href="/examples/">examples</a>
</div>
</body>
Expand Down
79 changes: 39 additions & 40 deletions src/js/core/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,48 +891,47 @@ class WrappedRange {
return this;
}

/**
* Splits text on range and returns a new range.
*/
splitText_yo() {
const pts = this.getPoints();

// Handle single text node
if (pts.sc === pts.ec && dom.isText(pts.sc)) {
if (pts.so > 0 && pts.so < pts.sc.data.length) {
pts.ec = pts.sc.splitText(pts.so);
pts.sc = pts.ec.previousSibling;

if (pts.eo > pts.so) {
pts.eo = pts.eo - pts.so;
const newContainer = pts.ec.splitText(pts.eo).previousSibling;
pts.sc = pts.ec = newContainer;
pts.eo = newContainer.data.length;
pts.so = 0;
} else {
pts.eo = 0;
}
}
} else {
// Split startContainer text node if needed
if (dom.isText(pts.sc) && pts.so > 0 && pts.so < pts.sc.data.length) {
pts.sc = pts.sc.splitText(pts.so);
pts.so = 0;
}

// Split endContainer text node if needed
if (dom.isText(pts.ec) && pts.eo > 0 && pts.eo < pts.ec.data.length) {
const newContainer = pts.ec.splitText(pts.eo).previousSibling;
pts.ec = newContainer;
pts.eo = newContainer.data.length;
}
}

return create(pts.sc, pts.so, pts.ec, pts.eo);
}
// /**
// * Splits text on range and returns a new range.
// */
// splitText_New() {
// const pts = this.getPoints();

// // Handle single text node
// if (pts.sc === pts.ec && dom.isText(pts.sc)) {
// if (pts.so > 0 && pts.so < pts.sc.data.length) {
// pts.ec = pts.sc.splitText(pts.so);
// pts.sc = pts.ec.previousSibling;

// if (pts.eo > pts.so) {
// pts.eo = pts.eo - pts.so;
// const newContainer = pts.ec.splitText(pts.eo).previousSibling;
// pts.sc = pts.ec = newContainer;
// pts.eo = newContainer.data.length;
// pts.so = 0;
// } else {
// pts.eo = 0;
// }
// }
// } else {
// // Split startContainer text node if needed
// if (dom.isText(pts.sc) && pts.so > 0 && pts.so < pts.sc.data.length) {
// pts.sc = pts.sc.splitText(pts.so);
// pts.so = 0;
// }

// // Split endContainer text node if needed
// if (dom.isText(pts.ec) && pts.eo > 0 && pts.eo < pts.ec.data.length) {
// const newContainer = pts.ec.splitText(pts.eo).previousSibling;
// pts.ec = newContainer;
// pts.eo = newContainer.data.length;
// }
// }

// return create(pts.sc, pts.so, pts.ec, pts.eo);
// }

splitText() {
// TODO: Remove range.splitText_old()
const isSameContainer = this.sc === this.ec;
const pts = this.getPoints();

Expand Down
14 changes: 7 additions & 7 deletions src/js/editing/Style.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class Style {
* @return {Object}
*/
fromNode($node) {
const properties = ['font-size', 'text-align', 'list-style-type', 'line-height'];
const properties = ['font-family', 'font-size', 'text-align', 'list-style-type', 'line-height'];
const styleInfo = this.jQueryCSS($node, properties) || {};

const fontSize = $node[0].style.fontSize || styleInfo['font-size'];
Expand Down Expand Up @@ -123,12 +123,12 @@ export default class Style {
// [workaround] prevent Firefox nsresult: "0x80004005 (NS_ERROR_FAILURE)"
try {
styleInfo = $.extend(styleInfo, {
// 'font-bold': document.queryCommandState('bold') ? 'bold' : 'normal',
// 'font-italic': document.queryCommandState('italic') ? 'italic' : 'normal',
// 'font-underline': document.queryCommandState('underline') ? 'underline' : 'normal',
// 'font-subscript': document.queryCommandState('subscript') ? 'subscript' : 'normal',
// 'font-superscript': document.queryCommandState('superscript') ? 'superscript' : 'normal',
// 'font-strikethrough': document.queryCommandState('strikethrough') ? 'strikethrough' : 'normal',
'font-bold': document.queryCommandState('bold') ? 'bold' : 'normal',
'font-italic': document.queryCommandState('italic') ? 'italic' : 'normal',
'font-underline': document.queryCommandState('underline') ? 'underline' : 'normal',
'font-subscript': document.queryCommandState('subscript') ? 'subscript' : 'normal',
'font-superscript': document.queryCommandState('superscript') ? 'superscript' : 'normal',
'font-strikethrough': document.queryCommandState('strikethrough') ? 'strikethrough' : 'normal',
'font-family': document.queryCommandValue('fontname') || styleInfo['font-family'],
});
} catch (e) {
Expand Down
3 changes: 2 additions & 1 deletion vite.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const config = defineConfig({

rollupOptions: {
input: {
main: './index.html',
//main: './index.html',
main: './examples/summernote-sm.html'
},
output: {
entryFileNames: `[name].js`,
Expand Down

0 comments on commit f0acc6a

Please sign in to comment.